summaryrefslogtreecommitdiff
path: root/Tests/FindPostgreSQL/Test/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'Tests/FindPostgreSQL/Test/main.c')
-rw-r--r--Tests/FindPostgreSQL/Test/main.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/Tests/FindPostgreSQL/Test/main.c b/Tests/FindPostgreSQL/Test/main.c
new file mode 100644
index 000000000..a63377a25
--- /dev/null
+++ b/Tests/FindPostgreSQL/Test/main.c
@@ -0,0 +1,24 @@
+#include <libpq-fe.h>
+#include <stdio.h>
+#include <string.h>
+
+int main()
+{
+ int version = PQlibVersion();
+ char version_string[100];
+ // 9.x and older encoding.
+ if (version < 100000) {
+ int major = version / 10000;
+ int minor = version % 10000 / 100;
+ int patch = version % 100;
+ snprintf(version_string, sizeof(version_string), "%d.%d.%d", major, minor,
+ patch);
+ } else {
+ int major = version / 10000;
+ int minor = version % 10000;
+ snprintf(version_string, sizeof(version_string), "%d.%d", major, minor);
+ }
+ printf("Found PostgreSQL version %s, expected version %s\n", version_string,
+ CMAKE_EXPECTED_POSTGRESQL_VERSION);
+ return strcmp(version_string, CMAKE_EXPECTED_POSTGRESQL_VERSION);
+}