Bug and possible fix in odbc driver
Bug and possible fix in odbc driver
От:
Kari Lempiainen <kari@funky.pp.fi>
Дата:
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