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

Commit9c279ae

Browse files
alvherrepull[bot]
authored andcommitted
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 parentec7712e commit9c279ae

File tree

1 file changed

+50
-1
lines changed

1 file changed

+50
-1
lines changed

‎src/bin/pg_upgrade/check.c

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ static void check_for_tables_with_oids(ClusterInfo *cluster);
2626
staticvoidcheck_for_composite_data_type_usage(ClusterInfo*cluster);
2727
staticvoidcheck_for_reg_data_type_usage(ClusterInfo*cluster);
2828
staticvoidcheck_for_aclitem_data_type_usage(ClusterInfo*cluster);
29+
staticvoidcheck_for_removed_data_type_usage(ClusterInfo*cluster,
30+
constchar*version,
31+
constchar*datatype);
2932
staticvoidcheck_for_jsonb_9_4_usage(ClusterInfo*cluster);
3033
staticvoidcheck_for_pg_role_prefix(ClusterInfo*cluster);
3134
staticvoidcheck_for_new_tablespace_dir(void);
@@ -111,6 +114,16 @@ check_and_dump_old_cluster(bool live_check)
111114
if (GET_MAJOR_VERSION(old_cluster.major_version) <=1500)
112115
check_for_aclitem_data_type_usage(&old_cluster);
113116

117+
/*
118+
* PG 12 removed types abstime, reltime, tinterval.
119+
*/
120+
if (GET_MAJOR_VERSION(old_cluster.major_version) <=1100)
121+
{
122+
check_for_removed_data_type_usage(&old_cluster,"12","abstime");
123+
check_for_removed_data_type_usage(&old_cluster,"12","reltime");
124+
check_for_removed_data_type_usage(&old_cluster,"12","tinterval");
125+
}
126+
114127
/*
115128
* PG 14 changed the function signature of encoding conversion functions.
116129
* Conversions from older versions cannot be upgraded automatically
@@ -1215,7 +1228,8 @@ check_for_aclitem_data_type_usage(ClusterInfo *cluster)
12151228
{
12161229
charoutput_path[MAXPGPATH];
12171230

1218-
prep_status("Checking for incompatible \"aclitem\" data type in user tables");
1231+
prep_status("Checking for incompatible \"%s\" data type in user tables",
1232+
"aclitem");
12191233

12201234
snprintf(output_path,sizeof(output_path),"tables_using_aclitem.txt");
12211235

@@ -1233,6 +1247,41 @@ check_for_aclitem_data_type_usage(ClusterInfo *cluster)
12331247
check_ok();
12341248
}
12351249

1250+
/*
1251+
* check_for_removed_data_type_usage
1252+
*
1253+
*Check for in-core data types that have been removed. Callers know
1254+
*the exact list.
1255+
*/
1256+
staticvoid
1257+
check_for_removed_data_type_usage(ClusterInfo*cluster,constchar*version,
1258+
constchar*datatype)
1259+
{
1260+
charoutput_path[MAXPGPATH];
1261+
chartypename[NAMEDATALEN];
1262+
1263+
prep_status("Checking for removed \"%s\" data type in user tables",
1264+
datatype);
1265+
1266+
snprintf(output_path,sizeof(output_path),"tables_using_%s.txt",
1267+
datatype);
1268+
snprintf(typename,sizeof(typename),"pg_catalog.%s",datatype);
1269+
1270+
if (check_for_data_type_usage(cluster,typename,output_path))
1271+
{
1272+
pg_log(PG_REPORT,"fatal");
1273+
pg_fatal("Your installation contains the \"%s\" data type in user tables.\n"
1274+
"The \"%s\" type has been removed in PostgreSQL version %s,\n"
1275+
"so this cluster cannot currently be upgraded. You can drop the\n"
1276+
"problem columns, or change them to another data type, and restart\n"
1277+
"the upgrade. A list of the problem columns is in the file:\n"
1278+
" %s",datatype,datatype,version,output_path);
1279+
}
1280+
else
1281+
check_ok();
1282+
}
1283+
1284+
12361285
/*
12371286
* check_for_jsonb_9_4_usage()
12381287
*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp