pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #8198: ROW() literals not supported in an IN clause
6+ messages / 4 participants
[nested] [flat]

* BUG #8198: ROW() literals not supported in an IN clause
@ 2013-06-01 16:06 divided.mind@gmail.com
  2013-06-04 10:35 ` Re: BUG #8198: ROW() literals not supported in an IN clause Amit Kapila <amit.kapila@huawei.com>
  2013-06-05 00:03 ` Re: BUG #8198: ROW() literals not supported in an IN clause Rafał Rzepecki <divided.mind@gmail.com>
  0 siblings, 2 replies; 6+ messages in thread

From: divided.mind@gmail.com @ 2013-06-01 16:06 UTC (permalink / raw)
  To: pgsql-bugs

The following bug has been logged on the website:

Bug reference:      8198
Logged by:          Rafal Rzepecki
Email address:      divided.mind@gmail.com
PostgreSQL version: 9.2.4
Operating system:   Ubuntu 13.04
Description:        

Row type literals constructed with ROW() cause an error when used in an IN
clause (string literals casted appropriately are allowed). This is
especially problematic since many client libraries use these literals to
pass values of row-type arguments, hence making it impossible to use them in
IN-clause queries.

To wit:
divide=# create type the_row as (mfg text, id text);
CREATE TYPE
divide=# create table the_table (widget the_row);                           
                                                                            
                          
CREATE TABLE                                                                
                                                                            
                            
divide=# insert into the_table values(row('foo', 'bar')::the_row);          
                                                                            
                            
INSERT 0 1                                                                  
                                                                            
                            
divide=# insert into the_table values('(bar,baz)'::the_row);                
                                                                            
                     
INSERT 0 1
divide=# select * from the_table;
  widget   
-----------
 (foo,bar)
 (bar,baz)
(2 rows)

divide=# select * from the_table where widget in ('(foo,bar)'::the_row);
  widget   
-----------
 (foo,bar)
(1 row)

divide=# select * from the_table where widget in
(row('foo','bar')::the_row);
ERROR:  arguments of row IN must all be row expressions
LINE 1: select * from the_table where widget in (row('foo','bar')::t...
                                             ^




-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: BUG #8198: ROW() literals not supported in an IN clause
  2013-06-01 16:06 BUG #8198: ROW() literals not supported in an IN clause divided.mind@gmail.com
@ 2013-06-04 10:35 ` Amit Kapila <amit.kapila@huawei.com>
  1 sibling, 0 replies; 6+ messages in thread

From: Amit Kapila @ 2013-06-04 10:35 UTC (permalink / raw)
  To: divided.mind@gmail.com; pgsql-bugs

On Saturday, June 01, 2013 9:37 PM 
 
> Row type literals constructed with ROW() cause an error when used in an
> IN
> clause (string literals casted appropriately are allowed). This is
> especially problematic since many client libraries use these literals
> to
> pass values of row-type arguments, hence making it impossible to use
> them in
> IN-clause queries.
> 
> To wit:
> divide=# create type the_row as (mfg text, id text);
> CREATE TYPE
> divide=# create table the_table (widget the_row);
> 
> 
> CREATE TABLE
> 
> 
> divide=# insert into the_table values(row('foo', 'bar')::the_row);
> 
> 
> INSERT 0 1
> 
> 
> divide=# insert into the_table values('(bar,baz)'::the_row);
> 
> 
> INSERT 0 1
> divide=# select * from the_table;
>   widget
> -----------
>  (foo,bar)
>  (bar,baz)
> (2 rows)
> 
> divide=# select * from the_table where widget in
> ('(foo,bar)'::the_row);
>   widget
> -----------
>  (foo,bar)
> (1 row)
> 
> divide=# select * from the_table where widget in
> (row('foo','bar')::the_row);
> ERROR:  arguments of row IN must all be row expressions
> LINE 1: select * from the_table where widget in (row('foo','bar')::t...

The similar query for equal ('=') operator works fine.
select * from the_table where widget = (row('foo','bar')::the_row);

The reason for above is that in function transformAExprOp(..), it uses make_row_comparison_op() to operate on expressions only if both left and right are row expressions, else it will use make_op() to operate on expressions. Refer code below in function transformAExprOp()  
else if (lexpr && IsA(lexpr, RowExpr) && 
                         rexpr && IsA(rexpr, RowExpr)) 
        { 
		    ....
                result = make_row_comparison_op(pstate, 
                                                                                a->name, 
                                                                                ((RowExpr *) lexpr)->args, 
                                                                                ((RowExpr *) rexpr)->args, 
                                                                                a->location); 
        } 
        else 
        { 
                ....
                result = (Node *) make_op(pstate, 
                                                                  a->name, 
                                                                  lexpr, 
                                                                  rexpr, 
                                                                  a->location); 
        }

However for IN clause, if any one expr (left or right) is RowExpr, then it will try to use make_row_comparison_op, which result in error.
Refer below code of function transformAExprIn():
if (haveRowExpr) 
                { 
                        if (!IsA(lexpr, RowExpr) || 
                                !IsA(rexpr, RowExpr)) 
                                ereport(ERROR, 
                                                (errcode(ERRCODE_SYNTAX_ERROR), 
                                   errmsg("arguments of row IN must all be row expressions"), 
                                                 parser_errposition(pstate, a->location))); 
                        cmp = make_row_comparison_op(pstate, 
                                                                                 a->name, 
                                                          (List *) copyObject(((RowExpr *) lexpr)->args), 
                                                                                 ((RowExpr *) rexpr)->args, 
                                                                                 a->location); 
                } 
                else 
                        cmp = (Node *) make_op(pstate, 
                                                                   a->name, 
                                                                   copyObject(lexpr), 
                                                                   rexpr, 
                                                                   a->location);

Changing the functionality of transformAExprIn() similar to transformAExprOp() will fix this issue, but not sure if there is any other side effect of same.

With Regards,
Amit Kapila.



-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: BUG #8198: ROW() literals not supported in an IN clause
  2013-06-01 16:06 BUG #8198: ROW() literals not supported in an IN clause divided.mind@gmail.com
@ 2013-06-05 00:03 ` Rafał Rzepecki <divided.mind@gmail.com>
  2013-06-05 05:58   ` Re: BUG #8198: ROW() literals not supported in an IN clause Amit Kapila <amit.kapila@huawei.com>
  2013-06-06 14:24   ` Re: BUG #8198: ROW() literals not supported in an IN clause Rafał Rzepecki <divided.mind@gmail.com>
  2013-06-09 22:44   ` Re: BUG #8198: ROW() literals not supported in an IN clause Tom Lane <tgl@sss.pgh.pa.us>
  1 sibling, 3 replies; 6+ messages in thread

From: Rafał Rzepecki @ 2013-06-05 00:03 UTC (permalink / raw)
  To: pgsql-bugs; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; Amit Kapila <amit.kapila@huawei.com>

On Tue, Jun 4, 2013 at 12:35 PM, Amit Kapila <amit.kapila@huawei.com> wrote:
> On Saturday, June 01, 2013 9:37 PM
>
>> Row type literals constructed with ROW() cause an error when used in an
>> IN
>> clause (string literals casted appropriately are allowed). This is
>> especially problematic since many client libraries use these literals
>> to
>> pass values of row-type arguments, hence making it impossible to use
>> them in
>> IN-clause queries.
>>
>> To wit:
>> divide=# create type the_row as (mfg text, id text);
>> CREATE TYPE
>> divide=# create table the_table (widget the_row);
>>
>>
>> CREATE TABLE
>>
>>
>> divide=# insert into the_table values(row('foo', 'bar')::the_row);
>>
>>
>> INSERT 0 1
>>
>>
>> divide=# insert into the_table values('(bar,baz)'::the_row);
>>
>>
>> INSERT 0 1
>> divide=# select * from the_table;
>>   widget
>> -----------
>>  (foo,bar)
>>  (bar,baz)
>> (2 rows)
>>
>> divide=# select * from the_table where widget in
>> ('(foo,bar)'::the_row);
>>   widget
>> -----------
>>  (foo,bar)
>> (1 row)
>>
>> divide=# select * from the_table where widget in
>> (row('foo','bar')::the_row);
>> ERROR:  arguments of row IN must all be row expressions
>> LINE 1: select * from the_table where widget in (row('foo','bar')::t...
>
> The similar query for equal ('=') operator works fine.
> select * from the_table where widget = (row('foo','bar')::the_row);
>
> The reason for above is that in function transformAExprOp(..), it uses make_row_comparison_op() to operate on expressions only if both left and right are row expressions, else it will use make_op() to operate on expressions. Refer code below in function transformAExprOp()
> else if (lexpr && IsA(lexpr, RowExpr) &&
>                          rexpr && IsA(rexpr, RowExpr))
>         {
>                     ....
>                 result = make_row_comparison_op(pstate,
>                                                                                 a->name,
>                                                                                 ((RowExpr *) lexpr)->args,
>                                                                                 ((RowExpr *) rexpr)->args,
>                                                                                 a->location);
>         }
>         else
>         {
>                 ....
>                 result = (Node *) make_op(pstate,
>                                                                   a->name,
>                                                                   lexpr,
>                                                                   rexpr,
>                                                                   a->location);
>         }
>
> However for IN clause, if any one expr (left or right) is RowExpr, then it will try to use make_row_comparison_op, which result in error.
> Refer below code of function transformAExprIn():
> if (haveRowExpr)
>                 {
>                         if (!IsA(lexpr, RowExpr) ||
>                                 !IsA(rexpr, RowExpr))
>                                 ereport(ERROR,
>                                                 (errcode(ERRCODE_SYNTAX_ERROR),
>                                    errmsg("arguments of row IN must all be row expressions"),
>                                                  parser_errposition(pstate, a->location)));
>                         cmp = make_row_comparison_op(pstate,
>                                                                                  a->name,
>                                                           (List *) copyObject(((RowExpr *) lexpr)->args),
>                                                                                  ((RowExpr *) rexpr)->args,
>                                                                                  a->location);
>                 }
>                 else
>                         cmp = (Node *) make_op(pstate,
>                                                                    a->name,
>                                                                    copyObject(lexpr),
>                                                                    rexpr,
>                                                                    a->location);
>
> Changing the functionality of transformAExprIn() similar to transformAExprOp() will fix this issue, but not sure if there is any other side effect of same.

Thanks for the analysis! This problem seems to have been introduced in
3d376fce8dd4 [1] (almost eight years ago! I guess not many people use
row types...).

I'm pretty sure the original intent was to afford some extra checks so
that conditions such as "ROW(1, 2) IN ((ROW(3, 4), ROW(5, 6, 7))"
would get rejected at parsing time (CCing the original author; please
confirm).

If I'm right, the proper fix would be (patch 0001; caution, not tested):

inline patch 1: src/backend/parser/parse_expr.c (+2/-3 lines) download inline-1.patch--- a/src/backend/parser/parse_expr.c +++ b/src/backend/parser/parse_expr.c @@ -1203,10 +1203,9 @@ transformAExprIn(ParseState *pstate, A_Expr *a) Node *rexpr = (Node *) lfirst(l); Node *cmp; - if (haveRowExpr) + if (haveRowExpr && IsA(lexpr, RowExpr)) { - if (!IsA(lexpr, RowExpr) || - !IsA(rexpr, RowExpr)) + if (!IsA(rexpr, RowExpr)) ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), errmsg("arguments of row IN must
all be row expressions"), Since the restriction seems a rather arbitrary (at least I fail to see any reason for it), it can be removed altogether (patch 0002, not tested as well):
inline patch 2: src/backend/parser/parse_expr.c (+0/-7 lines) download inline-2.patch--- a/src/backend/parser/parse_expr.c +++ b/src/backend/parser/parse_expr.c @@ -1203,20 +1203,12 @@ transformAExprIn(ParseState *pstate, A_Expr *a) Node *rexpr = (Node *) lfirst(l); Node *cmp; - if (haveRowExpr) - { - if (!IsA(lexpr, RowExpr) || - !IsA(rexpr, RowExpr)) - ereport(ERROR, - (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("arguments of row IN must
all be row expressions"), - parser_errposition(pstate, a->location))); + if (IsA(lexpr, RowExpr) && IsA(rexpr, RowExpr)) cmp = make_row_comparison_op(pstate, a->name, (List *) copyObject(((RowExpr *) lexpr)->args), ((RowExpr *) rexpr)->args, a->location); - } else cmp = (Node *) make_op(pstate, a->name, [1] http://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=3d376fce8dd45d43fb6dbeb5a08c08400a... -- Rafał Rzepecki -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs Patches and attachments: download all (4 files, .tar.gz)
0001-Only-use-make_row_comparison_op-in-transformAExprIn-.patch (application/octet-stream, 973B) download From bd4837bd11e97c5184616d86decf7b71046334c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Rzepecki?= <divided.mind@gmail.com> Date: Wed, 5 Jun 2013 01:56:40 +0200 Subject: [PATCH] Only use make_row_comparison_op in transformAExprIn if LHS is a RowExpr. --- src/backend/parser/parse_expr.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/backend/parser/parse_expr.c b/src/backend/parser/parse_expr.c index 7f0995f..5e2d92d 100644 --- a/src/backend/parser/parse_expr.c +++ b/src/backend/parser/parse_expr.c @@ -1203,10 +1203,9 @@ transformAExprIn(ParseState *pstate, A_Expr *a) Node *rexpr = (Node *) lfirst(l); Node *cmp; - if (haveRowExpr) + if (haveRowExpr && IsA(lexpr, RowExpr)) { - if (!IsA(lexpr, RowExpr) || - !IsA(rexpr, RowExpr)) + if (!IsA(rexpr, RowExpr)) ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), errmsg("arguments of row IN must all be row expressions"), -- 1.8.1.2
0002-Allow-mixing-RowExprs-and-other-expressions-in-the-R.patch (application/octet-stream, 1.2K) download From e6a89394f86e8d639583bbc6c55fcc6c17e9104f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Rzepecki?= <divided.mind@gmail.com> Date: Wed, 5 Jun 2013 02:01:08 +0200 Subject: [PATCH] Allow mixing RowExprs and other expressions in the RHS of IN. --- src/backend/parser/parse_expr.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/backend/parser/parse_expr.c b/src/backend/parser/parse_expr.c index 7f0995f..16e69bf 100644 --- a/src/backend/parser/parse_expr.c +++ b/src/backend/parser/parse_expr.c @@ -1203,20 +1203,12 @@ transformAExprIn(ParseState *pstate, A_Expr *a) Node *rexpr = (Node *) lfirst(l); Node *cmp; - if (haveRowExpr) - { - if (!IsA(lexpr, RowExpr) || - !IsA(rexpr, RowExpr)) - ereport(ERROR, - (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("arguments of row IN must all be row expressions"), - parser_errposition(pstate, a->location))); + if (IsA(lexpr, RowExpr) && IsA(rexpr, RowExpr)) cmp = make_row_comparison_op(pstate, a->name, (List *) copyObject(((RowExpr *) lexpr)->args), ((RowExpr *) rexpr)->args, a->location); - } else cmp = (Node *) make_op(pstate, a->name, -- 1.8.1.2
^ permalink raw reply [nested|flat] 6+ messages in thread

* Re: BUG #8198: ROW() literals not supported in an IN clause
  2013-06-01 16:06 BUG #8198: ROW() literals not supported in an IN clause divided.mind@gmail.com
  2013-06-05 00:03 ` Re: BUG #8198: ROW() literals not supported in an IN clause Rafał Rzepecki <divided.mind@gmail.com>
@ 2013-06-05 05:58   ` Amit Kapila <amit.kapila@huawei.com>
  2 siblings, 0 replies; 6+ messages in thread

From: Amit Kapila @ 2013-06-05 05:58 UTC (permalink / raw)
  To: 'Rafał Rzepecki' <divided.mind@gmail.com>; pgsql-bugs; +Cc: 'Tom Lane' <tgl@sss.pgh.pa.us>

On Wednesday, June 05, 2013 5:34 AM Rafał Rzepecki wrote:
> On Tue, Jun 4, 2013 at 12:35 PM, Amit Kapila <amit.kapila@huawei.com>
> wrote:
> > On Saturday, June 01, 2013 9:37 PM
> >
> >> Row type literals constructed with ROW() cause an error when used in
> >> an IN clause (string literals casted appropriately are allowed).
> This
> >> is especially problematic since many client libraries use these
> >> literals to pass values of row-type arguments, hence making it
> >> impossible to use them in IN-clause queries.
> >>
> 
> If I'm right, the proper fix would be (patch 0001; caution, not
> tested):
> 
> --- a/src/backend/parser/parse_expr.c
> +++ b/src/backend/parser/parse_expr.c
> @@ -1203,10 +1203,9 @@ transformAExprIn(ParseState *pstate, A_Expr *a)
>                 Node       *rexpr = (Node *) lfirst(l);
>                 Node       *cmp;
> 
> -               if (haveRowExpr)
> +               if (haveRowExpr && IsA(lexpr, RowExpr))
>                 {
> -                       if (!IsA(lexpr, RowExpr) ||
> -                               !IsA(rexpr, RowExpr))
> +                       if (!IsA(rexpr, RowExpr))
>                                 ereport(ERROR,
> 
> (errcode(ERRCODE_SYNTAX_ERROR),
>                                    errmsg("arguments of row IN must all
> be row expressions"),
> 
> 
> Since the restriction seems a rather arbitrary (at least I fail to see
> any reason for it), it can be removed altogether (patch 0002, not
> tested as well):
> 
> --- a/src/backend/parser/parse_expr.c
> +++ b/src/backend/parser/parse_expr.c
> @@ -1203,20 +1203,12 @@ transformAExprIn(ParseState *pstate, A_Expr *a)
>                 Node       *rexpr = (Node *) lfirst(l);
>                 Node       *cmp;
> 
> -               if (haveRowExpr)
> -               {
> -                       if (!IsA(lexpr, RowExpr) ||
> -                               !IsA(rexpr, RowExpr))
> -                               ereport(ERROR,
> -
> (errcode(ERRCODE_SYNTAX_ERROR),
> -                                  errmsg("arguments of row IN must
> all be row expressions"),
> -
> parser_errposition(pstate, a->location)));
> +               if (IsA(lexpr, RowExpr) && IsA(rexpr, RowExpr))
>                         cmp = make_row_comparison_op(pstate,
> 
>           a->name,
>                                                           (List *)
> copyObject(((RowExpr *) lexpr)->args),
> 
>           ((RowExpr *) rexpr)->args,
> 
>           a->location);
> -               }
>                 else
>                         cmp = (Node *) make_op(pstate,
>                                                                    a-
> >name,
> 

I had tried, both your patches have passed all regression tests (tested on Windows). I feel fixing it in a way similar to your Patch-1 would be
more appropriate as with Patch-1 it can generate meaningful error message for some cases like below:

postgres=# select * from the_table where ROW('abc','def') in (row('foo','bar')::the_row,12); 
ERROR:  arguments of row IN must all be row expressions 
LINE 1: select * from the_table where ROW('abc','def') in (row('foo'...


With Regards,
Amit Kapila.



-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: BUG #8198: ROW() literals not supported in an IN clause
  2013-06-01 16:06 BUG #8198: ROW() literals not supported in an IN clause divided.mind@gmail.com
  2013-06-05 00:03 ` Re: BUG #8198: ROW() literals not supported in an IN clause Rafał Rzepecki <divided.mind@gmail.com>
@ 2013-06-06 14:24   ` Rafał Rzepecki <divided.mind@gmail.com>
  2 siblings, 0 replies; 6+ messages in thread

From: Rafał Rzepecki @ 2013-06-06 14:24 UTC (permalink / raw)
  To: pgsql-bugs; Amit Kapila <amit.kapila@huawei.com>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>

On Wed, Jun 5, 2013 at 7:58 AM, Amit Kapila <amit.kapila@huawei.com> wrote:
> On Wednesday, June 05, 2013 5:34 AM Rafał Rzepecki wrote:
>> On Tue, Jun 4, 2013 at 12:35 PM, Amit Kapila <amit.kapila@huawei.com>
>> wrote:
>> > On Saturday, June 01, 2013 9:37 PM
>> >
>> >> Row type literals constructed with ROW() cause an error when used in
>> >> an IN clause (string literals casted appropriately are allowed).
>> This
>> >> is especially problematic since many client libraries use these
>> >> literals to pass values of row-type arguments, hence making it
>> >> impossible to use them in IN-clause queries.
>> >>
>>
>> If I'm right, the proper fix would be (patch 0001; caution, not
>> tested):
>>
>> --- a/src/backend/parser/parse_expr.c
>> +++ b/src/backend/parser/parse_expr.c
>> @@ -1203,10 +1203,9 @@ transformAExprIn(ParseState *pstate, A_Expr *a)
>>                 Node       *rexpr = (Node *) lfirst(l);
>>                 Node       *cmp;
>>
>> -               if (haveRowExpr)
>> +               if (haveRowExpr && IsA(lexpr, RowExpr))
>>                 {
>> -                       if (!IsA(lexpr, RowExpr) ||
>> -                               !IsA(rexpr, RowExpr))
>> +                       if (!IsA(rexpr, RowExpr))
>>                                 ereport(ERROR,
>>
>> (errcode(ERRCODE_SYNTAX_ERROR),
>>                                    errmsg("arguments of row IN must all
>> be row expressions"),
>>
>>
>> Since the restriction seems a rather arbitrary (at least I fail to see
>> any reason for it), it can be removed altogether (patch 0002, not
>> tested as well):
>>
>> --- a/src/backend/parser/parse_expr.c
>> +++ b/src/backend/parser/parse_expr.c
>> @@ -1203,20 +1203,12 @@ transformAExprIn(ParseState *pstate, A_Expr *a)
>>                 Node       *rexpr = (Node *) lfirst(l);
>>                 Node       *cmp;
>>
>> -               if (haveRowExpr)
>> -               {
>> -                       if (!IsA(lexpr, RowExpr) ||
>> -                               !IsA(rexpr, RowExpr))
>> -                               ereport(ERROR,
>> -
>> (errcode(ERRCODE_SYNTAX_ERROR),
>> -                                  errmsg("arguments of row IN must
>> all be row expressions"),
>> -
>> parser_errposition(pstate, a->location)));
>> +               if (IsA(lexpr, RowExpr) && IsA(rexpr, RowExpr))
>>                         cmp = make_row_comparison_op(pstate,
>>
>>           a->name,
>>                                                           (List *)
>> copyObject(((RowExpr *) lexpr)->args),
>>
>>           ((RowExpr *) rexpr)->args,
>>
>>           a->location);
>> -               }
>>                 else
>>                         cmp = (Node *) make_op(pstate,
>>                                                                    a-
>> >name,
>>
>
> I had tried, both your patches have passed all regression tests (tested on Windows). I feel fixing it in a way similar to your Patch-1 would be
> more appropriate as with Patch-1 it can generate meaningful error message for some cases like below:
>
> postgres=# select * from the_table where ROW('abc','def') in (row('foo','bar')::the_row,12);
> ERROR:  arguments of row IN must all be row expressions
> LINE 1: select * from the_table where ROW('abc','def') in (row('foo'...

Perhaps you're right, rare cases when you want to do something like
'ROW('abc','def') in (row('foo','bar')::the_row, a_column)' are, I
suppose, so exotic that working around this restriction probably won't
be much of a hassle.
--
Rafał Rzepecki


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: BUG #8198: ROW() literals not supported in an IN clause
  2013-06-01 16:06 BUG #8198: ROW() literals not supported in an IN clause divided.mind@gmail.com
  2013-06-05 00:03 ` Re: BUG #8198: ROW() literals not supported in an IN clause Rafał Rzepecki <divided.mind@gmail.com>
@ 2013-06-09 22:44   ` Tom Lane <tgl@sss.pgh.pa.us>
  2 siblings, 0 replies; 6+ messages in thread

From: Tom Lane @ 2013-06-09 22:44 UTC (permalink / raw)
  To: Rafał Rzepecki <divided.mind@gmail.com>; +Cc: pgsql-bugs; Amit Kapila <amit.kapila@huawei.com>

=?UTF-8?Q?Rafa=C5=82_Rzepecki?= <divided.mind@gmail.com> writes:
> I'm pretty sure the original intent was to afford some extra checks so
> that conditions such as "ROW(1, 2) IN ((ROW(3, 4), ROW(5, 6, 7))"
> would get rejected at parsing time (CCing the original author; please
> confirm).

No; the reason it was like that was that when that code was written,
make_row_comparison_op was the only way to compare two row values at
all.  We didn't have record_eq and friends; nor did we have arrays
of composites.

> Since the restriction seems a rather arbitrary (at least I fail to see
> any reason for it), it can be removed altogether (patch 0002, not
> tested as well):

This is reasonable as far as it goes, but I think it doesn't go far
enough --- there's really no reason anymore to reject RowExprs as
components of ScalarArrayOpExpr either.  I've extended this patch
some and committed it.  Thanks for the report!

			regards, tom lane


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 6+ messages in thread


end of thread, other threads:[~2013-06-09 22:44 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2013-06-01 16:06 BUG #8198: ROW() literals not supported in an IN clause divided.mind@gmail.com
2013-06-04 10:35 ` Amit Kapila <amit.kapila@huawei.com>
2013-06-05 00:03 ` Rafał Rzepecki <divided.mind@gmail.com>
2013-06-05 05:58   ` Amit Kapila <amit.kapila@huawei.com>
2013-06-06 14:24   ` Rafał Rzepecki <divided.mind@gmail.com>
2013-06-09 22:44   ` Tom Lane <tgl@sss.pgh.pa.us>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox