Skip site navigation (1) Skip section navigation (2)

Re: Patch: Allow SQL-language functions to reference parameters by parameter name

From: Hitoshi Harada <umi(dot)tanuki(at)gmail(dot)com>
To: Matthew Draper <matthew(at)trebex(dot)net>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Patch: Allow SQL-language functions to reference parameters by parameter name
Date: 2012-01-18 09:11:56
Message-ID: CAP7Qgm=EKf04XYiq42pA9hohdxB71eV=WCKxevh1x5U5ZY+7Kg@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-hackers
On Sat, Jan 14, 2012 at 8:10 AM, Matthew Draper <matthew(at)trebex(dot)net> wrote:
>
> I just remembered to make time to advance this from WIP to proposed
> patch this week... and then worked out I'm rudely dropping it into the
> last commitfest at the last minute. :/

The patch applies clean against master but compiles with warnings.
functions.c: In function ‘prepare_sql_fn_parse_info’:
functions.c:212: warning: unused variable ‘argnum’
functions.c: In function ‘sql_fn_post_column_ref’:
functions.c:341: warning: implicit declaration of function ‘ParseFuncOrColumn’
functions.c:345: warning: assignment makes pointer from integer without a cast

Then, I ran make check but hit a bunch of crash. Looking closer, I
found the FieldSelect returned from ParseFuncOrColumn is trimmed to
32bit pointer and subsequent operation on this is broken. I found
unnecessary cltq is inserted after call.

0x00000001001d8288 <sql_fn_post_column_ref+748>:	mov    $0x0,%eax
0x00000001001d828d <sql_fn_post_column_ref+753>:	callq  0x100132f75
<ParseFuncOrColumn>
0x00000001001d8292 <sql_fn_post_column_ref+758>:	cltq
0x00000001001d8294 <sql_fn_post_column_ref+760>:	mov    %rax,-0x48(%rbp)

My environment:
10.8.0 Darwin Kernel Version 10.8.0: Tue Jun  7 16:32:41 PDT 2011;
root:xnu-1504.15.3~1/RELEASE_X86_64 x86_64
$ gcc -v
Using built-in specs.
Target: i686-apple-darwin10
Configured with: /var/tmp/gcc/gcc-5666.3~6/src/configure
--disable-checking --enable-werror --prefix=/usr --mandir=/share/man
--enable-languages=c,objc,c++,obj-c++
--program-transform-name=/^[cg][^.-]*$/s/$/-4.2/
--with-slibdir=/usr/lib --build=i686-apple-darwin10
--program-prefix=i686-apple-darwin10- --host=x86_64-apple-darwin10
--target=i686-apple-darwin10 --with-gxx-include-dir=/include/c++/4.2.1
Thread model: posix
gcc version 4.2.1 (Apple Inc. build 5666) (dot 3)

(Now it occurred to me that forgetting the #include parse_func.h might
hit this breakage..., so I'll fix it here and continue to test, but if
you'll fix it yourself, let me know)

Regards,
-- 
Hitoshi Harada

In response to

Responses

pgsql-hackers by date

Next:From: Magnus HaganderDate: 2012-01-18 09:35:39
Subject: Re: psql \timing vs failed statements
Previous:From: Dimitri FontaineDate: 2012-01-18 09:09:34
Subject: Re: Command Triggers

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group