Skip to content

Commit 8af787e

Browse files
committed
Adjust check_for_isn_and_int8_passing_mismatch() so it is called for all
migrations. Backpatch to 9.0.
1 parent f31b1fd commit 8af787e

File tree

3 files changed

+98
-98
lines changed

3 files changed

+98
-98
lines changed

contrib/pg_upgrade/check.c

Lines changed: 96 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* server checks and output routines
55
*
66
* Copyright (c) 2010, PostgreSQL Global Development Group
7-
* $PostgreSQL: pgsql/contrib/pg_upgrade/check.c,v 1.13 2010/07/25 03:28:32 momjian Exp $
7+
* $PostgreSQL: pgsql/contrib/pg_upgrade/check.c,v 1.14 2010/07/25 03:47:29 momjian Exp $
88
*/
99

1010
#include "pg_upgrade.h"
@@ -14,6 +14,8 @@ static void set_locale_and_encoding(migratorContext *ctx, Cluster whichCluster);
1414
static void check_new_db_is_empty(migratorContext *ctx);
1515
static void check_locale_and_encoding(migratorContext *ctx, ControlData *oldctrl,
1616
ControlData *newctrl);
17+
static void check_for_isn_and_int8_passing_mismatch(migratorContext *ctx,
18+
Cluster whichCluster);
1719
static void check_for_reg_data_type_usage(migratorContext *ctx, Cluster whichCluster);
1820

1921

