Changeset: 93a170450fe1 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=93a170450fe1
Added Files:
        sql/test/mapi/Tests/perl_dec38.SQL.bat
        sql/test/mapi/Tests/perl_dec38.SQL.sh
        sql/test/mapi/Tests/perl_dec38.pl
        sql/test/mapi/Tests/perl_dec38.stable.err
        sql/test/mapi/Tests/perl_dec38.stable.out
        sql/test/mapi/Tests/perl_int128.SQL.bat
        sql/test/mapi/Tests/perl_int128.SQL.sh
        sql/test/mapi/Tests/perl_int128.pl
        sql/test/mapi/Tests/perl_int128.stable.err
        sql/test/mapi/Tests/perl_int128.stable.out
Modified Files:
        sql/test/mapi/Tests/All
Branch: int128
Log Message:

added simplistic perl::dbi test for 128-bit integers and 38-digit decimals


diffs (truncated from 451 to 300 lines):

diff --git a/sql/test/mapi/Tests/All b/sql/test/mapi/Tests/All
--- a/sql/test/mapi/Tests/All
+++ b/sql/test/mapi/Tests/All
@@ -16,5 +16,7 @@ HAVE_PHP?php_int64_dec18
 HAVE_HGE?mal_int128
 HAVE_HGE?sql_int128
 HAVE_PHP&HAVE_HGE?php_int128
+HAVE_PERL&HAVE_HGE?perl_int128
 HAVE_HGE?sql_dec38
 HAVE_PHP&HAVE_HGE?php_dec38
