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

Commit8845d85

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 parent21b4c3c commit8845d85

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
@@ -28,6 +28,9 @@ static void check_for_incompatible_polymorphics(ClusterInfo *cluster);
2828
staticvoidcheck_for_tables_with_oids(ClusterInfo*cluster);
2929
staticvoidcheck_for_composite_data_type_usage(ClusterInfo*cluster);
3030
staticvoidcheck_for_reg_data_type_usage(ClusterInfo*cluster);
31+
staticvoidcheck_for_removed_data_type_usage(ClusterInfo*cluster,
32+
constchar*version,
33+
constchar*datatype);
3134
staticvoidcheck_for_jsonb_9_4_usage(ClusterInfo*cluster);
3235
staticvoidcheck_for_pg_role_prefix(ClusterInfo*cluster);
3336
staticvoidcheck_for_new_tablespace_dir(ClusterInfo*new_cluster);
@@ -107,6 +110,16 @@ check_and_dump_old_cluster(bool live_check)
107110
check_for_reg_data_type_usage(&old_cluster);
108111
check_for_isn_and_int8_passing_mismatch(&old_cluster);
109112

113+
/*
114+
* PG 12 removed types abstime, reltime, tinterval.
115+
*/
116+
if (GET_MAJOR_VERSION(old_cluster.major_version) <=1100)
117+
{
118+
check_for_removed_data_type_usage(&old_cluster,"12","abstime");
119+
check_for_removed_data_type_usage(&old_cluster,"12","reltime");
120+
check_for_removed_data_type_usage(&old_cluster,"12","tinterval");
121+
}
122+
110123
/*
111124
* PG 14 changed the function signature of encoding conversion functions.
112125
* Conversions from older versions cannot be upgraded automatically
@@ -1335,6 +1348,40 @@ check_for_reg_data_type_usage(ClusterInfo *cluster)
13351348
check_ok();
13361349
}
13371350

1351+
/*
1352+
* check_for_removed_data_type_usage
1353+
*
1354+
*Check for in-core data types that have been removed. Callers know
1355+
*the exact list.
1356+
*/
1357+
staticvoid
1358+
check_for_removed_data_type_usage(ClusterInfo*cluster,constchar*version,
1359+
constchar*datatype)
1360+
{
1361+
charoutput_path[MAXPGPATH];
1362+
chartypename[NAMEDATALEN];
1363+
1364+
prep_status("Checking for removed \"%s\" data type in user tables",
1365+
datatype);
1366+
1367+
snprintf(output_path,sizeof(output_path),"tables_using_%s.txt",
1368+
datatype);
1369+
snprintf(typename,sizeof(typename),"pg_catalog.%s",datatype);
1370+
1371+
if (check_for_data_type_usage(cluster,typename,output_path))
1372+
{
1373+
pg_log(PG_REPORT,"fatal");
1374+
pg_fatal("Your installation contains the \"%s\" data type in user tables.\n"
1375+
"The \"%s\" type has been removed in PostgreSQL version %s,\n"
1376+
"so this cluster cannot currently be upgraded. You can drop the\n"
1377+
"problem columns, or change them to another data type, and restart\n"
1378+
"the upgrade. A list of the problem columns is in the file:\n"
1379+
" %s\n\n",datatype,datatype,version,output_path);
1380+
}
1381+
else
1382+
check_ok();
1383+
}
1384+
13381385

13391386
/*
13401387
* check_for_jsonb_9_4_usage()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp