1 message in com.mysql.lists.perlRe: DBI and backreference oddity| From | Sent On | Attachments |
|---|---|---|
| Hugo | 07 Jun 2000 05:41 |
| Subject: | Re: DBI and backreference oddity![]() |
|---|---|
| From: | Hugo (hv...@crypt.compulink.co.uk) |
| Date: | 06/07/2000 05:41:32 AM |
| List: | com.mysql.lists.perl |
In <3939...@magicgoeshere.com>, Niall O Broin wrote: :Here's the "self-contained" example (though you need MySQL - please feel :free to try with other DBD modules - if nothing else, it will help :isolate the problem.) : :#!/usr/bin/perl :# :use DBI; :use strict "vars"; :my ($String, $Target, $dbh); :my $database = "DBI:mysql:Photocall"; :my $user = "web"; :my $pass = "web"; :$dbh = DBI->connect($database, $user, $pass); :$String = "Part 1 Part 2 Part 3"; :$String =~ m-(Part 1) (Part 2) (Part 3)-; :print "backreference 2 is $2\n"; # remove this line to see problem :$Target = $dbh->quote($2); :print "Target is $Target\n"; :$dbh->disconnect; :exit(0);
This occurs because the low-level quoting routine checks SvOK() on the argument without first checking whether it is magical. The below patch (over Msql-Mysql-modules-1.2214) fixes it, but I don't know whether it is the best of all possible fixes, and I haven't checked for other similar problems in the rest of the code.
Hugo --- dbd/dbdimp.c.old Wed May 10 22:44:06 2000 +++ dbd/dbdimp.c Wed Jun 7 13:30:34 2000 @@ -2197,6 +2197,8 @@ char* sptr; STRLEN len;
+ if (SvGMAGICAL(str)) + mg_get(str); if (!SvOK(str)) { result = newSVpv("NULL", 4); } else {




