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

Commitb806b3d

Browse files
author
Thomas G. Lockhart
committed
Allow insert statements to have every column
supplied by a DEFAULT clause. Enables INSERT INTO TABLE DEFAULT VALUES...
1 parentdfab686 commitb806b3d

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

‎src/backend/parser/analyze.c

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.85 1998/09/01 04:30:15 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.86 1998/09/03 14:21:06 thomas Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -269,8 +269,8 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt)
269269
intndef=pstate->p_target_relation->rd_att->constr->num_defval;
270270

271271
/*
272-
* if stmt->cols == NIL then makeTargetNames returns list of all
273-
*attrs: have toshorter icolumns list...
272+
* if stmt->cols == NIL then makeTargetNames returns list of all attrs.
273+
*May have toshorten icolumns list...
274274
*/
275275
if (stmt->cols==NIL)
276276
{
@@ -279,11 +279,26 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt)
279279

280280
foreach(extrl,icolumns)
281281
{
282+
/*
283+
* decrements first, so if we started with zero items
284+
* it will now be negative
285+
*/
282286
if (--i <=0)
283287
break;
284288
}
285-
freeList(lnext(extrl));
286-
lnext(extrl)=NIL;
289+
/*
290+
* this an index into the targetList,
291+
* so make sure we had one to start...
292+
*/
293+
if (i >=0)
294+
{
295+
freeList(lnext(extrl));
296+
lnext(extrl)=NIL;
297+
}
298+
else
299+
{
300+
icolumns=NIL;
301+
}
287302
}
288303

289304
while (ndef-->0)
@@ -295,7 +310,7 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt)
295310
foreach(tl,icolumns)
296311
{
297312
id= (Ident*)lfirst(tl);
298-
if (!namestrcmp(&(att[defval[ndef].adnum-1]->attname),id->name))
313+
if (namestrcmp(&(att[defval[ndef].adnum-1]->attname),id->name)==0)
299314
break;
300315
}
301316
if (tl!=NIL)/* something given for this attr */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp