Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 58118db

Browse files
committed
Add new postgres -O option to allow system table structure changes.
1 parent 62a7754 commit 58118db

File tree

14 files changed

+57
-71
lines changed

14 files changed

+57
-71
lines changed

src/backend/bootstrap/bootstrap.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Copyright (c) 1994, Regents of the University of California
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.55 1999/02/13 23:14:52 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.56 1999/03/17 22:52:45 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -182,7 +182,7 @@ static char *relname; /* current relation name */
182182
Form_pg_attribute attrtypes[MAXATTR]; /* points to attribute info */
183183
static char *values[MAXATTR]; /* cooresponding attribute values */
184184
int numattr; /* number of attributes for cur. rel */
185-
extern int fsyncOff; /* do not fsync the database */
185+
extern bool disableFsync; /* do not fsync the database */
186186

187187
/* The test for HAVE_SIGSETJMP fails on Linux 2.0.x because the test
188188
* explicitly disallows sigsetjmp being a #define, which is how it
@@ -335,7 +335,7 @@ BootstrapMain(int argc, char *argv[])
335335
Noversion = true;
336336
break;
337337
case 'F':
338-
fsyncOff = true;
338+
disableFsync = true;
339339
break;
340340
case 'O':
341341
override = true;

src/backend/catalog/aclchk.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/catalog/aclchk.c,v 1.19 1999/02/13 23:14:54 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/catalog/aclchk.c,v 1.20 1999/03/17 22:52:47 momjian Exp $
1111
*
1212
* NOTES
1313
* See acl.h.
@@ -38,6 +38,7 @@
3838
#include "utils/memutils.h"
3939
#include "utils/syscache.h"
4040
#include "utils/tqual.h"
41+
#include "miscadmin.h"
4142

4243
static int32 aclcheck(char *relname, Acl *acl, AclId id, AclIdType idtype, AclMode mode);
4344

@@ -398,7 +399,7 @@ pg_aclcheck(char *relname, char *usename, AclMode mode)
398399
* themselves from themselves.)
399400
*/
400401
if (((mode & ACL_WR) || (mode & ACL_AP)) &&
401-
IsSystemRelationName(relname) &&
402+
!allowSystemTableMods && IsSystemRelationName(relname) &&
402403
!((Form_pg_shadow) GETSTRUCT(tuple))->usecatupd)
403404
{
404405
elog(DEBUG, "pg_aclcheck: catalog update to \"%s\": permission denied",

src/backend/catalog/heap.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.75 1999/02/23 07:54:03 thomas Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.76 1999/03/17 22:52:48 momjian Exp $
1111
*
1212
*
1313
* INTERFACE ROUTINES
@@ -195,7 +195,7 @@ heap_create(char *relname,
195195
*/
196196
AssertArg(natts > 0);
197197

198-
if (relname && IsSystemRelationName(relname) && IsNormalProcessingMode())
198+
if (relname && !allowSystemTableMods && IsSystemRelationName(relname) && IsNormalProcessingMode())
199199
{
200200
elog(ERROR, "Illegal class name '%s'"
201201
"\n\tThe 'pg_' name prefix is reserved for system catalogs",
@@ -1260,7 +1260,8 @@ heap_destroy_with_catalog(char *relname)
12601260
* ----------------
12611261
*/
12621262
/* allow temp of pg_class? Guess so. */
1263-
if (!istemp && IsSystemRelationName(RelationGetRelationName(rel)->data))
1263+
if (!istemp &&
1264+
!allowSystemTableMods && IsSystemRelationName(RelationGetRelationName(rel)->data))
12641265
elog(ERROR, "System relation '%s' cannot be destroyed",
12651266
&rel->rd_rel->relname);
12661267

src/backend/commands/command.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.39 1999/02/24 17:28:57 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.40 1999/03/17 22:52:51 momjian Exp $
1111
*
1212
* NOTES
1313
* The PortalExecutorHeapMemory crap needs to be eliminated
@@ -308,7 +308,7 @@ PerformAddAttribute(char *relationName,
308308
*
309309
* normally, only the owner of a class can change its schema.
310310
*/
311-
if (IsSystemRelationName(relationName))
311+
if (!allowSystemTableMods && IsSystemRelationName(relationName))
312312
elog(ERROR, "PerformAddAttribute: class \"%s\" is a system catalog",
313313
relationName);
314314
#ifndef NO_SECURITY

src/backend/commands/rename.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/rename.c,v 1.21 1999/02/13 23:15:09 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/rename.c,v 1.22 1999/03/17 22:52:52 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -81,7 +81,7 @@ renameatt(char *relname,
8181
*
8282
* normally, only the owner of a class can change its schema.
8383
*/
84-
if (IsSystemRelationName(relname))
84+
if (!allowSystemTableMods && IsSystemRelationName(relname))
8585
elog(ERROR, "renameatt: class \"%s\" is a system catalog",
8686
relname);
8787
#ifndef NO_SECURITY
@@ -207,11 +207,11 @@ renamerel(char *oldrelname, char *newrelname)
207207
newpath[MAXPGPATH];
208208
Relation irelations[Num_pg_class_indices];
209209

210-
if (IsSystemRelationName(oldrelname))
210+
if (!allowSystemTableMods && IsSystemRelationName(oldrelname))
211211
elog(ERROR, "renamerel: system relation \"%s\" not renamed",
212212
oldrelname);
213213

214-
if (IsSystemRelationName(newrelname))
214+
if (!allowSystemTableMods && IsSystemRelationName(newrelname))
215215
elog(ERROR, "renamerel: Illegal class name: \"%s\" -- pg_ is reserved for system catalogs",
216216
newrelname);
217217

src/backend/commands/trigger.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ CreateTrigger(CreateTrigStmt *stmt)
6666
int found = 0;
6767
int i;
6868

69-
if (IsSystemRelationName(stmt->relname))
69+
if (!allowSystemTableMods && IsSystemRelationName(stmt->relname))
7070
elog(ERROR, "CreateTrigger: can't create trigger for system relation %s", stmt->relname);
7171

7272
#ifndef NO_SECURITY

src/backend/parser/gram.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@
242242
*
243243
*
244244
* IDENTIFICATION
245-
* $Header: /cvsroot/pgsql/src/backend/parser/Attic/gram.c,v 2.81 1999/03/17 21:02:50 momjian Exp $
245+
* $Header: /cvsroot/pgsql/src/backend/parser/Attic/gram.c,v 2.82 1999/03/17 22:52:57 momjian Exp $
246246
*
247247
* HISTORY
248248
* AUTHOR DATE MAJOR EVENT

src/backend/storage/file/fd.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Copyright (c) 1994, Regents of the University of California
77
*
88
* IDENTIFICATION
9-
* $Id: fd.c,v 1.37 1999/02/13 23:18:05 momjian Exp $
9+
* $Id: fd.c,v 1.38 1999/03/17 22:53:06 momjian Exp $
1010
*
1111
* NOTES:
1212
*
@@ -168,9 +168,7 @@ static long pg_nofile(void);
168168
int
169169
pg_fsync(int fd)
170170
{
171-
extern int fsyncOff;
172-
173-
return fsyncOff ? 0 : fsync(fd);
171+
return disableFsync ? 0 : fsync(fd);
174172
}
175173

176174
#define fsync pg_fsync

src/backend/tcop/postgres.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.104 1999/02/21 03:49:27 scrappy Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.105 1999/03/17 22:53:18 momjian Exp $
1111
*
1212
* NOTES
1313
* this is the "main" module of the postgres backend and
@@ -917,6 +917,7 @@ usage(char *progname)
917917
#ifdef LOCK_MGR_DEBUG
918918
fprintf(stderr, "\t-K \t\tset locking debug level [0|1|2]\n");
919919
#endif
920+
fprintf(stderr, "\t-O \t\tallow system table structure changes\n");
920921
fprintf(stderr, "\t-P port\t\tset port file descriptor\n");
921922
fprintf(stderr, "\t-Q \t\tsuppress informational messages\n");
922923
fprintf(stderr, "\t-S buffers\tset amount of sort memory available\n");
@@ -1017,7 +1018,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
10171018
optind = 1; /* reset after postmaster usage */
10181019

10191020
while ((flag = getopt(argc, argv,
1020-
"A:B:CD:d:Eef:iK:Lm:MNo:P:pQS:st:v:x:FW:"))
1021+
"A:B:CD:d:Eef:iK:Lm:MNOo:P:pQS:st:v:x:FW:"))
10211022
!= EOF)
10221023
switch (flag)
10231024
{
@@ -1096,7 +1097,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
10961097
* turn off fsync
10971098
* --------------------
10981099
*/
1099-
fsyncOff = 1;
1100+
disableFsync = true;
11001101
break;
11011102

11021103
case 'f':
@@ -1168,6 +1169,14 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
11681169
StrNCpy(OutputFileName, optarg, MAXPGPATH);
11691170
break;
11701171

1172+
case 'O':
1173+
/* --------------------
1174+
* allow system table structure modifications
1175+
* --------------------
1176+
*/
1177+
allowSystemTableMods = true;
1178+
break;
1179+
11711180
case 'p': /* started by postmaster */
11721181
/* ----------------
11731182
* p - special flag passed if backend was forked
@@ -1522,7 +1531,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
15221531
if (!IsUnderPostmaster)
15231532
{
15241533
puts("\nPOSTGRES backend interactive interface ");
1525-
puts("$Revision: 1.104 $ $Date: 1999/02/21 03:49:27 $\n");
1534+
puts("$Revision: 1.105 $ $Date: 1999/03/17 22:53:18 $\n");
15261535
}
15271536

15281537
/* ----------------

src/backend/tcop/utility.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.58 1999/03/16 03:24:17 momjian Exp $
12+
* $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.59 1999/03/17 22:53:19 momjian Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -187,7 +187,7 @@ ProcessUtility(Node *parsetree,
187187
foreach(arg, args)
188188
{
189189
relname = strVal(lfirst(arg));
190-
if (IsSystemRelationName(relname))
190+
if (!allowSystemTableMods && IsSystemRelationName(relname))
191191
elog(ERROR, "class \"%s\" is a system catalog",
192192
relname);
193193
rel = heap_openr(relname);
@@ -268,7 +268,7 @@ ProcessUtility(Node *parsetree,
268268
CHECK_IF_ABORTED();
269269

270270
relname = stmt->relname;
271-
if (IsSystemRelationName(relname))
271+
if (!allowSystemTableMods && IsSystemRelationName(relname))
272272
elog(ERROR, "class \"%s\" is a system catalog",
273273
relname);
274274
#ifndef NO_SECURITY
@@ -457,7 +457,7 @@ ProcessUtility(Node *parsetree,
457457
{
458458
case INDEX:
459459
relname = stmt->name;
460-
if (IsSystemRelationName(relname))
460+
if (!allowSystemTableMods && IsSystemRelationName(relname))
461461
elog(ERROR, "class \"%s\" is a system catalog index",
462462
relname);
463463
#ifndef NO_SECURITY

src/backend/utils/init/globals.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/utils/init/globals.c,v 1.27 1999/02/13 23:20:00 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/utils/init/globals.c,v 1.28 1999/03/17 22:53:19 momjian Exp $
1111
*
1212
* NOTES
1313
* Globals used all over the place should be declared here and not
@@ -82,7 +82,8 @@ char DateFormat[20] = "%d-%m-%Y"; /* mjl: sizes! or better
8282
* malloc? XXX */
8383
char FloatFormat[20] = "%f";
8484

85-
int fsyncOff = 0;
85+
bool disableFsync = false;
86+
bool allowSystemTableMods = false;
8687
int SortMem = 512;
8788

8889
char *IndexedCatalogNames[] = {

0 commit comments

Comments
 (0)