Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Eisentraut2000-01-22 14:20:56 +0000
committerPeter Eisentraut2000-01-22 14:20:56 +0000
commitfa5400c0a40eab95499da5a54d8a526593a1f243 (patch)
treea3f2e20f0822b7cb850d51045c19e4f22cc5acb0 /src/backend
parent3f51bdafdca99e7f30c7198c218e66fe009a3dd9 (diff)
added ALTER TABLE DROP COLUMN, early version
Diffstat (limited to 'src/backend')
-rw-r--r--src/backend/access/heap/heapam.c4
-rw-r--r--src/backend/catalog/catalog.c4
-rw-r--r--src/backend/catalog/heap.c6
-rw-r--r--src/backend/catalog/pg_type.c4
-rw-r--r--src/backend/commands/command.c227
-rw-r--r--src/backend/commands/rename.c4
-rw-r--r--src/backend/parser/gram.y6
-rw-r--r--src/backend/utils/adt/name.c24
-rw-r--r--src/backend/utils/cache/relcache.c18
-rw-r--r--src/backend/utils/cache/temprel.c10
10 files changed, 255 insertions, 52 deletions
diff --git a/src/backend/access/heap/heapam.c b/src/backend/access/heap/heapam.c
index 4b7c4096222..6383a49dac5 100644
--- a/src/backend/access/heap/heapam.c
+++ b/src/backend/access/heap/heapam.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.63 2000/01/10 06:30:50 inoue Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.64 2000/01/22 14:20:43 petere Exp $
*
*
* INTERFACE ROUTINES
@@ -562,7 +562,7 @@ heap_open(Oid relationId, LOCKMODE lockmode)
* ----------------
*/
Relation
-heap_openr(char *relationName, LOCKMODE lockmode)
+heap_openr(const char *relationName, LOCKMODE lockmode)
{
Relation r;
diff --git a/src/backend/catalog/catalog.c b/src/backend/catalog/catalog.c
index 20256babded..d4d167739a9 100644
--- a/src/backend/catalog/catalog.c
+++ b/src/backend/catalog/catalog.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/catalog/catalog.c,v 1.28 2000/01/16 20:04:54 petere Exp $
+ * $Header: /cvsroot/pgsql/src/backend/catalog/catalog.c,v 1.29 2000/01/22 14:20:44 petere Exp $
*
*-------------------------------------------------------------------------
*/
@@ -38,7 +38,7 @@ relpath(const char *relname)
snprintf(path, bufsize, "%s/%s", DataDir, relname);
return path;
}
- return relname;
+ return pstrdup(relname);
}
/*
diff --git a/src/backend/catalog/heap.c b/src/backend/catalog/heap.c
index d61df6561b6..dc578bd8c2b 100644
--- a/src/backend/catalog/heap.c
+++ b/src/backend/catalog/heap.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.117 2000/01/17 23:57:43 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.118 2000/01/22 14:20:44 petere Exp $
*
*
* INTERFACE ROUTINES
@@ -480,7 +480,7 @@ CheckAttributeNames(TupleDesc tupdesc)
* --------------------------------
*/
Oid
-RelnameFindRelid(char *relname)
+RelnameFindRelid(const char *relname)
{
HeapTuple tuple;
Oid relid;
@@ -1441,7 +1441,7 @@ DeleteTypeTuple(Relation rel)
* --------------------------------
*/
void
-heap_drop_with_catalog(char *relname)
+heap_drop_with_catalog(const char *relname)
{
Relation rel;
Oid rid;
diff --git a/src/backend/catalog/pg_type.c b/src/backend/catalog/pg_type.c
index 3de8020595c..2be9fd68363 100644
--- a/src/backend/catalog/pg_type.c
+++ b/src/backend/catalog/pg_type.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/catalog/pg_type.c,v 1.47 2000/01/17 23:57:43 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/catalog/pg_type.c,v 1.48 2000/01/22 14:20:44 petere Exp $
*
*-------------------------------------------------------------------------
*/
@@ -525,7 +525,7 @@ TypeCreate(char *typeName,
* ----------------------------------------------------------------
*/
void
-TypeRename(char *oldTypeName, char *newTypeName)
+TypeRename(const char *oldTypeName, const char *newTypeName)
{
Relation pg_type_desc;
Relation idescs[Num_pg_type_indices];
diff --git a/src/backend/commands/command.c b/src/backend/commands/command.c
index 93322d7a7f7..5c29dd692ac 100644
--- a/src/backend/commands/command.c
+++ b/src/backend/commands/command.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.63 2000/01/16 20:04:55 petere Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.64 2000/01/22 14:20:45 petere Exp $
*
* NOTES
* The PortalExecutorHeapMemory crap needs to be eliminated
@@ -30,6 +30,7 @@
#include "catalog/pg_attrdef.h"
#include "catalog/pg_type.h"
#include "commands/command.h"
+#include "commands/rename.h"
#include "executor/execdefs.h"
#include "executor/executor.h"
#include "catalog/heap.h"
@@ -299,7 +300,7 @@ AlterTableAddColumn(const char *relationName,
Relation idescs[Num_pg_attr_indices];
Relation ridescs[Num_pg_class_indices];
bool hasindex;
- List *rawDefaults = NIL;
+// List *rawDefaults = NIL;
/*
* permissions checking. this would normally be done in utility.c,
@@ -319,7 +320,7 @@ AlterTableAddColumn(const char *relationName,
* Grab an exclusive lock on the target table, which we will NOT release
* until end of transaction.
*/
- rel = heap_openr((char *)relationName, AccessExclusiveLock);
+ rel = heap_openr(relationName, AccessExclusiveLock);
myrelid = RelationGetRelid(rel);
heap_close(rel, NoLock); /* close rel but keep lock! */
@@ -519,8 +520,7 @@ AlterTableAlterColumn(const char *relationName,
elog(ERROR, "ALTER TABLE: permission denied");
#endif
- /* XXX should heap_openr take const char * ? */
- rel = heap_openr((char *)relationName, AccessExclusiveLock);
+ rel = heap_openr(relationName, AccessExclusiveLock);
myrelid = RelationGetRelid(rel);
heap_close(rel, NoLock);
@@ -626,7 +626,7 @@ AlterTableAlterColumn(const char *relationName,
/* keep the system catalog indices current */
CatalogOpenIndices(Num_pg_attr_indices, Name_pg_attr_indices, irelations);
CatalogIndexInsert(irelations, Num_pg_attr_indices, attr_rel, newtuple);
- CatalogCloseIndices(Num_pg_class_indices, irelations);
+ CatalogCloseIndices(Num_pg_attrdef_indices, irelations);
/* get rid of actual default definition */
drop_default(myrelid, attnum);
@@ -672,31 +672,234 @@ drop_default(Oid relid, int16 attnum)
/*
* ALTER TABLE DROP COLUMN
+ *
+ * Strategy:
+ * - permission/sanity checks
+ * - create a new table _ATDC<name> with all attributes minus the desired one
+ * - copy over all the data
+ * - make the column defaults point to the new table
+ * - kill the old table
+ * - rename the intermediate table back
*/
void
AlterTableDropColumn(const char *relationName,
bool inh, const char *colName,
int behavior)
{
- elog(NOTICE, "ALTER TABLE / DROP COLUMN is not implemented");
+ Relation oldrel, newrel, defrel;
+ HeapTuple tuple;
+ TupleDesc olddesc, newdesc, defdsc;
+ int16 dropattnum, oldnumatts;
+ Oid oldrel_oid, newrel_oid;
+ char tmpname[NAMEDATALEN];
+ int16 i;
+ HeapScanDesc scan;
+ ScanKeyData scankey;
+
+ if (!allowSystemTableMods && IsSystemRelationName(relationName))
+ elog(ERROR, "ALTER TABLE: relation \"%s\" is a system catalog",
+ relationName);
+#ifndef NO_SECURITY
+ if (!pg_ownercheck(UserName, relationName, RELNAME))
+ elog(ERROR, "ALTER TABLE: permission denied");
+#endif
+
+ oldrel = heap_openr(relationName, AccessExclusiveLock);
+ if (oldrel->rd_rel->relkind != RELKIND_RELATION)
+ {
+ heap_close(oldrel, AccessExclusiveLock);
+ elog(ERROR, "ALTER TABLE: relation %s is not a table", relationName);
+ }
+
+ oldrel_oid = ObjectIdGetDatum(RelationGetRelid(oldrel));
+ oldnumatts = RelationGetNumberOfAttributes(oldrel);
+
+ if (oldnumatts==1)
+ {
+ heap_close(oldrel, AccessExclusiveLock);
+ elog(ERROR, "ALTER TABLE: relation %s only has one column", relationName);
+ }
+
+/* What to do here? */
+/*
+ if (length(find_all_inheritors(RelationGetRelid(oldrel)))>0)
+ elog(ERROR, "ALTER TABLE: cannot drop a column on table that is inherited from");
+*/
+ /*
+ * get the number of the attribute
+ */
+ tuple = SearchSysCacheTuple(ATTNAME, oldrel_oid, NameGetDatum(namein(colName)), 0, 0);
+ if (!HeapTupleIsValid(tuple))
+ {
+ heap_close(oldrel, AccessExclusiveLock);
+ elog(ERROR, "ALTER TABLE: relation \"%s\" has no column \"%s\"",
+ relationName, colName);
+ }
+
+ dropattnum = ((Form_pg_attribute) GETSTRUCT(tuple))->attnum;
+
+ if (snprintf(tmpname, NAMEDATALEN, "_ATDC%s", relationName)==-1)
+ {
+ heap_close(oldrel, AccessExclusiveLock);
+ elog(ERROR, "AlterTableDropColumn: relation name too long");
+ }
+
+ /*
+ * Build descriptor for new relation
+ */
+ olddesc = RelationGetDescr(oldrel);
+
+ newdesc = CreateTemplateTupleDesc(oldnumatts-1);
+ for(i = 1; i < dropattnum; i++)
+ {
+ Form_pg_attribute att = olddesc->attrs[i-1];
+ TupleDescInitEntry(newdesc, i, nameout(&(att->attname)),
+ att->atttypid, att->atttypmod,
+ att->attnelems, att->attisset);
+ /* the above function doesn't take care of these two */
+ newdesc->attrs[i-1]->attnotnull = att->attnotnull;
+ newdesc->attrs[i-1]->atthasdef = att->atthasdef;
+ }
+
+ for(i = dropattnum; i <= oldnumatts-1; i++)
+ {
+ Form_pg_attribute att = olddesc->attrs[i];
+ TupleDescInitEntry(newdesc, i, nameout(&(att->attname)),
+ att->atttypid, att->atttypmod,
+ att->attnelems, att->attisset);
+ /* the above function doesn't take care of these two */
+ newdesc->attrs[i-1]->attnotnull = att->attnotnull;
+ newdesc->attrs[i-1]->atthasdef = att->atthasdef;
+ }
+
+ /* Create the new table */
+ newrel_oid = heap_create_with_catalog(tmpname, newdesc, RELKIND_RELATION, false);
+ if (newrel_oid == InvalidOid)
+ {
+ heap_close(oldrel, AccessExclusiveLock);
+ elog(ERROR, "ALTER TABLE: something went wrong");
+ }
+
+ /* Make the new table visible */
+ CommandCounterIncrement();
+
+ /*
+ * Copy over the data
+ */
+ newrel = heap_open(newrel_oid, AccessExclusiveLock);
+
+ scan = heap_beginscan(oldrel, false, SnapshotNow, 0, NULL);
+ while (HeapTupleIsValid(tuple = heap_getnext(scan, 0)))
+ {
+ bool isnull;
+ Datum *new_record;
+ bool *new_record_nulls;
+ HeapTuple new_tuple;
+
+ new_record = palloc((oldnumatts-1) * sizeof(*new_record));
+ new_record_nulls = palloc((oldnumatts-1) * sizeof(*new_record_nulls));
+
+ for(i = 1; i < dropattnum; i++)
+ {
+ new_record[i-1] = heap_getattr(tuple, i, olddesc, &isnull);
+ new_record_nulls[i-1] = isnull ? 'n' : ' ';
+ }
+ for(i = dropattnum+1; i <= oldnumatts; i++)
+ {
+ new_record[i-2] = heap_getattr(tuple, i, olddesc, &isnull);
+ new_record_nulls[i-2] = isnull ? 'n' : ' ';
+ }
+
+ new_tuple = heap_formtuple(newdesc, new_record, new_record_nulls);
+ Assert(new_tuple);
+
+ if (heap_insert(newrel, new_tuple) == InvalidOid)
+ elog(ERROR, "AlterTableDropColumn: heap_insert failed");
+
+ pfree(new_record);
+ pfree(new_record_nulls);
+ }
+ heap_endscan(scan);
+
+ heap_close(newrel, NoLock);
+ heap_close(oldrel, NoLock);
+
+ /*
+ * Move defaults over to the new table
+ */
+ defrel = heap_openr(AttrDefaultRelationName, AccessExclusiveLock);
+ defdsc = RelationGetDescr(defrel);
+
+ /* look for all entries referencing the old table */
+ ScanKeyEntryInitialize(&scankey, 0x0, Anum_pg_attrdef_adrelid, F_OIDEQ,
+ ObjectIdGetDatum(oldrel_oid));
+ scan = heap_beginscan(defrel, false, SnapshotNow, 1, &scankey);
+ while(HeapTupleIsValid(tuple = heap_getnext(scan, false)))
+ {
+ HeapTuple newtuple;
+ int2 attrnum;
+ Relation irelations[Num_pg_attrdef_indices];
+
+ attrnum = ((Form_pg_attrdef) GETSTRUCT(tuple))->adnum;
+
+ /* remove the entry about the dropped column */
+ if (attrnum == dropattnum)
+ {
+ heap_delete(defrel, &tuple->t_self, NULL);
+ continue;
+ }
+
+ newtuple = heap_copytuple(tuple);
+
+ if (attrnum > dropattnum)
+ ((Form_pg_attrdef) GETSTRUCT(newtuple))->adnum--;
+
+ /* make it point to the new table */
+ ((Form_pg_attrdef) GETSTRUCT(newtuple))->adrelid = newrel_oid;
+ heap_update(defrel, &tuple->t_self, newtuple, NULL);
+
+ /* keep the system catalog indices current */
+ CatalogOpenIndices(Num_pg_attrdef_indices, Name_pg_attrdef_indices, irelations);
+ CatalogIndexInsert(irelations, Num_pg_attrdef_indices, defrel, newtuple);
+ CatalogCloseIndices(Num_pg_attrdef_indices, irelations);
+ }
+ heap_endscan(scan);
+ heap_close(defrel, NoLock);
+
+ CommandCounterIncrement();
+
+ /* make the old table disappear */
+ heap_drop_with_catalog(relationName);
+ CommandCounterIncrement();
+
+ /* set back original name */
+ TypeRename(tmpname, relationName);
+ renamerel(tmpname, relationName);
}
+/*
+ * ALTER TABLE ADD CONSTRAINT
+ */
void
AlterTableAddConstraint(const char *relationName,
bool inh, Node *newConstraint)
{
- elog(NOTICE, "ALTER TABLE / ADD CONSTRAINT is not implemented");
+ elog(ERROR, "ALTER TABLE / ADD CONSTRAINT is not implemented");
}
-void AlterTableDropConstraint(const char *relationName,
- bool inh, const char *constrName,
- int behavior)
+/*
+ * ALTER TABLE DROP CONSTRAINT
+ */
+void
+AlterTableDropConstraint(const char *relationName,
+ bool inh, const char *constrName,
+ int behavior)
{
- elog(NOTICE, "ALTER TABLE / DROP CONSTRAINT is not implemented");
+ elog(ERROR, "ALTER TABLE / DROP CONSTRAINT is not implemented");
}
diff --git a/src/backend/commands/rename.c b/src/backend/commands/rename.c
index 8a94597770e..b6bd229a569 100644
--- a/src/backend/commands/rename.c
+++ b/src/backend/commands/rename.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/Attic/rename.c,v 1.39 1999/12/16 22:19:42 wieck Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/Attic/rename.c,v 1.40 2000/01/22 14:20:45 petere Exp $
*
*-------------------------------------------------------------------------
*/
@@ -172,7 +172,7 @@ renameatt(char *relname,
* renamerel - change the name of a relation
*/
void
-renamerel(char *oldrelname, char *newrelname)
+renamerel(const char *oldrelname, const char *newrelname)
{
int i;
Relation targetrelation;
diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y
index ca22fc095f2..3a673bc74bf 100644
--- a/src/backend/parser/gram.y
+++ b/src/backend/parser/gram.y
@@ -10,7 +10,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.132 2000/01/20 02:24:50 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.133 2000/01/22 14:20:46 petere Exp $
*
* HISTORY
* AUTHOR DATE MAJOR EVENT
@@ -830,14 +830,14 @@ AlterTableStmt:
$$ = (Node *)n;
}
/* ALTER TABLE <name> DROP [COLUMN] <name> {RESTRICT|CASCADE} */
- | ALTER TABLE relation_name opt_inh_star DROP opt_column ColId drop_behavior
+ | ALTER TABLE relation_name opt_inh_star DROP opt_column ColId /* drop_behavior */
{
AlterTableStmt *n = makeNode(AlterTableStmt);
n->subtype = 'D';
n->relname = $3;
n->inh = $4;
n->name = $7;
- n->behavior = $8;
+ /* n->behavior = $8; */
$$ = (Node *)n;
}
/* ALTER TABLE <name> ADD CONSTRAINT ... */
diff --git a/src/backend/utils/adt/name.c b/src/backend/utils/adt/name.c
index 479d9e25393..da47dd1b343 100644
--- a/src/backend/utils/adt/name.c
+++ b/src/backend/utils/adt/name.c
@@ -11,7 +11,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/name.c,v 1.25 1999/11/25 19:15:20 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/name.c,v 1.26 2000/01/22 14:20:49 petere Exp $
*
*-------------------------------------------------------------------------
*/
@@ -31,7 +31,7 @@
* Now, always NULL terminated
*/
NameData *
-namein(char *s)
+namein(const char *s)
{
NameData *result;
int len;
@@ -54,7 +54,7 @@ namein(char *s)
* nameout - converts internal reprsentation to "..."
*/
char *
-nameout(NameData *s)
+nameout(const NameData *s)
{
if (s == NULL)
return "-";
@@ -82,7 +82,7 @@ nameout(NameData *s)
*
*/
bool
-nameeq(NameData *arg1, NameData *arg2)
+nameeq(const NameData *arg1, const NameData *arg2)
{
if (!arg1 || !arg2)
return 0;
@@ -91,7 +91,7 @@ nameeq(NameData *arg1, NameData *arg2)
}
bool
-namene(NameData *arg1, NameData *arg2)
+namene(const NameData *arg1, const NameData *arg2)
{
if (arg1 == NULL || arg2 == NULL)
return (bool) 0;
@@ -99,7 +99,7 @@ namene(NameData *arg1, NameData *arg2)
}
bool
-namelt(NameData *arg1, NameData *arg2)
+namelt(const NameData *arg1, const NameData *arg2)
{
if (arg1 == NULL || arg2 == NULL)
return (bool) 0;
@@ -107,7 +107,7 @@ namelt(NameData *arg1, NameData *arg2)
}
bool
-namele(NameData *arg1, NameData *arg2)
+namele(const NameData *arg1, const NameData *arg2)
{
if (arg1 == NULL || arg2 == NULL)
return (bool) 0;
@@ -115,7 +115,7 @@ namele(NameData *arg1, NameData *arg2)
}
bool
-namegt(NameData *arg1, NameData *arg2)
+namegt(const NameData *arg1, const NameData *arg2)
{
if (arg1 == NULL || arg2 == NULL)
return (bool) 0;
@@ -124,7 +124,7 @@ namegt(NameData *arg1, NameData *arg2)
}
bool
-namege(NameData *arg1, NameData *arg2)
+namege(const NameData *arg1, const NameData *arg2)
{
if (arg1 == NULL || arg2 == NULL)
return (bool) 0;
@@ -163,7 +163,7 @@ namecmp(Name n1, Name n2)
#endif
int
-namestrcpy(Name name, char *str)
+namestrcpy(Name name, const char *str)
{
if (!name || !str)
return -1;
@@ -173,7 +173,7 @@ namestrcpy(Name name, char *str)
#ifdef NOT_USED
int
-namestrcat(Name name, char *str)
+namestrcat(Name name, const char *str)
{
int i;
char *p,
@@ -195,7 +195,7 @@ namestrcat(Name name, char *str)
#endif
int
-namestrcmp(Name name, char *str)
+namestrcmp(Name name, const char *str)
{
if (!name && !str)
return 0;
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index ed11b77325d..a6b0f6ca9be 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.85 2000/01/15 02:59:39 petere Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.86 2000/01/22 14:20:50 petere Exp $
*
*-------------------------------------------------------------------------
*/
@@ -62,7 +62,7 @@
static void RelationClearRelation(Relation relation, bool rebuildIt);
static void RelationFlushRelation(Relation *relationPtr,
bool onlyFlushReferenceCountZero);
-static Relation RelationNameCacheGetRelation(char *relationName);
+static Relation RelationNameCacheGetRelation(const char *relationName);
static void RelationCacheAbortWalker(Relation *relationPtr,
int dummy);
static void init_irels(void);
@@ -1067,7 +1067,7 @@ RelationIdCacheGetRelation(Oid relationId)
* --------------------------------
*/
static Relation
-RelationNameCacheGetRelation(char *relationName)
+RelationNameCacheGetRelation(const char *relationName)
{
Relation rd;
NameData name;
@@ -1144,7 +1144,7 @@ RelationIdGetRelation(Oid relationId)
* --------------------------------
*/
Relation
-RelationNameGetRelation(char *relationName)
+RelationNameGetRelation(const char *relationName)
{
char *temprelname;
Relation rd;
@@ -1180,7 +1180,7 @@ RelationNameGetRelation(char *relationName)
* ----------------
*/
buildinfo.infotype = INFO_RELNAME;
- buildinfo.i.info_name = relationName;
+ buildinfo.i.info_name = (char *)relationName;
rd = RelationBuildDesc(buildinfo, NULL);
return rd;
@@ -1727,7 +1727,7 @@ AttrDefaultFetch(Relation relation)
if (adform->adnum != attrdef[i].adnum)
continue;
if (attrdef[i].adbin != NULL)
- elog(ERROR, "AttrDefaultFetch: second record found for attr %s in rel %s",
+ elog(NOTICE, "AttrDefaultFetch: second record found for attr %s in rel %s",
NameStr(relation->rd_att->attrs[adform->adnum - 1]->attname),
RelationGetRelationName(relation));
@@ -1735,7 +1735,7 @@ AttrDefaultFetch(Relation relation)
Anum_pg_attrdef_adbin,
adrel->rd_att, &isnull);
if (isnull)
- elog(ERROR, "AttrDefaultFetch: adbin IS NULL for attr %s in rel %s",
+ elog(NOTICE, "AttrDefaultFetch: adbin IS NULL for attr %s in rel %s",
NameStr(relation->rd_att->attrs[adform->adnum - 1]->attname),
RelationGetRelationName(relation));
attrdef[i].adbin = textout(val);
@@ -1744,13 +1744,13 @@ AttrDefaultFetch(Relation relation)
ReleaseBuffer(buffer);
if (i >= ndef)
- elog(ERROR, "AttrDefaultFetch: unexpected record found for attr %d in rel %s",
+ elog(NOTICE, "AttrDefaultFetch: unexpected record found for attr %d in rel %s",
adform->adnum,
RelationGetRelationName(relation));
}
if (found < ndef)
- elog(ERROR, "AttrDefaultFetch: %d record not found for rel %s",
+ elog(NOTICE, "AttrDefaultFetch: %d record not found for rel %s",
ndef - found, RelationGetRelationName(relation));
index_endscan(sd);
diff --git a/src/backend/utils/cache/temprel.c b/src/backend/utils/cache/temprel.c
index 23ac1aadbcf..88894a806e6 100644
--- a/src/backend/utils/cache/temprel.c
+++ b/src/backend/utils/cache/temprel.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/cache/Attic/temprel.c,v 1.18 1999/12/10 03:56:00 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/cache/Attic/temprel.c,v 1.19 2000/01/22 14:20:50 petere Exp $
*
*-------------------------------------------------------------------------
*/
@@ -49,7 +49,7 @@ typedef struct TempTable
void
-create_temp_relation(char *relname, HeapTuple pg_class_tuple)
+create_temp_relation(const char *relname, HeapTuple pg_class_tuple)
{
MemoryContext oldcxt;
TempTable *temp_rel;
@@ -202,7 +202,7 @@ invalidate_temp_relations(void)
}
char *
-get_temp_rel_by_username(char *user_relname)
+get_temp_rel_by_username(const char *user_relname)
{
List *l;
@@ -217,7 +217,7 @@ get_temp_rel_by_username(char *user_relname)
}
char *
-get_temp_rel_by_physicalname(char *relname)
+get_temp_rel_by_physicalname(const char *relname)
{
List *l;
@@ -229,5 +229,5 @@ get_temp_rel_by_physicalname(char *relname)
return temp_rel->user_relname;
}
/* needed for bootstrapping temp tables */
- return relname;
+ return pstrdup(relname);
}