1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-12 05:01:15 +03:00

Add new postgres -O option to allow system table structure changes.

This commit is contained in:
Bruce Momjian
1999-03-17 22:53:31 +00:00
parent 62a7754e1a
commit 58118db39d
14 changed files with 57 additions and 71 deletions

View File

@@ -7,7 +7,7 @@
* Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.55 1999/02/13 23:14:52 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.56 1999/03/17 22:52:45 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -182,7 +182,7 @@ static char *relname; /* current relation name */
Form_pg_attribute attrtypes[MAXATTR]; /* points to attribute info */
static char *values[MAXATTR]; /* cooresponding attribute values */
int numattr; /* number of attributes for cur. rel */
extern int fsyncOff; /* do not fsync the database */
extern bool disableFsync; /* do not fsync the database */
/* The test for HAVE_SIGSETJMP fails on Linux 2.0.x because the test
* explicitly disallows sigsetjmp being a #define, which is how it
@@ -335,7 +335,7 @@ BootstrapMain(int argc, char *argv[])
Noversion = true;
break;
case 'F':
fsyncOff = true;
disableFsync = true;
break;
case 'O':
override = true;

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/aclchk.c,v 1.19 1999/02/13 23:14:54 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/catalog/aclchk.c,v 1.20 1999/03/17 22:52:47 momjian Exp $
*
* NOTES
* See acl.h.
@@ -38,6 +38,7 @@
#include "utils/memutils.h"
#include "utils/syscache.h"
#include "utils/tqual.h"
#include "miscadmin.h"
static int32 aclcheck(char *relname, Acl *acl, AclId id, AclIdType idtype, AclMode mode);
@@ -398,7 +399,7 @@ pg_aclcheck(char *relname, char *usename, AclMode mode)
* themselves from themselves.)
*/
if (((mode & ACL_WR) || (mode & ACL_AP)) &&
IsSystemRelationName(relname) &&
!allowSystemTableMods && IsSystemRelationName(relname) &&
!((Form_pg_shadow) GETSTRUCT(tuple))->usecatupd)
{
elog(DEBUG, "pg_aclcheck: catalog update to \"%s\": permission denied",

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.75 1999/02/23 07:54:03 thomas Exp $
* $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.76 1999/03/17 22:52:48 momjian Exp $
*
*
* INTERFACE ROUTINES
@@ -195,7 +195,7 @@ heap_create(char *relname,
*/
AssertArg(natts > 0);
if (relname && IsSystemRelationName(relname) && IsNormalProcessingMode())
if (relname && !allowSystemTableMods && IsSystemRelationName(relname) && IsNormalProcessingMode())
{
elog(ERROR, "Illegal class name '%s'"
"\n\tThe 'pg_' name prefix is reserved for system catalogs",
@@ -1260,7 +1260,8 @@ heap_destroy_with_catalog(char *relname)
* ----------------
*/
/* allow temp of pg_class? Guess so. */
if (!istemp && IsSystemRelationName(RelationGetRelationName(rel)->data))
if (!istemp &&
!allowSystemTableMods && IsSystemRelationName(RelationGetRelationName(rel)->data))
elog(ERROR, "System relation '%s' cannot be destroyed",
&rel->rd_rel->relname);

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.39 1999/02/24 17:28:57 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.40 1999/03/17 22:52:51 momjian Exp $
*
* NOTES
* The PortalExecutorHeapMemory crap needs to be eliminated
@@ -308,7 +308,7 @@ PerformAddAttribute(char *relationName,
*
* normally, only the owner of a class can change its schema.
*/
if (IsSystemRelationName(relationName))
if (!allowSystemTableMods && IsSystemRelationName(relationName))
elog(ERROR, "PerformAddAttribute: class \"%s\" is a system catalog",
relationName);
#ifndef NO_SECURITY

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/rename.c,v 1.21 1999/02/13 23:15:09 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/rename.c,v 1.22 1999/03/17 22:52:52 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -81,7 +81,7 @@ renameatt(char *relname,
*
* normally, only the owner of a class can change its schema.
*/
if (IsSystemRelationName(relname))
if (!allowSystemTableMods && IsSystemRelationName(relname))
elog(ERROR, "renameatt: class \"%s\" is a system catalog",
relname);
#ifndef NO_SECURITY
@@ -207,11 +207,11 @@ renamerel(char *oldrelname, char *newrelname)
newpath[MAXPGPATH];
Relation irelations[Num_pg_class_indices];
if (IsSystemRelationName(oldrelname))
if (!allowSystemTableMods && IsSystemRelationName(oldrelname))
elog(ERROR, "renamerel: system relation \"%s\" not renamed",
oldrelname);
if (IsSystemRelationName(newrelname))
if (!allowSystemTableMods && IsSystemRelationName(newrelname))
elog(ERROR, "renamerel: Illegal class name: \"%s\" -- pg_ is reserved for system catalogs",
newrelname);

View File

@@ -66,7 +66,7 @@ CreateTrigger(CreateTrigStmt *stmt)
int found = 0;
int i;
if (IsSystemRelationName(stmt->relname))
if (!allowSystemTableMods && IsSystemRelationName(stmt->relname))
elog(ERROR, "CreateTrigger: can't create trigger for system relation %s", stmt->relname);
#ifndef NO_SECURITY

View File

@@ -242,7 +242,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/Attic/gram.c,v 2.81 1999/03/17 21:02:50 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/Attic/gram.c,v 2.82 1999/03/17 22:52:57 momjian Exp $
*
* HISTORY
* AUTHOR DATE MAJOR EVENT

View File

@@ -6,7 +6,7 @@
* Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Id: fd.c,v 1.37 1999/02/13 23:18:05 momjian Exp $
* $Id: fd.c,v 1.38 1999/03/17 22:53:06 momjian Exp $
*
* NOTES:
*
@@ -168,9 +168,7 @@ static long pg_nofile(void);
int
pg_fsync(int fd)
{
extern int fsyncOff;
return fsyncOff ? 0 : fsync(fd);
return disableFsync ? 0 : fsync(fd);
}
#define fsync pg_fsync

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.104 1999/02/21 03:49:27 scrappy Exp $
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.105 1999/03/17 22:53:18 momjian Exp $
*
* NOTES
* this is the "main" module of the postgres backend and
@@ -917,6 +917,7 @@ usage(char *progname)
#ifdef LOCK_MGR_DEBUG
fprintf(stderr, "\t-K \t\tset locking debug level [0|1|2]\n");
#endif
fprintf(stderr, "\t-O \t\tallow system table structure changes\n");
fprintf(stderr, "\t-P port\t\tset port file descriptor\n");
fprintf(stderr, "\t-Q \t\tsuppress informational messages\n");
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[])
optind = 1; /* reset after postmaster usage */
while ((flag = getopt(argc, argv,
"A:B:CD:d:Eef:iK:Lm:MNo:P:pQS:st:v:x:FW:"))
"A:B:CD:d:Eef:iK:Lm:MNOo:P:pQS:st:v:x:FW:"))
!= EOF)
switch (flag)
{
@@ -1096,7 +1097,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
* turn off fsync
* --------------------
*/
fsyncOff = 1;
disableFsync = true;
break;
case 'f':
@@ -1168,6 +1169,14 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
StrNCpy(OutputFileName, optarg, MAXPGPATH);
break;
case 'O':
/* --------------------
* allow system table structure modifications
* --------------------
*/
allowSystemTableMods = true;
break;
case 'p': /* started by postmaster */
/* ----------------
* p - special flag passed if backend was forked
@@ -1522,7 +1531,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
if (!IsUnderPostmaster)
{
puts("\nPOSTGRES backend interactive interface ");
puts("$Revision: 1.104 $ $Date: 1999/02/21 03:49:27 $\n");
puts("$Revision: 1.105 $ $Date: 1999/03/17 22:53:18 $\n");
}
/* ----------------

View File

@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.58 1999/03/16 03:24:17 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.59 1999/03/17 22:53:19 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -187,7 +187,7 @@ ProcessUtility(Node *parsetree,
foreach(arg, args)
{
relname = strVal(lfirst(arg));
if (IsSystemRelationName(relname))
if (!allowSystemTableMods && IsSystemRelationName(relname))
elog(ERROR, "class \"%s\" is a system catalog",
relname);
rel = heap_openr(relname);
@@ -268,7 +268,7 @@ ProcessUtility(Node *parsetree,
CHECK_IF_ABORTED();
relname = stmt->relname;
if (IsSystemRelationName(relname))
if (!allowSystemTableMods && IsSystemRelationName(relname))
elog(ERROR, "class \"%s\" is a system catalog",
relname);
#ifndef NO_SECURITY
@@ -457,7 +457,7 @@ ProcessUtility(Node *parsetree,
{
case INDEX:
relname = stmt->name;
if (IsSystemRelationName(relname))
if (!allowSystemTableMods && IsSystemRelationName(relname))
elog(ERROR, "class \"%s\" is a system catalog index",
relname);
#ifndef NO_SECURITY

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/init/globals.c,v 1.27 1999/02/13 23:20:00 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/init/globals.c,v 1.28 1999/03/17 22:53:19 momjian Exp $
*
* NOTES
* 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
* malloc? XXX */
char FloatFormat[20] = "%f";
int fsyncOff = 0;
bool disableFsync = false;
bool allowSystemTableMods = false;
int SortMem = 512;
char *IndexedCatalogNames[] = {