diff options
Diffstat (limited to 'src/backend/commands')
-rw-r--r-- | src/backend/commands/command.c | 9 | ||||
-rw-r--r-- | src/backend/commands/copy.c | 18 | ||||
-rw-r--r-- | src/backend/commands/creatinh.c | 9 |
3 files changed, 30 insertions, 6 deletions
diff --git a/src/backend/commands/command.c b/src/backend/commands/command.c index 74941993e47..6cbe9bda767 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.9 1997/08/18 20:52:11 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.10 1997/08/19 04:43:27 vadim Exp $ * * NOTES * The PortalExecutorHeapMemory crap needs to be eliminated @@ -279,7 +279,11 @@ PerformAddAttribute(char *relationName, elog(WARN, "PerformAddAttribute: you do not own class \"%s\"", relationName); #endif - + /* + * we can't add a not null attribute + */ + if (colDef->is_not_null) + elog(WARN,"Can't add a not null attribute to a existent relation"); /* * if the first element in the 'schema' list is a "*" then we are * supposed to add this attribute to all classes that inherit from @@ -454,6 +458,7 @@ PerformAddAttribute(char *relationName, attribute->attcacheoff = -1; attribute->attisset = (bool) (form->typtype == 'c'); attribute->attalign = form->typalign; + attribute->attnotnull = false; heap_insert(attrdesc, attributeTuple); if (hasindex) diff --git a/src/backend/commands/copy.c b/src/backend/commands/copy.c index b44414000b2..ee7948ac425 100644 --- a/src/backend/commands/copy.c +++ b/src/backend/commands/copy.c @@ -6,7 +6,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.25 1997/08/18 02:14:34 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.26 1997/08/19 04:43:28 vadim Exp $ * *------------------------------------------------------------------------- */ @@ -602,6 +602,22 @@ CopyFrom(Relation rel, bool binary, bool oids, FILE *fp, char *delim) tuple = heap_formtuple(tupDesc, values, nulls); if (oids) tuple->t_oid = loaded_oid; + + /* ---------------- + * Check the constraints of a tuple + * ---------------- + */ + + if (rel->rd_att->constr && rel->rd_att->constr->has_not_null) + { + int attrChk; + for (attrChk = 1; attrChk <= rel->rd_att->natts; attrChk++) { + if (rel->rd_att->attrs[attrChk-1]->attnotnull && heap_attisnull(tuple,attrChk)) + elog(WARN,"CopyFrom: Fail to add null value in not null attribute %s", + rel->rd_att->attrs[attrChk-1]->attname.data); + } + } + heap_insert(rel, tuple); if (has_index) { diff --git a/src/backend/commands/creatinh.c b/src/backend/commands/creatinh.c index 1113a84e26f..28143a993b6 100644 --- a/src/backend/commands/creatinh.c +++ b/src/backend/commands/creatinh.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/Attic/creatinh.c,v 1.11 1997/08/18 20:52:16 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/Attic/creatinh.c,v 1.12 1997/08/19 04:43:30 vadim Exp $ * *------------------------------------------------------------------------- */ @@ -276,14 +276,16 @@ MergeAttributes(List *schema, List *supers) AttributeTupleForm attribute = tupleDesc->attrs[attrno]; char *attributeName; char *attributeType; + AttrConstr constraints; HeapTuple tuple; ColumnDef *def; TypeName *typename; /* - * form name and type + * form name, type and constraints */ attributeName = (attribute->attname).data; + constraints.has_not_null = attribute->attnotnull; tuple = SearchSysCacheTuple(TYPOID, ObjectIdGetDatum(attribute->atttypid), @@ -311,7 +313,8 @@ MergeAttributes(List *schema, List *supers) def->colname = pstrdup(attributeName); typename->name = pstrdup(attributeType); def->typename = typename; - partialResult = lcons(def, partialResult); + def->is_not_null = constraints.has_not_null; + partialResult = lcons(def, partialResult); } /* |