1 message in com.mysql.lists.perlRe: DBI and backreference oddity
FromSent OnAttachments
Hugo07 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.

+ if (SvGMAGICAL(str)) + mg_get(str); if (!SvOK(str)) { result = newSVpv("NULL", 4); } else {