summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntony Dovgal <tony2001@php.net>2006-04-12 19:21:35 +0000
committerAntony Dovgal <tony2001@php.net>2006-04-12 19:21:35 +0000
commit5751903b1baad353521a47a0421c57ea16f614f5 (patch)
tree1ec26039a8e9be52d8468980a0d08b8cb8c7eee2
parent2d2f1cf0c696b49640dca7a034924131f6946737 (diff)
downloadphp-git-5751903b1baad353521a47a0421c57ea16f614f5.tar.gz
fix #37059 (oci_bind_by_name() doesn't support RAW and LONG RAW fields)
add tests
-rw-r--r--NEWS2
-rw-r--r--ext/oci8/oci8.c2
-rw-r--r--ext/oci8/oci8_statement.c6
-rw-r--r--ext/oci8/tests/bind_long.phpt38
-rw-r--r--ext/oci8/tests/bind_long_raw.phpt38
-rw-r--r--ext/oci8/tests/bind_raw.phpt39
-rw-r--r--ext/oci8/tests/test.gifbin0 -> 2523 bytes
7 files changed, 125 insertions, 0 deletions
diff --git a/NEWS b/NEWS
index cbf459552d..8cab0cfcc3 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,8 @@
PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? Apr 2006, PHP 5.1.3
+- FIxed bug #37059 (oci_bind_by_name() doesn't support RAW and LONG RAW
+ fields). (Tony)
- Fixed bug #37057 (xmlrpc_decode() may produce arrays with numeric strings,
which are unaccessible). (Tony)
- Fixed bug #37055 (incorrect reference counting for persistent OCI8
diff --git a/ext/oci8/oci8.c b/ext/oci8/oci8.c
index 87e5f3a775..1c73008ed4 100644
--- a/ext/oci8/oci8.c
+++ b/ext/oci8/oci8.c
@@ -541,6 +541,8 @@ PHP_MINIT_FUNCTION(oci)
REGISTER_LONG_CONSTANT("SQLT_FLT",SQLT_FLT, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SQLT_UIN",SQLT_UIN, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SQLT_LNG",SQLT_LNG, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SQLT_LBI",SQLT_LBI, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SQLT_BIN",SQLT_BIN, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SQLT_ODT",SQLT_ODT, CONST_CS | CONST_PERSISTENT);
#if defined(HAVE_OCI_INSTANT_CLIENT) || (defined(OCI_MAJOR_VERSION) && OCI_MAJOR_VERSION > 10)
REGISTER_LONG_CONSTANT("SQLT_BDOUBLE",SQLT_BDOUBLE, CONST_CS | CONST_PERSISTENT);
diff --git a/ext/oci8/oci8_statement.c b/ext/oci8/oci8_statement.c
index f930fdaa77..16a2b7e182 100644
--- a/ext/oci8/oci8_statement.c
+++ b/ext/oci8/oci8_statement.c
@@ -493,6 +493,9 @@ int php_oci_statement_execute(php_oci_statement *statement, ub4 mode TSRMLS_DC)
case SQLT_BIN:
default:
define_type = SQLT_CHR;
+ if (outcol->data_type == SQLT_BIN) {
+ define_type = SQLT_BIN;
+ }
if ((outcol->data_type == SQLT_DAT) || (outcol->data_type == SQLT_NUM)
#ifdef SQLT_TIMESTAMP
|| (outcol->data_type == SQLT_TIMESTAMP)
@@ -813,6 +816,9 @@ int php_oci_bind_by_name(php_oci_statement *statement, char *name, int name_len,
mode = OCI_DEFAULT;
break;
+ case SQLT_LBI:
+ case SQLT_BIN:
+ case SQLT_LNG:
case SQLT_CHR:
/* this is the default case when type was not specified */
convert_to_string(var);
diff --git a/ext/oci8/tests/bind_long.phpt b/ext/oci8/tests/bind_long.phpt
new file mode 100644
index 0000000000..58590f145a
--- /dev/null
+++ b/ext/oci8/tests/bind_long.phpt
@@ -0,0 +1,38 @@
+--TEST--
+bind LONG field
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__)."/connect.inc";
+
+$stmt = oci_parse($c, "create table phptestlng( id number(10), fileimage long)");
+oci_execute($stmt);
+
+$stmt = oci_parse ($c, "insert into phptestlng (id, fileimage) values (:id, :fileimage)");
+$i=1;
+$fileimage = file_get_contents( dirname(__FILE__)."/test.gif");
+
+oci_bind_by_name( $stmt, ":id", $i, -1);
+oci_bind_by_name( $stmt, ":fileimage", $fileimage, -1, SQLT_LNG);
+oci_execute($stmt, OCI_DEFAULT);
+oci_commit($c);
+
+$stmt = oci_parse($c, "SELECT fileimage FROM phptestlng");
+oci_execute($stmt);
+
+$row = oci_fetch_row($stmt);
+var_dump(md5($row[0]));
+var_dump(strlen($row[0]));
+
+$stmt = oci_parse($c, "drop table phptestlng");
+oci_execute($stmt);
+
+echo "Done\n";
+
+?>
+--EXPECT--
+string(32) "d04e7036e2f4221abc88fd14e960a45b"
+int(2523)
+Done
diff --git a/ext/oci8/tests/bind_long_raw.phpt b/ext/oci8/tests/bind_long_raw.phpt
new file mode 100644
index 0000000000..2a9962eace
--- /dev/null
+++ b/ext/oci8/tests/bind_long_raw.phpt
@@ -0,0 +1,38 @@
+--TEST--
+bind LONG RAW field
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__)."/connect.inc";
+
+$stmt = oci_parse($c, "create table phptestlngraw( id number(10), fileimage long raw)");
+oci_execute($stmt);
+
+$stmt = oci_parse ($c, "insert into phptestlngraw (id, fileimage) values (:id, :fileimage)");
+$i=1;
+$fileimage = file_get_contents( dirname(__FILE__)."/test.gif");
+
+oci_bind_by_name( $stmt, ":id", $i, -1);
+oci_bind_by_name( $stmt, ":fileimage", $fileimage, -1, SQLT_LBI);
+oci_execute($stmt, OCI_DEFAULT);
+oci_commit($c);
+
+$stmt = oci_parse($c, "SELECT fileimage FROM phptestlngraw");
+oci_execute($stmt);
+
+$row = oci_fetch_row($stmt);
+var_dump(md5($row[0]));
+var_dump(strlen($row[0]));
+
+$stmt = oci_parse($c, "drop table phptestlngraw");
+oci_execute($stmt);
+
+echo "Done\n";
+
+?>
+--EXPECT--
+string(32) "614fcbba1effb7caa27ef0ef25c27fcf"
+int(2523)
+Done
diff --git a/ext/oci8/tests/bind_raw.phpt b/ext/oci8/tests/bind_raw.phpt
new file mode 100644
index 0000000000..c9087e552b
--- /dev/null
+++ b/ext/oci8/tests/bind_raw.phpt
@@ -0,0 +1,39 @@
+--TEST--
+bind RAW field
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__)."/connect.inc";
+
+$stmt = oci_parse($c, "create table phptestrawtable( id number(10), fileimage raw(1000))");
+oci_execute($stmt);
+
+$stmt = oci_parse ($c, "insert into phptestrawtable (id, fileimage) values (:id, :fileimage)");
+$i=1;
+$fileimage = file_get_contents( dirname(__FILE__)."/test.gif");
+$fileimage = substr($fileimage, 0, 300);
+
+oci_bind_by_name( $stmt, ":id", $i, -1);
+oci_bind_by_name( $stmt, ":fileimage", $fileimage, -1, SQLT_BIN);
+oci_execute($stmt, OCI_DEFAULT);
+oci_commit($c);
+
+$stmt = oci_parse($c, "SELECT fileimage FROM phptestrawtable");
+oci_execute($stmt);
+
+$row = oci_fetch_row($stmt);
+var_dump(md5($row[0]));
+var_dump(strlen($row[0]));
+
+$stmt = oci_parse($c, "drop table phptestrawtable");
+oci_execute($stmt);
+
+echo "Done\n";
+
+?>
+--EXPECT--
+string(32) "88b274d7a257ac6f70435b83abd4e26e"
+int(300)
+Done
diff --git a/ext/oci8/tests/test.gif b/ext/oci8/tests/test.gif
new file mode 100644
index 0000000000..f352c7308f
--- /dev/null
+++ b/ext/oci8/tests/test.gif
Binary files differ