mirror of
https://github.com/postgres/postgres.git
synced 2026-04-22 22:59:54 -04:00
parent
d981976027
commit
7b24959434
1 changed files with 20 additions and 20 deletions
|
|
@ -602,9 +602,9 @@ check_and_dump_old_cluster(void)
|
||||||
check_for_connection_status(&old_cluster);
|
check_for_connection_status(&old_cluster);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Validate database, user, role and tablespace names from the old cluster.
|
* Validate database, user, role and tablespace names from the old
|
||||||
* No need to check in 19 or newer as newline and carriage return are
|
* cluster. No need to check in 19 or newer as newline and carriage return
|
||||||
* not allowed at the creation time of the object.
|
* are not allowed at the creation time of the object.
|
||||||
*/
|
*/
|
||||||
if (GET_MAJOR_VERSION(old_cluster.major_version) < 1900)
|
if (GET_MAJOR_VERSION(old_cluster.major_version) < 1900)
|
||||||
check_old_cluster_global_names(&old_cluster);
|
check_old_cluster_global_names(&old_cluster);
|
||||||
|
|
@ -2520,18 +2520,18 @@ static void
|
||||||
check_old_cluster_global_names(ClusterInfo *cluster)
|
check_old_cluster_global_names(ClusterInfo *cluster)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
PGconn *conn_template1;
|
PGconn *conn_template1;
|
||||||
PGresult *res;
|
PGresult *res;
|
||||||
int ntups;
|
int ntups;
|
||||||
FILE *script = NULL;
|
FILE *script = NULL;
|
||||||
char output_path[MAXPGPATH];
|
char output_path[MAXPGPATH];
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
prep_status("Checking names of databases, roles and tablespaces");
|
prep_status("Checking names of databases, roles and tablespaces");
|
||||||
|
|
||||||
snprintf(output_path, sizeof(output_path), "%s/%s",
|
snprintf(output_path, sizeof(output_path), "%s/%s",
|
||||||
log_opts.basedir,
|
log_opts.basedir,
|
||||||
"db_role_tablespace_invalid_names.txt");
|
"db_role_tablespace_invalid_names.txt");
|
||||||
|
|
||||||
conn_template1 = connectToServer(cluster, "template1");
|
conn_template1 = connectToServer(cluster, "template1");
|
||||||
|
|
||||||
|
|
@ -2540,18 +2540,18 @@ check_old_cluster_global_names(ClusterInfo *cluster)
|
||||||
* pg_authid because only superusers can view it.
|
* pg_authid because only superusers can view it.
|
||||||
*/
|
*/
|
||||||
res = executeQueryOrDie(conn_template1,
|
res = executeQueryOrDie(conn_template1,
|
||||||
"SELECT datname AS objname, 'database' AS objtype "
|
"SELECT datname AS objname, 'database' AS objtype "
|
||||||
"FROM pg_catalog.pg_database UNION ALL "
|
"FROM pg_catalog.pg_database UNION ALL "
|
||||||
"SELECT rolname AS objname, 'role' AS objtype "
|
"SELECT rolname AS objname, 'role' AS objtype "
|
||||||
"FROM pg_catalog.pg_roles UNION ALL "
|
"FROM pg_catalog.pg_roles UNION ALL "
|
||||||
"SELECT spcname AS objname, 'tablespace' AS objtype "
|
"SELECT spcname AS objname, 'tablespace' AS objtype "
|
||||||
"FROM pg_catalog.pg_tablespace ORDER BY 2 ");
|
"FROM pg_catalog.pg_tablespace ORDER BY 2 ");
|
||||||
|
|
||||||
ntups = PQntuples(res);
|
ntups = PQntuples(res);
|
||||||
for (i = 0; i < ntups; i++)
|
for (i = 0; i < ntups; i++)
|
||||||
{
|
{
|
||||||
char *objname = PQgetvalue(res, i, 0);
|
char *objname = PQgetvalue(res, i, 0);
|
||||||
char *objtype = PQgetvalue(res, i, 1);
|
char *objtype = PQgetvalue(res, i, 1);
|
||||||
|
|
||||||
/* If name has \n or \r, then report it. */
|
/* If name has \n or \r, then report it. */
|
||||||
if (strpbrk(objname, "\n\r"))
|
if (strpbrk(objname, "\n\r"))
|
||||||
|
|
@ -2571,10 +2571,10 @@ check_old_cluster_global_names(ClusterInfo *cluster)
|
||||||
fclose(script);
|
fclose(script);
|
||||||
pg_log(PG_REPORT, "fatal");
|
pg_log(PG_REPORT, "fatal");
|
||||||
pg_fatal("All the database, role and tablespace names should have only valid characters. A newline or \n"
|
pg_fatal("All the database, role and tablespace names should have only valid characters. A newline or \n"
|
||||||
"carriage return character is not allowed in these object names. To fix this, please \n"
|
"carriage return character is not allowed in these object names. To fix this, please \n"
|
||||||
"rename these names with valid names. \n"
|
"rename these names with valid names. \n"
|
||||||
"To see all %d invalid object names, refer db_role_tablespace_invalid_names.txt file. \n"
|
"To see all %d invalid object names, refer db_role_tablespace_invalid_names.txt file. \n"
|
||||||
" %s", count, output_path);
|
" %s", count, output_path);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
check_ok();
|
check_ok();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue