Thread: checking variadic "any" argument in parser - should be array

checking variadic "any" argument in parser - should be array

From
Pavel Stehule
Date:
Hello Tom

you did comment

! <----><------><------> * Non-null argument had better be an array.
The parser doesn't
! <----><------><------> * enforce this for VARIADIC ANY functions
(maybe it should?), so
! <----><------><------> * that check uses ereport not just elog.
! <----><------><------> */

So I moved this check to parser.

It is little bit stricter - requests typed NULL instead unknown NULL,
but it can mark error better and early

Regards

Pavel

Attachment

Re: checking variadic "any" argument in parser - should be array

From
Jeevan Chalke
Date:
Hi Pavel


On Sat, Jan 26, 2013 at 9:22 AM, Pavel Stehule <pavel.stehule@gmail.com> wrote:
Hello Tom

you did comment

! <----><------><------> * Non-null argument had better be an array.
The parser doesn't
! <----><------><------> * enforce this for VARIADIC ANY functions
(maybe it should?), so
! <----><------><------> * that check uses ereport not just elog.
! <----><------><------> */

So I moved this check to parser.

It is little bit stricter - requests typed NULL instead unknown NULL,
but it can mark error better and early

Tom suggested that this check should be better done by parser.
This patch tries to accomplish that.

I will go review this.

However, is it possible to you to re-base it on current master? I can't apply it using "git apply" but patch -p1 was succeeded with lot of offset.

Thanks
 

Regards

Pavel


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




--
Jeevan B Chalke
Senior Software Engineer, R&D
EnterpriseDB Corporation
The Enterprise PostgreSQL Company

Phone: +91 20 30589500

Website: www.enterprisedb.com
EnterpriseDB Blog: http://blogs.enterprisedb.com/
Follow us on Twitter: http://www.twitter.com/enterprisedb

This e-mail message (and any attachment) is intended for the use of the individual or entity to whom it is addressed. This message contains information from EnterpriseDB Corporation that may be privileged, confidential, or exempt from disclosure under applicable law. If you are not the intended recipient or authorized to receive this for the intended recipient, any use, dissemination, distribution, retention, archiving, or copying of this communication is strictly prohibited. If you have received this e-mail in error, please notify the sender immediately by reply e-mail and delete this message.

Re: checking variadic "any" argument in parser - should be array

From
Pavel Stehule
Date:
Hello

remastered version

Regards

Pavel

2013/6/26 Jeevan Chalke <jeevan.chalke@enterprisedb.com>:
> Hi Pavel
>
>
> On Sat, Jan 26, 2013 at 9:22 AM, Pavel Stehule <pavel.stehule@gmail.com>
> wrote:
>>
>> Hello Tom
>>
>> you did comment
>>
>> ! <----><------><------> * Non-null argument had better be an array.
>> The parser doesn't
>> ! <----><------><------> * enforce this for VARIADIC ANY functions
>> (maybe it should?), so
>> ! <----><------><------> * that check uses ereport not just elog.
>> ! <----><------><------> */
>>
>> So I moved this check to parser.
>>
>> It is little bit stricter - requests typed NULL instead unknown NULL,
>> but it can mark error better and early
>
>
> Tom suggested that this check should be better done by parser.
> This patch tries to accomplish that.
>
> I will go review this.
>
> However, is it possible to you to re-base it on current master? I can't
> apply it using "git apply" but patch -p1 was succeeded with lot of offset.
>
> Thanks
>
>>
>>
>> Regards
>>
>> Pavel
>>
>>
>> --
>> Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
>> To make changes to your subscription:
>> http://www.postgresql.org/mailpref/pgsql-hackers
>>
>
>
>
> --
> Jeevan B Chalke
> Senior Software Engineer, R&D
> EnterpriseDB Corporation
> The Enterprise PostgreSQL Company
>
> Phone: +91 20 30589500
>
> Website: www.enterprisedb.com
> EnterpriseDB Blog: http://blogs.enterprisedb.com/
> Follow us on Twitter: http://www.twitter.com/enterprisedb
>
> This e-mail message (and any attachment) is intended for the use of the
> individual or entity to whom it is addressed. This message contains
> information from EnterpriseDB Corporation that may be privileged,
> confidential, or exempt from disclosure under applicable law. If you are not
> the intended recipient or authorized to receive this for the intended
> recipient, any use, dissemination, distribution, retention, archiving, or
> copying of this communication is strictly prohibited. If you have received
> this e-mail in error, please notify the sender immediately by reply e-mail
> and delete this message.

Attachment

Re: checking variadic "any" argument in parser - should be array

From
Jeevan Chalke
Date:
<div dir="ltr">Hi Pavel,<br /><br />I had a look over your new patch and it looks good to me.<br /><br />My review
commentson patch:<br /><br />1. It cleanly applies with patch -p1 command.<br />2. make/make install/make check were
smooth.<br/> 3. My own testing didn't find any issue.<br />4. I had a code walk-through and I am little bit worried or
confusedon<br />following changes:<br /><br /><font size="1"><span style="font-family:courier new,monospace">         
if(PG_ARGISNULL(argidx))<br />               return NULL;<br />  <br />!         /*<br />!          * Non-null argument
hadbetter be an array.  The parser doesn't<br />!          * enforce this for VARIADIC ANY functions (maybe it
should?),so that<br />!          * check uses ereport not just elog.<br /> !          */<br />!         arr_typid =
get_fn_expr_argtype(fcinfo->flinfo,argidx);<br />!         if (!OidIsValid(arr_typid))<br />!            
elog(ERROR,"could not determine data type of concat() input");<br /> ! <br />!         if
(!OidIsValid(get_element_type(arr_typid)))<br/>!             ereport(ERROR,<br />!                    
(errcode(ERRCODE_DATATYPE_MISMATCH),<br/>!                      errmsg("VARIADIC argument must be an array")));<br />  
<br/>-         /* OK, safe to fetch the array value */<br />          arr = PG_GETARG_ARRAYTYPE_P(argidx);<br />  <br
/>         /*<br />--- 3820,3828 ----<br />          if (PG_ARGISNULL(argidx))<br />              return NULL;<br />  
<br/>!         /* Non-null argument had better be an array */<br />!        
Assert(OidIsValid(get_element_type(get_fn_expr_argtype(fcinfo->flinfo,argidx))));<br />  <br />          arr =
PG_GETARG_ARRAYTYPE_P(argidx);<br/></span></font><br />We have moved checking of array type in parser
(ParseFuncOrColumn())which<br />basically verifies that argument type is indeed an array. Which exactly same<br />as
thatof second if statement in earlier code, which you replaced by an<br /> Assert.<br /><br />However, what about first
ifstatement ? Is it NO more required now? What if<br />get_fn_expr_argtype() returns InvalidOid, don't you think we
needto throw<br />an error saying "could not determine data type of concat() input"?<br /><br />Well, I tried hard to
triggerthat code, but didn't able to get any test<br />which fails with that error in earlier version and with your
version.And<br />thus I believe it is a dead code, which you removed ? Is it so ?<br /><br />Moreover, if in any case
get_fn_expr_argtype()returns an InvalidOid, we<br />will hit an Assert rather than an error, is this what you expect
?<br/><br />5. This patch has user visibility, i.e. now we are throwing an error when<br /> user only says "VARIADIC
NULL"like:<br /><br /><span style="font-family:courier new,monospace">    select concat(variadic NULL) is
NULL;</span><br/><br />Previously it was working but now we are throwing an error. Well we are now<br /> more stricter
thanearlier with using VARIADIC + ANY, so I have no issue as<br />such. But I guess we need to document this user
visibilitychange. I don't<br />know exactly where though. I searched for VARIADIC and all related<br /> documentation
saysit needs an array, so nothing harmful as such, so you can<br />ignore this review comment but I thought it worth
mentioningit.<br /><br />Thanks<br /><div class="gmail_extra"><br /><br /><div class="gmail_quote"> On Thu, Jun 27,
2013at 12:35 AM, Pavel Stehule <span dir="ltr"><<a href="mailto:pavel.stehule@gmail.com"
target="_blank">pavel.stehule@gmail.com</a>></span>wrote:<br /><blockquote class="gmail_quote" style="margin:0px 0px
0px0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hello<br /><br /> remastered version<br /><br />
Regards<br/><br /> Pavel<br /><br /> 2013/6/26 Jeevan Chalke <<a
href="mailto:jeevan.chalke@enterprisedb.com">jeevan.chalke@enterprisedb.com</a>>:<br/><div class=""><div
class="h5">>Hi Pavel<br /> ><br /> ><br /> > On Sat, Jan 26, 2013 at 9:22 AM, Pavel Stehule <<a
href="mailto:pavel.stehule@gmail.com">pavel.stehule@gmail.com</a>><br/> > wrote:<br /> >><br /> >>
HelloTom<br /> >><br /> >> you did comment<br /> >><br /> >> !
<----><------><------>* Non-null argument had better be an array.<br /> >> The parser
doesn't<br/> >> ! <----><------><------> * enforce this for VARIADIC ANY functions<br />
>>(maybe it should?), so<br /> >> ! <----><------><------> * that check uses ereport not
justelog.<br /> >> ! <----><------><------> */<br /> >><br /> >> So I moved this
checkto parser.<br /> >><br /> >> It is little bit stricter - requests typed NULL instead unknown NULL,<br
/>>> but it can mark error better and early<br /> ><br /> ><br /> > Tom suggested that this check should
bebetter done by parser.<br /> > This patch tries to accomplish that.<br /> ><br /> > I will go review
this.<br/> ><br /> > However, is it possible to you to re-base it on current master? I can't<br /> > apply it
using"git apply" but patch -p1 was succeeded with lot of offset.<br /> ><br /> > Thanks<br /> ><br />
>><br/> >><br /> >> Regards<br /> >><br /> >> Pavel<br /> >><br /> >><br />
>>--<br /> >> Sent via pgsql-hackers mailing list (<a
href="mailto:pgsql-hackers@postgresql.org">pgsql-hackers@postgresql.org</a>)<br/> >> To make changes to your
subscription:<br/> >> <a href="http://www.postgresql.org/mailpref/pgsql-hackers"
target="_blank">http://www.postgresql.org/mailpref/pgsql-hackers</a><br/> >><br /> ><br /> ><br /> ><br
/>> --<br /> > Jeevan B Chalke<br /> > Senior Software Engineer, R&D<br /> > EnterpriseDB
Corporation<br/> > The Enterprise PostgreSQL Company<br /> ><br /> > Phone: +91 20 30589500<br /> ><br />
>Website: <a href="http://www.enterprisedb.com" target="_blank">www.enterprisedb.com</a><br /> > EnterpriseDB
Blog:<a href="http://blogs.enterprisedb.com/" target="_blank">http://blogs.enterprisedb.com/</a><br /> > Follow us
onTwitter: <a href="http://www.twitter.com/enterprisedb" target="_blank">http://www.twitter.com/enterprisedb</a><br />
><br/> > This e-mail message (and any attachment) is intended for the use of the<br /> > individual or entity
towhom it is addressed. This message contains<br /> > information from EnterpriseDB Corporation that may be
privileged,<br/> > confidential, or exempt from disclosure under applicable law. If you are not<br /> > the
intendedrecipient or authorized to receive this for the intended<br /> > recipient, any use, dissemination,
distribution,retention, archiving, or<br /> > copying of this communication is strictly prohibited. If you have
received<br/> > this e-mail in error, please notify the sender immediately by reply e-mail<br /> > and delete
thismessage.<br /></div></div></blockquote></div><br /><br clear="all" /><br />-- <br />Jeevan B Chalke<br />Senior
SoftwareEngineer, R&D<br />EnterpriseDB Corporation<br />The Enterprise PostgreSQL Company<br /><br />Phone: +91 20
30589500<br/><br />Website: <a href="http://www.enterprisedb.com" target="_blank">www.enterprisedb.com</a><br />
EnterpriseDBBlog: <a href="http://blogs.enterprisedb.com/" target="_blank">http://blogs.enterprisedb.com/</a><br
/>Followus on Twitter: <a href="http://www.twitter.com/enterprisedb"
target="_blank">http://www.twitter.com/enterprisedb</a><br/><br />This e-mail message (and any attachment) is intended
forthe use of the individual or entity to whom it is addressed. This message contains information from EnterpriseDB
Corporationthat may be privileged, confidential, or exempt from disclosure under applicable law. If you are not the
intendedrecipient or authorized to receive this for the intended recipient, any use, dissemination, distribution,
retention,archiving, or copying of this communication is strictly prohibited. If you have received this e-mail in
error,please notify the sender immediately by reply e-mail and delete this message. </div></div> 

Re: checking variadic "any" argument in parser - should be array

From
Pavel Stehule
Date:
Hello

2013/6/27 Jeevan Chalke <jeevan.chalke@enterprisedb.com>:
> Hi Pavel,
>
> I had a look over your new patch and it looks good to me.
>
> My review comments on patch:
>
> 1. It cleanly applies with patch -p1 command.
> 2. make/make install/make check were smooth.
> 3. My own testing didn't find any issue.
> 4. I had a code walk-through and I am little bit worried or confused on
> following changes:
>
>           if (PG_ARGISNULL(argidx))
>               return NULL;
>
> !         /*
> !          * Non-null argument had better be an array.  The parser doesn't
> !          * enforce this for VARIADIC ANY functions (maybe it should?), so
> that
> !          * check uses ereport not just elog.
> !          */
> !         arr_typid = get_fn_expr_argtype(fcinfo->flinfo, argidx);
> !         if (!OidIsValid(arr_typid))
> !             elog(ERROR, "could not determine data type of concat()
> input");
> !
> !         if (!OidIsValid(get_element_type(arr_typid)))
> !             ereport(ERROR,
> !                     (errcode(ERRCODE_DATATYPE_MISMATCH),
> !                      errmsg("VARIADIC argument must be an array")));
>
> -         /* OK, safe to fetch the array value */
>           arr = PG_GETARG_ARRAYTYPE_P(argidx);
>
>           /*
> --- 3820,3828 ----
>           if (PG_ARGISNULL(argidx))
>               return NULL;
>
> !         /* Non-null argument had better be an array */
> !
> Assert(OidIsValid(get_element_type(get_fn_expr_argtype(fcinfo->flinfo,
> argidx))));
>
>           arr = PG_GETARG_ARRAYTYPE_P(argidx);
>
> We have moved checking of array type in parser (ParseFuncOrColumn()) which
> basically verifies that argument type is indeed an array. Which exactly same
> as that of second if statement in earlier code, which you replaced by an
> Assert.
>
> However, what about first if statement ? Is it NO more required now? What if
> get_fn_expr_argtype() returns InvalidOid, don't you think we need to throw
> an error saying "could not determine data type of concat() input"?

yes, If I understand well to question, a main differences is in stage
of checking. When I do a check in parser stage, then I can expect so
"actual_arg_types" array holds a valid values.

>
> Well, I tried hard to trigger that code, but didn't able to get any test
> which fails with that error in earlier version and with your version. And
> thus I believe it is a dead code, which you removed ? Is it so ?

It is removed in this version :), and it is not a bug, so there is not
reason for patching previous versions. Probably there should be a
Assert instead of error. This code is relatively mature - so I don't
expect a issue from SQL level now. On second hand, this functions can
be called via DirectFunctionCall API from custom C server side
routines, and there a developer can does a bug simply if doesn't fill
necessary structs well. So, there can be Asserts still.

>
> Moreover, if in any case get_fn_expr_argtype() returns an InvalidOid, we
> will hit an Assert rather than an error, is this what you expect ?
>

in this moment yes,

small change can helps with searching of source of possible issues.

so instead on line
Assert(OidIsValid(get_element_type(get_fn_expr_argtype(fcinfo->flinfo,
argidx))));

use two lines

Assert(OidIsValid(get_fn_expr_argtype(fcinfo->flinfo, argidx)));
Assert(OidIsValid(get_element_type(get_fn_expr_argtype(fcinfo->flinfo,
argidx))));

what you think?

> 5. This patch has user visibility, i.e. now we are throwing an error when
> user only says "VARIADIC NULL" like:
>
>     select concat(variadic NULL) is NULL;
>
> Previously it was working but now we are throwing an error. Well we are now
> more stricter than earlier with using VARIADIC + ANY, so I have no issue as
> such. But I guess we need to document this user visibility change. I don't
> know exactly where though. I searched for VARIADIC and all related
> documentation says it needs an array, so nothing harmful as such, so you can
> ignore this review comment but I thought it worth mentioning it.

yes, it is point for possible issues in RELEASE NOTES, I am thinking ???

Regards

Pavel

>
> Thanks
>
>
>
> On Thu, Jun 27, 2013 at 12:35 AM, Pavel Stehule <pavel.stehule@gmail.com>
> wrote:
>>
>> Hello
>>
>> remastered version
>>
>> Regards
>>
>> Pavel
>>
>> 2013/6/26 Jeevan Chalke <jeevan.chalke@enterprisedb.com>:
>> > Hi Pavel
>> >
>> >
>> > On Sat, Jan 26, 2013 at 9:22 AM, Pavel Stehule <pavel.stehule@gmail.com>
>> > wrote:
>> >>
>> >> Hello Tom
>> >>
>> >> you did comment
>> >>
>> >> ! <----><------><------> * Non-null argument had better be an array.
>> >> The parser doesn't
>> >> ! <----><------><------> * enforce this for VARIADIC ANY functions
>> >> (maybe it should?), so
>> >> ! <----><------><------> * that check uses ereport not just elog.
>> >> ! <----><------><------> */
>> >>
>> >> So I moved this check to parser.
>> >>
>> >> It is little bit stricter - requests typed NULL instead unknown NULL,
>> >> but it can mark error better and early
>> >
>> >
>> > Tom suggested that this check should be better done by parser.
>> > This patch tries to accomplish that.
>> >
>> > I will go review this.
>> >
>> > However, is it possible to you to re-base it on current master? I can't
>> > apply it using "git apply" but patch -p1 was succeeded with lot of
>> > offset.
>> >
>> > Thanks
>> >
>> >>
>> >>
>> >> Regards
>> >>
>> >> Pavel
>> >>
>> >>
>> >> --
>> >> Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
>> >> To make changes to your subscription:
>> >> http://www.postgresql.org/mailpref/pgsql-hackers
>> >>
>> >
>> >
>> >
>> > --
>> > Jeevan B Chalke
>> > Senior Software Engineer, R&D
>> > EnterpriseDB Corporation
>> > The Enterprise PostgreSQL Company
>> >
>> > Phone: +91 20 30589500
>> >
>> > Website: www.enterprisedb.com
>> > EnterpriseDB Blog: http://blogs.enterprisedb.com/
>> > Follow us on Twitter: http://www.twitter.com/enterprisedb
>> >
>> > This e-mail message (and any attachment) is intended for the use of the
>> > individual or entity to whom it is addressed. This message contains
>> > information from EnterpriseDB Corporation that may be privileged,
>> > confidential, or exempt from disclosure under applicable law. If you are
>> > not
>> > the intended recipient or authorized to receive this for the intended
>> > recipient, any use, dissemination, distribution, retention, archiving,
>> > or
>> > copying of this communication is strictly prohibited. If you have
>> > received
>> > this e-mail in error, please notify the sender immediately by reply
>> > e-mail
>> > and delete this message.
>
>
>
>
> --
> Jeevan B Chalke
> Senior Software Engineer, R&D
> EnterpriseDB Corporation
> The Enterprise PostgreSQL Company
>
> Phone: +91 20 30589500
>
> Website: www.enterprisedb.com
> EnterpriseDB Blog: http://blogs.enterprisedb.com/
> Follow us on Twitter: http://www.twitter.com/enterprisedb
>
> This e-mail message (and any attachment) is intended for the use of the
> individual or entity to whom it is addressed. This message contains
> information from EnterpriseDB Corporation that may be privileged,
> confidential, or exempt from disclosure under applicable law. If you are not
> the intended recipient or authorized to receive this for the intended
> recipient, any use, dissemination, distribution, retention, archiving, or
> copying of this communication is strictly prohibited. If you have received
> this e-mail in error, please notify the sender immediately by reply e-mail
> and delete this message.



Re: checking variadic "any" argument in parser - should be array

From
Jeevan Chalke
Date:
Hi Pavel,


On Fri, Jun 28, 2013 at 2:53 AM, Pavel Stehule <pavel.stehule@gmail.com> wrote:
Hello

2013/6/27 Jeevan Chalke <jeevan.chalke@enterprisedb.com>:
> Hi Pavel,
>
> I had a look over your new patch and it looks good to me.
>
> My review comments on patch:
>
> 1. It cleanly applies with patch -p1 command.
> 2. make/make install/make check were smooth.
> 3. My own testing didn't find any issue.
> 4. I had a code walk-through and I am little bit worried or confused on
> following changes:
>
>           if (PG_ARGISNULL(argidx))
>               return NULL;
>
> !         /*
> !          * Non-null argument had better be an array.  The parser doesn't
> !          * enforce this for VARIADIC ANY functions (maybe it should?), so
> that
> !          * check uses ereport not just elog.
> !          */
> !         arr_typid = get_fn_expr_argtype(fcinfo->flinfo, argidx);
> !         if (!OidIsValid(arr_typid))
> !             elog(ERROR, "could not determine data type of concat()
> input");
> !
> !         if (!OidIsValid(get_element_type(arr_typid)))
> !             ereport(ERROR,
> !                     (errcode(ERRCODE_DATATYPE_MISMATCH),
> !                      errmsg("VARIADIC argument must be an array")));
>
> -         /* OK, safe to fetch the array value */
>           arr = PG_GETARG_ARRAYTYPE_P(argidx);
>
>           /*
> --- 3820,3828 ----
>           if (PG_ARGISNULL(argidx))
>               return NULL;
>
> !         /* Non-null argument had better be an array */
> !
> Assert(OidIsValid(get_element_type(get_fn_expr_argtype(fcinfo->flinfo,
> argidx))));
>
>           arr = PG_GETARG_ARRAYTYPE_P(argidx);
>
> We have moved checking of array type in parser (ParseFuncOrColumn()) which
> basically verifies that argument type is indeed an array. Which exactly same
> as that of second if statement in earlier code, which you replaced by an
> Assert.
>
> However, what about first if statement ? Is it NO more required now? What if
> get_fn_expr_argtype() returns InvalidOid, don't you think we need to throw
> an error saying "could not determine data type of concat() input"?

yes, If I understand well to question, a main differences is in stage
of checking. When I do a check in parser stage, then I can expect so
"actual_arg_types" array holds a valid values.

That's fine.
 

>
> Well, I tried hard to trigger that code, but didn't able to get any test
> which fails with that error in earlier version and with your version. And
> thus I believe it is a dead code, which you removed ? Is it so ?

It is removed in this version :), and it is not a bug, so there is not
reason for patching previous versions. Probably there should be a
Assert instead of error. This code is relatively mature - so I don't
expect a issue from SQL level now. On second hand, this functions can
be called via DirectFunctionCall API from custom C server side
routines, and there a developer can does a bug simply if doesn't fill
necessary structs well. So, there can be Asserts still.

>
> Moreover, if in any case get_fn_expr_argtype() returns an InvalidOid, we
> will hit an Assert rather than an error, is this what you expect ?
>

in this moment yes,

small change can helps with searching of source of possible issues.

so instead on line
Assert(OidIsValid(get_element_type(get_fn_expr_argtype(fcinfo->flinfo,
argidx))));

use two lines

Assert(OidIsValid(get_fn_expr_argtype(fcinfo->flinfo, argidx)));
Assert(OidIsValid(get_element_type(get_fn_expr_argtype(fcinfo->flinfo,
argidx))));

what you think?

Well, I am still not fully understand or convinced about first Assert, error will be good enough like what we have now.

Anyway, converting it over two lines eases the debugging efforts. But please take output of get_fn_expr_argtype(fcinfo->flinfo, argidx) into separate variable so that we will avoid calling same function twice.

I think some short comment for these Asserts will be good. At-least for second one as it is already done by parser and non-arrays are not at expected at this point.


> 5. This patch has user visibility, i.e. now we are throwing an error when
> user only says "VARIADIC NULL" like:
>
>     select concat(variadic NULL) is NULL;
>
> Previously it was working but now we are throwing an error. Well we are now
> more stricter than earlier with using VARIADIC + ANY, so I have no issue as
> such. But I guess we need to document this user visibility change. I don't
> know exactly where though. I searched for VARIADIC and all related
> documentation says it needs an array, so nothing harmful as such, so you can
> ignore this review comment but I thought it worth mentioning it.

yes, it is point for possible issues in RELEASE NOTES, I am thinking ???


Well, writer of release notes should be aware of this. And I hope he will be. So no issue.

Thanks
 
Regards

Pavel

>
> Thanks
>
>
>
> On Thu, Jun 27, 2013 at 12:35 AM, Pavel Stehule <pavel.stehule@gmail.com>
> wrote:
>>
>> Hello
>>
>> remastered version
>>
>> Regards
>>
>> Pavel
>>
>> 2013/6/26 Jeevan Chalke <jeevan.chalke@enterprisedb.com>:
>> > Hi Pavel
>> >
>> >
>> > On Sat, Jan 26, 2013 at 9:22 AM, Pavel Stehule <pavel.stehule@gmail.com>
>> > wrote:
>> >>
>> >> Hello Tom
>> >>
>> >> you did comment
>> >>
>> >> ! <----><------><------> * Non-null argument had better be an array.
>> >> The parser doesn't
>> >> ! <----><------><------> * enforce this for VARIADIC ANY functions
>> >> (maybe it should?), so
>> >> ! <----><------><------> * that check uses ereport not just elog.
>> >> ! <----><------><------> */
>> >>
>> >> So I moved this check to parser.
>> >>
>> >> It is little bit stricter - requests typed NULL instead unknown NULL,
>> >> but it can mark error better and early
>> >
>> >
>> > Tom suggested that this check should be better done by parser.
>> > This patch tries to accomplish that.
>> >
>> > I will go review this.
>> >
>> > However, is it possible to you to re-base it on current master? I can't
>> > apply it using "git apply" but patch -p1 was succeeded with lot of
>> > offset.
>> >
>> > Thanks
>> >
>> >>
>> >>
>> >> Regards
>> >>
>> >> Pavel
>> >>
>> >>
>> >> --
>> >> Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
>> >> To make changes to your subscription:
>> >> http://www.postgresql.org/mailpref/pgsql-hackers
>> >>
>> >
>> >
>> >
>> > --
>> > Jeevan B Chalke
>> > Senior Software Engineer, R&D
>> > EnterpriseDB Corporation
>> > The Enterprise PostgreSQL Company
>> >
>> > Phone: +91 20 30589500
>> >
>> > Website: www.enterprisedb.com
>> > EnterpriseDB Blog: http://blogs.enterprisedb.com/
>> > Follow us on Twitter: http://www.twitter.com/enterprisedb
>> >
>> > This e-mail message (and any attachment) is intended for the use of the
>> > individual or entity to whom it is addressed. This message contains
>> > information from EnterpriseDB Corporation that may be privileged,
>> > confidential, or exempt from disclosure under applicable law. If you are
>> > not
>> > the intended recipient or authorized to receive this for the intended
>> > recipient, any use, dissemination, distribution, retention, archiving,
>> > or
>> > copying of this communication is strictly prohibited. If you have
>> > received
>> > this e-mail in error, please notify the sender immediately by reply
>> > e-mail
>> > and delete this message.
>
>
>
>
> --
> Jeevan B Chalke
> Senior Software Engineer, R&D
> EnterpriseDB Corporation
> The Enterprise PostgreSQL Company
>
> Phone: +91 20 30589500
>
> Website: www.enterprisedb.com
> EnterpriseDB Blog: http://blogs.enterprisedb.com/
> Follow us on Twitter: http://www.twitter.com/enterprisedb
>
> This e-mail message (and any attachment) is intended for the use of the
> individual or entity to whom it is addressed. This message contains
> information from EnterpriseDB Corporation that may be privileged,
> confidential, or exempt from disclosure under applicable law. If you are not
> the intended recipient or authorized to receive this for the intended
> recipient, any use, dissemination, distribution, retention, archiving, or
> copying of this communication is strictly prohibited. If you have received
> this e-mail in error, please notify the sender immediately by reply e-mail
> and delete this message.



--
Jeevan B Chalke
Senior Software Engineer, R&D
EnterpriseDB Corporation
The Enterprise PostgreSQL Company

Phone: +91 20 30589500

Website: www.enterprisedb.com
EnterpriseDB Blog: http://blogs.enterprisedb.com/
Follow us on Twitter: http://www.twitter.com/enterprisedb

This e-mail message (and any attachment) is intended for the use of the individual or entity to whom it is addressed. This message contains information from EnterpriseDB Corporation that may be privileged, confidential, or exempt from disclosure under applicable law. If you are not the intended recipient or authorized to receive this for the intended recipient, any use, dissemination, distribution, retention, archiving, or copying of this communication is strictly prohibited. If you have received this e-mail in error, please notify the sender immediately by reply e-mail and delete this message.

Re: checking variadic "any" argument in parser - should be array

From
Pavel Stehule
Date:
2013/6/28 Jeevan Chalke <jeevan.chalke@enterprisedb.com>:
> Hi Pavel,
>
>
> On Fri, Jun 28, 2013 at 2:53 AM, Pavel Stehule <pavel.stehule@gmail.com>
> wrote:
>>
>> Hello
>>
>> 2013/6/27 Jeevan Chalke <jeevan.chalke@enterprisedb.com>:
>> > Hi Pavel,
>> >
>> > I had a look over your new patch and it looks good to me.
>> >
>> > My review comments on patch:
>> >
>> > 1. It cleanly applies with patch -p1 command.
>> > 2. make/make install/make check were smooth.
>> > 3. My own testing didn't find any issue.
>> > 4. I had a code walk-through and I am little bit worried or confused on
>> > following changes:
>> >
>> >           if (PG_ARGISNULL(argidx))
>> >               return NULL;
>> >
>> > !         /*
>> > !          * Non-null argument had better be an array.  The parser
>> > doesn't
>> > !          * enforce this for VARIADIC ANY functions (maybe it should?),
>> > so
>> > that
>> > !          * check uses ereport not just elog.
>> > !          */
>> > !         arr_typid = get_fn_expr_argtype(fcinfo->flinfo, argidx);
>> > !         if (!OidIsValid(arr_typid))
>> > !             elog(ERROR, "could not determine data type of concat()
>> > input");
>> > !
>> > !         if (!OidIsValid(get_element_type(arr_typid)))
>> > !             ereport(ERROR,
>> > !                     (errcode(ERRCODE_DATATYPE_MISMATCH),
>> > !                      errmsg("VARIADIC argument must be an array")));
>> >
>> > -         /* OK, safe to fetch the array value */
>> >           arr = PG_GETARG_ARRAYTYPE_P(argidx);
>> >
>> >           /*
>> > --- 3820,3828 ----
>> >           if (PG_ARGISNULL(argidx))
>> >               return NULL;
>> >
>> > !         /* Non-null argument had better be an array */
>> > !
>> > Assert(OidIsValid(get_element_type(get_fn_expr_argtype(fcinfo->flinfo,
>> > argidx))));
>> >
>> >           arr = PG_GETARG_ARRAYTYPE_P(argidx);
>> >
>> > We have moved checking of array type in parser (ParseFuncOrColumn())
>> > which
>> > basically verifies that argument type is indeed an array. Which exactly
>> > same
>> > as that of second if statement in earlier code, which you replaced by an
>> > Assert.
>> >
>> > However, what about first if statement ? Is it NO more required now?
>> > What if
>> > get_fn_expr_argtype() returns InvalidOid, don't you think we need to
>> > throw
>> > an error saying "could not determine data type of concat() input"?
>>
>> yes, If I understand well to question, a main differences is in stage
>> of checking. When I do a check in parser stage, then I can expect so
>> "actual_arg_types" array holds a valid values.
>
>
> That's fine.
>
>>
>>
>> >
>> > Well, I tried hard to trigger that code, but didn't able to get any test
>> > which fails with that error in earlier version and with your version.
>> > And
>> > thus I believe it is a dead code, which you removed ? Is it so ?
>>
>> It is removed in this version :), and it is not a bug, so there is not
>> reason for patching previous versions. Probably there should be a
>> Assert instead of error. This code is relatively mature - so I don't
>> expect a issue from SQL level now. On second hand, this functions can
>> be called via DirectFunctionCall API from custom C server side
>> routines, and there a developer can does a bug simply if doesn't fill
>> necessary structs well. So, there can be Asserts still.
>>
>> >
>> > Moreover, if in any case get_fn_expr_argtype() returns an InvalidOid, we
>> > will hit an Assert rather than an error, is this what you expect ?
>> >
>>
>> in this moment yes,
>>
>> small change can helps with searching of source of possible issues.
>>
>> so instead on line
>> Assert(OidIsValid(get_element_type(get_fn_expr_argtype(fcinfo->flinfo,
>> argidx))));
>>
>> use two lines
>>
>> Assert(OidIsValid(get_fn_expr_argtype(fcinfo->flinfo, argidx)));
>> Assert(OidIsValid(get_element_type(get_fn_expr_argtype(fcinfo->flinfo,
>> argidx))));
>>
>> what you think?
>
>
> Well, I am still not fully understand or convinced about first Assert, error
> will be good enough like what we have now.
>
> Anyway, converting it over two lines eases the debugging efforts. But please
> take output of get_fn_expr_argtype(fcinfo->flinfo, argidx) into separate
> variable so that we will avoid calling same function twice.

It is called in Assert, so it will be removed in production
environment. Using variable for this purpose is useless and less
maintainable.

>
> I think some short comment for these Asserts will be good. At-least for
> second one as it is already done by parser and non-arrays are not at
> expected at this point.
>

yes, I'll add some comment

Regards

Pavel


>>
>> > 5. This patch has user visibility, i.e. now we are throwing an error
>> > when
>> > user only says "VARIADIC NULL" like:
>> >
>> >     select concat(variadic NULL) is NULL;
>> >
>> > Previously it was working but now we are throwing an error. Well we are
>> > now
>> > more stricter than earlier with using VARIADIC + ANY, so I have no issue
>> > as
>> > such. But I guess we need to document this user visibility change. I
>> > don't
>> > know exactly where though. I searched for VARIADIC and all related
>> > documentation says it needs an array, so nothing harmful as such, so you
>> > can
>> > ignore this review comment but I thought it worth mentioning it.
>>
>> yes, it is point for possible issues in RELEASE NOTES, I am thinking ???
>>
>
> Well, writer of release notes should be aware of this. And I hope he will
> be. So no issue.
>
> Thanks
>
>>
>> Regards
>>
>> Pavel
>>
>> >
>> > Thanks
>> >
>> >
>> >
>> > On Thu, Jun 27, 2013 at 12:35 AM, Pavel Stehule
>> > <pavel.stehule@gmail.com>
>> > wrote:
>> >>
>> >> Hello
>> >>
>> >> remastered version
>> >>
>> >> Regards
>> >>
>> >> Pavel
>> >>
>> >> 2013/6/26 Jeevan Chalke <jeevan.chalke@enterprisedb.com>:
>> >> > Hi Pavel
>> >> >
>> >> >
>> >> > On Sat, Jan 26, 2013 at 9:22 AM, Pavel Stehule
>> >> > <pavel.stehule@gmail.com>
>> >> > wrote:
>> >> >>
>> >> >> Hello Tom
>> >> >>
>> >> >> you did comment
>> >> >>
>> >> >> ! <----><------><------> * Non-null argument had better be an array.
>> >> >> The parser doesn't
>> >> >> ! <----><------><------> * enforce this for VARIADIC ANY functions
>> >> >> (maybe it should?), so
>> >> >> ! <----><------><------> * that check uses ereport not just elog.
>> >> >> ! <----><------><------> */
>> >> >>
>> >> >> So I moved this check to parser.
>> >> >>
>> >> >> It is little bit stricter - requests typed NULL instead unknown
>> >> >> NULL,
>> >> >> but it can mark error better and early
>> >> >
>> >> >
>> >> > Tom suggested that this check should be better done by parser.
>> >> > This patch tries to accomplish that.
>> >> >
>> >> > I will go review this.
>> >> >
>> >> > However, is it possible to you to re-base it on current master? I
>> >> > can't
>> >> > apply it using "git apply" but patch -p1 was succeeded with lot of
>> >> > offset.
>> >> >
>> >> > Thanks
>> >> >
>> >> >>
>> >> >>
>> >> >> Regards
>> >> >>
>> >> >> Pavel
>> >> >>
>> >> >>
>> >> >> --
>> >> >> Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
>> >> >> To make changes to your subscription:
>> >> >> http://www.postgresql.org/mailpref/pgsql-hackers
>> >> >>
>> >> >
>> >> >
>> >> >
>> >> > --
>> >> > Jeevan B Chalke
>> >> > Senior Software Engineer, R&D
>> >> > EnterpriseDB Corporation
>> >> > The Enterprise PostgreSQL Company
>> >> >
>> >> > Phone: +91 20 30589500
>> >> >
>> >> > Website: www.enterprisedb.com
>> >> > EnterpriseDB Blog: http://blogs.enterprisedb.com/
>> >> > Follow us on Twitter: http://www.twitter.com/enterprisedb
>> >> >
>> >> > This e-mail message (and any attachment) is intended for the use of
>> >> > the
>> >> > individual or entity to whom it is addressed. This message contains
>> >> > information from EnterpriseDB Corporation that may be privileged,
>> >> > confidential, or exempt from disclosure under applicable law. If you
>> >> > are
>> >> > not
>> >> > the intended recipient or authorized to receive this for the intended
>> >> > recipient, any use, dissemination, distribution, retention,
>> >> > archiving,
>> >> > or
>> >> > copying of this communication is strictly prohibited. If you have
>> >> > received
>> >> > this e-mail in error, please notify the sender immediately by reply
>> >> > e-mail
>> >> > and delete this message.
>> >
>> >
>> >
>> >
>> > --
>> > Jeevan B Chalke
>> > Senior Software Engineer, R&D
>> > EnterpriseDB Corporation
>> > The Enterprise PostgreSQL Company
>> >
>> > Phone: +91 20 30589500
>> >
>> > Website: www.enterprisedb.com
>> > EnterpriseDB Blog: http://blogs.enterprisedb.com/
>> > Follow us on Twitter: http://www.twitter.com/enterprisedb
>> >
>> > This e-mail message (and any attachment) is intended for the use of the
>> > individual or entity to whom it is addressed. This message contains
>> > information from EnterpriseDB Corporation that may be privileged,
>> > confidential, or exempt from disclosure under applicable law. If you are
>> > not
>> > the intended recipient or authorized to receive this for the intended
>> > recipient, any use, dissemination, distribution, retention, archiving,
>> > or
>> > copying of this communication is strictly prohibited. If you have
>> > received
>> > this e-mail in error, please notify the sender immediately by reply
>> > e-mail
>> > and delete this message.
>
>
>
>
> --
> Jeevan B Chalke
> Senior Software Engineer, R&D
> EnterpriseDB Corporation
> The Enterprise PostgreSQL Company
>
> Phone: +91 20 30589500
>
> Website: www.enterprisedb.com
> EnterpriseDB Blog: http://blogs.enterprisedb.com/
> Follow us on Twitter: http://www.twitter.com/enterprisedb
>
> This e-mail message (and any attachment) is intended for the use of the
> individual or entity to whom it is addressed. This message contains
> information from EnterpriseDB Corporation that may be privileged,
> confidential, or exempt from disclosure under applicable law. If you are not
> the intended recipient or authorized to receive this for the intended
> recipient, any use, dissemination, distribution, retention, archiving, or
> copying of this communication is strictly prohibited. If you have received
> this e-mail in error, please notify the sender immediately by reply e-mail
> and delete this message.



Re: checking variadic "any" argument in parser - should be array

From
Pavel Stehule
Date:
Hello

updated patch - precious Assert, more comments

Regards

Pavel

2013/6/29 Pavel Stehule <pavel.stehule@gmail.com>:
> 2013/6/28 Jeevan Chalke <jeevan.chalke@enterprisedb.com>:
>> Hi Pavel,
>>
>>
>> On Fri, Jun 28, 2013 at 2:53 AM, Pavel Stehule <pavel.stehule@gmail.com>
>> wrote:
>>>
>>> Hello
>>>
>>> 2013/6/27 Jeevan Chalke <jeevan.chalke@enterprisedb.com>:
>>> > Hi Pavel,
>>> >
>>> > I had a look over your new patch and it looks good to me.
>>> >
>>> > My review comments on patch:
>>> >
>>> > 1. It cleanly applies with patch -p1 command.
>>> > 2. make/make install/make check were smooth.
>>> > 3. My own testing didn't find any issue.
>>> > 4. I had a code walk-through and I am little bit worried or confused on
>>> > following changes:
>>> >
>>> >           if (PG_ARGISNULL(argidx))
>>> >               return NULL;
>>> >
>>> > !         /*
>>> > !          * Non-null argument had better be an array.  The parser
>>> > doesn't
>>> > !          * enforce this for VARIADIC ANY functions (maybe it should?),
>>> > so
>>> > that
>>> > !          * check uses ereport not just elog.
>>> > !          */
>>> > !         arr_typid = get_fn_expr_argtype(fcinfo->flinfo, argidx);
>>> > !         if (!OidIsValid(arr_typid))
>>> > !             elog(ERROR, "could not determine data type of concat()
>>> > input");
>>> > !
>>> > !         if (!OidIsValid(get_element_type(arr_typid)))
>>> > !             ereport(ERROR,
>>> > !                     (errcode(ERRCODE_DATATYPE_MISMATCH),
>>> > !                      errmsg("VARIADIC argument must be an array")));
>>> >
>>> > -         /* OK, safe to fetch the array value */
>>> >           arr = PG_GETARG_ARRAYTYPE_P(argidx);
>>> >
>>> >           /*
>>> > --- 3820,3828 ----
>>> >           if (PG_ARGISNULL(argidx))
>>> >               return NULL;
>>> >
>>> > !         /* Non-null argument had better be an array */
>>> > !
>>> > Assert(OidIsValid(get_element_type(get_fn_expr_argtype(fcinfo->flinfo,
>>> > argidx))));
>>> >
>>> >           arr = PG_GETARG_ARRAYTYPE_P(argidx);
>>> >
>>> > We have moved checking of array type in parser (ParseFuncOrColumn())
>>> > which
>>> > basically verifies that argument type is indeed an array. Which exactly
>>> > same
>>> > as that of second if statement in earlier code, which you replaced by an
>>> > Assert.
>>> >
>>> > However, what about first if statement ? Is it NO more required now?
>>> > What if
>>> > get_fn_expr_argtype() returns InvalidOid, don't you think we need to
>>> > throw
>>> > an error saying "could not determine data type of concat() input"?
>>>
>>> yes, If I understand well to question, a main differences is in stage
>>> of checking. When I do a check in parser stage, then I can expect so
>>> "actual_arg_types" array holds a valid values.
>>
>>
>> That's fine.
>>
>>>
>>>
>>> >
>>> > Well, I tried hard to trigger that code, but didn't able to get any test
>>> > which fails with that error in earlier version and with your version.
>>> > And
>>> > thus I believe it is a dead code, which you removed ? Is it so ?
>>>
>>> It is removed in this version :), and it is not a bug, so there is not
>>> reason for patching previous versions. Probably there should be a
>>> Assert instead of error. This code is relatively mature - so I don't
>>> expect a issue from SQL level now. On second hand, this functions can
>>> be called via DirectFunctionCall API from custom C server side
>>> routines, and there a developer can does a bug simply if doesn't fill
>>> necessary structs well. So, there can be Asserts still.
>>>
>>> >
>>> > Moreover, if in any case get_fn_expr_argtype() returns an InvalidOid, we
>>> > will hit an Assert rather than an error, is this what you expect ?
>>> >
>>>
>>> in this moment yes,
>>>
>>> small change can helps with searching of source of possible issues.
>>>
>>> so instead on line
>>> Assert(OidIsValid(get_element_type(get_fn_expr_argtype(fcinfo->flinfo,
>>> argidx))));
>>>
>>> use two lines
>>>
>>> Assert(OidIsValid(get_fn_expr_argtype(fcinfo->flinfo, argidx)));
>>> Assert(OidIsValid(get_element_type(get_fn_expr_argtype(fcinfo->flinfo,
>>> argidx))));
>>>
>>> what you think?
>>
>>
>> Well, I am still not fully understand or convinced about first Assert, error
>> will be good enough like what we have now.
>>
>> Anyway, converting it over two lines eases the debugging efforts. But please
>> take output of get_fn_expr_argtype(fcinfo->flinfo, argidx) into separate
>> variable so that we will avoid calling same function twice.
>
> It is called in Assert, so it will be removed in production
> environment. Using variable for this purpose is useless and less
> maintainable.
>
>>
>> I think some short comment for these Asserts will be good. At-least for
>> second one as it is already done by parser and non-arrays are not at
>> expected at this point.
>>
>
> yes, I'll add some comment
>
> Regards
>
> Pavel
>
>
>>>
>>> > 5. This patch has user visibility, i.e. now we are throwing an error
>>> > when
>>> > user only says "VARIADIC NULL" like:
>>> >
>>> >     select concat(variadic NULL) is NULL;
>>> >
>>> > Previously it was working but now we are throwing an error. Well we are
>>> > now
>>> > more stricter than earlier with using VARIADIC + ANY, so I have no issue
>>> > as
>>> > such. But I guess we need to document this user visibility change. I
>>> > don't
>>> > know exactly where though. I searched for VARIADIC and all related
>>> > documentation says it needs an array, so nothing harmful as such, so you
>>> > can
>>> > ignore this review comment but I thought it worth mentioning it.
>>>
>>> yes, it is point for possible issues in RELEASE NOTES, I am thinking ???
>>>
>>
>> Well, writer of release notes should be aware of this. And I hope he will
>> be. So no issue.
>>
>> Thanks
>>
>>>
>>> Regards
>>>
>>> Pavel
>>>
>>> >
>>> > Thanks
>>> >
>>> >
>>> >
>>> > On Thu, Jun 27, 2013 at 12:35 AM, Pavel Stehule
>>> > <pavel.stehule@gmail.com>
>>> > wrote:
>>> >>
>>> >> Hello
>>> >>
>>> >> remastered version
>>> >>
>>> >> Regards
>>> >>
>>> >> Pavel
>>> >>
>>> >> 2013/6/26 Jeevan Chalke <jeevan.chalke@enterprisedb.com>:
>>> >> > Hi Pavel
>>> >> >
>>> >> >
>>> >> > On Sat, Jan 26, 2013 at 9:22 AM, Pavel Stehule
>>> >> > <pavel.stehule@gmail.com>
>>> >> > wrote:
>>> >> >>
>>> >> >> Hello Tom
>>> >> >>
>>> >> >> you did comment
>>> >> >>
>>> >> >> ! <----><------><------> * Non-null argument had better be an array.
>>> >> >> The parser doesn't
>>> >> >> ! <----><------><------> * enforce this for VARIADIC ANY functions
>>> >> >> (maybe it should?), so
>>> >> >> ! <----><------><------> * that check uses ereport not just elog.
>>> >> >> ! <----><------><------> */
>>> >> >>
>>> >> >> So I moved this check to parser.
>>> >> >>
>>> >> >> It is little bit stricter - requests typed NULL instead unknown
>>> >> >> NULL,
>>> >> >> but it can mark error better and early
>>> >> >
>>> >> >
>>> >> > Tom suggested that this check should be better done by parser.
>>> >> > This patch tries to accomplish that.
>>> >> >
>>> >> > I will go review this.
>>> >> >
>>> >> > However, is it possible to you to re-base it on current master? I
>>> >> > can't
>>> >> > apply it using "git apply" but patch -p1 was succeeded with lot of
>>> >> > offset.
>>> >> >
>>> >> > Thanks
>>> >> >
>>> >> >>
>>> >> >>
>>> >> >> Regards
>>> >> >>
>>> >> >> Pavel
>>> >> >>
>>> >> >>
>>> >> >> --
>>> >> >> Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
>>> >> >> To make changes to your subscription:
>>> >> >> http://www.postgresql.org/mailpref/pgsql-hackers
>>> >> >>
>>> >> >
>>> >> >
>>> >> >
>>> >> > --
>>> >> > Jeevan B Chalke
>>> >> > Senior Software Engineer, R&D
>>> >> > EnterpriseDB Corporation
>>> >> > The Enterprise PostgreSQL Company
>>> >> >
>>> >> > Phone: +91 20 30589500
>>> >> >
>>> >> > Website: www.enterprisedb.com
>>> >> > EnterpriseDB Blog: http://blogs.enterprisedb.com/
>>> >> > Follow us on Twitter: http://www.twitter.com/enterprisedb
>>> >> >
>>> >> > This e-mail message (and any attachment) is intended for the use of
>>> >> > the
>>> >> > individual or entity to whom it is addressed. This message contains
>>> >> > information from EnterpriseDB Corporation that may be privileged,
>>> >> > confidential, or exempt from disclosure under applicable law. If you
>>> >> > are
>>> >> > not
>>> >> > the intended recipient or authorized to receive this for the intended
>>> >> > recipient, any use, dissemination, distribution, retention,
>>> >> > archiving,
>>> >> > or
>>> >> > copying of this communication is strictly prohibited. If you have
>>> >> > received
>>> >> > this e-mail in error, please notify the sender immediately by reply
>>> >> > e-mail
>>> >> > and delete this message.
>>> >
>>> >
>>> >
>>> >
>>> > --
>>> > Jeevan B Chalke
>>> > Senior Software Engineer, R&D
>>> > EnterpriseDB Corporation
>>> > The Enterprise PostgreSQL Company
>>> >
>>> > Phone: +91 20 30589500
>>> >
>>> > Website: www.enterprisedb.com
>>> > EnterpriseDB Blog: http://blogs.enterprisedb.com/
>>> > Follow us on Twitter: http://www.twitter.com/enterprisedb
>>> >
>>> > This e-mail message (and any attachment) is intended for the use of the
>>> > individual or entity to whom it is addressed. This message contains
>>> > information from EnterpriseDB Corporation that may be privileged,
>>> > confidential, or exempt from disclosure under applicable law. If you are
>>> > not
>>> > the intended recipient or authorized to receive this for the intended
>>> > recipient, any use, dissemination, distribution, retention, archiving,
>>> > or
>>> > copying of this communication is strictly prohibited. If you have
>>> > received
>>> > this e-mail in error, please notify the sender immediately by reply
>>> > e-mail
>>> > and delete this message.
>>
>>
>>
>>
>> --
>> Jeevan B Chalke
>> Senior Software Engineer, R&D
>> EnterpriseDB Corporation
>> The Enterprise PostgreSQL Company
>>
>> Phone: +91 20 30589500
>>
>> Website: www.enterprisedb.com
>> EnterpriseDB Blog: http://blogs.enterprisedb.com/
>> Follow us on Twitter: http://www.twitter.com/enterprisedb
>>
>> This e-mail message (and any attachment) is intended for the use of the
>> individual or entity to whom it is addressed. This message contains
>> information from EnterpriseDB Corporation that may be privileged,
>> confidential, or exempt from disclosure under applicable law. If you are not
>> the intended recipient or authorized to receive this for the intended
>> recipient, any use, dissemination, distribution, retention, archiving, or
>> copying of this communication is strictly prohibited. If you have received
>> this e-mail in error, please notify the sender immediately by reply e-mail
>> and delete this message.

Attachment

Re: checking variadic "any" argument in parser - should be array

From
Alvaro Herrera
Date:
Pavel Stehule escribió:
> Hello
> 
> updated patch - precious Assert, more comments

Pavel, can you please remove quoted text from messages you reply to?
This message has 10kb of completely useless text.

Thanks,

-- 
Álvaro Herrera                http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services



Re: checking variadic "any" argument in parser - should be array

From
Pavel Stehule
Date:
2013/6/29 Pavel Stehule <pavel.stehule@gmail.com>:
> Hello
>
> updated patch - precious Assert, more comments
>
> Regards
>
> Pavel
>

stripped

Attachment

Re: checking variadic "any" argument in parser - should be array

From
Jeevan Chalke
Date:
<div dir="ltr"><br /><div class="gmail_extra"><br /><br /><div class="gmail_quote">On Mon, Jul 1, 2013 at 8:36 PM,
PavelStehule <span dir="ltr"><<a href="mailto:pavel.stehule@gmail.com"
target="_blank">pavel.stehule@gmail.com</a>></span>wrote:<br /><blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px#ccc solid;padding-left:1ex">2013/6/29 Pavel Stehule <<a
href="mailto:pavel.stehule@gmail.com">pavel.stehule@gmail.com</a>>:<br/><div class="im">> Hello<br /> ><br />
>updated patch - precious Assert, more comments<br /> ><br /> > Regards<br /> ><br /> > Pavel<br />
><br/><br /></div>stripped<br /></blockquote></div><br /></div><div class="gmail_extra">Thanks.<br /><br
/></div><divclass="gmail_extra">Patch looks good to me now.<br /></div><div class="gmail_extra">Revalidated and didn't
seeany issue so marking "Ready For Committer".<br /><br /></div><div class="gmail_extra">Thanks Pavel.<br clear="all"
/></div><divclass="gmail_extra"><br />-- <br />Jeevan B Chalke<br />Senior Software Engineer, R&D<br />EnterpriseDB
Corporation<br/>The Enterprise PostgreSQL Company<br /></div></div> 

Re: checking variadic "any" argument in parser - should be array

From
Andrew Dunstan
Date:
On 06/29/2013 03:29 PM, Pavel Stehule wrote:



>>>>> 5. This patch has user visibility, i.e. now we are throwing an error
>>>>> when
>>>>> user only says "VARIADIC NULL" like:
>>>>>
>>>>>      select concat(variadic NULL) is NULL;
>>>>>
>>>>> Previously it was working but now we are throwing an error. Well we are
>>>>> now
>>>>> more stricter than earlier with using VARIADIC + ANY, so I have no issue
>>>>> as
>>>>> such. But I guess we need to document this user visibility change. I
>>>>> don't
>>>>> know exactly where though. I searched for VARIADIC and all related
>>>>> documentation says it needs an array, so nothing harmful as such, so you
>>>>> can
>>>>> ignore this review comment but I thought it worth mentioning it.
>>>> yes, it is point for possible issues in RELEASE NOTES, I am thinking ???
>>>>
>>> Well, writer of release notes should be aware of this. And I hope he will
>>> be. So no issue.


Is the behaviour change really unavoidable? Is it really what we want? 
Nobody seems to have picked up on this except the author and the 
reviewer. I'd hate us to do this and then surprise people. I'm not sure 
how many people are using VARIADIC "any", but I have started doing so 
and expect to do so more, and I suspect I'm not alone.

cheers

andrew




Re: checking variadic "any" argument in parser - should be array

From
Pavel Stehule
Date:
Hello

2013/7/14 Andrew Dunstan <andrew@dunslane.net>:
>
> On 06/29/2013 03:29 PM, Pavel Stehule wrote:
>
>
>
>>>>>> 5. This patch has user visibility, i.e. now we are throwing an error
>>>>>> when
>>>>>> user only says "VARIADIC NULL" like:
>>>>>>
>>>>>>      select concat(variadic NULL) is NULL;
>>>>>>
>>>>>> Previously it was working but now we are throwing an error. Well we
>>>>>> are
>>>>>> now
>>>>>> more stricter than earlier with using VARIADIC + ANY, so I have no
>>>>>> issue
>>>>>> as
>>>>>> such. But I guess we need to document this user visibility change. I
>>>>>> don't
>>>>>> know exactly where though. I searched for VARIADIC and all related
>>>>>> documentation says it needs an array, so nothing harmful as such, so
>>>>>> you
>>>>>> can
>>>>>> ignore this review comment but I thought it worth mentioning it.
>>>>>
>>>>> yes, it is point for possible issues in RELEASE NOTES, I am thinking
>>>>> ???
>>>>>
>>>> Well, writer of release notes should be aware of this. And I hope he
>>>> will
>>>> be. So no issue.
>
>
>
> Is the behaviour change really unavoidable? Is it really what we want?
> Nobody seems to have picked up on this except the author and the reviewer.
> I'd hate us to do this and then surprise people. I'm not sure how many
> people are using VARIADIC "any", but I have started doing so and expect to
> do so more, and I suspect I'm not alone.

It doesn't disallow NULL - it disallow nonarray types on this
possition, because there are must be only array type values. Other
possible usage created unambiguous behave.

so SELECT varfx(VARIADIC NULL) -- is disallowed
but SELECT varfx(VARIADIC NULL::text[]) -- is allowed

for example, I can wrote SELECT varfx(10,20,30), but I cannot write
SELECT varfx(VARIADIC 10,20,30) - because this behave should be
undefined.

Can me  send, your use case, where this check is unwanted, please.

The execution of variadic function can be little bit faster, because
this check is moved from execution to parser stage (and it is reason,
why I cannot to check NULL, because I have no simply access to
information about some parameter is constant or not.

It should to fix unwanted behave where VARIADIC keyword was ignored -
I am sure so this is some what we want, but I don't know your
arguments against, so please, send me you use case.

Regards

Pavel



>
> cheers
>
> andrew
>



Re: checking variadic "any" argument in parser - should be array

From
Andrew Dunstan
Date:
On 07/14/2013 12:28 AM, Pavel Stehule wrote:
> Hello
>
> 2013/7/14 Andrew Dunstan <andrew@dunslane.net>:
>> On 06/29/2013 03:29 PM, Pavel Stehule wrote:
>>
>>
>>
>>>>>>> 5. This patch has user visibility, i.e. now we are throwing an error
>>>>>>> when
>>>>>>> user only says "VARIADIC NULL" like:
>>>>>>>
>>>>>>>       select concat(variadic NULL) is NULL;
>>>>>>>
>>>>>>> Previously it was working but now we are throwing an error. Well we
>>>>>>> are
>>>>>>> now
>>>>>>> more stricter than earlier with using VARIADIC + ANY, so I have no
>>>>>>> issue
>>>>>>> as
>>>>>>> such. But I guess we need to document this user visibility change. I
>>>>>>> don't
>>>>>>> know exactly where though. I searched for VARIADIC and all related
>>>>>>> documentation says it needs an array, so nothing harmful as such, so
>>>>>>> you
>>>>>>> can
>>>>>>> ignore this review comment but I thought it worth mentioning it.
>>>>>> yes, it is point for possible issues in RELEASE NOTES, I am thinking
>>>>>> ???
>>>>>>
>>>>> Well, writer of release notes should be aware of this. And I hope he
>>>>> will
>>>>> be. So no issue.
>>
>>
>> Is the behaviour change really unavoidable? Is it really what we want?
>> Nobody seems to have picked up on this except the author and the reviewer.
>> I'd hate us to do this and then surprise people. I'm not sure how many
>> people are using VARIADIC "any", but I have started doing so and expect to
>> do so more, and I suspect I'm not alone.
> It doesn't disallow NULL - it disallow nonarray types on this
> possition, because there are must be only array type values. Other
> possible usage created unambiguous behave.
>
> so SELECT varfx(VARIADIC NULL) -- is disallowed
> but SELECT varfx(VARIADIC NULL::text[]) -- is allowed


Quite so, I understand exactly what the defined behaviour will be.


>
> for example, I can wrote SELECT varfx(10,20,30), but I cannot write
> SELECT varfx(VARIADIC 10,20,30) - because this behave should be
> undefined.
>
> Can me  send, your use case, where this check is unwanted, please.


The only question I raised was for the NULL case. If you're not saying 
"VARIADIC NULL" then I have no issue.

Anyway, nobody else seem to care much (and I suspect very few people are 
writing VARIADIC "any" functions anyway, apart from you and me). So I'll 
see about getting this committed shortly.

cheers

andrew




Re: checking variadic "any" argument in parser - should be array

From
Pavel Stehule
Date:
2013/7/15 Andrew Dunstan <andrew@dunslane.net>:
>
> On 07/14/2013 12:28 AM, Pavel Stehule wrote:
>>
>> Hello
>>
>> 2013/7/14 Andrew Dunstan <andrew@dunslane.net>:
>>>
>>> On 06/29/2013 03:29 PM, Pavel Stehule wrote:
>>>
>>>
>>>
>>>>>>>> 5. This patch has user visibility, i.e. now we are throwing an error
>>>>>>>> when
>>>>>>>> user only says "VARIADIC NULL" like:
>>>>>>>>
>>>>>>>>       select concat(variadic NULL) is NULL;
>>>>>>>>
>>>>>>>> Previously it was working but now we are throwing an error. Well we
>>>>>>>> are
>>>>>>>> now
>>>>>>>> more stricter than earlier with using VARIADIC + ANY, so I have no
>>>>>>>> issue
>>>>>>>> as
>>>>>>>> such. But I guess we need to document this user visibility change. I
>>>>>>>> don't
>>>>>>>> know exactly where though. I searched for VARIADIC and all related
>>>>>>>> documentation says it needs an array, so nothing harmful as such, so
>>>>>>>> you
>>>>>>>> can
>>>>>>>> ignore this review comment but I thought it worth mentioning it.
>>>>>>>
>>>>>>> yes, it is point for possible issues in RELEASE NOTES, I am thinking
>>>>>>> ???
>>>>>>>
>>>>>> Well, writer of release notes should be aware of this. And I hope he
>>>>>> will
>>>>>> be. So no issue.
>>>
>>>
>>>
>>> Is the behaviour change really unavoidable? Is it really what we want?
>>> Nobody seems to have picked up on this except the author and the
>>> reviewer.
>>> I'd hate us to do this and then surprise people. I'm not sure how many
>>> people are using VARIADIC "any", but I have started doing so and expect
>>> to
>>> do so more, and I suspect I'm not alone.
>>
>> It doesn't disallow NULL - it disallow nonarray types on this
>> possition, because there are must be only array type values. Other
>> possible usage created unambiguous behave.
>>
>> so SELECT varfx(VARIADIC NULL) -- is disallowed
>> but SELECT varfx(VARIADIC NULL::text[]) -- is allowed
>
>
>
> Quite so, I understand exactly what the defined behaviour will be.
>
>
>
>>
>> for example, I can wrote SELECT varfx(10,20,30), but I cannot write
>> SELECT varfx(VARIADIC 10,20,30) - because this behave should be
>> undefined.
>>
>> Can me  send, your use case, where this check is unwanted, please.
>
>
>
> The only question I raised was for the NULL case. If you're not saying
> "VARIADIC NULL" then I have no issue.

NULL is allowed - but it should be typed.

>
> Anyway, nobody else seem to care much (and I suspect very few people are
> writing VARIADIC "any" functions anyway, apart from you and me). So I'll see
> about getting this committed shortly.
>

exactly

Regards

Pavel

> cheers
>
> andrew
>