mirror of
https://github.com/postgres/postgres.git
synced 2025-07-27 12:41:57 +03:00
Make pg_upgrade output more consistent with project style
Add errno-based output to error messages where appropriate, reformat blocks to about 72 characters per line, use spaces instead of tabs for indentation, and other style adjustments.
This commit is contained in:
@ -26,7 +26,7 @@ old_8_3_check_for_name_data_type_usage(ClusterInfo *cluster)
|
||||
bool found = false;
|
||||
char output_path[MAXPGPATH];
|
||||
|
||||
prep_status("Checking for invalid 'name' user columns");
|
||||
prep_status("Checking for invalid \"name\" user columns");
|
||||
|
||||
snprintf(output_path, sizeof(output_path), "%s/tables_using_name.txt",
|
||||
os_info.cwd);
|
||||
@ -70,10 +70,10 @@ old_8_3_check_for_name_data_type_usage(ClusterInfo *cluster)
|
||||
{
|
||||
found = true;
|
||||
if (script == NULL && (script = fopen(output_path, "w")) == NULL)
|
||||
pg_log(PG_FATAL, "could not create necessary file: %s\n", output_path);
|
||||
pg_log(PG_FATAL, "could not open file \"%s\": %s\n", output_path, getErrorText(errno));
|
||||
if (!db_used)
|
||||
{
|
||||
fprintf(script, "Database: %s\n", active_db->db_name);
|
||||
fprintf(script, "Database: %s\n", active_db->db_name);
|
||||
db_used = true;
|
||||
}
|
||||
fprintf(script, " %s.%s.%s\n",
|
||||
@ -94,13 +94,12 @@ old_8_3_check_for_name_data_type_usage(ClusterInfo *cluster)
|
||||
{
|
||||
pg_log(PG_REPORT, "fatal\n");
|
||||
pg_log(PG_FATAL,
|
||||
"| Your installation contains the \"name\" data type in\n"
|
||||
"| user tables. This data type changed its internal\n"
|
||||
"| alignment between your old and new clusters so this\n"
|
||||
"| cluster cannot currently be upgraded. You can\n"
|
||||
"| remove the problem tables and restart the upgrade.\n"
|
||||
"| A list of the problem columns is in the file:\n"
|
||||
"| \t%s\n\n", output_path);
|
||||
"Your installation contains the \"name\" data type in user tables. This\n"
|
||||
"data type changed its internal alignment between your old and new\n"
|
||||
"clusters so this cluster cannot currently be upgraded. You can remove\n"
|
||||
"the problem tables and restart the upgrade. A list of the problem\n"
|
||||
"columns is in the file:\n"
|
||||
" %s\n\n", output_path);
|
||||
}
|
||||
else
|
||||
check_ok();
|
||||
@ -160,10 +159,10 @@ old_8_3_check_for_tsquery_usage(ClusterInfo *cluster)
|
||||
{
|
||||
found = true;
|
||||
if (script == NULL && (script = fopen(output_path, "w")) == NULL)
|
||||
pg_log(PG_FATAL, "could not create necessary file: %s\n", output_path);
|
||||
pg_log(PG_FATAL, "could not open file \"%s\": %s\n", output_path, getErrorText(errno));
|
||||
if (!db_used)
|
||||
{
|
||||
fprintf(script, "Database: %s\n", active_db->db_name);
|
||||
fprintf(script, "Database: %s\n", active_db->db_name);
|
||||
db_used = true;
|
||||
}
|
||||
fprintf(script, " %s.%s.%s\n",
|
||||
@ -184,13 +183,12 @@ old_8_3_check_for_tsquery_usage(ClusterInfo *cluster)
|
||||
{
|
||||
pg_log(PG_REPORT, "fatal\n");
|
||||
pg_log(PG_FATAL,
|
||||
"| Your installation contains the \"tsquery\" data type.\n"
|
||||
"| This data type added a new internal field between\n"
|
||||
"| your old and new clusters so this cluster cannot\n"
|
||||
"| currently be upgraded. You can remove the problem\n"
|
||||
"| columns and restart the upgrade. A list of the\n"
|
||||
"| problem columns is in the file:\n"
|
||||
"| \t%s\n\n", output_path);
|
||||
"Your installation contains the \"tsquery\" data type. This data type\n"
|
||||
"added a new internal field between your old and new clusters so this\n"
|
||||
"cluster cannot currently be upgraded. You can remove the problem\n"
|
||||
"columns and restart the upgrade. A list of the problem columns is in the\n"
|
||||
"file:\n"
|
||||
" %s\n\n", output_path);
|
||||
}
|
||||
else
|
||||
check_ok();
|
||||
@ -278,7 +276,7 @@ old_8_3_rebuild_tsvector_tables(ClusterInfo *cluster, bool check_mode)
|
||||
if (!check_mode)
|
||||
{
|
||||
if (script == NULL && (script = fopen(output_path, "w")) == NULL)
|
||||
pg_log(PG_FATAL, "could not create necessary file: %s\n", output_path);
|
||||
pg_log(PG_FATAL, "could not open file \"%s\": %s\n", output_path, getErrorText(errno));
|
||||
if (!db_used)
|
||||
{
|
||||
fprintf(script, "\\connect %s\n\n",
|
||||
@ -326,20 +324,17 @@ old_8_3_rebuild_tsvector_tables(ClusterInfo *cluster, bool check_mode)
|
||||
report_status(PG_WARNING, "warning");
|
||||
if (check_mode)
|
||||
pg_log(PG_WARNING, "\n"
|
||||
"| Your installation contains tsvector columns.\n"
|
||||
"| The tsvector internal storage format changed\n"
|
||||
"| between your old and new clusters so the tables\n"
|
||||
"| must be rebuilt. After upgrading, you will be\n"
|
||||
"| given instructions.\n\n");
|
||||
"Your installation contains tsvector columns. The tsvector internal\n"
|
||||
"storage format changed between your old and new clusters so the tables\n"
|
||||
"must be rebuilt. After upgrading, you will be given instructions.\n\n");
|
||||
else
|
||||
pg_log(PG_WARNING, "\n"
|
||||
"| Your installation contains tsvector columns.\n"
|
||||
"| The tsvector internal storage format changed\n"
|
||||
"| between your old and new clusters so the tables\n"
|
||||
"| must be rebuilt. The file:\n"
|
||||
"| \t%s\n"
|
||||
"| when executed by psql by the database super-user\n"
|
||||
"| will rebuild all tables with tsvector columns.\n\n",
|
||||
"Your installation contains tsvector columns. The tsvector internal\n"
|
||||
"storage format changed between your old and new clusters so the tables\n"
|
||||
"must be rebuilt. The file:\n"
|
||||
" %s\n"
|
||||
"when executed by psql by the database superuser will rebuild all tables\n"
|
||||
"with tsvector columns.\n\n",
|
||||
output_path);
|
||||
}
|
||||
else
|
||||
@ -360,7 +355,7 @@ old_8_3_invalidate_hash_gin_indexes(ClusterInfo *cluster, bool check_mode)
|
||||
bool found = false;
|
||||
char output_path[MAXPGPATH];
|
||||
|
||||
prep_status("Checking for hash and gin indexes");
|
||||
prep_status("Checking for hash and GIN indexes");
|
||||
|
||||
snprintf(output_path, sizeof(output_path), "%s/reindex_hash_and_gin.sql",
|
||||
os_info.cwd);
|
||||
@ -379,11 +374,11 @@ old_8_3_invalidate_hash_gin_indexes(ClusterInfo *cluster, bool check_mode)
|
||||
/* find hash and gin indexes */
|
||||
res = executeQueryOrDie(conn,
|
||||
"SELECT n.nspname, c.relname "
|
||||
"FROM pg_catalog.pg_class c, "
|
||||
"FROM pg_catalog.pg_class c, "
|
||||
" pg_catalog.pg_index i, "
|
||||
" pg_catalog.pg_am a, "
|
||||
" pg_catalog.pg_namespace n "
|
||||
"WHERE i.indexrelid = c.oid AND "
|
||||
"WHERE i.indexrelid = c.oid AND "
|
||||
" c.relam = a.oid AND "
|
||||
" c.relnamespace = n.oid AND "
|
||||
" a.amname IN ('hash', 'gin') AND "
|
||||
@ -398,7 +393,7 @@ old_8_3_invalidate_hash_gin_indexes(ClusterInfo *cluster, bool check_mode)
|
||||
if (!check_mode)
|
||||
{
|
||||
if (script == NULL && (script = fopen(output_path, "w")) == NULL)
|
||||
pg_log(PG_FATAL, "could not create necessary file: %s\n", output_path);
|
||||
pg_log(PG_FATAL, "could not open file \"%s\": %s\n", output_path, getErrorText(errno));
|
||||
if (!db_used)
|
||||
{
|
||||
fprintf(script, "\\connect %s\n",
|
||||
@ -418,10 +413,10 @@ old_8_3_invalidate_hash_gin_indexes(ClusterInfo *cluster, bool check_mode)
|
||||
PQclear(executeQueryOrDie(conn,
|
||||
"UPDATE pg_catalog.pg_index i "
|
||||
"SET indisvalid = false "
|
||||
"FROM pg_catalog.pg_class c, "
|
||||
"FROM pg_catalog.pg_class c, "
|
||||
" pg_catalog.pg_am a, "
|
||||
" pg_catalog.pg_namespace n "
|
||||
"WHERE i.indexrelid = c.oid AND "
|
||||
"WHERE i.indexrelid = c.oid AND "
|
||||
" c.relam = a.oid AND "
|
||||
" c.relnamespace = n.oid AND "
|
||||
" a.amname IN ('hash', 'gin')"));
|
||||
@ -437,23 +432,18 @@ old_8_3_invalidate_hash_gin_indexes(ClusterInfo *cluster, bool check_mode)
|
||||
report_status(PG_WARNING, "warning");
|
||||
if (check_mode)
|
||||
pg_log(PG_WARNING, "\n"
|
||||
"| Your installation contains hash and/or gin\n"
|
||||
"| indexes. These indexes have different\n"
|
||||
"| internal formats between your old and new\n"
|
||||
"| clusters so they must be reindexed with the\n"
|
||||
"| REINDEX command. After upgrading, you will\n"
|
||||
"| be given REINDEX instructions.\n\n");
|
||||
"Your installation contains hash and/or GIN indexes. These indexes have\n"
|
||||
"different internal formats between your old and new clusters, so they\n"
|
||||
"must be reindexed with the REINDEX command. After upgrading, you will\n"
|
||||
"be given REINDEX instructions.\n\n");
|
||||
else
|
||||
pg_log(PG_WARNING, "\n"
|
||||
"| Your installation contains hash and/or gin\n"
|
||||
"| indexes. These indexes have different internal\n"
|
||||
"| formats between your old and new clusters so\n"
|
||||
"| they must be reindexed with the REINDEX command.\n"
|
||||
"| The file:\n"
|
||||
"| \t%s\n"
|
||||
"| when executed by psql by the database super-user\n"
|
||||
"| will recreate all invalid indexes; until then,\n"
|
||||
"| none of these indexes will be used.\n\n",
|
||||
"Your installation contains hash and/or GIN indexes. These indexes have\n"
|
||||
"different internal formats between your old and new clusters, so they\n"
|
||||
"must be reindexed with the REINDEX command. The file:\n"
|
||||
" %s\n"
|
||||
"when executed by psql by the database superuser will recreate all invalid\n"
|
||||
"indexes; until then, none of these indexes will be used.\n\n",
|
||||
output_path);
|
||||
}
|
||||
else
|
||||
@ -523,7 +513,7 @@ old_8_3_invalidate_bpchar_pattern_ops_indexes(ClusterInfo *cluster,
|
||||
if (!check_mode)
|
||||
{
|
||||
if (script == NULL && (script = fopen(output_path, "w")) == NULL)
|
||||
pg_log(PG_FATAL, "could not create necessary file: %s\n", output_path);
|
||||
pg_log(PG_FATAL, "could not open file \"%s\": %s\n", output_path, getErrorText(errno));
|
||||
if (!db_used)
|
||||
{
|
||||
fprintf(script, "\\connect %s\n",
|
||||
@ -567,23 +557,18 @@ old_8_3_invalidate_bpchar_pattern_ops_indexes(ClusterInfo *cluster,
|
||||
report_status(PG_WARNING, "warning");
|
||||
if (check_mode)
|
||||
pg_log(PG_WARNING, "\n"
|
||||
"| Your installation contains indexes using\n"
|
||||
"| \"bpchar_pattern_ops\". These indexes have\n"
|
||||
"| different internal formats between your old and\n"
|
||||
"| new clusters so they must be reindexed with the\n"
|
||||
"| REINDEX command. After upgrading, you will be\n"
|
||||
"| given REINDEX instructions.\n\n");
|
||||
"Your installation contains indexes using \"bpchar_pattern_ops\". These\n"
|
||||
"indexes have different internal formats between your old and new clusters\n"
|
||||
"so they must be reindexed with the REINDEX command. After upgrading, you\n"
|
||||
"will be given REINDEX instructions.\n\n");
|
||||
else
|
||||
pg_log(PG_WARNING, "\n"
|
||||
"| Your installation contains indexes using\n"
|
||||
"| \"bpchar_pattern_ops\". These indexes have\n"
|
||||
"| different internal formats between your old and\n"
|
||||
"| new clusters so they must be reindexed with the\n"
|
||||
"| REINDEX command. The file:\n"
|
||||
"| \t%s\n"
|
||||
"| when executed by psql by the database super-user\n"
|
||||
"| will recreate all invalid indexes; until then,\n"
|
||||
"| none of these indexes will be used.\n\n",
|
||||
"Your installation contains indexes using \"bpchar_pattern_ops\". These\n"
|
||||
"indexes have different internal formats between your old and new clusters\n"
|
||||
"so they must be reindexed with the REINDEX command. The file:\n"
|
||||
" %s\n"
|
||||
"when executed by psql by the database superuser will recreate all invalid\n"
|
||||
"indexes; until then, none of these indexes will be used.\n\n",
|
||||
output_path);
|
||||
}
|
||||
else
|
||||
@ -648,7 +633,7 @@ old_8_3_create_sequence_script(ClusterInfo *cluster)
|
||||
found = true;
|
||||
|
||||
if (script == NULL && (script = fopen(output_path, "w")) == NULL)
|
||||
pg_log(PG_FATAL, "could not create necessary file: %s\n", output_path);
|
||||
pg_log(PG_FATAL, "could not open file \"%s\": %s\n", output_path, getErrorText(errno));
|
||||
if (!db_used)
|
||||
{
|
||||
fprintf(script, "\\connect %s\n\n",
|
||||
|
Reference in New Issue
Block a user