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

Commit76dd09b

Browse files
committed
Add postmaster/postgres undocumented -b option for binary upgrades.
This option turns off autovacuum, prevents non-super-user connections,and enables oid setting hooks in the backend. The code continues to usethe old autoavacuum disable settings for servers with earlier catalogversions.This includes a catalog version bump to identify servers that supportthe -b option.
1 parent02e6a11 commit76dd09b

File tree

16 files changed

+64
-28
lines changed

16 files changed

+64
-28
lines changed

‎contrib/pg_upgrade/check.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ check_cluster_compatibility(bool live_check)
264264

265265
/* Is it 9.0 but without tablespace directories? */
266266
if (GET_MAJOR_VERSION(new_cluster.major_version)==900&&
267-
new_cluster.controldata.cat_ver<TABLE_SPACE_SUBDIRS)
267+
new_cluster.controldata.cat_ver<TABLE_SPACE_SUBDIRS_CAT_VER)
268268
pg_log(PG_FATAL,"This utility can only upgrade to PostgreSQL version 9.0 after 2010-01-11\n"
269269
"because of backend API changes made during development.\n");
270270
}

‎contrib/pg_upgrade/pg_upgrade.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@
5858
#defineatooid(x) ((Oid) strtoul((x), NULL, 10))
5959

6060
/* OID system catalog preservation added during PG 9.0 development */
61-
#defineTABLE_SPACE_SUBDIRS 201001111
61+
#defineTABLE_SPACE_SUBDIRS_CAT_VER 201001111
62+
/* postmaster/postgres -b (binary_upgrade) flag added during PG 9.1 development */
63+
#defineBINARY_UPGRADE_SERVER_FLAG_CAT_VER 201104251
6264

6365
/*
6466
* Each relation is represented by a relinfo structure.

‎contrib/pg_upgrade/server.c

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,11 @@ start_postmaster(ClusterInfo *cluster, bool quiet)
173173
constchar*datadir;
174174
unsigned shortport;
175175
boolexit_hook_registered= false;
176+
#ifndefWIN32
177+
char*output_filename=log_opts.filename;
178+
#else
179+
char*output_filename=DEVNULL;
180+
#endif
176181

177182
bindir=cluster->bindir;
178183
datadir=cluster->pgdata;
@@ -193,7 +198,6 @@ start_postmaster(ClusterInfo *cluster, bool quiet)
193198
* same file because we get the error: "The process cannot access the file
194199
* because it is being used by another process." so we have to send all
195200
* other output to 'nul'.
196-
*
197201
* Using autovacuum=off disables cleanup vacuum and analyze, but freeze
198202
* vacuums can still happen, so we set autovacuum_freeze_max_age to its
199203
* maximum. We assume all datfrozenxid and relfrozen values are less than
@@ -202,15 +206,13 @@ start_postmaster(ClusterInfo *cluster, bool quiet)
202206
*/
203207
snprintf(cmd,sizeof(cmd),
204208
SYSTEMQUOTE"\"%s/pg_ctl\" -l \"%s\" -D \"%s\" "
205-
"-o \"-p %d -c autovacuum=off "
206-
"-c autovacuum_freeze_max_age=2000000000\" "
207-
"start >> \"%s\" 2>&1"SYSTEMQUOTE,
208-
bindir,
209-
#ifndefWIN32
210-
log_opts.filename,datadir,port,log_opts.filename);
211-
#else
212-
DEVNULL,datadir,port,DEVNULL);
213-
#endif
209+
"-o \"-p %d %s\" start >> \"%s\" 2>&1"SYSTEMQUOTE,
210+
bindir,output_filename,datadir,port,
211+
(cluster->controldata.cat_ver >=
212+
BINARY_UPGRADE_SERVER_FLAG_CAT_VER) ?"-b" :
213+
"-c autovacuum=off -c autovacuum_freeze_max_age=2000000000",
214+
log_opts.filename);
215+
214216
exec_prog(true,"%s",cmd);
215217

216218
/* wait for the server to start properly */

