-
Notifications
You must be signed in to change notification settings - Fork 77
#475: Improve error message for unsupported named parameters #476
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -1725,6 +1725,10 @@ parameter value and C<execute> the statement again, with other values | |||||
unchanged. The attribute remains properly populated after the C<finish> | ||||||
method is called, with the values from the last execution. | ||||||
MySQL does not support named place holders in C<bind_param>. If a | ||||||
string is passed to C<bind_param> as the parameter index then a | ||||||
"named parameters are unsupported" error is reported. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
btw. I think |
||||||
=item mysql_gtids | ||||||
Returns GTID(s) if GTID session tracking is ensabled in the server via | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
use strict; | ||
use warnings; | ||
|
||
use Test::More; | ||
use DBI; | ||
use vars qw($test_dsn $test_user $test_password); | ||
use lib 't', '.'; | ||
require 'lib.pl'; | ||
|
||
my $dbh; | ||
eval {$dbh = DBI->connect($test_dsn, $test_user, $test_password, | ||
{ RaiseError => 1, AutoCommit => 1}) or ServerError();}; | ||
|
||
if ($@) { | ||
plan skip_all => "no database connection"; | ||
} | ||
plan tests => 11; | ||
|
||
SKIP: { | ||
skip 'SET @@auto_increment_offset needs MySQL >= 5.0.2', 2 unless $dbh->{mysql_serverversion} >= 50002; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. DBD::mysql needs MySQL 8.0 or newer, so this shouldn't be needed. But on the other hand... it doesn't hurt either. |
||
ok $dbh->do('SET @@auto_increment_offset = 1'); | ||
ok $dbh->do('SET @@auto_increment_increment = 1'); | ||
} | ||
|
||
my $create= <<EOT; | ||
CREATE TEMPORARY TABLE dbd_mysql_t45bindnamedparam ( | ||
id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, | ||
num INT(3)) | ||
EOT | ||
|
||
ok $dbh->do($create), "create table dbd_mysql_t45bindnamedparam"; | ||
|
||
ok $dbh->do("INSERT INTO dbd_mysql_t45bindnamedparam VALUES(NULL, 1)"), "insert into dbd_mysql_t45bindnamedparam (null, 1)"; | ||
|
||
my $rows; | ||
ok ($rows= $dbh->selectall_arrayref("SELECT * FROM dbd_mysql_t45bindnamedparam")); | ||
|
||
is $rows->[0][1], 1, "\$rows->[0][1] == 1"; | ||
|
||
ok (my $sth = $dbh->prepare("SELECT * FROM dbd_mysql_t45bindnamedparam WHERE num = :num")); | ||
|
||
$dbh->{PrintError} = 0; | ||
$dbh->{PrintWarn} = 0; | ||
eval {($sth->bind_param(":num", 1, SQL_INTEGER()));}; | ||
$dbh->{PrintError} = 1; | ||
$dbh->{PrintWarn} = 1; | ||
ok defined($DBI::errstr); | ||
|
||
like($DBI::errstr, qr/named parameters are unsupported/, 'bind_param reports exepcted error with named parameter'); | ||
|
||
ok ($sth->finish()); | ||
|
||
ok ($dbh->disconnect()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a test for this error?
What if there are multiple params. Does it indicate which one is the issue? Could/should it?