public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] DBD-mysql select failures with MySQL 4.1
@ 2005-06-27  3:55 Anthony Gorecki
  2005-06-27  4:28 ` Zac Medico
  2005-06-27 11:40 ` Michael Cummings
  0 siblings, 2 replies; 6+ messages in thread
From: Anthony Gorecki @ 2005-06-27  3:55 UTC (permalink / raw
  To: gentoo-dev

[-- Attachment #1: Type: text/plain, Size: 1613 bytes --]

Hello,

I've been encountering an unusual string of errors while attempting to 
retrieve information from a database using DBD-mysql-2.9007 and mysql-4.1.12. 
The database in question is of type InnoDB. Below is an example:

#!/usr/bin/perl -w

use strict;
use DBI;

my $db_conn = DBI->connect('DBI:mysql:infrastructure', 'system', 'readonly');
if (!$db_conn) {
    error('The program was unable to connect to the database.');
}

$_ = $db_conn->selectrow_array("
    SELECT \@user_id := (
        SELECT user_id FROM users WHERE username = 'agorecki' LIMIT 1)
    );
");

if (!defined($_)) {
    $db_conn->disconnect();
    error('It appears that the user account has disappeared since login '.
        'time...'
    );
}


The same query in MySQL will return the session variable, however DBD-mysql 
returns undefined. Similarly, when I run:

SELECT type
FROM svn_access
WHERE 'test' REGEXP REPLACE(path_regex, '\$USERNAME\$', 'agorecki') = 1
    AND (user_id = @user_id
        OR group_id = ANY (SELECT group_id FROM group_memberships WHERE
            user_id = @user_id)
        OR (user_id IS NULL AND group_id IS NULL)
    )
ORDER BY type DESC LIMIT 1;


through selectrow_array (properly encoded for use in a PERL script), I also 
receive an undefined result. The above query correctly returns one row when 
input into a MySQL console and executed.

The only thing that actually managed to execute and return a value 
successfully was:
$_ = $db_conn->selectrow_array("SELECT 'hello';");

Any thoughts?


-- 
Anthony Gorecki
Ectro-Linux Foundation

[-- Attachment #2: Type: application/pgp-signature, Size: 828 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2005-06-27 11:45 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-06-27  3:55 [gentoo-dev] DBD-mysql select failures with MySQL 4.1 Anthony Gorecki
2005-06-27  4:28 ` Zac Medico
2005-06-27  4:34   ` Anthony Gorecki
2005-06-27  6:24     ` Francesco R
2005-06-27  6:35       ` Anthony Gorecki
2005-06-27 11:40 ` Michael Cummings

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox