18 messages in com.mysql.lists.perlRe: placeholder funny w msql-mysql-mo...| From | Sent On | Attachments |
|---|---|---|
| col...@news.sift.co.uk | 06 Oct 1999 09:29 | |
| Yoichi Takayama | 06 Oct 1999 17:01 | |
| col...@news.sift.co.uk | 07 Oct 1999 03:20 | |
| Jochen Wiedmann | 07 Oct 1999 04:59 | |
| Yoichi Takayama | 07 Oct 1999 06:09 | |
| Rob Huffstedtler | 07 Oct 1999 06:23 | |
| col...@news.sift.co.uk | 07 Oct 1999 06:36 | |
| Hugo | 07 Oct 1999 06:42 | |
| Jochen Wiedmann | 07 Oct 1999 07:22 | |
| Jochen Wiedmann | 07 Oct 1999 07:27 | |
| col...@news.sift.co.uk | 07 Oct 1999 07:34 | |
| col...@news.sift.co.uk | 07 Oct 1999 07:47 | |
| Hugo | 07 Oct 1999 08:36 | |
| Yoichi Takayama | 07 Oct 1999 18:35 | |
| Jochen Wiedmann | 08 Oct 1999 02:03 | |
| Jochen Wiedmann | 08 Oct 1999 05:10 | |
| col...@sift.co.uk | 08 Oct 1999 06:36 | |
| Yoichi Takayama | 08 Oct 1999 18:18 |
| Subject: | Re: placeholder funny w msql-mysql-modules-1.2207![]() |
|---|---|
| From: | Yoichi Takayama (yoi...@psych.usyd.edu.au) |
| Date: | 10/06/1999 05:01:32 PM |
| List: | com.mysql.lists.perl |
I thought that we are rather meant to write like:
$myStr = 'Hello World?'; $EscStr = $dbh->quote( $myStr ); $qst = "SELECT name from table WHERE name = $EscStr";
Is Perl really supposed to handle nested quotes?
Yoichi
col...@news.sift.co.uk wrote: I have come across a number of situations using MySQL with the modules release 1.2207 where placeholder characters were being substituted when they occured within quoted strings, specifically where the " character is used to delimit the string. Specifically where the select statement "SELECT name from table WHERE name = "Hello World?" " would be passed to MySQL as "SELECT name from table WHERE name = "Hello WorldNULL" "
Digging further I tracked this down to the function CountParam( *char ) declared in dbd/bindparam.h which would seem to be a little broken with regards to many kinds of nested quotes in combination with ?'s in perfectly valid SQL.
Here is a patch which fixes all the problems I was having. May I take the time out to apologise to sending a few of these to jo...@ispsoft.de ( the email in the .h file ) before I realised of the existence of this list. Just in case he is reading . Sorry for bothering you.
--- ../bindparam.h Wed Oct 6 17:15:42 1999 +++ ./bindparam.h Wed Oct 6 17:15:33 1999 @@ -31,20 +31,21 @@ static int CountParam(char* statement) { char* ptr = statement; int numParam = 0; + char last,token;
+ last = *ptr; while (*ptr) { switch (*ptr++) { + case '"' : + token = '"' ; + /* fall through */ case '\'': /* * Skip string */ - while (*ptr && *ptr != '\'') { - if (*ptr == '\\') { + token = '\'' ; + while (*ptr && *ptr != token && last != '\\' ) { ++ptr; - } - if (*ptr) { - ++ptr; - } } if (*ptr) { ++ptr; @@ -56,6 +57,7 @@ default: break; } + last = *ptr; } return numParam; }
-- Regards, Colin M Strickland
"Tape my beatworm !"
--------------------------------------------------------------------- Please check "http://www.mysql.com/Manual_chapter/manual_toc.html" before posting. To request this thread, e-mail msql...@lists.mysql.com
To unsubscribe, send a message to the address shown in the List-Unsubscribe header of this message. If you cannot see it, e-mail msql...@lists.mysql.com instead.
__________________________________________________________________________ Yoichi Takayama, PhD Ph +61-2-9351-2905 Manager of Computer Services FAX +61-2-9351-2603 Griffith Taylor Bldg (A19) Department of Psychology mailto:yoi...@psych.usyd.edu.au The University of Sydney http://www.psych.usyd.edu.au/staff/yoichi/ NSW 2006, Australia
__________________________________________________________________________ Conflict Resolution: Treat others as how you would like to be treated (this does not apply to S&M persons!).




