summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ext/sybase_ct/tests/bug29064.phpt143
-rw-r--r--ext/sybase_ct/tests/test_query_nostore.phpt98
2 files changed, 241 insertions, 0 deletions
diff --git a/ext/sybase_ct/tests/bug29064.phpt b/ext/sybase_ct/tests/bug29064.phpt
new file mode 100644
index 0000000000..902fe43358
--- /dev/null
+++ b/ext/sybase_ct/tests/bug29064.phpt
@@ -0,0 +1,143 @@
+--TEST--
+Sybase-CT bug #29064 (Exact numeric/decimal/money datatypes lose precision)
+--SKIPIF--
+<?php require('skipif.inc'); ?>
+--FILE--
+<?php
+/* This file is part of PHP test framework for ext/sybase_ct
+ *
+ * $Id$
+ */
+
+ require('test.inc');
+
+ $db= sybase_connect_ex();
+
+ // Create a temporary table and fill it with test values
+ var_dump(sybase_query('
+ create table #test (
+ test_decimal decimal(38, 6) null,
+ test_numeric numeric(38, 12) null,
+ test_money money null,
+ test_bigint decimal(38, 0) null,
+ test_int int null,
+ test_smallmoney smallmoney null,
+ test_smallint smallint null,
+ test_tinyint tinyint null,
+ test_real float null,
+ test_double float null
+ )
+ ', $db));
+ var_dump(sybase_query('
+ insert into #test (
+ test_decimal,
+ test_numeric,
+ test_money,
+ test_bigint,
+ test_int,
+ test_smallmoney,
+ test_smallint,
+ test_tinyint,
+ test_real,
+ test_double
+ ) values (
+ 12345678901234567890123456789012.123456,
+ 12345678901234567890123456.123456789012,
+ 123456789012345.1234,
+ 12345678901234567890123456789012345678,
+ 1234567890,
+ 123456.1234,
+ 12345,
+ 123,
+ 123456789.12345679,
+ 123456789.12345679
+ )
+ ', $db));
+ var_dump(sybase_query('
+ insert into #test (
+ test_decimal,
+ test_numeric,
+ test_money,
+ test_bigint,
+ test_int,
+ test_smallmoney,
+ test_smallint,
+ test_tinyint,
+ test_real,
+ test_double
+ ) values (
+ -12345678901234567890123456789012.123456,
+ -12345678901234567890123456.123456789012,
+ -123456789012345.1234,
+ -12345678901234567890123456789012345678,
+ -1234567890,
+ -123456.1234,
+ -12345,
+ 255,
+ -123456789.12345679,
+ -123456789.12345679
+ )
+ ', $db));
+
+ // Select the data
+ var_dump(sybase_select_ex($db, 'select * from #test'));
+
+ // Clean up and close connection
+ var_dump(sybase_query('drop table #test', $db));
+ sybase_close($db);
+?>
+--EXPECTF--
+bool(true)
+bool(true)
+bool(true)
+>>> Query: select * from #test
+<<< Return: resource
+array(2) {
+ [0]=>
+ array(10) {
+ ["test_decimal"]=>
+ string(39) "12345678901234567890123456789012.123456"
+ ["test_numeric"]=>
+ string(39) "12345678901234567890123456.123456789012"
+ ["test_money"]=>
+ string(18) "123456789012345.12"
+ ["test_bigint"]=>
+ string(38) "12345678901234567890123456789012345678"
+ ["test_int"]=>
+ int(1234567890)
+ ["test_smallmoney"]=>
+ float(123456.12)
+ ["test_smallint"]=>
+ int(12345)
+ ["test_tinyint"]=>
+ int(123)
+ ["test_real"]=>
+ string(16) "123456789.123457"
+ ["test_double"]=>
+ string(16) "123456789.123457"
+ }
+ [1]=>
+ array(10) {
+ ["test_decimal"]=>
+ string(40) "-12345678901234567890123456789012.123456"
+ ["test_numeric"]=>
+ string(40) "-12345678901234567890123456.123456789012"
+ ["test_money"]=>
+ string(19) "-123456789012345.12"
+ ["test_bigint"]=>
+ string(39) "-12345678901234567890123456789012345678"
+ ["test_int"]=>
+ int(-1234567890)
+ ["test_smallmoney"]=>
+ float(-123456.12)
+ ["test_smallint"]=>
+ int(-12345)
+ ["test_tinyint"]=>
+ int(255)
+ ["test_real"]=>
+ string(17) "-123456789.123457"
+ ["test_double"]=>
+ string(17) "-123456789.123457"
+ }
+}
+bool(true)
diff --git a/ext/sybase_ct/tests/test_query_nostore.phpt b/ext/sybase_ct/tests/test_query_nostore.phpt
new file mode 100644
index 0000000000..9d717ec2fd
--- /dev/null
+++ b/ext/sybase_ct/tests/test_query_nostore.phpt
@@ -0,0 +1,98 @@
+--TEST--
+Sybase-CT query without storing
+--SKIPIF--
+<?php require('skipif.inc'); ?>
+--FILE--
+<?php
+/* This file is part of PHP test framework for ext/sybase_ct
+ *
+ * $Id$
+ */
+
+ require('test.inc');
+
+ $db= sybase_connect_ex();
+
+ // Create test table and insert some data
+ var_dump(sybase_query('
+ create table #test (
+ id numeric(10, 0) primary key not null,
+ caption varchar(255) not null,
+ author varchar(50) not null,
+ link varchar(255) null,
+ lastchange datetime default getdate() null
+ )
+ ', $db));
+ var_dump(sybase_query('insert into #test (
+ id, caption, author
+ ) values (
+ 1, "Hello", "timm"
+ )
+ ', $db));
+ var_dump(sybase_query('insert into #test (
+ id, caption, author, link
+ ) values (
+ 2, "World", "thekid", "http://thekid.de/"
+ )
+ ', $db));
+ var_dump(sybase_query('insert into #test (
+ id, caption, author
+ ) values (
+ 3, "PHP", "friebe"
+ )
+ ', $db));
+
+ // Fetch data
+ $q= sybase_unbuffered_query('select * from #test order by id', $db, FALSE);
+ var_dump($q);
+ while ($row= sybase_fetch_assoc($q)) {
+ var_dump($row);
+ }
+
+ // Clean up and close connection
+ var_dump(sybase_query('drop table #test'));
+ sybase_close($db);
+?>
+--EXPECTF--
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+resource(%d) of type (sybase-ct result)
+array(5) {
+ ["id"]=>
+ int(1)
+ ["caption"]=>
+ string(5) "Hello"
+ ["author"]=>
+ string(4) "timm"
+ ["link"]=>
+ NULL
+ ["lastchange"]=>
+ string(%d) "%s"
+}
+array(5) {
+ ["id"]=>
+ int(2)
+ ["caption"]=>
+ string(5) "World"
+ ["author"]=>
+ string(6) "thekid"
+ ["link"]=>
+ string(17) "http://thekid.de/"
+ ["lastchange"]=>
+ string(%d) "%s"
+}
+array(5) {
+ ["id"]=>
+ int(3)
+ ["caption"]=>
+ string(3) "PHP"
+ ["author"]=>
+ string(6) "friebe"
+ ["link"]=>
+ NULL
+ ["lastchange"]=>
+ string(%d) "%s"
+}
+bool(true)