On 6 Mar 2002, Jeffrey W. Baker wrote:

> I don't like this patch.  It looks like it could walk off the beginning
> of a string.  Also I'm not certain if I understand the problem.  I
> assume that you want to do:
> 
> SELECT foo FROM bar WHERE baz = \'?
> 
> Is that correct?  I'm having a hard time imagining a working, valid SQL
> statement that would look like that, but I am wide open to examples.
> 

SELECT foo FROM bar WHERE baz = '\\\\' AND that = '?' AND.......;

There are an even number of '\'s so the last quote should terminate the
literal; however, DBD::Pg was seeing it as an escaped quote so, for
DBD::Pg the literal would run to the next "'" and then it would see the ?
as a place holder (or a :\d+).

And as for it running off of the front of the string it can't happen
becuase you are in_literal which means that there is at least one quote in
the string and the test in the while loop is (*(str-bs)) == '\\' where bs
is just the number of backslashes that have been counted up to that point;
so with a string of '\\\\\\\\\\\\\\\\\\\\\\'   It would hit the last quote
then count back in the string till get gets to a char that is not a
backslash (the fist ') and then drop out. Of course if you want you could 
always put in another sanity check.  If there is something that I missed,
let me know.


Rudy


Reply via email to