1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-28 23:42:10 +03:00

Add INSERT(..., DEFAULT, ).

Rod Taylor
This commit is contained in:
Bruce Momjian
2002-04-05 11:56:55 +00:00
parent aab0b8f5eb
commit 97b4e5ad30
11 changed files with 123 additions and 16 deletions

View File

@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.226 2002/04/02 06:30:34 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.227 2002/04/05 11:56:51 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -518,13 +518,29 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt,
TargetEntry *tle = (TargetEntry *) lfirst(tl);
ResTarget *col;
Assert(!tle->resdom->resjunk);
if (icolumns == NIL || attnos == NIL)
elog(ERROR, "INSERT has more expressions than target columns");
col = (ResTarget *) lfirst(icolumns);
Assert(IsA(col, ResTarget));
updateTargetListEntry(pstate, tle, col->name, lfirsti(attnos),
/*
* When the value is to be set to the column default we can simply
* drop it now and handle it later on using methods for missing
* columns.
*/
if (!IsA(tle, InsertDefault))
{
Assert(IsA(col, ResTarget));
Assert(!tle->resdom->resjunk);
updateTargetListEntry(pstate, tle, col->name, lfirsti(attnos),
col->indirection);
}
else
{
icolumns = lremove(icolumns, icolumns);
attnos = lremove(attnos, attnos);
qry->targetList = lremove(tle, qry->targetList);
}
icolumns = lnext(icolumns);
attnos = lnext(attnos);
}