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

Commitbb34970

Browse files
committed
Use a bitmapset instead of a list for duplicate-column checking in
checkInsertTargets(). Avoids O(N^2) behavior on wide target lists.
1 parent9e52381 commitbb34970

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

‎src/backend/parser/parse_target.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,15 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/parser/parse_target.c,v 1.129 2005/01/13 17:19:09 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/parser/parse_target.c,v 1.130 2005/03/26 06:28:59 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
1515
#include"postgres.h"
1616

1717
#include"commands/dbcommands.h"
1818
#include"miscadmin.h"
19+
#include"nodes/bitmapset.h"
1920
#include"nodes/makefuncs.h"
2021
#include"parser/parsetree.h"
2122
#include"parser/parse_coerce.h"
@@ -630,7 +631,8 @@ checkInsertTargets(ParseState *pstate, List *cols, List **attrnos)
630631
/*
631632
* Do initial validation of user-supplied INSERT column list.
632633
*/
633-
List*wholecols=NIL;
634+
Bitmapset*wholecols=NULL;
635+
Bitmapset*partialcols=NULL;
634636
ListCell*tl;
635637

636638
foreach(tl,cols)
@@ -649,21 +651,23 @@ checkInsertTargets(ParseState *pstate, List *cols, List **attrnos)
649651
if (col->indirection==NIL)
650652
{
651653
/* whole column; must not have any other assignment */
652-
if (list_member_int(*attrnos,attrno))
654+
if (bms_is_member(attrno,wholecols)||
655+
bms_is_member(attrno,partialcols))
653656
ereport(ERROR,
654657
(errcode(ERRCODE_DUPLICATE_COLUMN),
655658
errmsg("column \"%s\" specified more than once",
656659
name)));
657-
wholecols=lappend_int(wholecols,attrno);
660+
wholecols=bms_add_member(wholecols,attrno);
658661
}
659662
else
660663
{
661664
/* partial column; must not have any whole assignment */
662-
if (list_member_int(wholecols,attrno))
665+
if (bms_is_member(attrno,wholecols))
663666
ereport(ERROR,
664667
(errcode(ERRCODE_DUPLICATE_COLUMN),
665668
errmsg("column \"%s\" specified more than once",
666669
name)));
670+
partialcols=bms_add_member(partialcols,attrno);
667671
}
668672

669673
*attrnos=lappend_int(*attrnos,attrno);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp