Skip to content

Commit 64719a1

Browse files
committed
Use a 'datallowconn' check for avoiding 'template0', rather than
hardcoding a 'template0' check, per suggestion from Alvaro. This might fix a problem where someone has allowed 'template0' connections, but it is a cleaner approach even if doesn't fix the bug.
1 parent 60e7f45 commit 64719a1

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

contrib/pg_upgrade/pg_upgrade.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -304,15 +304,14 @@ set_frozenxids(migratorContext *ctx)
304304
PQclear(executeQueryOrDie(ctx, conn,
305305
"UPDATE pg_catalog.pg_database "
306306
"SET datfrozenxid = '%u' "
307-
/* cannot connect to 'template0', so ignore */
308-
"WHERE datname != 'template0'",
307+
"WHERE datallowconn = true",
309308
ctx->old.controldata.chkpnt_nxtxid));
310309

311310
/* get database names */
312311
dbres = executeQueryOrDie(ctx, conn,
313312
"SELECT datname "
314313
"FROM pg_catalog.pg_database "
315-
"WHERE datname != 'template0'");
314+
"WHERE datallowconn = true");
316315

317316
/* free dbres below */
318317
PQfinish(conn);

0 commit comments

Comments
 (0)