1
0
mirror of https://github.com/postgres/postgres.git synced 2025-09-02 04:21:28 +03:00

NOT NULL implementation (submitted by Robson Paniago de Miranda).

This commit is contained in:
Vadim B. Mikheev
1997-08-19 04:46:15 +00:00
parent b99c63cfc0
commit b992e200b8
16 changed files with 453 additions and 337 deletions

View File

@@ -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)

View File

@@ -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) {

View File

@@ -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);
}
/*