diff options
Diffstat (limited to 'src/backend/parser/analyze.c')
-rw-r--r-- | src/backend/parser/analyze.c | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/src/backend/parser/analyze.c b/src/backend/parser/analyze.c index 080392b97f5..0de9c5bb851 100644 --- a/src/backend/parser/analyze.c +++ b/src/backend/parser/analyze.c @@ -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); } |