Commit faebf2f8 authored by Vadim B. Mikheev's avatar Vadim B. Mikheev

Turn constraints off for sequences & views

elog(WARN,"ADD ATTRIBUTE: DEFAULT is not implemented, yet");
Call ExecConstraints in CopyFrom
parent 530876fe
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.12 1997/08/21 03:01:27 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.13 1997/08/22 14:22:07 vadim Exp $
* *
* NOTES * NOTES
* The PortalExecutorHeapMemory crap needs to be eliminated * The PortalExecutorHeapMemory crap needs to be eliminated
...@@ -283,7 +283,9 @@ PerformAddAttribute(char *relationName, ...@@ -283,7 +283,9 @@ PerformAddAttribute(char *relationName,
* we can't add a not null attribute * we can't add a not null attribute
*/ */
if (colDef->is_not_null) if (colDef->is_not_null)
elog(WARN,"Can't add a not null attribute to a existent relation"); elog(WARN,"Can't add a not null attribute to a existent relation");
if (colDef->defval)
elog(WARN,"ADD ATTRIBUTE: DEFAULT is not implemented, yet");
/* /*
* if the first element in the 'schema' list is a "*" then we are * if the first element in the 'schema' list is a "*" then we are
* supposed to add this attribute to all classes that inherit from * supposed to add this attribute to all classes that inherit from
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.26 1997/08/19 04:43:28 vadim Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.27 1997/08/22 14:22:09 vadim Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -608,15 +608,18 @@ CopyFrom(Relation rel, bool binary, bool oids, FILE *fp, char *delim) ...@@ -608,15 +608,18 @@ CopyFrom(Relation rel, bool binary, bool oids, FILE *fp, char *delim)
* ---------------- * ----------------
*/ */
if (rel->rd_att->constr && rel->rd_att->constr->has_not_null) if ( rel->rd_att->constr )
{ {
int attrChk; HeapTuple newtuple;
for (attrChk = 1; attrChk <= rel->rd_att->natts; attrChk++) {
if (rel->rd_att->attrs[attrChk-1]->attnotnull && heap_attisnull(tuple,attrChk)) newtuple = ExecConstraints ("CopyFrom", rel, tuple);
elog(WARN,"CopyFrom: Fail to add null value in not null attribute %s",
rel->rd_att->attrs[attrChk-1]->attname.data); if ( newtuple != tuple )
} {
} pfree (tuple);
tuple = newtuple;
}
}
heap_insert(rel, tuple); heap_insert(rel, tuple);
......
...@@ -97,6 +97,8 @@ DefineSequence (CreateSeqStmt *seq) ...@@ -97,6 +97,8 @@ DefineSequence (CreateSeqStmt *seq)
typnam->arrayBounds = NULL; typnam->arrayBounds = NULL;
coldef = makeNode(ColumnDef); coldef = makeNode(ColumnDef);
coldef->typename = typnam; coldef->typename = typnam;
coldef->defval = NULL;
coldef->is_not_null = false;
null[i-1] = ' '; null[i-1] = ' ';
switch (i) switch (i)
...@@ -149,6 +151,7 @@ DefineSequence (CreateSeqStmt *seq) ...@@ -149,6 +151,7 @@ DefineSequence (CreateSeqStmt *seq)
stmt->archiveLoc = -1; /* default */ stmt->archiveLoc = -1; /* default */
stmt->archiveType = ARCH_NONE; stmt->archiveType = ARCH_NONE;
stmt->inhRelnames = NIL; stmt->inhRelnames = NIL;
stmt->constraints = NIL;
ItsSequenceCreation = true; /* hack */ ItsSequenceCreation = true; /* hack */
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/view.c,v 1.7 1997/01/10 20:17:20 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/view.c,v 1.8 1997/08/22 14:22:14 vadim Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -77,6 +77,9 @@ DefineVirtualRelation(char *relname, List *tlist) ...@@ -77,6 +77,9 @@ DefineVirtualRelation(char *relname, List *tlist)
def->colname = pstrdup(resname); def->colname = pstrdup(resname);
def->typename = typename; def->typename = typename;
def->is_not_null = false;
def->defval = (char*) NULL;
attrList = lappend(attrList, def); attrList = lappend(attrList, def);
} }
...@@ -95,6 +98,7 @@ DefineVirtualRelation(char *relname, List *tlist) ...@@ -95,6 +98,7 @@ DefineVirtualRelation(char *relname, List *tlist)
createStmt.archiveType = ARCH_NONE; createStmt.archiveType = ARCH_NONE;
createStmt.location = -1; createStmt.location = -1;
createStmt.archiveLoc = -1; createStmt.archiveLoc = -1;
createStmt.constraints = NIL;
/* /*
* finally create the relation... * finally create the relation...
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment