Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hSgx4-0002ml-Gr for pgsql-odbc@arkaria.postgresql.org; Mon, 20 May 2019 11:59:34 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hSgw5-0007uX-6I for pgsql-odbc@arkaria.postgresql.org; Mon, 20 May 2019 11:58:33 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hSgw4-0007uP-UJ for pgsql-odbc@lists.postgresql.org; Mon, 20 May 2019 11:58:33 +0000 Received: from mail01.asahi-net.or.jp ([202.224.55.13]) by magus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hSgw0-0004QE-DE for pgsql-odbc@lists.postgresql.org; Mon, 20 May 2019 11:58:32 +0000 Received: from [192.168.0.6] (KD124208079206.ppp-bb.dion.ne.jp [124.208.79.206]) (Authenticated sender: GQ9H-INUE) by mail01.asahi-net.or.jp (Postfix) with ESMTPA id BDC3811D2C0; Mon, 20 May 2019 20:58:23 +0900 (JST) Subject: Re: Bound parameters in escaped functions To: Grant Shirreffs Cc: "pgsql-odbc@lists.postgresql.org" References: <697c5065-225a-e0e0-fd64-c16a18ae45d6@dream.email.ne.jp> From: "Inoue, Hiroshi" Message-ID: <5255d098-13ca-db21-e50a-8909aba74252@dream.email.ne.jp> Date: Mon, 20 May 2019 20:58:21 +0900 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------2368BC28656CD6DC10D906C7" Content-Language: en-US X-Antivirus: AVG (VPS 190520-0, 2019/05/20), Outbound message X-Antivirus-Status: Clean List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------2368BC28656CD6DC10D906C7 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Hi, We would make a new release this weekend. regards, Hiroshi Inoue On 2019/05/20 6:21, Grant Shirreffs wrote: > > Thank you, Hiroshi. > > Do you have any idea when there is likely to be a formal release > containing this fix? > > Kind regards > > Grant > > *From:*Inoue, Hiroshi > *Sent:* Sunday, 19 May 2019 16:06 > *To:* Grant Shirreffs > *Cc:* pgsql-odbc@lists.postgresql.org > *Subject:* Re: Bound parameters in escaped functions > > Hi Grant, > > I've pushed changes to git. > Please look at > https://git.postgresql.org/gitweb/?p=psqlodbc.git;a=summary . > > regards, > Hiroshi Inoue > > On 2019/05/17 9:48, Inoue, Hiroshi wrote: > > Hi Grant, > > Thanks for the report. > I would take care of the bug fix. > > regards, > Hiroshi Inoue > > On 2019/05/14 12:58, Grant Shirreffs wrote: > > Hello, > > I have found a bug in the translation of ‘?’ parameters in > escaped ODBC functions. > > Where there is an escaped ODBC function within another, for > example: > >                 CASE WHEN {fn LENGTH({fn LTRIM(Name || > ?))=?     […] > > During convert_escape (convert.c:5471), at line 5626 the > QueryBuild object is copied to a local temporary (‘ncb’), > which is then passed to ‘processParameters’, which then calls > recursively back into convert_escape for the inner function. > > Then, at line 5771, the parameter number from ncb is passed > back into the original QueryBuild, so that query processing > carries on successfully.  However, crucially, the > dollar_number value from ncb, which has been incremented while > processing the parameters inside the function, is not passed > back.  So although the parameters themselves are correctly > handled, the incorrect PostgreSQL placeholder symbol is generated. > > In the example above, the resulting SQL is: > >                 CASE WHEN LENGTH(LTRIM(Name || $1))=$1::int4   […] > > Where it should of course be: > >                 CASE WHEN LENGTH(LTRIM(Name) || $1))=$2:int4 > > The fix is to copy the dollar_number back from ncb to the > original QueryBuild: > > if(SQL_ERROR != retval) > >             { > >                   qb->param_number = nqb.param_number; > >                   qb->dollar_number = nqb.dollar_number; > >                   qb->flags = nqb.flags; > >             } > --- このメールは、AVG によってウイルス チェックされています。 http://www.avg.com --------------2368BC28656CD6DC10D906C7 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit Hi,

We would make a new release this weekend.

regards,
Hiroshi Inoue

On 2019/05/20 6:21, Grant Shirreffs wrote:

Thank you, Hiroshi.

 

Do you have any idea when there is likely to be a formal release containing this fix?

 

Kind regards

Grant

 

From: Inoue, Hiroshi <h-inoue@dream.email.ne.jp>
Sent: Sunday, 19 May 2019 16:06
To: Grant Shirreffs <GShirreffs@stayinfront.com>
Cc: pgsql-odbc@lists.postgresql.org
Subject: Re: Bound parameters in escaped functions

 

Hi Grant,

I've pushed changes to git.
Please look at
    https://git.postgresql.org/gitweb/?p=psqlodbc.git;a=summary .

regards,
Hiroshi Inoue

On 2019/05/17 9:48, Inoue, Hiroshi wrote:

Hi Grant,

Thanks for the report.
I would take care of the bug fix.

regards,
Hiroshi Inoue

On 2019/05/14 12:58, Grant Shirreffs wrote:

Hello,

 

I have found a bug in the translation of ‘?’ parameters in escaped ODBC functions.

 

Where there is an escaped ODBC function within another, for example:

 

                CASE WHEN {fn LENGTH({fn LTRIM(Name || ?))=?     […]

 

During convert_escape (convert.c:5471), at line 5626 the QueryBuild object is copied to a local temporary (‘ncb’), which is then passed to ‘processParameters’, which then calls recursively back into convert_escape for the inner function.

 

Then, at line 5771, the parameter number from ncb is passed back into the original QueryBuild, so that query processing carries on successfully.  However, crucially, the dollar_number value from ncb, which has been incremented while processing the parameters inside the function, is not passed back.  So although the parameters themselves are correctly handled, the incorrect PostgreSQL placeholder symbol is generated.

 

In the example above, the resulting SQL is:

 

                CASE WHEN LENGTH(LTRIM(Name || $1))=$1::int4   […]

 

Where it should of course be:

 

                CASE WHEN LENGTH(LTRIM(Name) || $1))=$2:int4

 

The fix is to copy the dollar_number back from ncb to the original QueryBuild:

 

            if (SQL_ERROR != retval)

            {

                  qb->param_number = nqb.param_number;

                  qb->dollar_number = nqb.dollar_number;

                  qb->flags = nqb.flags;

            }



ウイルス フリー。 www.avg.com
--------------2368BC28656CD6DC10D906C7--