public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
From: Zac Medico <zmedico@gmail.com>
To: gentoo-dev@lists.gentoo.org
Subject: Re: [gentoo-dev] DBD-mysql select failures with MySQL 4.1
Date: Sun, 26 Jun 2005 21:28:53 -0700	[thread overview]
Message-ID: <42BF8085.1010206@gmail.com> (raw)
In-Reply-To: <200506262055.54827.agorecki@ectrolinux.com>

Anthony Gorecki wrote:
> 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?
> 
> 

Have you checked the DBI error status?  See the parts about $DBI::err, $DBI::errstr, and RaiseError here:

http://search.cpan.org/~timb/DBI-1.48/DBI.pm

Zac
-- 
gentoo-dev@gentoo.org mailing list



  reply	other threads:[~2005-06-27  4:32 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-06-27  3:55 [gentoo-dev] DBD-mysql select failures with MySQL 4.1 Anthony Gorecki
2005-06-27  4:28 ` Zac Medico [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=42BF8085.1010206@gmail.com \
    --to=zmedico@gmail.com \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox