mirror of
https://github.com/postgres/postgres.git
synced 2025-04-25 21:42:33 +03:00
Allow insert statements to have every column
supplied by a DEFAULT clause. Enables INSERT INTO TABLE DEFAULT VALUES...
This commit is contained in:
parent
dfab686ce8
commit
b806b3d3f8
@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.85 1998/09/01 04:30:15 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.86 1998/09/03 14:21:06 thomas Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -269,8 +269,8 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt)
|
|||||||
int ndef = pstate->p_target_relation->rd_att->constr->num_defval;
|
int ndef = pstate->p_target_relation->rd_att->constr->num_defval;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* if stmt->cols == NIL then makeTargetNames returns list of all
|
* if stmt->cols == NIL then makeTargetNames returns list of all attrs.
|
||||||
* attrs: have to shorter icolumns list...
|
* May have to shorten icolumns list...
|
||||||
*/
|
*/
|
||||||
if (stmt->cols == NIL)
|
if (stmt->cols == NIL)
|
||||||
{
|
{
|
||||||
@ -279,11 +279,26 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt)
|
|||||||
|
|
||||||
foreach(extrl, icolumns)
|
foreach(extrl, icolumns)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
* decrements first, so if we started with zero items
|
||||||
|
* it will now be negative
|
||||||
|
*/
|
||||||
if (--i <= 0)
|
if (--i <= 0)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
freeList(lnext(extrl));
|
/*
|
||||||
lnext(extrl) = NIL;
|
* this an index into the targetList,
|
||||||
|
* so make sure we had one to start...
|
||||||
|
*/
|
||||||
|
if (i >= 0)
|
||||||
|
{
|
||||||
|
freeList(lnext(extrl));
|
||||||
|
lnext(extrl) = NIL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
icolumns = NIL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
while (ndef-- > 0)
|
while (ndef-- > 0)
|
||||||
@ -295,7 +310,7 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt)
|
|||||||
foreach(tl, icolumns)
|
foreach(tl, icolumns)
|
||||||
{
|
{
|
||||||
id = (Ident *) lfirst(tl);
|
id = (Ident *) lfirst(tl);
|
||||||
if (!namestrcmp(&(att[defval[ndef].adnum - 1]->attname), id->name))
|
if (namestrcmp(&(att[defval[ndef].adnum - 1]->attname), id->name) == 0)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (tl != NIL) /* something given for this attr */
|
if (tl != NIL) /* something given for this attr */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user