1 |
Anthony Gorecki wrote: |
2 |
> Hello, |
3 |
> |
4 |
> I've been encountering an unusual string of errors while attempting to |
5 |
> retrieve information from a database using DBD-mysql-2.9007 and mysql-4.1.12. |
6 |
> The database in question is of type InnoDB. Below is an example: |
7 |
> |
8 |
> #!/usr/bin/perl -w |
9 |
> |
10 |
> use strict; |
11 |
> use DBI; |
12 |
> |
13 |
> my $db_conn = DBI->connect('DBI:mysql:infrastructure', 'system', 'readonly'); |
14 |
> if (!$db_conn) { |
15 |
> error('The program was unable to connect to the database.'); |
16 |
> } |
17 |
> |
18 |
> $_ = $db_conn->selectrow_array(" |
19 |
> SELECT \@user_id := ( |
20 |
> SELECT user_id FROM users WHERE username = 'agorecki' LIMIT 1) |
21 |
> ); |
22 |
> "); |
23 |
> |
24 |
> if (!defined($_)) { |
25 |
> $db_conn->disconnect(); |
26 |
> error('It appears that the user account has disappeared since login '. |
27 |
> 'time...' |
28 |
> ); |
29 |
> } |
30 |
> |
31 |
> |
32 |
> The same query in MySQL will return the session variable, however DBD-mysql |
33 |
> returns undefined. Similarly, when I run: |
34 |
> |
35 |
> SELECT type |
36 |
> FROM svn_access |
37 |
> WHERE 'test' REGEXP REPLACE(path_regex, '\$USERNAME\$', 'agorecki') = 1 |
38 |
> AND (user_id = @user_id |
39 |
> OR group_id = ANY (SELECT group_id FROM group_memberships WHERE |
40 |
> user_id = @user_id) |
41 |
> OR (user_id IS NULL AND group_id IS NULL) |
42 |
> ) |
43 |
> ORDER BY type DESC LIMIT 1; |
44 |
> |
45 |
> |
46 |
> through selectrow_array (properly encoded for use in a PERL script), I also |
47 |
> receive an undefined result. The above query correctly returns one row when |
48 |
> input into a MySQL console and executed. |
49 |
> |
50 |
> The only thing that actually managed to execute and return a value |
51 |
> successfully was: |
52 |
> $_ = $db_conn->selectrow_array("SELECT 'hello';"); |
53 |
> |
54 |
> Any thoughts? |
55 |
> |
56 |
> |
57 |
|
58 |
Have you checked the DBI error status? See the parts about $DBI::err, $DBI::errstr, and RaiseError here: |
59 |
|
60 |
http://search.cpan.org/~timb/DBI-1.48/DBI.pm |
61 |
|
62 |
Zac |
63 |
-- |
64 |
gentoo-dev@g.o mailing list |