Mercurial > hg > monetdb-perl
annotate DBD/t/12bind.t @ 54:b0ac51c36919
Properly handle bound parameters with question marks in them
author | Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com> |
---|---|
date | Fri, 14 Oct 2022 17:24:58 +0200 (2022-10-14) |
parents | 8c8bd15f7a0b |
children |
rev | line source |
---|---|
0
cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1 #!perl -I./t |
cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2 |
cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
3 # This Source Code Form is subject to the terms of the Mozilla Public |
cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
4 # License, v. 2.0. If a copy of the MPL was not distributed with this |
cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
5 # file, You can obtain one at http://mozilla.org/MPL/2.0/. |
cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
6 # |
12 | 7 # Copyright 1997 - July 2008 CWI, August 2008 - 2019 MonetDB B.V. |
0
cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
8 |
cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
9 $| = 1; |
cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
10 |
cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
11 use strict; |
cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
12 use warnings; |
cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
13 use DBI(); |
cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
14 use DBD_TEST(); |
cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
15 |
cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
16 use Test::More; |
cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
17 |
cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
18 if (defined $ENV{DBI_DSN}) { |
54
b0ac51c36919
Properly handle bound parameters with question marks in them
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
12
diff
changeset
|
19 plan tests => 7; |
0
cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
20 } else { |
cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
21 plan skip_all => 'Cannot test without DB info'; |
cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
22 } |
cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
23 |
cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
24 my $dbh = DBI->connect or die "Connect failed: $DBI::errstr\n"; |
cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
25 ok ( defined $dbh, 'Connection'); |
cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
26 |
cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
27 ok( DBD_TEST::tab_create( $dbh ),"Create the test table $DBD_TEST::table_name"); |
cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
28 |
cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
29 my $data = |
cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
30 [ |
cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
31 [ 1,'foo' ,'me' x 120 ,'1998-05-13','1988-05-13 01:12:33'] |
cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
32 , [ 2,'bar' ,'bar varchar' ,'1998-05-14','1998-05-14 01:25:33'] |
cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
33 , [ 3,'bletch','bletch varchar','1998-05-15','1998-05-15 01:15:33'] |
cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
34 , [ 4,'bletch','me' x 14 ,'1998-05-15','1998-05-15 01:15:33'] |
cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
35 ]; |
cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
36 |
cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
37 ok( tab_insert( $dbh, $data ),'Insert test data'); |
cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
38 |
cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
39 ok( tab_select( $dbh ),'Select test data'); |
cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
40 |
54
b0ac51c36919
Properly handle bound parameters with question marks in them
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
12
diff
changeset
|
41 ok( tab_bind_question_marks( $dbh ), 'Bind data with question marks'); |
b0ac51c36919
Properly handle bound parameters with question marks in them
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
12
diff
changeset
|
42 |
0
cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
43 ok( DBD_TEST::tab_delete( $dbh ),'Drop test table'); |
cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
44 |
cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
45 ok( $dbh->disconnect,'Disconnect'); |
cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
46 |
cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
47 |
cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
48 sub tab_select |
cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
49 { |
cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
50 my $dbh = shift; |
cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
51 |
cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
52 my $sth = $dbh->prepare("SELECT A,B,C,D FROM $DBD_TEST::table_name WHERE a = ?") |
cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
53 or return undef; |
cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
54 my $ti = DBD_TEST::get_type_for_column( $dbh,'A'); |
cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
55 for my $v ( 1, 3, 2, 4, 10 ) { |
cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
56 $sth->bind_param( 1, $v, { TYPE => $ti->{DATA_TYPE} } ); |
cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
57 $sth->execute; |
cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
58 while ( my $row = $sth->fetch ) { |
cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
59 print "# -- $row->[0] length:", length $row->[1]," $row->[1] $row->[2] $row->[3]\n"; |
cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
60 if ( $row->[0] != $v ) { |
cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
61 print "# Bind value failed! bind value = $v, returned value = $row->[0]\n"; |
cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
62 return undef; |
cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
63 } |
cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
64 } |
cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
65 } |
cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
66 return 1; |
cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
67 } |
cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
68 |
54
b0ac51c36919
Properly handle bound parameters with question marks in them
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
12
diff
changeset
|
69 sub tab_bind_question_marks |
b0ac51c36919
Properly handle bound parameters with question marks in them
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
12
diff
changeset
|
70 { |
b0ac51c36919
Properly handle bound parameters with question marks in them
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
12
diff
changeset
|
71 my $dbh = shift; |
b0ac51c36919
Properly handle bound parameters with question marks in them
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
12
diff
changeset
|
72 |
b0ac51c36919
Properly handle bound parameters with question marks in them
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
12
diff
changeset
|
73 my $sth = $dbh->prepare("SELECT ? AS x, ? AS y"); |
b0ac51c36919
Properly handle bound parameters with question marks in them
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
12
diff
changeset
|
74 unless ( $sth ) { |
b0ac51c36919
Properly handle bound parameters with question marks in them
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
12
diff
changeset
|
75 print $DBI::errstr; |
b0ac51c36919
Properly handle bound parameters with question marks in them
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
12
diff
changeset
|
76 return 0; |
b0ac51c36919
Properly handle bound parameters with question marks in them
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
12
diff
changeset
|
77 } |
b0ac51c36919
Properly handle bound parameters with question marks in them
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
12
diff
changeset
|
78 |
b0ac51c36919
Properly handle bound parameters with question marks in them
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
12
diff
changeset
|
79 # without question marks |
b0ac51c36919
Properly handle bound parameters with question marks in them
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
12
diff
changeset
|
80 $sth->execute("foo", "bar"); |
b0ac51c36919
Properly handle bound parameters with question marks in them
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
12
diff
changeset
|
81 my($x, $y) = $sth->fetchrow_array; |
b0ac51c36919
Properly handle bound parameters with question marks in them
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
12
diff
changeset
|
82 if ($x ne "foo") { |
b0ac51c36919
Properly handle bound parameters with question marks in them
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
12
diff
changeset
|
83 print "# when binding foo and bar, expected foo, got '$x'"; |
b0ac51c36919
Properly handle bound parameters with question marks in them
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
12
diff
changeset
|
84 return undef; |
b0ac51c36919
Properly handle bound parameters with question marks in them
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
12
diff
changeset
|
85 } |
b0ac51c36919
Properly handle bound parameters with question marks in them
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
12
diff
changeset
|
86 if ($y ne "bar") { |
b0ac51c36919
Properly handle bound parameters with question marks in them
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
12
diff
changeset
|
87 print "# when binding foo and bar, expected bar, got '$y'"; |
b0ac51c36919
Properly handle bound parameters with question marks in them
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
12
diff
changeset
|
88 return undef; |
b0ac51c36919
Properly handle bound parameters with question marks in them
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
12
diff
changeset
|
89 } |
b0ac51c36919
Properly handle bound parameters with question marks in them
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
12
diff
changeset
|
90 |
b0ac51c36919
Properly handle bound parameters with question marks in them
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
12
diff
changeset
|
91 # with question marks |
b0ac51c36919
Properly handle bound parameters with question marks in them
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
12
diff
changeset
|
92 $sth->execute("foo?", "bar?"); |
b0ac51c36919
Properly handle bound parameters with question marks in them
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
12
diff
changeset
|
93 ($x, $y) = $sth->fetchrow_array; |
b0ac51c36919
Properly handle bound parameters with question marks in them
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
12
diff
changeset
|
94 if ($x ne "foo?") { |
b0ac51c36919
Properly handle bound parameters with question marks in them
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
12
diff
changeset
|
95 print "# when binding foo? and bar?, expected foo?, got '$x'"; |
b0ac51c36919
Properly handle bound parameters with question marks in them
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
12
diff
changeset
|
96 return undef; |
b0ac51c36919
Properly handle bound parameters with question marks in them
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
12
diff
changeset
|
97 } |
b0ac51c36919
Properly handle bound parameters with question marks in them
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
12
diff
changeset
|
98 if ($y ne "bar?") { |
b0ac51c36919
Properly handle bound parameters with question marks in them
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
12
diff
changeset
|
99 print "# when binding foo? and bar?, expected bar?, got '$y'"; |
b0ac51c36919
Properly handle bound parameters with question marks in them
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
12
diff
changeset
|
100 return undef; |
b0ac51c36919
Properly handle bound parameters with question marks in them
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
12
diff
changeset
|
101 } |
b0ac51c36919
Properly handle bound parameters with question marks in them
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
12
diff
changeset
|
102 |
b0ac51c36919
Properly handle bound parameters with question marks in them
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
12
diff
changeset
|
103 return 1; |
b0ac51c36919
Properly handle bound parameters with question marks in them
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
12
diff
changeset
|
104 } |
b0ac51c36919
Properly handle bound parameters with question marks in them
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
12
diff
changeset
|
105 |
0
cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
106 sub tab_insert |
cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
107 { |
cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
108 my $dbh = shift; |
cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
109 my $data = shift; |
cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
110 |
cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
111 my $sth = $dbh->prepare("INSERT INTO $DBD_TEST::table_name (A, B, C, D) VALUES (?, ?, ?, ?)"); |
cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
112 unless ( $sth ) { |
cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
113 print $DBI::errstr; |
cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
114 return 0; |
cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
115 } |
cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
116 $sth->{PrintError} = 1; |
cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
117 for ( @$data ) { |
cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
118 my $ti; |
cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
119 |
cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
120 $ti = DBD_TEST::get_type_for_column( $dbh,'A'); |
cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
121 $sth->bind_param( 1, $_->[ 0], { TYPE => $ti->{DATA_TYPE} } ); |
cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
122 |
cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
123 $ti = DBD_TEST::get_type_for_column( $dbh,'B'); |
cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
124 # $_->[1] = $_->[1] x (int( int( $ti->{COLUMN_SIZE} / 2 ) / length( $_->[1] ) ) ); # XXX |
cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
125 $sth->bind_param( 2, $_->[ 1], { TYPE => $ti->{DATA_TYPE} } ); |
cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
126 |
cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
127 $ti = DBD_TEST::get_type_for_column( $dbh,'C'); |
cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
128 $sth->bind_param( 3, $_->[ 2], { TYPE => $ti->{DATA_TYPE} } ); |
cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
129 |
cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
130 $ti = DBD_TEST::get_type_for_column( $dbh,'D'); |
cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
131 my $i = ( $ti->{DATA_TYPE} == DBI::SQL_TYPE_DATE || $ti->{DATA_TYPE} == DBI::SQL_DATE ) ? 3 : 4; |
cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
132 $sth->bind_param( 4, $_->[$i], { TYPE => $ti->{DATA_TYPE} } ); |
cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
133 |
cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
134 return 0 unless $sth->execute; |
cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
135 } |
cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
136 1; |
cedccb7e0143
Copy of clients/perl directory without Tests from MonetDB changeset 4d2d4532228a.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
137 } |