diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-13 12:24:36 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-13 12:24:36 +0000 |
commit | 06eaf7232e9a920468c0f8d74dcf2fe8b555501c (patch) | |
tree | e2c7b5777f728320e5b5542b6213fd3591ba51e2 /plugin/handler_socket/regtest/test_01_lib/test10.pl | |
parent | Initial commit. (diff) | |
download | mariadb-06eaf7232e9a920468c0f8d74dcf2fe8b555501c.tar.xz mariadb-06eaf7232e9a920468c0f8d74dcf2fe8b555501c.zip |
Adding upstream version 1:10.11.6.upstream/1%10.11.6
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | plugin/handler_socket/regtest/test_01_lib/test10.pl | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/plugin/handler_socket/regtest/test_01_lib/test10.pl b/plugin/handler_socket/regtest/test_01_lib/test10.pl new file mode 100644 index 00000000..560976ba --- /dev/null +++ b/plugin/handler_socket/regtest/test_01_lib/test10.pl @@ -0,0 +1,93 @@ +#!/usr/bin/env perl + +# vim:sw=2:ai + +# test for nulls + +BEGIN { + push @INC, "../common/"; +}; + +use strict; +use warnings; +use hstest; + +my $dbh = hstest::init_testdb(); +my $table = 'hstesttbl'; +my $tablesize = 256; +$dbh->do( + "create table $table (" . + "k varchar(30) primary key, " . + "v1 varchar(30), " . + "v2 varchar(30)) " . + "engine = innodb default charset = binary"); +srand(999); + +my %valmap = (); + +# setting null +print "HSINSERT"; +my $hs = hstest::get_hs_connection(undef, 9999); +my $dbname = $hstest::conf{dbname}; +$hs->open_index(1, $dbname, $table, '', 'k,v1,v2'); +for (my $i = 0; $i < $tablesize; ++$i) { + my $k = "" . $i; + my $v1 = "v1_" . $i; + my $v2 = undef; # null value + my $r = $hs->execute_insert(1, [ $k, $v1, $v2 ]); + my $err = $r->[0]; + if ($err != 0) { + my $err_str = $r->[1]; + print "$err $err_str\n"; + } +} +undef $hs; + +dump_table(); + +# setting null +print "HSUPDATE"; +$hs = hstest::get_hs_connection(undef, 9999); +$dbname = $hstest::conf{dbname}; +$hs->open_index(2, $dbname, $table, '', 'v1'); +for (my $i = 0; $i < $tablesize; ++$i) { + my $r = $hs->execute_single(2, '=', [ $i ], 1000, 0, 'U', [ undef ]); + my $err = $r->[0]; + if ($err != 0) { + my $err_str = $r->[1]; + print "$err $err_str\n"; + } +} +undef $hs; + +dump_table(); + +# setting non-null +print "HSUPDATE"; +$hs = hstest::get_hs_connection(undef, 9999); +$dbname = $hstest::conf{dbname}; +$hs->open_index(2, $dbname, $table, '', 'v1'); +for (my $i = 0; $i < $tablesize; ++$i) { + my $r = $hs->execute_single(2, '=', [ $i ], 1000, 0, 'U', [ "hoge" ]); + my $err = $r->[0]; + if ($err != 0) { + my $err_str = $r->[1]; + print "$err $err_str\n"; + } +} +undef $hs; + +dump_table(); + +sub dump_table { + print "DUMP_TABLE\n"; + my $aref = $dbh->selectall_arrayref("select k,v1,v2 from $table order by k"); + for my $row (@$aref) { + my ($k, $v1, $v2) = @$row; + $v1 = "[null]" if !defined($v1); + $v2 = "[null]" if !defined($v2); + print "$k $v1 $v2\n"; + # print "MISMATCH\n" if ($valmap{$k} ne $v); + } +} + |