5 if (defined $ENV{DBI_DSN}) {
8 plan skip_all => 'cannot test without DB info';
11 my $dbh = DBI->connect($ENV{DBI_DSN}, $ENV{DBI_USER}, $ENV{DBI_PASS},
12 {RaiseError => 1, AutoCommit => 0}
15 'connect with transaction'
19 one=>["'", "'\\" . sprintf("%03o", ord("'")) . "'"],
20 two=>["''", "'" . ("\\" . sprintf("%03o", ord("'")))x2 . "'"],
21 three=>["\\", "'\\" . sprintf("%03o", ord("\\")) . "'"],
22 four=>["\\'", sprintf("'\\%03o\\%03o'", ord("\\"), ord("'"))],
23 five=>["\\'?:", sprintf("'\\%03o\\%03o?:'", ord("\\"), ord("'"))],
26 foreach my $test (keys %tests) {
27 my ($unq, $quo, $ref);
29 $unq = $tests{$test}->[0];
30 $ref = $tests{$test}->[1];
31 $quo = $dbh->quote($unq);
34 "$test: $unq -> expected $quo got $ref"
38 # Make sure that SQL_BINARY doesn't work.
39 # eval { $dbh->quote('foo', { TYPE => DBI::SQL_BINARY })};
41 local $dbh->{PrintError} = 0;
42 $dbh->quote('foo', DBI::SQL_BINARY);
44 ok($@ && $@ =~ /Use of SQL_BINARY invalid in quote/,
48 ok($dbh->disconnect(),