OSDN Git Service

Turn constraints off for sequences & views
authorVadim B. Mikheev <vadim4o@yahoo.com>
Fri, 22 Aug 1997 14:22:14 +0000 (14:22 +0000)
committerVadim B. Mikheev <vadim4o@yahoo.com>
Fri, 22 Aug 1997 14:22:14 +0000 (14:22 +0000)
elog(WARN,"ADD ATTRIBUTE: DEFAULT is not implemented, yet");
Call ExecConstraints in CopyFrom

src/backend/commands/command.c
src/backend/commands/copy.c
src/backend/commands/sequence.c
src/backend/commands/view.c

index cf8b136..376bd3a 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * 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
  *    The PortalExecutorHeapMemory crap needs to be eliminated
@@ -283,7 +283,9 @@ PerformAddAttribute(char *relationName,
      * 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");
+       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
      * supposed to add this attribute to all classes that inherit from
index ee7948a..5fb9487 100644 (file)
@@ -6,7 +6,7 @@
  *
  *
  * 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)
         * ----------------
         */
        
-       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);
-           }
-         }
+       if ( rel->rd_att->constr )
+       {
+           HeapTuple newtuple;
+       
+           newtuple = ExecConstraints ("CopyFrom", rel, tuple);
+           
+           if ( newtuple != tuple )
+           {
+               pfree (tuple);
+               tuple = newtuple;
+           }
+       }
        
         heap_insert(rel, tuple);
             
index d737a8c..5d35f7b 100644 (file)
@@ -97,6 +97,8 @@ DefineSequence (CreateSeqStmt *seq)
        typnam->arrayBounds = NULL;
        coldef = makeNode(ColumnDef);
        coldef->typename = typnam;
+       coldef->defval = NULL;
+       coldef->is_not_null = false;
        null[i-1] = ' ';
 
        switch (i)
@@ -149,6 +151,7 @@ DefineSequence (CreateSeqStmt *seq)
     stmt->archiveLoc = -1;             /* default */
     stmt->archiveType = ARCH_NONE;
     stmt->inhRelnames = NIL;
+    stmt->constraints = NIL;
     
     ItsSequenceCreation = true;                /* hack */
 
index 6bbd80c..3cd011a 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * 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)
            def->colname = pstrdup(resname);
 
            def->typename = typename;
+           
+           def->is_not_null = false;
+           def->defval = (char*) NULL;
 
            attrList = lappend(attrList, def);
        }
@@ -95,6 +98,7 @@ DefineVirtualRelation(char *relname, List *tlist)
     createStmt.archiveType = ARCH_NONE;
     createStmt.location = -1;
     createStmt.archiveLoc = -1;
+    createStmt.constraints = NIL;
 
     /*
      * finally create the relation...