Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
postgres-lambda-diff
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jakob Huber
postgres-lambda-diff
Commits
0969dc86
Commit
0969dc86
authored
21 years ago
by
Bruce Momjian
Browse files
Options
Downloads
Patches
Plain Diff
Allow LIKE/ILIKE to appear in more places in a query.
Fabien COELHO
parent
6165bbab
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/backend/parser/gram.y
+24
-7
24 additions, 7 deletions
src/backend/parser/gram.y
src/test/regress/expected/arrays.out
+49
-0
49 additions, 0 deletions
src/test/regress/expected/arrays.out
src/test/regress/sql/arrays.sql
+10
-0
10 additions, 0 deletions
src/test/regress/sql/arrays.sql
with
83 additions
and
7 deletions
src/backend/parser/gram.y
+
24
−
7
View file @
0969dc86
...
@@ -11,7 +11,7 @@
...
@@ -11,7 +11,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.4
49
2004/0
3/17 20:48:42 tgl
Exp $
* $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.4
50
2004/0
4/05 03:07:26 momjian
Exp $
*
*
* HISTORY
* HISTORY
* AUTHOR DATE MAJOR EVENT
* AUTHOR DATE MAJOR EVENT
...
@@ -194,7 +194,7 @@ static void doNegateFloat(Value *v);
...
@@ -194,7 +194,7 @@ static void doNegateFloat(Value *v);
database_name access_method_clause access_method attr_name
database_name access_method_clause access_method attr_name
index_name name function_name file_name
index_name name function_name file_name
%type <list> func_name handler_name qual_Op qual_all_Op
%type <list> func_name handler_name qual_Op qual_all_Op
subquery_Op
opt_class opt_validator
opt_class opt_validator
%type <range> qualified_name OptConstrFromTable
%type <range> qualified_name OptConstrFromTable
...
@@ -5692,7 +5692,7 @@ r_expr: row IN_P select_with_parens
...
@@ -5692,7 +5692,7 @@ r_expr: row IN_P select_with_parens
/* Stick a NOT on top */
/* Stick a NOT on top */
$$ = (Node *) makeA_Expr(AEXPR_NOT, NIL, NULL, (Node *) n);
$$ = (Node *) makeA_Expr(AEXPR_NOT, NIL, NULL, (Node *) n);
}
}
| row
qual_all
_Op sub_type select_with_parens
| row
subquery
_Op sub_type select_with_parens
%prec Op
%prec Op
{
{
SubLink *n = makeNode(SubLink);
SubLink *n = makeNode(SubLink);
...
@@ -5702,7 +5702,7 @@ r_expr: row IN_P select_with_parens
...
@@ -5702,7 +5702,7 @@ r_expr: row IN_P select_with_parens
n->subselect = $4;
n->subselect = $4;
$$ = (Node *)n;
$$ = (Node *)n;
}
}
| row
qual_all
_Op select_with_parens
| row
subquery
_Op select_with_parens
%prec Op
%prec Op
{
{
SubLink *n = makeNode(SubLink);
SubLink *n = makeNode(SubLink);
...
@@ -5712,7 +5712,7 @@ r_expr: row IN_P select_with_parens
...
@@ -5712,7 +5712,7 @@ r_expr: row IN_P select_with_parens
n->subselect = $3;
n->subselect = $3;
$$ = (Node *)n;
$$ = (Node *)n;
}
}
| row
qual_all
_Op row
| row
subquery
_Op row
%prec Op
%prec Op
{
{
$$ = makeRowExpr($2, $1, $3);
$$ = makeRowExpr($2, $1, $3);
...
@@ -5807,6 +5807,23 @@ qual_all_Op:
...
@@ -5807,6 +5807,23 @@ qual_all_Op:
| OPERATOR '(' any_operator ')' { $$ = $3; }
| OPERATOR '(' any_operator ')' { $$ = $3; }
;
;
subquery_Op:
all_Op { $$ = makeList1(makeString($1)); }
| OPERATOR '(' any_operator ')' { $$ = $3; }
| LIKE { $$ = makeList1(makeString("~~")); }
| NOT LIKE { $$ = makeList1(makeString("!~~")); }
| ILIKE { $$ = makeList1(makeString("~~*")); }
| NOT ILIKE { $$ = makeList1(makeString("!~~*")); }
/* cannot put SIMILAR TO here, because SIMILAR TO is a hack.
* the regular expression is preprocessed by a function (similar_escape),
* and the ~ operator for posix regular expressions is used.
* x SIMILAR TO y -> x ~ similar_escape(y)
* this transformation is made on the fly by the parser upwards.
* however the SubLink structure which handles any/some/all stuff
* is not ready for such a thing.
*/
;
/*
/*
* General expressions
* General expressions
* This is the heart of the expression syntax.
* This is the heart of the expression syntax.
...
@@ -6132,7 +6149,7 @@ a_expr: c_expr { $$ = $1; }
...
@@ -6132,7 +6149,7 @@ a_expr: c_expr { $$ = $1; }
$$ = n;
$$ = n;
}
}
}
}
| a_expr
qual_all
_Op sub_type select_with_parens %prec Op
| a_expr
subquery
_Op sub_type select_with_parens %prec Op
{
{
SubLink *n = makeNode(SubLink);
SubLink *n = makeNode(SubLink);
n->subLinkType = $3;
n->subLinkType = $3;
...
@@ -6141,7 +6158,7 @@ a_expr: c_expr { $$ = $1; }
...
@@ -6141,7 +6158,7 @@ a_expr: c_expr { $$ = $1; }
n->subselect = $4;
n->subselect = $4;
$$ = (Node *)n;
$$ = (Node *)n;
}
}
| a_expr
qual_all
_Op sub_type '(' a_expr ')' %prec Op
| a_expr
subquery
_Op sub_type '(' a_expr ')' %prec Op
{
{
if ($3 == ANY_SUBLINK)
if ($3 == ANY_SUBLINK)
$$ = (Node *) makeA_Expr(AEXPR_OP_ANY, $2, $1, $5);
$$ = (Node *) makeA_Expr(AEXPR_OP_ANY, $2, $1, $5);
...
...
This diff is collapsed.
Click to expand it.
src/test/regress/expected/arrays.out
+
49
−
0
View file @
0969dc86
...
@@ -377,3 +377,52 @@ select * from arr_tbl where f1 > '{1,2,3}' and f1 <= '{1,5,3}';
...
@@ -377,3 +377,52 @@ select * from arr_tbl where f1 > '{1,2,3}' and f1 <= '{1,5,3}';
-- note: if above select doesn't produce the expected tuple order,
-- note: if above select doesn't produce the expected tuple order,
-- then you didn't get an indexscan plan, and something is busted.
-- then you didn't get an indexscan plan, and something is busted.
-- test [not] (like|ilike) (any|all) (...)
select 'foo' like any (array['%a', '%o']); -- t
?column?
----------
t
(1 row)
select 'foo' like any (array['%a', '%b']); -- f
?column?
----------
f
(1 row)
select 'foo' like all (array['f%', '%o']); -- t
?column?
----------
t
(1 row)
select 'foo' like all (array['f%', '%b']); -- f
?column?
----------
f
(1 row)
select 'foo' not like any (array['%a', '%b']); -- t
?column?
----------
t
(1 row)
select 'foo' not like all (array['%a', '%o']); -- f
?column?
----------
f
(1 row)
select 'foo' ilike any (array['%A', '%O']); -- t
?column?
----------
t
(1 row)
select 'foo' ilike all (array['F%', '%O']); -- t
?column?
----------
t
(1 row)
This diff is collapsed.
Click to expand it.
src/test/regress/sql/arrays.sql
+
10
−
0
View file @
0969dc86
...
@@ -183,3 +183,13 @@ set enable_seqscan to off;
...
@@ -183,3 +183,13 @@ set enable_seqscan to off;
select
*
from
arr_tbl
where
f1
>
'{1,2,3}'
and
f1
<=
'{1,5,3}'
;
select
*
from
arr_tbl
where
f1
>
'{1,2,3}'
and
f1
<=
'{1,5,3}'
;
-- note: if above select doesn't produce the expected tuple order,
-- note: if above select doesn't produce the expected tuple order,
-- then you didn't get an indexscan plan, and something is busted.
-- then you didn't get an indexscan plan, and something is busted.
-- test [not] (like|ilike) (any|all) (...)
select
'foo'
like
any
(
array
[
'%a'
,
'%o'
]);
-- t
select
'foo'
like
any
(
array
[
'%a'
,
'%b'
]);
-- f
select
'foo'
like
all
(
array
[
'f%'
,
'%o'
]);
-- t
select
'foo'
like
all
(
array
[
'f%'
,
'%b'
]);
-- f
select
'foo'
not
like
any
(
array
[
'%a'
,
'%b'
]);
-- t
select
'foo'
not
like
all
(
array
[
'%a'
,
'%o'
]);
-- f
select
'foo'
ilike
any
(
array
[
'%A'
,
'%O'
]);
-- t
select
'foo'
ilike
all
(
array
[
'F%'
,
'%O'
]);
-- t
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment