blob: a63377a25620a195af7672b2431741363f347e9d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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);
}
|