Make toast-table creation and deletion work somewhat reliably.
Don't go through pg_exec_query_dest(), but directly to the execution routines. Also, extend parameter lists so that there's no need to change the global setting of allowSystemTableMods, a hack that was certain to cause trouble in the event of any error.
This commit is contained in:
parent
9cf327790d
commit
cdeca5f590
@ -9,7 +9,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/bootstrap/bootparse.y,v 1.30 2000/06/18 22:43:51 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/bootstrap/bootparse.y,v 1.31 2000/07/04 06:11:22 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -166,7 +166,7 @@ Boot_CreateStmt:
|
||||
puts("creating bootstrap relation");
|
||||
tupdesc = CreateTupleDesc(numattr,attrtypes);
|
||||
reldesc = heap_create(LexIDStr($3), tupdesc,
|
||||
false, true);
|
||||
false, true, true);
|
||||
if (DebugMode)
|
||||
puts("bootstrap relation created ok");
|
||||
}
|
||||
@ -177,7 +177,10 @@ Boot_CreateStmt:
|
||||
|
||||
tupdesc = CreateTupleDesc(numattr,attrtypes);
|
||||
id = heap_create_with_catalog(LexIDStr($3),
|
||||
tupdesc, RELKIND_RELATION, false);
|
||||
tupdesc,
|
||||
RELKIND_RELATION,
|
||||
false,
|
||||
true);
|
||||
if (!Quiet)
|
||||
printf("CREATED relation %s with OID %u\n",
|
||||
LexIDStr($3), id);
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.137 2000/07/03 23:09:27 wieck Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.138 2000/07/04 06:11:23 tgl Exp $
|
||||
*
|
||||
*
|
||||
* INTERFACE ROUTINES
|
||||
@ -172,7 +172,8 @@ Relation
|
||||
heap_create(char *relname,
|
||||
TupleDesc tupDesc,
|
||||
bool istemp,
|
||||
bool storage_create)
|
||||
bool storage_create,
|
||||
bool allow_system_table_mods)
|
||||
{
|
||||
static unsigned int uniqueId = 0;
|
||||
|
||||
@ -189,7 +190,7 @@ heap_create(char *relname,
|
||||
*/
|
||||
AssertArg(natts > 0);
|
||||
|
||||
if (relname && !allowSystemTableMods &&
|
||||
if (relname && !allow_system_table_mods &&
|
||||
IsSystemRelationName(relname) && IsNormalProcessingMode())
|
||||
{
|
||||
elog(ERROR, "Illegal class name '%s'"
|
||||
@ -744,7 +745,8 @@ Oid
|
||||
heap_create_with_catalog(char *relname,
|
||||
TupleDesc tupdesc,
|
||||
char relkind,
|
||||
bool istemp)
|
||||
bool istemp,
|
||||
bool allow_system_table_mods)
|
||||
{
|
||||
Relation pg_class_desc;
|
||||
Relation new_rel_desc;
|
||||
@ -769,9 +771,9 @@ heap_create_with_catalog(char *relname,
|
||||
(istemp && get_temp_rel_by_username(relname) != NULL))
|
||||
elog(ERROR, "Relation '%s' already exists", relname);
|
||||
|
||||
/* save user relation name because heap_create changes it */
|
||||
if (istemp)
|
||||
{
|
||||
/* save user relation name because heap_create changes it */
|
||||
temp_relname = pstrdup(relname); /* save original value */
|
||||
relname = palloc(NAMEDATALEN);
|
||||
strcpy(relname, temp_relname); /* heap_create will change this */
|
||||
@ -797,7 +799,8 @@ heap_create_with_catalog(char *relname,
|
||||
* work of creating the disk file for the relation.
|
||||
* ----------------
|
||||
*/
|
||||
new_rel_desc = heap_create(relname, tupdesc, istemp, false);
|
||||
new_rel_desc = heap_create(relname, tupdesc, istemp, false,
|
||||
allow_system_table_mods);
|
||||
|
||||
new_rel_oid = new_rel_desc->rd_att->attrs[0]->attrelid;
|
||||
|
||||
@ -1419,7 +1422,8 @@ DeleteTypeTuple(Relation rel)
|
||||
* --------------------------------
|
||||
*/
|
||||
void
|
||||
heap_drop_with_catalog(const char *relname)
|
||||
heap_drop_with_catalog(const char *relname,
|
||||
bool allow_system_table_mods)
|
||||
{
|
||||
Relation rel;
|
||||
Oid rid;
|
||||
@ -1438,7 +1442,7 @@ heap_drop_with_catalog(const char *relname)
|
||||
* ----------------
|
||||
*/
|
||||
/* allow temp of pg_class? Guess so. */
|
||||
if (!istemp && !allowSystemTableMods &&
|
||||
if (!istemp && !allow_system_table_mods &&
|
||||
IsSystemRelationName(RelationGetRelationName(rel)))
|
||||
elog(ERROR, "System relation '%s' cannot be destroyed",
|
||||
RelationGetRelationName(rel));
|
||||
@ -1546,15 +1550,9 @@ heap_drop_with_catalog(const char *relname)
|
||||
if (has_toasttable)
|
||||
{
|
||||
char toast_relname[NAMEDATALEN];
|
||||
bool old_allow;
|
||||
|
||||
old_allow = allowSystemTableMods;
|
||||
allowSystemTableMods = true;
|
||||
|
||||
sprintf(toast_relname, "pg_toast_%d", rid);
|
||||
heap_drop_with_catalog(toast_relname);
|
||||
|
||||
allowSystemTableMods = old_allow;
|
||||
sprintf(toast_relname, "pg_toast_%u", rid);
|
||||
heap_drop_with_catalog(toast_relname, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.121 2000/06/30 07:04:17 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.122 2000/07/04 06:11:23 tgl Exp $
|
||||
*
|
||||
*
|
||||
* INTERFACE ROUTINES
|
||||
@ -946,7 +946,8 @@ index_create(char *heapRelationName,
|
||||
Node *predicate,
|
||||
bool islossy,
|
||||
bool unique,
|
||||
bool primary)
|
||||
bool primary,
|
||||
bool allow_system_table_mods)
|
||||
{
|
||||
Relation heapRelation;
|
||||
Relation indexRelation;
|
||||
@ -989,13 +990,13 @@ index_create(char *heapRelationName,
|
||||
numatts,
|
||||
attNums);
|
||||
|
||||
/* save user relation name because heap_create changes it */
|
||||
if (istemp)
|
||||
{
|
||||
temp_relname = pstrdup(indexRelationName); /* save original value */
|
||||
/* save user relation name because heap_create changes it */
|
||||
temp_relname = pstrdup(indexRelationName); /* save original value */
|
||||
indexRelationName = palloc(NAMEDATALEN);
|
||||
strcpy(indexRelationName, temp_relname); /* heap_create will
|
||||
* change this */
|
||||
strcpy(indexRelationName, temp_relname); /* heap_create will
|
||||
* change this */
|
||||
}
|
||||
|
||||
/* ----------------
|
||||
@ -1003,7 +1004,7 @@ index_create(char *heapRelationName,
|
||||
* ----------------
|
||||
*/
|
||||
indexRelation = heap_create(indexRelationName, indexTupDesc,
|
||||
istemp, false);
|
||||
istemp, false, allow_system_table_mods);
|
||||
|
||||
/* ----------------
|
||||
* construct the index relation descriptor
|
||||
|
@ -15,7 +15,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/cluster.c,v 1.56 2000/06/17 23:41:36 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/cluster.c,v 1.57 2000/07/04 06:11:27 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -30,6 +30,7 @@
|
||||
#include "catalog/pg_proc.h"
|
||||
#include "commands/cluster.h"
|
||||
#include "commands/rename.h"
|
||||
#include "miscadmin.h"
|
||||
#include "utils/builtins.h"
|
||||
#include "utils/syscache.h"
|
||||
|
||||
@ -140,7 +141,7 @@ cluster(char *oldrelname, char *oldindexname)
|
||||
StartTransactionCommand();
|
||||
|
||||
/* Destroy old heap (along with its index) and rename new. */
|
||||
heap_drop_with_catalog(saveoldrelname);
|
||||
heap_drop_with_catalog(saveoldrelname, allowSystemTableMods);
|
||||
|
||||
CommitTransactionCommand();
|
||||
StartTransactionCommand();
|
||||
@ -176,7 +177,8 @@ copy_heap(Oid OIDOldHeap)
|
||||
tupdesc = CreateTupleDescCopy(OldHeapDesc);
|
||||
|
||||
OIDNewHeap = heap_create_with_catalog(NewName, tupdesc,
|
||||
RELKIND_RELATION, false);
|
||||
RELKIND_RELATION, false,
|
||||
allowSystemTableMods);
|
||||
|
||||
if (!OidIsValid(OIDNewHeap))
|
||||
elog(ERROR, "clusterheap: cannot create temporary heap relation\n");
|
||||
@ -276,7 +278,8 @@ copy_index(Oid OIDOldIndex, Oid OIDNewHeap)
|
||||
(Node *) NULL, /* XXX where's the predicate? */
|
||||
Old_pg_index_Form->indislossy,
|
||||
Old_pg_index_Form->indisunique,
|
||||
Old_pg_index_Form->indisprimary);
|
||||
Old_pg_index_Form->indisprimary,
|
||||
allowSystemTableMods);
|
||||
|
||||
setRelhasindexInplace(OIDNewHeap, true, false);
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.82 2000/07/03 23:09:33 wieck Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.83 2000/07/04 06:11:27 tgl Exp $
|
||||
*
|
||||
* NOTES
|
||||
* The PerformAddAttribute() code, like most of the relation
|
||||
@ -21,8 +21,10 @@
|
||||
|
||||
#include "catalog/catalog.h"
|
||||
#include "catalog/catname.h"
|
||||
#include "catalog/index.h"
|
||||
#include "catalog/indexing.h"
|
||||
#include "catalog/pg_attrdef.h"
|
||||
#include "catalog/pg_opclass.h"
|
||||
#include "commands/command.h"
|
||||
#include "executor/spi.h"
|
||||
#include "catalog/heap.h"
|
||||
@ -1184,22 +1186,18 @@ AlterTableCreateToastTable(const char *relationName)
|
||||
Form_pg_attribute *att;
|
||||
Relation class_rel;
|
||||
Relation ridescs[Num_pg_class_indices];
|
||||
Oid toast_relid = 2;
|
||||
Oid toast_idxid = 2;
|
||||
Oid toast_relid;
|
||||
Oid toast_idxid;
|
||||
bool has_toastable_attrs = false;
|
||||
bool old_allow;
|
||||
int i;
|
||||
|
||||
char toast_relname[NAMEDATALEN];
|
||||
char toast_idxname[NAMEDATALEN];
|
||||
char tmp_query[1024];
|
||||
Relation toast_rel;
|
||||
AttrNumber attNums[1];
|
||||
Oid classObjectId[1];
|
||||
|
||||
/*
|
||||
* permissions checking. this would normally be done in utility.c,
|
||||
* but this particular routine is recursive.
|
||||
*
|
||||
* normally, only the owner of a class can change its schema.
|
||||
* permissions checking. XXX exactly what is appropriate here?
|
||||
*/
|
||||
/*
|
||||
if (!allowSystemTableMods && IsSystemRelationName(relationName))
|
||||
@ -1215,7 +1213,7 @@ AlterTableCreateToastTable(const char *relationName)
|
||||
* Grab an exclusive lock on the target table, which we will NOT
|
||||
* release until end of transaction.
|
||||
*/
|
||||
rel = heap_openr(relationName, RowExclusiveLock);
|
||||
rel = heap_openr(relationName, AccessExclusiveLock);
|
||||
myrelid = RelationGetRelid(rel);
|
||||
|
||||
/*
|
||||
@ -1240,8 +1238,8 @@ AlterTableCreateToastTable(const char *relationName)
|
||||
* Get the pg_class tuple for the relation
|
||||
*/
|
||||
reltup = SearchSysCacheTuple(RELNAME,
|
||||
PointerGetDatum(relationName),
|
||||
0, 0, 0);
|
||||
PointerGetDatum(relationName),
|
||||
0, 0, 0);
|
||||
|
||||
if (!HeapTupleIsValid(reltup))
|
||||
elog(ERROR, "ALTER TABLE: relation \"%s\" not found",
|
||||
@ -1261,26 +1259,43 @@ AlterTableCreateToastTable(const char *relationName)
|
||||
relationName);
|
||||
|
||||
/*
|
||||
* Create the toast table and it's index
|
||||
* This is bad and ugly, because we need to override
|
||||
* allowSystemTableMods in order to keep the toast
|
||||
* table- and index-name out of the users namespace.
|
||||
* Create the toast table and its index
|
||||
*/
|
||||
sprintf(toast_relname, "pg_toast_%d", myrelid);
|
||||
sprintf(toast_idxname, "pg_toast_%d_idx", myrelid);
|
||||
sprintf(toast_relname, "pg_toast_%u", myrelid);
|
||||
sprintf(toast_idxname, "pg_toast_%u_idx", myrelid);
|
||||
|
||||
old_allow = allowSystemTableMods;
|
||||
allowSystemTableMods = true;
|
||||
/* this is pretty painful... need a tuple descriptor */
|
||||
tupdesc = CreateTemplateTupleDesc(3);
|
||||
TupleDescInitEntry(tupdesc, (AttrNumber) 1,
|
||||
"chunk_id",
|
||||
OIDOID,
|
||||
-1, 0, false);
|
||||
TupleDescInitEntry(tupdesc, (AttrNumber) 2,
|
||||
"chunk_seq",
|
||||
INT4OID,
|
||||
-1, 0, false);
|
||||
TupleDescInitEntry(tupdesc, (AttrNumber) 3,
|
||||
"chunk_data",
|
||||
TEXTOID, /* XXX wouldn't BYTEAOID be better? */
|
||||
-1, 0, false);
|
||||
|
||||
sprintf(tmp_query, "create table \"%s\" (chunk_id oid, chunk_seq int4, chunk_data text)",
|
||||
toast_relname);
|
||||
pg_exec_query_dest(tmp_query, None, CurrentMemoryContext);
|
||||
/* XXX use RELKIND_TOASTVALUE here? */
|
||||
/* XXX what if owning relation is temp? need we mark toasttable too? */
|
||||
heap_create_with_catalog(toast_relname, tupdesc, RELKIND_RELATION,
|
||||
false, true);
|
||||
|
||||
sprintf(tmp_query, "create index \"%s\" on \"%s\" (chunk_id)",
|
||||
toast_idxname, toast_relname);
|
||||
pg_exec_query_dest(tmp_query, None, CurrentMemoryContext);
|
||||
/* make the toast relation visible, else index creation will fail */
|
||||
CommandCounterIncrement();
|
||||
|
||||
allowSystemTableMods = old_allow;
|
||||
/* create index on chunk_id */
|
||||
attNums[0] = 1;
|
||||
classObjectId[0] = OID_OPS_OID;
|
||||
index_create(toast_relname, toast_idxname, NULL, NULL, BTREE_AM_OID,
|
||||
1, attNums, classObjectId,
|
||||
(Node *) NULL, false, false, false, true);
|
||||
|
||||
/* make the index visible in this transaction */
|
||||
CommandCounterIncrement();
|
||||
|
||||
/*
|
||||
* Get the OIDs of the newly created objects
|
||||
@ -1318,8 +1333,8 @@ AlterTableCreateToastTable(const char *relationName)
|
||||
|
||||
heap_freetuple(reltup);
|
||||
|
||||
heap_close(class_rel, RowExclusiveLock);
|
||||
heap_close(rel, NoLock);
|
||||
heap_close(class_rel, NoLock);
|
||||
}
|
||||
|
||||
|
||||
|
@ -9,9 +9,9 @@
|
||||
*
|
||||
* IDENTIFICATION
|
||||
<<<<<<< creatinh.c
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/creatinh.c,v 1.61 2000/06/12 03:40:29 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/creatinh.c,v 1.62 2000/07/04 06:11:27 tgl Exp $
|
||||
=======
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/creatinh.c,v 1.61 2000/06/12 03:40:29 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/creatinh.c,v 1.62 2000/07/04 06:11:27 tgl Exp $
|
||||
>>>>>>> 1.58
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
@ -27,6 +27,7 @@
|
||||
#include "catalog/pg_ipl.h"
|
||||
#include "catalog/pg_type.h"
|
||||
#include "commands/creatinh.h"
|
||||
#include "miscadmin.h"
|
||||
#include "utils/syscache.h"
|
||||
|
||||
/* ----------------
|
||||
@ -146,7 +147,8 @@ DefineRelation(CreateStmt *stmt, char relkind)
|
||||
}
|
||||
|
||||
relationId = heap_create_with_catalog(relname, descriptor,
|
||||
relkind, stmt->istemp);
|
||||
relkind, stmt->istemp,
|
||||
allowSystemTableMods);
|
||||
|
||||
StoreCatalogInheritance(relationId, inheritList);
|
||||
|
||||
@ -224,7 +226,7 @@ void
|
||||
RemoveRelation(char *name)
|
||||
{
|
||||
AssertArg(name);
|
||||
heap_drop_with_catalog(name);
|
||||
heap_drop_with_catalog(name, allowSystemTableMods);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/indexcmds.c,v 1.32 2000/06/28 03:31:28 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/indexcmds.c,v 1.33 2000/07/04 06:11:27 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -17,6 +17,7 @@
|
||||
|
||||
#include "access/genam.h"
|
||||
#include "access/heapam.h"
|
||||
#include "catalog/catalog.h"
|
||||
#include "catalog/catname.h"
|
||||
#include "catalog/heap.h"
|
||||
#include "catalog/index.h"
|
||||
@ -28,6 +29,7 @@
|
||||
#include "catalog/pg_proc.h"
|
||||
#include "catalog/pg_shadow.h"
|
||||
#include "commands/defrem.h"
|
||||
#include "miscadmin.h"
|
||||
#include "optimizer/clauses.h"
|
||||
#include "optimizer/planmain.h"
|
||||
#include "optimizer/prep.h"
|
||||
@ -38,8 +40,6 @@
|
||||
#include "utils/builtins.h"
|
||||
#include "utils/fmgroids.h"
|
||||
#include "utils/syscache.h"
|
||||
#include "miscadmin.h" /* ReindexDatabase() */
|
||||
#include "catalog/catalog.h" /* ReindexDatabase() */
|
||||
|
||||
#define IsFuncIndex(ATTR_LIST) (((IndexElem*)lfirst(ATTR_LIST))->args != NIL)
|
||||
|
||||
@ -197,7 +197,7 @@ DefineIndex(char *heapRelationName,
|
||||
accessMethodId, numberOfAttributes, attributeNumberA,
|
||||
classObjectId,
|
||||
(Node *) cnfPred,
|
||||
lossy, unique, primary);
|
||||
lossy, unique, primary, allowSystemTableMods);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -215,7 +215,7 @@ DefineIndex(char *heapRelationName,
|
||||
accessMethodId, numberOfAttributes, attributeNumberA,
|
||||
classObjectId,
|
||||
(Node *) cnfPred,
|
||||
lossy, unique, primary);
|
||||
lossy, unique, primary, allowSystemTableMods);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/remove.c,v 1.49 2000/05/28 20:34:50 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/remove.c,v 1.50 2000/07/04 06:11:29 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -236,7 +236,7 @@ AttributeAndRelationRemove(Oid typeOid)
|
||||
char *name;
|
||||
|
||||
name = NameStr(((Form_pg_class) GETSTRUCT(tup))->relname);
|
||||
heap_drop_with_catalog(name);
|
||||
heap_drop_with_catalog(name, allowSystemTableMods);
|
||||
}
|
||||
heap_endscan(scan);
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $Id: view.c,v 1.44 2000/06/30 07:06:05 tgl Exp $
|
||||
* $Id: view.c,v 1.45 2000/07/04 06:11:30 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -17,6 +17,7 @@
|
||||
#include "catalog/heap.h"
|
||||
#include "commands/creatinh.h"
|
||||
#include "commands/view.h"
|
||||
#include "miscadmin.h"
|
||||
#include "nodes/makefuncs.h"
|
||||
#include "parser/parse_relation.h"
|
||||
#include "parser/parse_type.h"
|
||||
@ -296,5 +297,5 @@ RemoveView(char *viewName)
|
||||
* We just have to drop the relation; the associated rules will
|
||||
* be cleaned up automatically.
|
||||
*/
|
||||
heap_drop_with_catalog(viewName);
|
||||
heap_drop_with_catalog(viewName, allowSystemTableMods);
|
||||
}
|
||||
|
@ -27,7 +27,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.118 2000/06/17 21:48:47 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.119 2000/07/04 06:11:33 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -877,8 +877,12 @@ InitPlan(CmdType operation, Query *parseTree, Plan *plan, EState *estate)
|
||||
*/
|
||||
tupdesc = CreateTupleDescCopy(tupType);
|
||||
|
||||
intoRelationId = heap_create_with_catalog(intoName,
|
||||
tupdesc, RELKIND_RELATION, parseTree->isTemp);
|
||||
intoRelationId =
|
||||
heap_create_with_catalog(intoName,
|
||||
tupdesc,
|
||||
RELKIND_RELATION,
|
||||
parseTree->isTemp,
|
||||
allowSystemTableMods);
|
||||
|
||||
FreeTupleDesc(tupdesc);
|
||||
|
||||
|
@ -9,7 +9,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/libpq/Attic/be-pqexec.c,v 1.33 2000/06/28 03:31:41 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/libpq/Attic/be-pqexec.c,v 1.34 2000/07/04 06:11:37 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -136,7 +136,11 @@ PQexec(char *query)
|
||||
* pg_exec_query_dest will put the query results in a portal which will
|
||||
* end up on the top of the portal stack.
|
||||
*
|
||||
* XXX memory context manipulation needs thought here.
|
||||
* XXX memory context manipulation is WRONG here --- the query needs
|
||||
* to be executed in a context different from CurrentMemoryContext,
|
||||
* perhaps a freshly created sub-context. If I were expecting that
|
||||
* this code needs to work again, then I'd fix it. But actually I'm
|
||||
* planning to rip out this entire module sometime soon... tgl 7/2000.
|
||||
* ----------------
|
||||
*/
|
||||
pg_exec_query_dest(query, Local, CurrentMemoryContext);
|
||||
|
@ -9,7 +9,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/large_object/inv_api.c,v 1.72 2000/06/28 03:32:04 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/large_object/inv_api.c,v 1.73 2000/07/04 06:11:39 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -137,7 +137,8 @@ inv_create(int flags)
|
||||
* be located on whatever storage manager the user requested.
|
||||
*/
|
||||
|
||||
heap_create_with_catalog(objname, tupdesc, RELKIND_LOBJECT, false);
|
||||
heap_create_with_catalog(objname, tupdesc, RELKIND_LOBJECT,
|
||||
false, false);
|
||||
|
||||
/* make the relation visible in this transaction */
|
||||
CommandCounterIncrement();
|
||||
@ -165,7 +166,7 @@ inv_create(int flags)
|
||||
classObjectId[0] = INT4_OPS_OID;
|
||||
index_create(objname, indname, NULL, NULL, BTREE_AM_OID,
|
||||
1, &attNums[0], &classObjectId[0],
|
||||
(Node *) NULL, false, false, false);
|
||||
(Node *) NULL, false, false, false, false);
|
||||
|
||||
/* make the index visible in this transaction */
|
||||
CommandCounterIncrement();
|
||||
@ -297,7 +298,7 @@ inv_drop(Oid lobjId)
|
||||
* Since heap_drop_with_catalog will destroy the relcache entry,
|
||||
* there's no need to drop the refcount in this path.
|
||||
*/
|
||||
heap_drop_with_catalog(RelationGetRelationName(r));
|
||||
heap_drop_with_catalog(RelationGetRelationName(r), false);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.165 2000/07/03 20:48:37 petere Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.166 2000/07/04 06:11:43 tgl Exp $
|
||||
*
|
||||
* NOTES
|
||||
* this is the "main" module of the postgres backend and
|
||||
@ -538,7 +538,7 @@ pg_plan_query(Query *querytree)
|
||||
*
|
||||
* parse_context references a context suitable for holding the
|
||||
* parse/rewrite trees (typically this will be QueryContext).
|
||||
* This context must be longer-lived than the CurrentMemoryContext!
|
||||
* This context *must* be longer-lived than the CurrentMemoryContext!
|
||||
* In fact, if the query string might contain BEGIN/COMMIT commands,
|
||||
* parse_context had better outlive TopTransactionContext!
|
||||
*
|
||||
@ -559,6 +559,16 @@ pg_exec_query_dest(char *query_string, /* string to execute */
|
||||
List *querytree_list,
|
||||
*querytree_item;
|
||||
|
||||
/*
|
||||
* If you called this routine with parse_context = CurrentMemoryContext,
|
||||
* you blew it. They *must* be different, else the context reset
|
||||
* at the bottom of the loop will destroy the querytree list.
|
||||
* (We really ought to check that parse_context isn't a child of
|
||||
* CurrentMemoryContext either, but that would take more cycles than
|
||||
* it's likely to be worth.)
|
||||
*/
|
||||
Assert(parse_context != CurrentMemoryContext);
|
||||
|
||||
/*
|
||||
* Switch to appropriate context for constructing parsetrees.
|
||||
*/
|
||||
@ -1404,7 +1414,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
|
||||
if (!IsUnderPostmaster)
|
||||
{
|
||||
puts("\nPOSTGRES backend interactive interface ");
|
||||
puts("$Revision: 1.165 $ $Date: 2000/07/03 20:48:37 $\n");
|
||||
puts("$Revision: 1.166 $ $Date: 2000/07/04 06:11:43 $\n");
|
||||
}
|
||||
|
||||
/*
|
||||
|
5
src/backend/utils/cache/temprel.c
vendored
5
src/backend/utils/cache/temprel.c
vendored
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/cache/Attic/temprel.c,v 1.25 2000/06/28 03:32:25 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/cache/Attic/temprel.c,v 1.26 2000/07/04 06:11:47 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -33,6 +33,7 @@
|
||||
|
||||
#include "catalog/heap.h"
|
||||
#include "catalog/index.h"
|
||||
#include "miscadmin.h"
|
||||
#include "utils/catcache.h"
|
||||
#include "utils/temprel.h"
|
||||
|
||||
@ -112,7 +113,7 @@ remove_all_temp_relations(void)
|
||||
|
||||
/* safe from deallocation */
|
||||
strcpy(relname, temp_rel->user_relname);
|
||||
heap_drop_with_catalog(relname);
|
||||
heap_drop_with_catalog(relname, allowSystemTableMods);
|
||||
}
|
||||
else
|
||||
index_drop(temp_rel->relid);
|
||||
|
@ -6,7 +6,7 @@
|
||||
*
|
||||
* Copyright (c) 2000, PostgreSQL Development Team
|
||||
*
|
||||
* $Id: tuptoaster.h,v 1.4 2000/07/04 00:04:03 tgl Exp $
|
||||
* $Id: tuptoaster.h,v 1.5 2000/07/04 06:11:50 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -34,10 +34,6 @@ extern void heap_tuple_toast_attrs(Relation rel,
|
||||
|
||||
extern varattrib *heap_tuple_untoast_attr(varattrib * attr);
|
||||
|
||||
extern void heap_create_toast_table(Oid new_reloid,
|
||||
TupleDesc new_tupdesc, bool istemp);
|
||||
|
||||
|
||||
#endif /* TUPLE_TOASTER_ACTIVE */
|
||||
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $Id: heap.h,v 1.30 2000/06/18 22:44:25 tgl Exp $
|
||||
* $Id: heap.h,v 1.31 2000/07/04 06:11:54 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -26,13 +26,18 @@ typedef struct RawColumnDefault
|
||||
extern Oid RelnameFindRelid(const char *relname);
|
||||
|
||||
extern Relation heap_create(char *relname, TupleDesc tupDesc,
|
||||
bool istemp, bool storage_create);
|
||||
bool istemp, bool storage_create,
|
||||
bool allow_system_table_mods);
|
||||
|
||||
extern bool heap_storage_create(Relation rel);
|
||||
|
||||
extern Oid heap_create_with_catalog(char *relname, TupleDesc tupdesc,
|
||||
char relkind, bool istemp);
|
||||
char relkind, bool istemp,
|
||||
bool allow_system_table_mods);
|
||||
|
||||
extern void heap_drop_with_catalog(const char *relname,
|
||||
bool allow_system_table_mods);
|
||||
|
||||
extern void heap_drop_with_catalog(const char *relname);
|
||||
extern void heap_truncate(char *relname);
|
||||
|
||||
extern void AddRelationRawConstraints(Relation rel,
|
||||
|
@ -7,7 +7,7 @@
|
||||
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $Id: index.h,v 1.26 2000/06/30 07:04:06 tgl Exp $
|
||||
* $Id: index.h,v 1.27 2000/07/04 06:11:54 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -37,7 +37,8 @@ extern void index_create(char *heapRelationName,
|
||||
Node *predicate,
|
||||
bool islossy,
|
||||
bool unique,
|
||||
bool primary);
|
||||
bool primary,
|
||||
bool allow_system_table_mods);
|
||||
|
||||
extern void index_drop(Oid indexId);
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $Id: pg_opclass.h,v 1.33 2000/06/19 03:54:45 tgl Exp $
|
||||
* $Id: pg_opclass.h,v 1.34 2000/07/04 06:11:54 tgl Exp $
|
||||
*
|
||||
* NOTES
|
||||
* the genbki.sh script reads this file and generates .bki
|
||||
@ -74,6 +74,7 @@ DESCR("");
|
||||
#define INT4_OPS_OID 426
|
||||
DATA(insert OID = 427 ( oid_ops 26 ));
|
||||
DESCR("");
|
||||
#define OID_OPS_OID 427
|
||||
DATA(insert OID = 428 ( float4_ops 700 ));
|
||||
DESCR("");
|
||||
DATA(insert OID = 429 ( char_ops 18 ));
|
||||
|
Loading…
x
Reference in New Issue
Block a user