+HAVE_PERL&HAVE_HGE?perl_dec38
diff --git a/sql/test/mapi/Tests/perl_dec38.SQL.bat 
b/sql/test/mapi/Tests/perl_dec38.SQL.bat
new file mode 100755
--- /dev/null
+++ b/sql/test/mapi/Tests/perl_dec38.SQL.bat
@@ -0,0 +1,6 @@
+@echo off
+
+prompt # $t $g  
+echo on
+
+perl %TSTSRCDIR\perl_dec38.pl %MAPIPORT% %TSTDB%
diff --git a/sql/test/mapi/Tests/perl_dec38.SQL.sh 
b/sql/test/mapi/Tests/perl_dec38.SQL.sh
new file mode 100755
--- /dev/null
+++ b/sql/test/mapi/Tests/perl_dec38.SQL.sh
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+Mlog -x "perl $TSTSRCDIR/perl_dec38.pl $MAPIPORT $TSTDB"
diff --git a/sql/test/mapi/Tests/perl_dec38.pl 
b/sql/test/mapi/Tests/perl_dec38.pl
new file mode 100755
--- /dev/null
+++ b/sql/test/mapi/Tests/perl_dec38.pl
@@ -0,0 +1,85 @@
+#!/usr/bin/env perl
+
+# The contents of this file are subject to the MonetDB Public License
+# Version 1.1 (the "License"); you may not use this file except in
+# compliance with the License. You may obtain a copy of the License at
+# http://www.monetdb.org/Legal/MonetDBLicense
+#
+# Software distributed under the License is distributed on an "AS IS"
+# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+# License for the specific language governing rights and limitations
+# under the License.
+#
+# The Original Code is the MonetDB Database System.
+#
+# The Initial Developer of the Original Code is CWI.
+# Portions created by CWI are Copyright (C) 1997-July 2008 CWI.
+# Copyright August 2008-2014 MonetDB B.V.
+# All Rights Reserved.
+
+use strict;
+use warnings;
+use DBI();
+
+# determine the data sources:
+my @ds = DBI->data_sources('monetdb');
+print "data sources: @ds\n";
+
+# connect to the database:
+my $dsn = 
"dbi:monetdb:database=$ARGV[1];host=localhost;port=$ARGV[0];language=sql";
+my $dbh = DBI->connect( $dsn,
+  "monetdb", "monetdb",
+  { PrintError => 0, RaiseError => 1 }  # turn on exception handling
+);
+
+$dbh->do('CREATE TABLE perl_dec38 (d38_0 DECIMAL(38,0), d38_19 DECIMAL(38,19), 
d38_38 DECIMAL(38,38));');
+$dbh->do('INSERT INTO perl_dec38 VALUES 
(12345678901234567899876543210987654321, 
1234567890123456789.9876543210987654321, 
.12345678901234567899876543210987654321);');
+# "variable binding stuff" does not work, yet(?), due to missing type 
DBI::SQL_HUGEINT
+#{
+#  # variable binding stuff:
+#  my $sth = $dbh->prepare('INSERT INTO perl_dec38 VALUES (?,?,?);');
+#  $sth->bind_param( 1, 12345678909876543211234567890987654321 );
+#  $sth->bind_param( 2, 1234567890987654321.1234567890987654321 );
+#  $sth->bind_param( 3, .12345678909876543211234567890987654321 );
+#  $sth->execute;
+#}
+{
+  my $sth = $dbh->prepare('SELECT * FROM perl_dec38;');
+  # get all rows one at a time:
+  $sth->execute;
+  while ( my $row = $sth->fetch ) {
+    print "row: $row->[0], $row->[1], $row->[2]\n";
+  }
+  # get all rows at once:
+  $sth->execute;
+  my $t = $sth->fetchall_arrayref;
+  my $r = @$t;         # row count
+  my $f = @{$t->[0]};  # field count
+  print "rows: $r, fields: $f\n";
+  for my $i ( 0 .. $r-1 ) {
+    for my $j ( 0 .. $f-1 ) {
+      print "field[$i,$j]: $t->[$i][$j]\n";
+    }
+  }
+}
+{
+  # get values of the first column from each row:
+  my $row = $dbh->selectcol_arrayref('SELECT * FROM perl_dec38;');
+  print "head[$_]: $row->[$_]\n" for 0 .. 0;
+}
+{
+  my @row = $dbh->selectrow_array('SELECT * FROM perl_dec38;');
+  print "field[0]: $row[0]\n";
+  print "field[1]: $row[1]\n";
+  print "field[2]: $row[2]\n";
+}
+{
+  my $row = $dbh->selectrow_arrayref('SELECT * FROM perl_dec38;');
+  print "field[0]: $row->[0]\n";
+  print "field[1]: $row->[1]\n";
+  print "field[2]: $row->[2]\n";
+}
+my $sth = $dbh->prepare('DROP TABLE perl_dec38;');
+$sth->execute;
+$dbh->disconnect;
+print "\nFinished\n";
diff --git a/sql/test/mapi/Tests/perl_dec38.stable.err 
b/sql/test/mapi/Tests/perl_dec38.stable.err
new file mode 100644
--- /dev/null
+++ b/sql/test/mapi/Tests/perl_dec38.stable.err
@@ -0,0 +1,41 @@
+stderr of test 'perl_dec38` in directory 'sql/test/mapi` itself:
+
+
+# 16:02:16 >  
+# 16:02:16 >  "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set" 
"mapi_open=true" "--set" "mapi_port=34799" "--set" 
"mapi_usock=/var/tmp/mtest-18973/.s.monetdb.34799" "--set" "monet_prompt=" 
"--forcemito" "--set" "mal_listing=2" 
"--dbpath=/ufs/manegold/_/Monet/HG/int128/prefix/--disable-debug_--enable-assert_--enable-optimize/var/MonetDB/mTests_sql_test_mapi"
 "--set" "mal_listing=0"
+# 16:02:16 >  
+
+# builtin opt  gdk_dbpath = 
/ufs/manegold/_/Monet/HG/int128/prefix/--disable-debug_--enable-assert_--enable-optimize/var/monetdb5/dbfarm/demo
+# builtin opt  gdk_debug = 0
+# builtin opt  gdk_vmtrim = no
+# builtin opt  monet_prompt = >
+# builtin opt  monet_daemon = no
+# builtin opt  mapi_port = 50000
+# builtin opt  mapi_open = false
+# builtin opt  mapi_autosense = false
+# builtin opt  sql_optimizer = default_pipe
+# builtin opt  sql_debug = 0
+# cmdline opt  gdk_nr_threads = 0
+# cmdline opt  mapi_open = true
+# cmdline opt  mapi_port = 34799
+# cmdline opt  mapi_usock = /var/tmp/mtest-18973/.s.monetdb.34799
+# cmdline opt  monet_prompt = 
+# cmdline opt  mal_listing = 2
+# cmdline opt  gdk_dbpath = 
/ufs/manegold/_/Monet/HG/int128/prefix/--disable-debug_--enable-assert_--enable-optimize/var/MonetDB/mTests_sql_test_mapi
+# cmdline opt  mal_listing = 0
+# cmdline opt  gdk_debug = 536870922
+
+# 16:02:16 >  
+# 16:02:16 >  "./perl_dec38.SQL.sh" "perl_dec38"
+# 16:02:16 >  
+
+
+# 16:02:16 >  
+# 16:02:16 >  perl 
/net/rome.ins.cwi.nl/export/scratch2/manegold/.rig./scratch0/Monet/HG/int128/source/MonetDB/sql/test/mapi/Tests/perl_dec38.pl
 34799 mTests_sql_test_mapi
+# 16:02:16 >  
+
+
+# 16:02:16 >  
+# 16:02:16 >  "Done."
+# 16:02:16 >  
+
diff --git a/sql/test/mapi/Tests/perl_dec38.stable.out 
b/sql/test/mapi/Tests/perl_dec38.stable.out
new file mode 100644
--- /dev/null
+++ b/sql/test/mapi/Tests/perl_dec38.stable.out
@@ -0,0 +1,51 @@
+stdout of test 'perl_dec38` in directory 'sql/test/mapi` itself:
+
+
+# 16:02:16 >  
+# 16:02:16 >  "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set" 
"mapi_open=true" "--set" "mapi_port=34799" "--set" 
"mapi_usock=/var/tmp/mtest-18973/.s.monetdb.34799" "--set" "monet_prompt=" 
"--forcemito" "--set" "mal_listing=2" 
"--dbpath=/ufs/manegold/_/Monet/HG/int128/prefix/--disable-debug_--enable-assert_--enable-optimize/var/MonetDB/mTests_sql_test_mapi"
 "--set" "mal_listing=0"
+# 16:02:16 >  
+
+# MonetDB 5 server v11.18.0
+# This is an unreleased version
+# Serving database 'mTests_sql_test_mapi', using 8 threads
+# Compiled for x86_64-unknown-linux-gnu/64bit with 64bit OIDs and 128bit 
integers dynamically linked
+# Found 15.591 GiB available main-memory.
+# Copyright (c) 1993-July 2008 CWI.
+# Copyright (c) August 2008-2014 MonetDB B.V., all rights reserved
+# Visit http://www.monetdb.org/ for further information
+# Listening for connection requests on mapi:monetdb://rome.ins.cwi.nl:34799/
+# Listening for UNIX domain connection requests on 
mapi:monetdb:///var/tmp/mtest-18973/.s.monetdb.34799
+# MonetDB/GIS module loaded
+# MonetDB/SQL module loaded
+
+Ready.
+
+# 16:02:16 >  
+# 16:02:16 >  "./perl_dec38.SQL.sh" "perl_dec38"
+# 16:02:16 >  
+
+
+# 16:02:16 >  
+# 16:02:16 >  perl 
/net/rome.ins.cwi.nl/export/scratch2/manegold/.rig./scratch0/Monet/HG/int128/source/MonetDB/sql/test/mapi/Tests/perl_dec38.pl
 34799 mTests_sql_test_mapi
+# 16:02:16 >  
+
+data sources: dbi:monetdb:
+row: 12345678901234567899876543210987654321, 
1234567890123456789.9876543210987654321, 
0.12345678901234567899876543210987654321
+rows: 1, fields: 3
+field[0,0]: 12345678901234567899876543210987654321
+field[0,1]: 1234567890123456789.9876543210987654321
+field[0,2]: 0.12345678901234567899876543210987654321
+head[0]: 12345678901234567899876543210987654321
+field[0]: 12345678901234567899876543210987654321
+field[1]: 1234567890123456789.9876543210987654321
+field[2]: 0.12345678901234567899876543210987654321
+field[0]: 12345678901234567899876543210987654321
+field[1]: 1234567890123456789.9876543210987654321
+field[2]: 0.12345678901234567899876543210987654321
+
+Finished
+
+# 16:02:16 >  
+# 16:02:16 >  "Done."
+# 16:02:16 >  
+
diff --git a/sql/test/mapi/Tests/perl_int128.SQL.bat 
b/sql/test/mapi/Tests/perl_int128.SQL.bat
new file mode 100755
--- /dev/null
+++ b/sql/test/mapi/Tests/perl_int128.SQL.bat
@@ -0,0 +1,6 @@
+@echo off
+
+prompt # $t $g  
+echo on
+
+perl %TSTSRCDIR\perl_int128.pl %MAPIPORT% %TSTDB%
diff --git a/sql/test/mapi/Tests/perl_int128.SQL.sh 
b/sql/test/mapi/Tests/perl_int128.SQL.sh
new file mode 100755
--- /dev/null
+++ b/sql/test/mapi/Tests/perl_int128.SQL.sh
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+Mlog -x "perl $TSTSRCDIR/perl_int128.pl $MAPIPORT $TSTDB"
diff --git a/sql/test/mapi/Tests/perl_int128.pl 
b/sql/test/mapi/Tests/perl_int128.pl
new file mode 100755
--- /dev/null
+++ b/sql/test/mapi/Tests/perl_int128.pl
@@ -0,0 +1,79 @@
+#!/usr/bin/env perl
+
+# The contents of this file are subject to the MonetDB Public License
+# Version 1.1 (the "License"); you may not use this file except in
+# compliance with the License. You may obtain a copy of the License at
+# http://www.monetdb.org/Legal/MonetDBLicense
+#
+# Software distributed under the License is distributed on an "AS IS"
+# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+# License for the specific language governing rights and limitations
+# under the License.
+#
+# The Original Code is the MonetDB Database System.
+#
+# The Initial Developer of the Original Code is CWI.
+# Portions created by CWI are Copyright (C) 1997-July 2008 CWI.
+# Copyright August 2008-2014 MonetDB B.V.
+# All Rights Reserved.
+
+use strict;
+use warnings;
+use DBI();
+
+# determine the data sources:
+my @ds = DBI->data_sources('monetdb');
+print "data sources: @ds\n";
+
+# connect to the database:
+my $dsn = 
"dbi:monetdb:database=$ARGV[1];host=localhost;port=$ARGV[0];language=sql";
+my $dbh = DBI->connect( $dsn,
+  "monetdb", "monetdb",
+  { PrintError => 0, RaiseError => 1 }  # turn on exception handling
+);
+
+$dbh->do('CREATE TABLE perl_int128 (i HUGEINT);');
+$dbh->do('INSERT INTO perl_int128 VALUES 
(123456789098765432101234567890987654321);');
+# "variable binding stuff" does not work, yet(?), due to missing type 
DBI::SQL_HUGEINT
+#{
+#  # variable binding stuff:
+#  my $sth = $dbh->prepare('INSERT INTO perl_int128 VALUES (?);');
+#  $sth->bind_param( 1, 123456789012345678909876543210987654321, 
DBI::SQL_HUGEINT() );
+#  $sth->execute;
+#}
+{
+  my $sth = $dbh->prepare('SELECT * FROM perl_int128;');
+  # get all rows one at a time:
+  $sth->execute;
+  while ( my $row = $sth->fetch ) {
+    print "row: $row->[0]\n";
+  }
+  # get all rows at once:
+  $sth->execute;
+  my $t = $sth->fetchall_arrayref;
+  my $r = @$t;         # row count
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to