Bug and possible fix in odbc driver - Mailing list pgsql-interfaces

From Kari Lempiainen
Subject Bug and possible fix in odbc driver
Date
Msg-id a1kbls4ofl8tibtjeo11f8hnb34r0vv372@4ax.com
Whole thread Raw
List pgsql-interfaces
 I wrote a message to this list yesterday about how to use question
mark in query. Discard that message. I did some hacking and found a
bug in current PostgreSQL odbc driver. The bug shows up when using \'
as an escaped single quote in literals rather than ''.
I noticed the bug when I tried to run the following query:

SELECT performer_id, cd_id, name, tracknumber, sortname, label, year,
bpm, frames from track where name = 'Why don\'t we do it in the road?'
I got the error message "Unterminated quoted string". The current
PostgreSQL driver uncorrectly thinks the quote ends at after the
escaped single quote, and expects to find a parameter marker in the
end. I did a quick fix for this in the function
copy_statement_with_parameters in convert.c. I changed the line:

if (old_statement[opos] == '\'')

to line:

if (old_statement[opos] == '\'' && !(opos > 0 && old_statement[opos-1]
!= '\\'))
Obviously there will trouble with this fix when we have literals like
'A strange \\'' literal?'

K


pgsql-interfaces by date:

Previous
From: Bob Kline
Date:
Subject: Bug in getMoreResults()?
Next
From: "Byron Nikolaidis"
Date:
Subject: Re: How to use question mark in query thru ODBC from Windows