Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc76da69

Browse files
Report incompatible roles in pg_upgrade checking
When checking for roles with a pg_ prefix in <= 9.5 servers, reportall found roles in a text file as how other checks are done insteadof just reporting that they exist. Rolenames are printed with theirOids to match other reports.Author: Daniel Gustafsson <daniel@yesql.se>Reviewed-by: Bruce Momjian <bruce@momjian.us>Reviewed-by: Michael Paquier <michael@paquier.xyz>Discussion:https://postgr.es/m/4BB2735C-C347-4CF7-AFB1-8573BE930066@yesql.se
1 parentab81006 commitc76da69

File tree

1 file changed

+32
-7
lines changed

1 file changed

+32
-7
lines changed

‎src/bin/pg_upgrade/check.c

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1395,27 +1395,52 @@ check_for_pg_role_prefix(ClusterInfo *cluster)
13951395
{
13961396
PGresult*res;
13971397
PGconn*conn=connectToServer(cluster,"template1");
1398+
intntups;
1399+
inti_roloid;
1400+
inti_rolname;
1401+
FILE*script=NULL;
1402+
charoutput_path[MAXPGPATH];
13981403

13991404
prep_status("Checking for roles starting with \"pg_\"");
14001405

1406+
snprintf(output_path,sizeof(output_path),"%s/%s",
1407+
log_opts.basedir,
1408+
"pg_role_prefix.txt");
1409+
14011410
res=executeQueryOrDie(conn,
1402-
"SELECT* "
1411+
"SELECToid AS roloid, rolname "
14031412
"FROM pg_catalog.pg_roles "
14041413
"WHERE rolname ~ '^pg_'");
14051414

1406-
if (PQntuples(res)!=0)
1415+
ntups=PQntuples(res);
1416+
i_roloid=PQfnumber(res,"roloid");
1417+
i_rolname=PQfnumber(res,"rolname");
1418+
for (introwno=0;rowno<ntups;rowno++)
14071419
{
1408-
if (cluster==&old_cluster)
1409-
pg_fatal("The source cluster contains roles starting with \"pg_\"");
1410-
else
1411-
pg_fatal("The target cluster contains roles starting with \"pg_\"");
1420+
if (script==NULL&& (script=fopen_priv(output_path,"w"))==NULL)
1421+
pg_fatal("could not open file \"%s\": %s",
1422+
output_path,strerror(errno));
1423+
fprintf(script,"%s (oid=%s)\n",
1424+
PQgetvalue(res,rowno,i_rolname),
1425+
PQgetvalue(res,rowno,i_roloid));
14121426
}
14131427

14141428
PQclear(res);
14151429

14161430
PQfinish(conn);
14171431

1418-
check_ok();
1432+
if (script)
1433+
{
1434+
fclose(script);
1435+
pg_log(PG_REPORT,"fatal");
1436+
pg_fatal("Your installation contains roles starting with \"pg_\".\n"
1437+
"\"pg_\" is a reserved prefix for system roles, the cluster\n"
1438+
"cannot be upgraded until these roles are renamed.\n"
1439+
"A list of roles starting with \"pg_\" is in the file:\n"
1440+
" %s",output_path);
1441+
}
1442+
else
1443+
check_ok();
14191444
}
14201445

14211446
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp