pg.ddx.io  pgsql-odbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Inoue, Hiroshi <h-inoue@dream.email.ne.jp>
To: Grant Shirreffs <GShirreffs@stayinfront.com>
Cc: pgsql-odbc@lists.postgresql.org <pgsql-odbc@lists.postgresql.org>
Subject: Re: Bound parameters in escaped functions
Date: Sun, 19 May 2019 13:06:21 +0900
Message-ID: <697c5065-225a-e0e0-fd64-c16a18ae45d6@dream.email.ne.jp> (raw)
In-Reply-To: <fee85324-bbc2-2cf6-2a6d-78f262b09980@dream.email.ne.jp>
References: <CY4PR18MB1079433ABC03436BFE934628CF080@CY4PR18MB1079.namprd18.prod.outlook.com>
	<fee85324-bbc2-2cf6-2a6d-78f262b09980@dream.email.ne.jp>

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

view thread (5+ messages)  latest in thread

Message-ID: <697c5065-225a-e0e0-fd64-c16a18ae45d6@dream.email.ne.jp>
Permalink:  ../697c5065-225a-e0e0-fd64-c16a18ae45d6@dream.email.ne.jp/
Also on:    postgresql.org/message-id/697c5065-225a-e0e0-fd64-c16a18ae45d6@dream.email.ne.jp

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-odbc@postgresql.org
  Cc: h-inoue@dream.email.ne.jp, GShirreffs@stayinfront.com
  Subject: Re: Bound parameters in escaped functions
  In-Reply-To: <697c5065-225a-e0e0-fd64-c16a18ae45d6@dream.email.ne.jp>
  References: <CY4PR18MB1079433ABC03436BFE934628CF080@CY4PR18MB1079.namprd18.prod.outlook.com> <fee85324-bbc2-2cf6-2a6d-78f262b09980@dream.email.ne.jp> <697c5065-225a-e0e0-fd64-c16a18ae45d6@dream.email.ne.jp>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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