Gentoo Archives: gentoo-dev

From: Anthony Gorecki <agorecki@××××××××××.com>
To: gentoo-dev@l.g.o
Subject: [gentoo-dev] DBD-mysql select failures with MySQL 4.1
Date: Mon, 27 Jun 2005 04:03:26
Message-Id: 200506262055.54827.agorecki@ectrolinux.com
1 Hello,
2
3 I've been encountering an unusual string of errors while attempting to
4 retrieve information from a database using DBD-mysql-2.9007 and mysql-4.1.12.
5 The database in question is of type InnoDB. Below is an example:
6
7 #!/usr/bin/perl -w
8
9 use strict;
10 use DBI;
11
12 my $db_conn = DBI->connect('DBI:mysql:infrastructure', 'system', 'readonly');
13 if (!$db_conn) {
14 error('The program was unable to connect to the database.');
15 }
16
17 $_ = $db_conn->selectrow_array("
18 SELECT \@user_id := (
19 SELECT user_id FROM users WHERE username = 'agorecki' LIMIT 1)
20 );
21 ");
22
23 if (!defined($_)) {
24 $db_conn->disconnect();
25 error('It appears that the user account has disappeared since login '.
26 'time...'
27 );
28 }
29
30
31 The same query in MySQL will return the session variable, however DBD-mysql
32 returns undefined. Similarly, when I run:
33
34 SELECT type
35 FROM svn_access
36 WHERE 'test' REGEXP REPLACE(path_regex, '\$USERNAME\$', 'agorecki') = 1
37 AND (user_id = @user_id
38 OR group_id = ANY (SELECT group_id FROM group_memberships WHERE
39 user_id = @user_id)
40 OR (user_id IS NULL AND group_id IS NULL)
41 )
42 ORDER BY type DESC LIMIT 1;
43
44
45 through selectrow_array (properly encoded for use in a PERL script), I also
46 receive an undefined result. The above query correctly returns one row when
47 input into a MySQL console and executed.
48
49 The only thing that actually managed to execute and return a value
50 successfully was:
51 $_ = $db_conn->selectrow_array("SELECT 'hello';");
52
53 Any thoughts?
54
55
56 --
57 Anthony Gorecki
58 Ectro-Linux Foundation

Replies

Subject Author
Re: [gentoo-dev] DBD-mysql select failures with MySQL 4.1 Zac Medico <zmedico@×××××.com>
Re: [gentoo-dev] DBD-mysql select failures with MySQL 4.1 Michael Cummings <mcummings@g.o>