1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-23 14:01:44 +03:00

Require ownership permission for CREATE INDEX, per bug report.

Disallow CREATE INDEX on system catalogs, non-tables (views, sequences, etc).
Disallow CREATE/DROP TRIGGER on system catalogs, non-tables.
Disallow ALTER TABLE ADD/DROP CONSTRAINT on system catalogs.
Disallow FOREIGN KEY reference to non-table.
None of these things can actually work in the present system structure,
but the code was letting them pass without complaint.
This commit is contained in:
Tom Lane
2002-01-03 23:21:32 +00:00
parent d02f0aaa3b
commit dc6b4deb97
5 changed files with 58 additions and 14 deletions

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/indexcmds.c,v 1.61 2001/11/20 02:46:13 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/indexcmds.c,v 1.62 2002/01/03 23:19:36 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -73,6 +73,7 @@ DefineIndex(char *heapRelationName,
Oid *classObjectId;
Oid accessMethodId;
Oid relationId;
Relation rel;
HeapTuple tuple;
Form_pg_am accessMethodForm;
IndexInfo *indexInfo;
@ -90,12 +91,25 @@ DefineIndex(char *heapRelationName,
INDEX_MAX_KEYS);
/*
* compute heap relation id
* Open heap relation, acquire a suitable lock on it, remember its OID
*/
if ((relationId = RelnameFindRelid(heapRelationName)) == InvalidOid)
elog(ERROR, "DefineIndex: relation \"%s\" not found",
rel = heap_openr(heapRelationName, ShareLock);
/* Note: during bootstrap may see uncataloged relation */
if (rel->rd_rel->relkind != RELKIND_RELATION &&
rel->rd_rel->relkind != RELKIND_UNCATALOGED)
elog(ERROR, "DefineIndex: relation \"%s\" is not a table",
heapRelationName);
relationId = RelationGetRelid(rel);
heap_close(rel, NoLock);
if (!IsBootstrapProcessingMode() &&
IsSystemRelationName(heapRelationName) &&
!IndexesAreActive(relationId, false))
elog(ERROR, "Existing indexes are inactive. REINDEX first");
/*
* look up the access method, verify it can handle the requested
* features
@ -131,9 +145,6 @@ DefineIndex(char *heapRelationName,
CheckPredicate(cnfPred, rangetable, relationId);
}
if (!IsBootstrapProcessingMode() && IsSystemRelationName(heapRelationName) && !IndexesAreActive(relationId, false))
elog(ERROR, "Existing indexes are inactive. REINDEX first");
/*
* Prepare arguments for index_create, primarily an IndexInfo
* structure