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

Commitd3946c4

Browse files
committed
pg_upgrade: check for types removed in pg12
Commitcda6a8d removed a few datatypes, but didn't updatepg_upgrade --check to throw error if these types are used. So the usersfind that pg_upgrade --check tells them that everything is fine, only tofail when the real upgrade is attempted.Reviewed-by: Tristan Partin <tristan@neon.tech>Reviewed-by: Suraj Kharage <suraj.kharage@enterprisedb.com>Discussion:https://postgr.es/m/202309201654.ng4ksea25mti@alvherre.pgsql
1 parent07896f4 commitd3946c4

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

‎src/bin/pg_upgrade/check.c

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ static void check_for_isn_and_int8_passing_mismatch(ClusterInfo *cluster);
2525
staticvoidcheck_for_tables_with_oids(ClusterInfo*cluster);
2626
staticvoidcheck_for_composite_data_type_usage(ClusterInfo*cluster);
2727
staticvoidcheck_for_reg_data_type_usage(ClusterInfo*cluster);
28+
staticvoidcheck_for_removed_data_type_usage(ClusterInfo*cluster,
29+
constchar*version,
30+
constchar*datatype);
2831
staticvoidcheck_for_jsonb_9_4_usage(ClusterInfo*cluster);
2932
staticvoidcheck_for_pg_role_prefix(ClusterInfo*cluster);
3033
staticvoidcheck_for_new_tablespace_dir(ClusterInfo*new_cluster);
@@ -103,6 +106,16 @@ check_and_dump_old_cluster(bool live_check)
103106
check_for_reg_data_type_usage(&old_cluster);
104107
check_for_isn_and_int8_passing_mismatch(&old_cluster);
105108

109+
/*
110+
* PG 12 removed types abstime, reltime, tinterval.
111+
*/
112+
if (GET_MAJOR_VERSION(old_cluster.major_version) <=1100)
113+
{
114+
check_for_removed_data_type_usage(&old_cluster,"12","abstime");
115+
check_for_removed_data_type_usage(&old_cluster,"12","reltime");
116+
check_for_removed_data_type_usage(&old_cluster,"12","tinterval");
117+
}
118+
106119
/*
107120
* Pre-PG 12 allowed tables to be declared WITH OIDS, which is not
108121
* supported anymore. Verify there are none, iff applicable.
@@ -1120,6 +1133,40 @@ check_for_reg_data_type_usage(ClusterInfo *cluster)
11201133
check_ok();
11211134
}
11221135

1136+
/*
1137+
* check_for_removed_data_type_usage
1138+
*
1139+
*Check for in-core data types that have been removed. Callers know
1140+
*the exact list.
1141+
*/
1142+
staticvoid
1143+
check_for_removed_data_type_usage(ClusterInfo*cluster,constchar*version,
1144+
constchar*datatype)
1145+
{
1146+
charoutput_path[MAXPGPATH];
1147+
chartypename[NAMEDATALEN];
1148+
1149+
prep_status("Checking for removed \"%s\" data type in user tables",
1150+
datatype);
1151+
1152+
snprintf(output_path,sizeof(output_path),"tables_using_%s.txt",
1153+
datatype);
1154+
snprintf(typename,sizeof(typename),"pg_catalog.%s",datatype);
1155+
1156+
if (check_for_data_type_usage(cluster,typename,output_path))
1157+
{
1158+
pg_log(PG_REPORT,"fatal");
1159+
pg_fatal("Your installation contains the \"%s\" data type in user tables.\n"
1160+
"The \"%s\" type has been removed in PostgreSQL version %s,\n"
1161+
"so this cluster cannot currently be upgraded. You can drop the\n"
1162+
"problem columns, or change them to another data type, and restart\n"
1163+
"the upgrade. A list of the problem columns is in the file:\n"
1164+
" %s\n\n",datatype,datatype,version,output_path);
1165+
}
1166+
else
1167+
check_ok();
1168+
}
1169+
11231170

11241171
/*
11251172
* check_for_jsonb_9_4_usage()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp