aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/commands')
-rw-r--r--src/backend/commands/command.c15
-rw-r--r--src/backend/commands/creatinh.c44
2 files changed, 27 insertions, 32 deletions
diff --git a/src/backend/commands/command.c b/src/backend/commands/command.c
index 745eae08322..ef6b66d9c33 100644
--- a/src/backend/commands/command.c
+++ b/src/backend/commands/command.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.66 2000/01/26 05:56:13 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.67 2000/01/29 16:58:34 petere Exp $
*
* NOTES
* The PortalExecutorHeapMemory crap needs to be eliminated
@@ -301,7 +301,6 @@ AlterTableAddColumn(const char *relationName,
Relation idescs[Num_pg_attr_indices];
Relation ridescs[Num_pg_class_indices];
bool hasindex;
-// List *rawDefaults = NIL;
/*
* permissions checking. this would normally be done in utility.c,
@@ -386,9 +385,9 @@ AlterTableAddColumn(const char *relationName,
/*
* XXX is the following check sufficient?
*/
- if (((Form_pg_class) GETSTRUCT(reltup))->relkind == RELKIND_INDEX)
+ if (((Form_pg_class) GETSTRUCT(reltup))->relkind != RELKIND_RELATION)
{
- elog(ERROR, "ALTER TABLE: index relation \"%s\" not changed",
+ elog(ERROR, "ALTER TABLE: relation \"%s\" is not a table",
relationName);
}
@@ -429,7 +428,7 @@ AlterTableAddColumn(const char *relationName,
0, 0);
if (HeapTupleIsValid(tup))
- elog(ERROR, "ALTER TABLE: column name \"%s\" already exists in relation \"%s\"",
+ elog(ERROR, "ALTER TABLE: column name \"%s\" already exists in table \"%s\"",
colDef->colname, relationName);
/*
@@ -627,14 +626,12 @@ 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_attrdef_indices, irelations);
+ CatalogCloseIndices(Num_pg_attr_indices, irelations);
/* get rid of actual default definition */
drop_default(myrelid, attnum);
}
- else
- elog(NOTICE, "ALTER TABLE: there was no default on column \"%s\" of relation \"%s\"",
- colName, relationName);
+
heap_endscan(scan);
heap_close(attr_rel, NoLock);
}
diff --git a/src/backend/commands/creatinh.c b/src/backend/commands/creatinh.c
index a90019974ef..da0fcd479ed 100644
--- a/src/backend/commands/creatinh.c
+++ b/src/backend/commands/creatinh.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/Attic/creatinh.c,v 1.55 2000/01/26 05:56:13 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/Attic/creatinh.c,v 1.56 2000/01/29 16:58:34 petere Exp $
*
*-------------------------------------------------------------------------
*/
@@ -31,8 +31,8 @@
* ----------------
*/
-static int checkAttrExists(char *attributeName,
- char *attributeType, List *schema);
+static bool checkAttrExists(const char *attributeName,
+ const char *attributeType, List *schema);
static List *MergeAttributes(List *schema, List *supers, List **supconstr);
static void StoreCatalogInheritance(Oid relationId, List *supers);
@@ -291,7 +291,7 @@ MergeAttributes(List *schema, List *supers, List **supconstr)
if (!strcmp(coldef->colname, restdef->colname))
{
- elog(ERROR, "attribute '%s' duplicated",
+ elog(ERROR, "CREATE TABLE: attribute \"%s\" duplicated",
coldef->colname);
}
}
@@ -304,7 +304,7 @@ MergeAttributes(List *schema, List *supers, List **supconstr)
{
if (!strcmp(strVal(lfirst(entry)), strVal(lfirst(rest))))
{
- elog(ERROR, "relation '%s' duplicated",
+ elog(ERROR, "CREATE TABLE: inherited relation \"%s\" duplicated",
strVal(lfirst(entry)));
}
}
@@ -326,9 +326,8 @@ MergeAttributes(List *schema, List *supers, List **supconstr)
tupleDesc = RelationGetDescr(relation);
constr = tupleDesc->constr;
- /* XXX shouldn't this test be stricter? No indexes, for example? */
- if (relation->rd_rel->relkind == 'S')
- elog(ERROR, "MergeAttr: Can't inherit from sequence superclass '%s'", name);
+ if (relation->rd_rel->relkind != RELKIND_RELATION)
+ elog(ERROR, "CREATE TABLE: inherited relation \"%s\" is not a table", name);
for (attrno = relation->rd_rel->relnatts - 1; attrno >= 0; attrno--)
{
@@ -353,15 +352,15 @@ MergeAttributes(List *schema, List *supers, List **supconstr)
* check validity
*
*/
- if (checkAttrExists(attributeName, attributeType, inhSchema) ||
- checkAttrExists(attributeName, attributeType, schema))
- {
+ if (checkAttrExists(attributeName, attributeType, schema))
+ elog(ERROR, "CREATE TABLE: attribute \"%s\" already exists in inherited schema",
+ attributeName);
+ if (checkAttrExists(attributeName, attributeType, inhSchema))
/*
* this entry already exists
*/
continue;
- }
/*
* add an entry to the schema
@@ -629,11 +628,13 @@ again:
heap_close(relation, RowExclusiveLock);
}
+
+
/*
- * returns 1 if attribute already exists in schema, 0 otherwise.
+ * returns true if attribute already exists in schema, false otherwise.
*/
-static int
-checkAttrExists(char *attributeName, char *attributeType, List *schema)
+static bool
+checkAttrExists(const char *attributeName, const char *attributeType, List *schema)
{
List *s;
@@ -641,19 +642,16 @@ checkAttrExists(char *attributeName, char *attributeType, List *schema)
{
ColumnDef *def = lfirst(s);
- if (!strcmp(attributeName, def->colname))
+ if (strcmp(attributeName, def->colname)==0)
{
-
/*
* attribute exists. Make sure the types are the same.
*/
if (strcmp(attributeType, def->typename->name) != 0)
- {
- elog(ERROR, "%s and %s conflict for %s",
- attributeType, def->typename->name, attributeName);
- }
- return 1;
+ elog(ERROR, "CREATE TABLE: attribute \"%s\" type conflict (%s and %s)",
+ attributeName, attributeType, def->typename->name);
+ return true;
}
}
- return 0;
+ return false;
}