13
13
14
14
#include "access/transam.h"
15
15
16
- #define PG_UPGRADE_SUPPORT "$libdir/pg_upgrade_support"
17
-
18
- /*
19
- * install_support_functions_in_new_db()
20
- *
21
- * pg_upgrade requires some support functions that enable it to modify
22
- * backend behavior.
23
- */
24
- void
25
- install_support_functions_in_new_db (const char * db_name )
26
- {
27
- PGconn * conn = connectToServer (& new_cluster , db_name );
28
-
29
- /* suppress NOTICE of dropped objects */
30
- PQclear (executeQueryOrDie (conn ,
31
- "SET client_min_messages = warning;" ));
32
- PQclear (executeQueryOrDie (conn ,
33
- "DROP SCHEMA IF EXISTS binary_upgrade CASCADE;" ));
34
- PQclear (executeQueryOrDie (conn ,
35
- "RESET client_min_messages;" ));
36
-
37
- PQclear (executeQueryOrDie (conn ,
38
- "CREATE SCHEMA binary_upgrade;" ));
39
-
40
- PQclear (executeQueryOrDie (conn ,
41
- "CREATE OR REPLACE FUNCTION "
42
- "binary_upgrade.set_next_pg_type_oid(OID) "
43
- "RETURNS VOID "
44
- "AS '$libdir/pg_upgrade_support' "
45
- "LANGUAGE C STRICT;" ));
46
- PQclear (executeQueryOrDie (conn ,
47
- "CREATE OR REPLACE FUNCTION "
48
- "binary_upgrade.set_next_array_pg_type_oid(OID) "
49
- "RETURNS VOID "
50
- "AS '$libdir/pg_upgrade_support' "
51
- "LANGUAGE C STRICT;" ));
52
- PQclear (executeQueryOrDie (conn ,
53
- "CREATE OR REPLACE FUNCTION "
54
- "binary_upgrade.set_next_toast_pg_type_oid(OID) "
55
- "RETURNS VOID "
56
- "AS '$libdir/pg_upgrade_support' "
57
- "LANGUAGE C STRICT;" ));
58
- PQclear (executeQueryOrDie (conn ,
59
- "CREATE OR REPLACE FUNCTION "
60
- "binary_upgrade.set_next_heap_pg_class_oid(OID) "
61
- "RETURNS VOID "
62
- "AS '$libdir/pg_upgrade_support' "
63
- "LANGUAGE C STRICT;" ));
64
- PQclear (executeQueryOrDie (conn ,
65
- "CREATE OR REPLACE FUNCTION "
66
- "binary_upgrade.set_next_index_pg_class_oid(OID) "
67
- "RETURNS VOID "
68
- "AS '$libdir/pg_upgrade_support' "
69
- "LANGUAGE C STRICT;" ));
70
- PQclear (executeQueryOrDie (conn ,
71
- "CREATE OR REPLACE FUNCTION "
72
- "binary_upgrade.set_next_toast_pg_class_oid(OID) "
73
- "RETURNS VOID "
74
- "AS '$libdir/pg_upgrade_support' "
75
- "LANGUAGE C STRICT;" ));
76
- PQclear (executeQueryOrDie (conn ,
77
- "CREATE OR REPLACE FUNCTION "
78
- "binary_upgrade.set_next_pg_enum_oid(OID) "
79
- "RETURNS VOID "
80
- "AS '$libdir/pg_upgrade_support' "
81
- "LANGUAGE C STRICT;" ));
82
- PQclear (executeQueryOrDie (conn ,
83
- "CREATE OR REPLACE FUNCTION "
84
- "binary_upgrade.set_next_pg_authid_oid(OID) "
85
- "RETURNS VOID "
86
- "AS '$libdir/pg_upgrade_support' "
87
- "LANGUAGE C STRICT;" ));
88
- PQclear (executeQueryOrDie (conn ,
89
- "CREATE OR REPLACE FUNCTION "
90
- "binary_upgrade.create_empty_extension(text, text, bool, text, oid[], text[], text[]) "
91
- "RETURNS VOID "
92
- "AS '$libdir/pg_upgrade_support' "
93
- "LANGUAGE C;" ));
94
- PQfinish (conn );
95
- }
96
-
97
-
98
- void
99
- uninstall_support_functions_from_new_cluster (void )
100
- {
101
- int dbnum ;
102
-
103
- prep_status ("Removing support functions from new cluster" );
104
-
105
- for (dbnum = 0 ; dbnum < new_cluster .dbarr .ndbs ; dbnum ++ )
106
- {
107
- DbInfo * new_db = & new_cluster .dbarr .dbs [dbnum ];
108
- PGconn * conn = connectToServer (& new_cluster , new_db -> db_name );
109
-
110
- /* suppress NOTICE of dropped objects */
111
- PQclear (executeQueryOrDie (conn ,
112
- "SET client_min_messages = warning;" ));
113
- PQclear (executeQueryOrDie (conn ,
114
- "DROP SCHEMA binary_upgrade CASCADE;" ));
115
- PQclear (executeQueryOrDie (conn ,
116
- "RESET client_min_messages;" ));
117
- PQfinish (conn );
118
- }
119
- check_ok ();
120
- }
121
-
122
16
123
17
/*
124
18
* get_loadable_libraries()
@@ -218,8 +112,6 @@ get_loadable_libraries(void)
218
112
if (found_public_plpython_handler )
219
113
pg_fatal ("Remove the problem functions from the old cluster to continue.\n" );
220
114
221
- totaltups ++ ; /* reserve for pg_upgrade_support */
222
-
223
115
/* Allocate what's certainly enough space */
224
116
os_info .libraries = (char * * ) pg_malloc (totaltups * sizeof (char * ));
225
117
@@ -228,7 +120,6 @@ get_loadable_libraries(void)
228
120
* there probably aren't enough entries to matter.
229
121
*/
230
122
totaltups = 0 ;
231
- os_info .libraries [totaltups ++ ] = pg_strdup (PG_UPGRADE_SUPPORT );
232
123
233
124
for (dbnum = 0 ; dbnum < old_cluster .dbarr .ndbs ; dbnum ++ )
234
125
{
@@ -321,10 +212,6 @@ check_loadable_libraries(void)
321
212
{
322
213
found = true;
323
214
324
- /* exit and report missing support library with special message */
325
- if (strcmp (lib , PG_UPGRADE_SUPPORT ) == 0 )
326
- pg_fatal ("The pg_upgrade_support module must be created and installed in the new cluster.\n" );
327
-
328
215
if (script == NULL && (script = fopen_priv (output_path , "w" )) == NULL )
329
216
pg_fatal ("Could not open file \"%s\": %s\n" ,
330
217
output_path , getErrorText (errno ));
0 commit comments