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

Commit3d376fc

Browse files
committed
Change the parser to translate "foo [NOT] IN (expression-list)" to
ScalarArrayOpExpr when possible, that is, whenever there is an array typefor the values of the expression list. This completes the project I'vebeen working on to improve the speed of index searches with long IN lists,as per discussion back in mid-October.I did not force initdb, but until you do one you will see failures in the"rules" regression test, because some of the standard system views use INand their compiled formats have changed.
1 parent8a9acd3 commit3d376fc

File tree

5 files changed

+212
-103
lines changed

5 files changed

+212
-103
lines changed

‎src/backend/nodes/outfuncs.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/nodes/outfuncs.c,v 1.263 2005/11/26 22:14:56 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/nodes/outfuncs.c,v 1.264 2005/11/28 04:35:30 tgl Exp $
1212
*
1313
* NOTES
1414
* Every node type that can appear in stored rules' parsetrees *must*
@@ -1597,6 +1597,10 @@ _outAExpr(StringInfo str, A_Expr *node)
15971597
appendStringInfo(str," OF ");
15981598
WRITE_NODE_FIELD(name);
15991599
break;
1600+
caseAEXPR_IN:
1601+
appendStringInfo(str," IN ");
1602+
WRITE_NODE_FIELD(name);
1603+
break;
16001604
default:
16011605
appendStringInfo(str," ??");
16021606
break;
@@ -1658,6 +1662,7 @@ _outAConst(StringInfo str, A_Const *node)
16581662
{
16591663
WRITE_NODE_TYPE("A_CONST");
16601664

1665+
appendStringInfo(str," :val ");
16611666
_outValue(str,&(node->val));
16621667
WRITE_NODE_FIELD(typename);
16631668
}

‎src/backend/parser/gram.y

Lines changed: 19 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*
1212
*
1313
* IDENTIFICATION
14-
* $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.515 2005/11/22 15:24:17 adunstan Exp $
14+
* $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.516 2005/11/28 04:35:31 tgl Exp $
1515
*
1616
* HISTORY
1717
* AUTHORDATEMAJOR EVENT
@@ -6721,7 +6721,7 @@ a_expr:c_expr{ $$ = $1; }
67216721
}
67226722
| a_expr IS NOT OF'(' type_list')'%prec IS
67236723
{
6724-
$$ = (Node *) makeSimpleA_Expr(AEXPR_OF,"!=",$1, (Node *)$6);
6724+
$$ = (Node *) makeSimpleA_Expr(AEXPR_OF,"<>",$1, (Node *)$6);
67256725
}
67266726
| a_expr BETWEEN opt_asymmetric b_expr AND b_expr%prec BETWEEN
67276727
{
@@ -6760,38 +6760,30 @@ a_expr:c_expr{ $$ = $1; }
67606760
/* in_expr returns a SubLink or a list of a_exprs*/
67616761
if (IsA($3, SubLink))
67626762
{
6763-
SubLink *n = (SubLink *)$3;
6764-
n->subLinkType = ANY_SUBLINK;
6765-
if (IsA($1, RowExpr))
6766-
n->lefthand = ((RowExpr *)$1)->args;
6767-
else
6768-
n->lefthand = list_make1($1);
6769-
n->operName = list_make1(makeString("="));
6770-
$$ = (Node *)n;
6763+
/* generate foo = ANY (subquery)*/
6764+
SubLink *n = (SubLink *)$3;
6765+
n->subLinkType = ANY_SUBLINK;
6766+
if (IsA($1, RowExpr))
6767+
n->lefthand = ((RowExpr *)$1)->args;
6768+
else
6769+
n->lefthand = list_make1($1);
6770+
n->operName = list_make1(makeString("="));
6771+
$$ = (Node *)n;
67716772
}
67726773
else
67736774
{
6774-
Node *n =NULL;
6775-
ListCell *l;
6776-
foreach(l, (List *) $3)
6777-
{
6778-
Node *cmp;
6779-
cmp = (Node *)makeSimpleA_Expr(AEXPR_OP,"=", $1,lfirst(l));
6780-
if (n ==NULL)
6781-
n = cmp;
6782-
else
6783-
n = (Node *)makeA_Expr(AEXPR_OR, NIL, n, cmp);
6784-
}
6785-
$$ = n;
6775+
/* generate scalar IN expression*/
6776+
$$ = (Node *) makeSimpleA_Expr(AEXPR_IN,"=",$1,$3);
67866777
}
67876778
}
67886779
| a_expr NOT IN_P in_expr
67896780
{
67906781
/* in_expr returns a SubLink or a list of a_exprs*/
67916782
if (IsA($4, SubLink))
67926783
{
6793-
/* Make an IN node*/
6794-
SubLink *n = (SubLink *)$4;
6784+
/* generate NOT (foo = ANY (subquery))*/
6785+
/* Make an = ANY node*/
6786+
SubLink *n = (SubLink *)$4;
67956787
n->subLinkType = ANY_SUBLINK;
67966788
if (IsA($1, RowExpr))
67976789
n->lefthand = ((RowExpr *)$1)->args;
@@ -6803,18 +6795,8 @@ a_expr:c_expr{ $$ = $1; }
68036795
}
68046796
else
68056797
{
6806-
Node *n =NULL;
6807-
ListCell *l;
6808-
foreach(l, (List *) $4)
6809-
{
6810-
Node *cmp;
6811-
cmp = (Node *)makeSimpleA_Expr(AEXPR_OP,"<>", $1,lfirst(l));
6812-
if (n ==NULL)
6813-
n = cmp;
6814-
else
6815-
n = (Node *)makeA_Expr(AEXPR_AND, NIL, n, cmp);
6816-
}
6817-
$$ = n;
6798+
/* generate scalar NOT IN expression*/
6799+
$$ = (Node *) makeSimpleA_Expr(AEXPR_IN,"<>",$1,$4);
68186800
}
68196801
}
68206802
| a_expr subquery_Op sub_type select_with_parens %prec Op
@@ -6904,7 +6886,7 @@ b_expr:c_expr
69046886
}
69056887
| b_expr IS NOT OF'(' type_list')'%prec IS
69066888
{
6907-
$$ = (Node *) makeSimpleA_Expr(AEXPR_OF,"!=",$1, (Node *)$6);
6889+
$$ = (Node *) makeSimpleA_Expr(AEXPR_OF,"<>",$1, (Node *)$6);
69086890
}
69096891
;
69106892

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp