Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitfaebf2f

Browse files
committed
Turn constraints off for sequences & views
elog(WARN,"ADD ATTRIBUTE: DEFAULT is not implemented, yet");Call ExecConstraints in CopyFrom
1 parent530876f commitfaebf2f

File tree

4 files changed

+25
-13
lines changed

4 files changed

+25
-13
lines changed

‎src/backend/commands/command.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.12 1997/08/21 03:01:27 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.13 1997/08/22 14:22:07 vadim Exp $
1111
*
1212
* NOTES
1313
* The PortalExecutorHeapMemory crap needs to be eliminated
@@ -283,7 +283,9 @@ PerformAddAttribute(char *relationName,
283283
* we can't add a not null attribute
284284
*/
285285
if (colDef->is_not_null)
286-
elog(WARN,"Can't add a not null attribute to a existent relation");
286+
elog(WARN,"Can't add a not null attribute to a existent relation");
287+
if (colDef->defval)
288+
elog(WARN,"ADD ATTRIBUTE: DEFAULT is not implemented, yet");
287289
/*
288290
* if the first element in the 'schema' list is a "*" then we are
289291
* supposed to add this attribute to all classes that inherit from

‎src/backend/commands/copy.c

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
*
88
* IDENTIFICATION
9-
* $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.26 1997/08/19 04:43:28 vadim Exp $
9+
* $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.27 1997/08/22 14:22:09 vadim Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -608,15 +608,18 @@ CopyFrom(Relation rel, bool binary, bool oids, FILE *fp, char *delim)
608608
* ----------------
609609
*/
610610

611-
if (rel->rd_att->constr&&rel->rd_att->constr->has_not_null)
612-
{
613-
intattrChk;
614-
for (attrChk=1;attrChk <=rel->rd_att->natts;attrChk++) {
615-
if (rel->rd_att->attrs[attrChk-1]->attnotnull&&heap_attisnull(tuple,attrChk))
616-
elog(WARN,"CopyFrom: Fail to add null value in not null attribute %s",
617-
rel->rd_att->attrs[attrChk-1]->attname.data);
618-
}
619-
}
611+
if (rel->rd_att->constr )
612+
{
613+
HeapTuplenewtuple;
614+
615+
newtuple=ExecConstraints ("CopyFrom",rel,tuple);
616+
617+
if (newtuple!=tuple )
618+
{
619+
pfree (tuple);
620+
tuple=newtuple;
621+
}
622+
}
620623

621624
heap_insert(rel,tuple);
622625

‎src/backend/commands/sequence.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ DefineSequence (CreateSeqStmt *seq)
9797
typnam->arrayBounds=NULL;
9898
coldef=makeNode(ColumnDef);
9999
coldef->typename=typnam;
100+
coldef->defval=NULL;
101+
coldef->is_not_null= false;
100102
null[i-1]=' ';
101103

102104
switch (i)
@@ -149,6 +151,7 @@ DefineSequence (CreateSeqStmt *seq)
149151
stmt->archiveLoc=-1;/* default */
150152
stmt->archiveType=ARCH_NONE;
151153
stmt->inhRelnames=NIL;
154+
stmt->constraints=NIL;
152155

153156
ItsSequenceCreation= true;/* hack */
154157

‎src/backend/commands/view.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/commands/view.c,v 1.7 1997/01/10 20:17:20 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/commands/view.c,v 1.8 1997/08/22 14:22:14 vadim Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -77,6 +77,9 @@ DefineVirtualRelation(char *relname, List *tlist)
7777
def->colname=pstrdup(resname);
7878

7979
def->typename=typename;
80+
81+
def->is_not_null= false;
82+
def->defval= (char*)NULL;
8083

8184
attrList=lappend(attrList,def);
8285
}
@@ -95,6 +98,7 @@ DefineVirtualRelation(char *relname, List *tlist)
9598
createStmt.archiveType=ARCH_NONE;
9699
createStmt.location=-1;
97100
createStmt.archiveLoc=-1;
101+
createStmt.constraints=NIL;
98102

99103
/*
100104
* finally create the relation...

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp