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[] = {

View File

@ -26,7 +26,7 @@
#
#
# IDENTIFICATION
# $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.57 1999/01/28 15:28:40 wieck Exp $
# $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.58 1999/03/17 22:53:25 momjian Exp $
#
#-------------------------------------------------------------------------
@ -398,7 +398,7 @@ fi
echo
PGSQL_OPT="-o /dev/null -F -Q -D$PGDATA"
PGSQL_OPT="-o /dev/null -O -F -Q -D$PGDATA"
# If the COPY is first, the VACUUM generates an error, so we vacuum first
echo "Vacuuming template1"
@ -408,7 +408,7 @@ echo "COPY pg_shadow TO '$PGDATA/pg_pwd' USING DELIMITERS '\\t'" | \
postgres $PGSQL_OPT template1 > /dev/null
echo "Creating public pg_user view"
echo "CREATE TABLE xpg_user ( \
echo "CREATE TABLE pg_user ( \
usename name, \
usesysid int4, \
usecreatedb bool, \
@ -418,12 +418,6 @@ echo "CREATE TABLE xpg_user ( \
passwd text, \
valuntil abstime);" | postgres $PGSQL_OPT template1 > /dev/null
#move it into pg_user
echo "UPDATE pg_class SET relname = 'pg_user' WHERE relname = 'xpg_user';" |\
postgres $PGSQL_OPT template1 > /dev/null
echo "UPDATE pg_type SET typname = 'pg_user' WHERE typname = 'xpg_user';" |\
postgres $PGSQL_OPT template1 > /dev/null
mv $PGDATA/base/template1/xpg_user $PGDATA/base/template1/pg_user
echo "CREATE RULE \"_RETpg_user\" AS ON SELECT TO pg_user DO INSTEAD \
SELECT usename, usesysid, usecreatedb, usetrace, \
@ -434,16 +428,10 @@ echo "REVOKE ALL on pg_shadow FROM public" | \
postgres $PGSQL_OPT template1 > /dev/null
echo "Creating view pg_rules"
echo "CREATE TABLE xpg_rules ( \
echo "CREATE TABLE pg_rules ( \
tablename name, \
rulename name, \
definition text);" | postgres $PGSQL_OPT template1 > /dev/null
#move it into pg_rules
echo "UPDATE pg_class SET relname = 'pg_rules' WHERE relname = 'xpg_rules';" |\
postgres $PGSQL_OPT template1 > /dev/null
echo "UPDATE pg_type SET typname = 'pg_rules' WHERE typname = 'xpg_rules';" |\
postgres $PGSQL_OPT template1 > /dev/null
mv $PGDATA/base/template1/xpg_rules $PGDATA/base/template1/pg_rules
echo "CREATE RULE \"_RETpg_rules\" AS ON SELECT TO pg_rules DO INSTEAD \
SELECT C.relname AS tablename, \
@ -455,16 +443,10 @@ echo "CREATE RULE \"_RETpg_rules\" AS ON SELECT TO pg_rules DO INSTEAD \
postgres $PGSQL_OPT template1 > /dev/null
echo "Creating view pg_views"
echo "CREATE TABLE xpg_views ( \
echo "CREATE TABLE pg_views ( \
viewname name, \
viewowner name, \
definition text);" | postgres $PGSQL_OPT template1 > /dev/null
#move it into pg_views
echo "UPDATE pg_class SET relname = 'pg_views' WHERE relname = 'xpg_views';" |\
postgres $PGSQL_OPT template1 > /dev/null
echo "UPDATE pg_type SET typname = 'pg_views' WHERE typname = 'xpg_views';" |\
postgres $PGSQL_OPT template1 > /dev/null
mv $PGDATA/base/template1/xpg_views $PGDATA/base/template1/pg_views
echo "CREATE RULE \"_RETpg_views\" AS ON SELECT TO pg_views DO INSTEAD \
SELECT C.relname AS viewname, \
@ -476,18 +458,12 @@ echo "CREATE RULE \"_RETpg_views\" AS ON SELECT TO pg_views DO INSTEAD \
postgres $PGSQL_OPT template1 > /dev/null
echo "Creating view pg_tables"
echo "CREATE TABLE xpg_tables ( \
echo "CREATE TABLE pg_tables ( \
tablename name, \
tableowner name, \
hasindexes bool, \
hasrules bool, \
hastriggers bool);" | postgres $PGSQL_OPT template1 > /dev/null
#move it into pg_tables
echo "UPDATE pg_class SET relname = 'pg_tables' WHERE relname = 'xpg_tables';" |\
postgres $PGSQL_OPT template1 > /dev/null
echo "UPDATE pg_type SET typname = 'pg_tables' WHERE typname = 'xpg_tables';" |\
postgres $PGSQL_OPT template1 > /dev/null
mv $PGDATA/base/template1/xpg_tables $PGDATA/base/template1/pg_tables
echo "CREATE RULE \"_RETpg_tables\" AS ON SELECT TO pg_tables DO INSTEAD \
SELECT C.relname AS tablename, \
@ -501,16 +477,10 @@ echo "CREATE RULE \"_RETpg_tables\" AS ON SELECT TO pg_tables DO INSTEAD \
postgres $PGSQL_OPT template1 > /dev/null
echo "Creating view pg_indexes"
echo "CREATE TABLE xpg_indexes ( \
echo "CREATE TABLE pg_indexes ( \
tablename name, \
indexname name, \
indexdef text);" | postgres $PGSQL_OPT template1 > /dev/null
#move it into pg_indexes
echo "UPDATE pg_class SET relname = 'pg_indexes' WHERE relname = 'xpg_indexes';" |\
postgres $PGSQL_OPT template1 > /dev/null
echo "UPDATE pg_type SET typname = 'pg_indexes' WHERE typname = 'xpg_indexes';" |\
postgres $PGSQL_OPT template1 > /dev/null
mv $PGDATA/base/template1/xpg_indexes $PGDATA/base/template1/pg_indexes
echo "CREATE RULE \"_RETpg_indexes\" AS ON SELECT TO pg_indexes DO INSTEAD \
SELECT C.relname AS tablename, \
@ -528,4 +498,3 @@ echo "copy pg_description from '$GLOBAL_DESCR'" | \
postgres $PGSQL_OPT template1 > /dev/null
echo "vacuum analyze" | \
postgres $PGSQL_OPT template1 > /dev/null

View File

@ -11,7 +11,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: miscadmin.h,v 1.35 1999/02/13 23:20:46 momjian Exp $
* $Id: miscadmin.h,v 1.36 1999/03/17 22:53:30 momjian Exp $
*
* NOTES
* some of the information in this file will be moved to
@ -94,7 +94,8 @@ extern char CTZName[];
extern char FloatFormat[];
extern char DateFormat[];
extern int fsyncOff;
extern bool disableFsync;
extern bool allowSystemTableMods;
extern int SortMem;
extern Oid LastOidProcessed; /* for query rewrite */

View File

@ -1,6 +1,6 @@
.\" This is -*-nroff-*-
.\" XXX standard disclaimer belongs here....
.\" $Header: /cvsroot/pgsql/src/man/Attic/postgres.1,v 1.13 1999/02/18 05:26:34 momjian Exp $
.\" $Header: /cvsroot/pgsql/src/man/Attic/postgres.1,v 1.14 1999/03/17 22:53:31 momjian Exp $
.TH POSTGRESQL UNIX 12/08/96 PostgreSQL PostgreSQL
.SH NAME
postgres - the Postgres backend server
@ -22,6 +22,9 @@ data_directory]
.BR "-F"
]
[\c
.BR "-O"
]
[\c
.BR "-P"
filedes]
[\c
@ -99,6 +102,9 @@ Disable automatic fsync() call after each transaction.
This option improves performance, but an operating system crash
while a transaction is in progress will probably cause data loss.
.TP
.BR "-O"
Override restrictions, so system table structures can be modified(pg_*).
.TP
.BR "-P" " filedes"
.IR "filedes"
specifies the file descriptor that corresponds to the socket (port) on