@@ -63,11 +65,11 @@ check_old_cluster(migratorContext *ctx, bool live_check,
6365
*/
6466

6567
check_for_reg_data_type_usage(ctx, CLUSTER_OLD);
68+
check_for_isn_and_int8_passing_mismatch(ctx, CLUSTER_OLD);
6669

6770
/* old = PG 8.3 checks? */
6871
if (GET_MAJOR_VERSION(ctx->old.major_version) <= 803)
6972
{
70-
old_8_3_check_for_isn_and_int8_passing_mismatch(ctx, CLUSTER_OLD);
7173
old_8_3_check_for_name_data_type_usage(ctx, CLUSTER_OLD);
7274
old_8_3_check_for_tsquery_usage(ctx, CLUSTER_OLD);
7375
if (ctx->check)
@@ -443,6 +445,98 @@ create_script_for_old_cluster_deletion(migratorContext *ctx,
443445
}
444446

445447

448+
/*
449+
* check_for_isn_and_int8_passing_mismatch()
450+
*
451+
* /contrib/isn relies on data type int8, and in 8.4 int8 can now be passed
452+
* by value. The schema dumps the CREATE TYPE PASSEDBYVALUE setting so
453+
* it must match for the old and new servers.
454+
*/
455+
void
456+
check_for_isn_and_int8_passing_mismatch(migratorContext *ctx, Cluster whichCluster)
457+
{
458+
ClusterInfo *active_cluster = (whichCluster == CLUSTER_OLD) ?
459+
&ctx->old : &ctx->new;
460+
int dbnum;
461+
FILE *script = NULL;
462+
bool found = false;
463+
char output_path[MAXPGPATH];
464+
465+
prep_status(ctx, "Checking for /contrib/isn with bigint-passing mismatch");
466+
467+
if (ctx->old.controldata.float8_pass_by_value ==
468+
ctx->new.controldata.float8_pass_by_value)
469+
{
470+
/* no mismatch */
471+
check_ok(ctx);
472+
return;
473+
}
474+
475+
snprintf(output_path, sizeof(output_path), "%s/contrib_isn_and_int8_pass_by_value.txt",
476+
ctx->cwd);
477+
478+
for (dbnum = 0; dbnum < active_cluster->dbarr.ndbs; dbnum++)
479+
{
480+
PGresult *res;
481+
bool db_used = false;
482+
int ntups;
483+
int rowno;
484+
int i_nspname,
485+
i_proname;
486+
DbInfo *active_db = &active_cluster->dbarr.dbs[dbnum];
487+
PGconn *conn = connectToServer(ctx, active_db->db_name, whichCluster);
488+
489+
/* Find any functions coming from contrib/isn */
490+
res = executeQueryOrDie(ctx, conn,
491+
"SELECT n.nspname, p.proname "
492+
"FROM pg_catalog.pg_proc p, "
493+
" pg_catalog.pg_namespace n "
494+
"WHERE p.pronamespace = n.oid AND "
495+
" p.probin = '$libdir/isn'");
496+
497+
ntups = PQntuples(res);
498+
i_nspname = PQfnumber(res, "nspname");
499+
i_proname = PQfnumber(res, "proname");
500+
for (rowno = 0; rowno < ntups; rowno++)
501+
{
502+
found = true;
503+
if (script == NULL && (script = fopen(output_path, "w")) == NULL)
504+
pg_log(ctx, PG_FATAL, "Could not create necessary file: %s\n", output_path);
505+
if (!db_used)
506+
{
507+
fprintf(script, "Database: %s\n", active_db->db_name);
508+
db_used = true;
509+
}
510+
fprintf(script, " %s.%s\n",
511+
PQgetvalue(res, rowno, i_nspname),
512+
PQgetvalue(res, rowno, i_proname));
513+
}
514+
515+
PQclear(res);
516+
517+
PQfinish(conn);
518+
}
519+
520+
if (found)
521+
{
522+
fclose(script);
523+
pg_log(ctx, PG_REPORT, "fatal\n");
524+
pg_log(ctx, PG_FATAL,
525+
"| Your installation contains \"/contrib/isn\" functions\n"
526+
"| which rely on the bigint data type. Your old and\n"
527+
"| new clusters pass bigint values differently so this\n"
528+
"| cluster cannot currently be upgraded. You can\n"
529+
"| manually migrate data that use \"/contrib/isn\"\n"
530+
"| facilities and remove \"/contrib/isn\" from the\n"
531+
"| old cluster and restart the migration. A list\n"
532+
"| of the problem functions is in the file:\n"
533+
"| \t%s\n\n", output_path);
534+
}
535+
else
536+
check_ok(ctx);
537+
}
538+
539+
446540
/*
447541
* check_for_reg_data_type_usage()
448542
* pg_upgrade only preserves these system values:

contrib/pg_upgrade/pg_upgrade.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* pg_upgrade.h
33
*
44
* Copyright (c) 2010, PostgreSQL Global Development Group
5-
* $PostgreSQL: pgsql/contrib/pg_upgrade/pg_upgrade.h,v 1.15 2010/07/06 19:18:55 momjian Exp $
5+
* $PostgreSQL: pgsql/contrib/pg_upgrade/pg_upgrade.h,v 1.16 2010/07/25 03:47:29 momjian Exp $
66
*/
77

88
#include "postgres.h"
@@ -388,8 +388,6 @@ void old_8_3_check_for_name_data_type_usage(migratorContext *ctx,
388388
Cluster whichCluster);
389389
void old_8_3_check_for_tsquery_usage(migratorContext *ctx,
390390
Cluster whichCluster);
391-
void old_8_3_check_for_isn_and_int8_passing_mismatch(migratorContext *ctx,
392-
Cluster whichCluster);
393391
void old_8_3_rebuild_tsvector_tables(migratorContext *ctx,
394392
bool check_mode, Cluster whichCluster);
395393
void old_8_3_invalidate_hash_gin_indexes(migratorContext *ctx,

contrib/pg_upgrade/version_old_8_3.c

Lines changed: 1 addition & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Postgres-version-specific routines
55
*
66
* Copyright (c) 2010, PostgreSQL Global Development Group
7-
* $PostgreSQL: pgsql/contrib/pg_upgrade/version_old_8_3.c,v 1.7 2010/07/25 03:28:32 momjian Exp $
7+
* $PostgreSQL: pgsql/contrib/pg_upgrade/version_old_8_3.c,v 1.8 2010/07/25 03:47:29 momjian Exp $
88
*/
99

1010
#include "pg_upgrade.h"
@@ -197,98 +197,6 @@ old_8_3_check_for_tsquery_usage(migratorContext *ctx, Cluster whichCluster)
197197
}
198198

199199

200-
/*
201-
* old_8_3_check_for_isn_and_int8_passing_mismatch()
202-
* 8.3 -> 8.4
203-
* /contrib/isn relies on data type int8, and in 8.4 int8 is now passed
204-
* by value. The schema dumps the CREATE TYPE PASSEDBYVALUE setting so
205-
* it must match for the old and new servers.
206-
*/
207-
void
208-
old_8_3_check_for_isn_and_int8_passing_mismatch(migratorContext *ctx, Cluster whichCluster)
209-
{
210-
ClusterInfo *active_cluster = (whichCluster == CLUSTER_OLD) ?
211-
&ctx->old : &ctx->new;
212-
int dbnum;
213-
FILE *script = NULL;
214-
bool found = false;
215-
char output_path[MAXPGPATH];
216-
217-
prep_status(ctx, "Checking for /contrib/isn with bigint-passing mismatch");
218-
219-
if (ctx->old.controldata.float8_pass_by_value ==
220-
ctx->new.controldata.float8_pass_by_value)
221-
{
222-
/* no mismatch */
223-
check_ok(ctx);
224-
return;
225-
}
226-
227-
snprintf(output_path, sizeof(output_path), "%s/contrib_isn_and_int8_pass_by_value.txt",
228-
ctx->cwd);
229-
230-
for (dbnum = 0; dbnum < active_cluster->dbarr.ndbs; dbnum++)
231-
{
232-
PGresult *res;
233-
bool db_used = false;
234-
int ntups;
235-
int rowno;
236-
int i_nspname,
237-
i_proname;
238-
DbInfo *active_db = &active_cluster->dbarr.dbs[dbnum];
239-
PGconn *conn = connectToServer(ctx, active_db->db_name, whichCluster);
240-
241-
/* Find any functions coming from contrib/isn */
242-
res = executeQueryOrDie(ctx, conn,
243-
"SELECT n.nspname, p.proname "
244-
"FROM pg_catalog.pg_proc p, "
245-
" pg_catalog.pg_namespace n "
246-
"WHERE p.pronamespace = n.oid AND "
247-
" p.probin = '$libdir/isn'");
248-
249-
ntups = PQntuples(res);
250-
i_nspname = PQfnumber(res, "nspname");
251-
i_proname = PQfnumber(res, "proname");
252-
for (rowno = 0; rowno < ntups; rowno++)
253-
{
254-
found = true;
255-
if (script == NULL && (script = fopen(output_path, "w")) == NULL)
256-
pg_log(ctx, PG_FATAL, "Could not create necessary file: %s\n", output_path);
257-
if (!db_used)
258-
{
259-
fprintf(script, "Database: %s\n", active_db->db_name);
260-
db_used = true;
261-
}
262-
fprintf(script, " %s.%s\n",
263-
PQgetvalue(res, rowno, i_nspname),
264-
PQgetvalue(res, rowno, i_proname));
265-
}
266-
267-
PQclear(res);
268-
269-
PQfinish(conn);
270-
}
271-
272-
if (found)
273-
{
274-
fclose(script);
275-
pg_log(ctx, PG_REPORT, "fatal\n");
276-
pg_log(ctx, PG_FATAL,
277-
"| Your installation contains \"/contrib/isn\" functions\n"
278-
"| which rely on the bigint data type. Your old and\n"
279-
"| new clusters pass bigint values differently so this\n"
280-
"| cluster cannot currently be upgraded. You can\n"
281-
"| manually migrate data that use \"/contrib/isn\"\n"
282-
"| facilities and remove \"/contrib/isn\" from the\n"
283-
"| old cluster and restart the migration. A list\n"
284-
"| of the problem functions is in the file:\n"
285-
"| \t%s\n\n", output_path);
286-
}
287-
else
288-
check_ok(ctx);
289-
}
290-
291-
292200
/*
293201
* old_8_3_rebuild_tsvector_tables()
294202
* 8.3 -> 8.4

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy