Bug and possible fix in odbc driver

From: Kari Lempiainen <kari(at)funky(dot)pp(dot)fi>
To: pgsql-interfaces(at)postgresql(dot)org
Cc: byron(dot)nikolaidis(at)home(dot)com
Subject: Bug and possible fix in odbc driver
Date: 2000-06-25 09:53:06
Message-ID: a1kbls4ofl8tibtjeo11f8hnb34r0vv372@4ax.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Browse pgsql-interfaces by date

  From Date Subject
Next Message Byron Nikolaidis 2000-06-25 19:46:43 Re: How to use question mark in query thru ODBC from Windows
Previous Message Bob Kline 2000-06-24 19:15:21 Bug in getMoreResults()?