diff options
| author | Steve Singer | 2017-07-10 02:00:12 +0000 |
|---|---|---|
| committer | Steve Singer | 2017-07-10 02:00:12 +0000 |
| commit | ec07e91b3dd2e91a5922bc70fdf618ee4cbf3dd8 (patch) | |
| tree | 799953fac1dffa25151330f3ff14698d919aac8a | |
| parent | 1585f5a793980ed3150d1cbfe20c0d23aa870ad3 (diff) | |
Add support for PG10
PostgreSQL 10 does away with the old convention of $MAJOR.$MINOR.$PATCH
The existing version detection parsing code does not deal with the new
convention. Update the configure check, the slonik check and the slon check
to work with the new convention and continue to work with the old one.
| -rw-r--r-- | config/acx_libpq.m4 | 5 | ||||
| -rw-r--r-- | src/slon/dbutils.c | 9 | ||||
| -rw-r--r-- | src/slonik/dbutil.c | 12 |
3 files changed, 17 insertions, 9 deletions
diff --git a/config/acx_libpq.m4 b/config/acx_libpq.m4 index 47d4b679..7653357c 100644 --- a/config/acx_libpq.m4 +++ b/config/acx_libpq.m4 @@ -140,10 +140,9 @@ if test -n "$PG_CONFIG_LOCATION"; then PG_CONFIGURE=`$PG_CONFIG_LOCATION --configure` pg_config_version=`$PG_CONFIG_LOCATION --version` - PG_VERSION=`expr "$pg_config_version" : '[[^0-9]]*\([[0-9]]*\.[[0-9]]*\)'` - + PG_VERSION=`expr "$pg_config_version" : '[[^0-9]]*\([[0-9\.]]*\)'` AC_MSG_CHECKING(for correct version of PostgreSQL) - PG_VERSION_MAJOR=`echo $PG_VERSION | cut -d. -f1` + PG_VERSION_MAJOR=`echo $PG_VERSION | sed -e 's|\([[0-9]]*\)\(\.*.*\)|\1|'` PG_VERSION_MINOR=`echo $PG_VERSION | cut -d. -f2` if test "$PG_VERSION_MAJOR" = "7"; then AC_MSG_RESULT("error") diff --git a/src/slon/dbutils.c b/src/slon/dbutils.c index 726b4586..8450b44b 100644 --- a/src/slon/dbutils.c +++ b/src/slon/dbutils.c @@ -614,6 +614,7 @@ db_get_version(PGconn *conn) int major = 0; int minor = 0; int patch = 0; + int scanres=0; dstring_init(&query); slon_mkquery(&query, "SELECT version();"); @@ -624,8 +625,12 @@ db_get_version(PGconn *conn) PQclear(res); return -1; } - if (sscanf(PQgetvalue(res, 0, 0), "PostgreSQL %d.%d.%d", &major, &minor, &patch) < 2 && - sscanf(PQgetvalue(res, 0, 0), "EnterpriseDB %d.%d.%d", &major, &minor, &patch) < 2) + scanres=sscanf(PQgetvalue(res, 0, 0), "PostgreSQL %d.%d.%d", &major, &minor, &patch); + if(scanres < 1) + { + scanres=sscanf(PQgetvalue(res, 0, 0), "EnterpriseDB %d.%d.%d", &major, &minor, &patch); + } + if ( scanres < 1) { PQclear(res); return -1; diff --git a/src/slonik/dbutil.c b/src/slonik/dbutil.c index 8de5699a..a0f3151b 100644 --- a/src/slonik/dbutil.c +++ b/src/slonik/dbutil.c @@ -441,7 +441,8 @@ db_get_version(SlonikStmt * stmt, SlonikAdmInfo * adminfo) int minor = 0; int patch = 0; int version = 0; - + int scanres=0; + if (db_begin_xact(stmt, adminfo, false) < 0) return -1; @@ -452,9 +453,12 @@ db_get_version(SlonikStmt * stmt, SlonikAdmInfo * adminfo) if (res == NULL) return -1; - - if (sscanf(PQgetvalue(res, 0, 0), "PostgreSQL %d.%d.%d", &major, &minor, &patch) < 2 && - sscanf(PQgetvalue(res, 0, 0), "EnterpriseDB %d.%d.%d", &major, &minor, &patch) < 2) + scanres=sscanf(PQgetvalue(res, 0, 0), "PostgreSQL %d.%d.%d", &major, &minor, &patch); + if(scanres < 1) + { + scanres=sscanf(PQgetvalue(res, 0, 0), "EnterpriseDB %d.%d.%d", &major, &minor, &patch); + } + if ( scanres < 1) { fprintf(stderr, "%s:%d: failed to parse %s for DB version\n", stmt->stmt_filename, stmt->stmt_lno, |