‎src/backend/catalog/heap.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1053,15 +1053,17 @@ heap_create_with_catalog(const char *relname,
10531053
* Use binary-upgrade override for pg_class.oid/relfilenode, if
10541054
* supplied.
10551055
*/
1056-
if (OidIsValid(binary_upgrade_next_heap_pg_class_oid)&&
1056+
if (IsBinaryUpgrade&&
1057+
OidIsValid(binary_upgrade_next_heap_pg_class_oid)&&
10571058
(relkind==RELKIND_RELATION||relkind==RELKIND_SEQUENCE||
10581059
relkind==RELKIND_VIEW||relkind==RELKIND_COMPOSITE_TYPE||
10591060
relkind==RELKIND_FOREIGN_TABLE))
10601061
{
10611062
relid=binary_upgrade_next_heap_pg_class_oid;
10621063
binary_upgrade_next_heap_pg_class_oid=InvalidOid;
10631064
}
1064-
elseif (OidIsValid(binary_upgrade_next_toast_pg_class_oid)&&
1065+
elseif (IsBinaryUpgrade&&
1066+
OidIsValid(binary_upgrade_next_toast_pg_class_oid)&&
10651067
relkind==RELKIND_TOASTVALUE)
10661068
{
10671069
relid=binary_upgrade_next_toast_pg_class_oid;

‎src/backend/catalog/index.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -789,7 +789,8 @@ index_create(Relation heapRelation,
789789
* Use binary-upgrade override for pg_class.oid/relfilenode, if
790790
* supplied.
791791
*/
792-
if (OidIsValid(binary_upgrade_next_index_pg_class_oid))
792+
if (IsBinaryUpgrade&&
793+
OidIsValid(binary_upgrade_next_index_pg_class_oid))
793794
{
794795
indexRelationId=binary_upgrade_next_index_pg_class_oid;
795796
binary_upgrade_next_index_pg_class_oid=InvalidOid;

‎src/backend/catalog/pg_enum.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include"catalog/pg_enum.h"
2222
#include"catalog/pg_type.h"
2323
#include"storage/lmgr.h"
24+
#include"miscadmin.h"
2425
#include"utils/builtins.h"
2526
#include"utils/fmgroids.h"
2627
#include"utils/rel.h"
@@ -311,7 +312,7 @@ AddEnumLabel(Oid enumTypeOid,
311312
}
312313

313314
/* Get a new OID for the new label */
314-
if (OidIsValid(binary_upgrade_next_pg_enum_oid))
315+
if (IsBinaryUpgrade&&OidIsValid(binary_upgrade_next_pg_enum_oid))
315316
{
316317
/*
317318
* Use binary-upgrade override for pg_enum.oid, if supplied. During

‎src/backend/catalog/pg_type.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ TypeShellMake(const char *typeName, Oid typeNamespace, Oid ownerId)
125125
tup=heap_form_tuple(tupDesc,values,nulls);
126126

127127
/* Use binary-upgrade override for pg_type.oid, if supplied. */
128-
if (OidIsValid(binary_upgrade_next_pg_type_oid))
128+
if (IsBinaryUpgrade&&OidIsValid(binary_upgrade_next_pg_type_oid))
129129
{
130130
HeapTupleSetOid(tup,binary_upgrade_next_pg_type_oid);
131131
binary_upgrade_next_pg_type_oid=InvalidOid;
@@ -430,7 +430,7 @@ TypeCreate(Oid newTypeOid,
430430
if (OidIsValid(newTypeOid))
431431
HeapTupleSetOid(tup,newTypeOid);
432432
/* Use binary-upgrade override for pg_type.oid, if supplied. */
433-
elseif (OidIsValid(binary_upgrade_next_pg_type_oid))
433+
elseif (IsBinaryUpgrade&&OidIsValid(binary_upgrade_next_pg_type_oid))
434434
{
435435
HeapTupleSetOid(tup,binary_upgrade_next_pg_type_oid);
436436
binary_upgrade_next_pg_type_oid=InvalidOid;

‎src/backend/catalog/toasting.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,8 @@ create_toast_table(Relation rel, Oid toastOid, Oid toastIndexOid, Datum reloptio
157157
* creation even if it seems not to need one.
158158
*/
159159
if (!needs_toast_table(rel)&&
160-
!OidIsValid(binary_upgrade_next_toast_pg_class_oid))
160+
(!IsBinaryUpgrade||
161+
!OidIsValid(binary_upgrade_next_toast_pg_class_oid)))
161162
return false;
162163

163164
/*
@@ -202,7 +203,7 @@ create_toast_table(Relation rel, Oid toastOid, Oid toastIndexOid, Datum reloptio
202203
namespaceid=PG_TOAST_NAMESPACE;
203204

204205
/* Use binary-upgrade override for pg_type.oid, if supplied. */
205-
if (OidIsValid(binary_upgrade_next_toast_pg_type_oid))
206+
if (IsBinaryUpgrade&&OidIsValid(binary_upgrade_next_toast_pg_type_oid))
206207
{
207208
toast_typid=binary_upgrade_next_toast_pg_type_oid;
208209
binary_upgrade_next_toast_pg_type_oid=InvalidOid;

‎src/backend/commands/typecmds.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1550,7 +1550,7 @@ AssignTypeArrayOid(void)
15501550
Oidtype_array_oid;
15511551

15521552
/* Use binary-upgrade override for pg_type.typarray, if supplied. */
1553-
if (OidIsValid(binary_upgrade_next_array_pg_type_oid))
1553+
if (IsBinaryUpgrade&&OidIsValid(binary_upgrade_next_array_pg_type_oid))
15541554
{
15551555
type_array_oid=binary_upgrade_next_array_pg_type_oid;
15561556
binary_upgrade_next_array_pg_type_oid=InvalidOid;

‎src/backend/commands/user.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ CreateRole(CreateRoleStmt *stmt)
388388
* pg_largeobject_metadata contains pg_authid.oid's, so we use the
389389
* binary-upgrade override, if specified.
390390
*/
391-
if (OidIsValid(binary_upgrade_next_pg_authid_oid))
391+
if (IsBinaryUpgrade&&OidIsValid(binary_upgrade_next_pg_authid_oid))
392392
{
393393
HeapTupleSetOid(tuple,binary_upgrade_next_pg_authid_oid);
394394
binary_upgrade_next_pg_authid_oid=InvalidOid;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp