From: Christopher Jones Date: Tue, 4 Mar 2008 21:46:24 +0000 (+0000) Subject: MFH Fix bug #41069 (db link crash). Also allow SQLT_AFC (aka CHAR datatype) in oci_b... X-Git-Tag: BEFORE_NEW_PARAMETER_PARSE~702 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=af6734c1ff56ba8fc64a3056afe45390f57ee4fa;p=php MFH Fix bug #41069 (db link crash). Also allow SQLT_AFC (aka CHAR datatype) in oci_bind_by_name --- diff --git a/ext/oci8/oci8_statement.c b/ext/oci8/oci8_statement.c index a07937a9a4..d95456f15f 100644 --- a/ext/oci8/oci8_statement.c +++ b/ext/oci8/oci8_statement.c @@ -125,22 +125,13 @@ php_oci_statement *php_oci_statement_create (php_oci_connection *connection, cha Set prefetch buffer size for the statement (we're assuming that one row is ~1K sized) */ int php_oci_statement_set_prefetch(php_oci_statement *statement, long size TSRMLS_DC) { - ub4 prefetch = size * 1024; + ub4 prefetch = size; if (size < 1) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Number of rows has to be greater than or equal to 1"); return 1; } - PHP_OCI_CALL_RETURN(statement->errcode, OCIAttrSet, (statement->stmt, OCI_HTYPE_STMT, &prefetch, 0, OCI_ATTR_PREFETCH_MEMORY, statement->err)); - - if (statement->errcode != OCI_SUCCESS) { - php_oci_error(statement->err, statement->errcode TSRMLS_CC); - PHP_OCI_HANDLE_ERROR(statement->connection, statement->errcode); - return 1; - } - - prefetch = size; PHP_OCI_CALL_RETURN(statement->errcode, OCIAttrSet, (statement->stmt, OCI_HTYPE_STMT, &prefetch, 0, OCI_ATTR_PREFETCH_ROWS, statement->err)); if (statement->errcode != OCI_SUCCESS) { @@ -975,8 +966,8 @@ int php_oci_bind_by_name(php_oci_statement *statement, char *name, int name_len, case SQLT_LBI: case SQLT_BIN: case SQLT_LNG: - case SQLT_CHR: - /* this is the default case when type was not specified */ + case SQLT_AFC: + case SQLT_CHR: /* SQLT_CHR is the default value when type was not specified */ if (Z_TYPE_P(var) != IS_NULL) { convert_to_string(var); } diff --git a/ext/oci8/tests/bind_char_1.phpt b/ext/oci8/tests/bind_char_1.phpt new file mode 100644 index 0000000000..fd76e60738 --- /dev/null +++ b/ext/oci8/tests/bind_char_1.phpt @@ -0,0 +1,287 @@ +--TEST-- +SELECT oci_bind_by_name with SQLT_AFC aka CHAR +--SKIPIF-- + +--FILE-- + +--EXPECT-- +*** Non-null Data Tests against CHAR*** +Test 1.1: Type: default. Length: default + Querying: +Test 1.2: Type: AFC. Length: default + Querying: + :1: + :abc : + :: +Test 1.3: Type: AFC: Length: 0 + Querying: + Oci_execute error ORA-1460 Exiting Query +Test 1.4: Type: AFC: Length: strlen + Querying: + :1: + :abc : + :: +Test 1.5: Type: AFC. Length: strlen-1 + Querying: + Oci_execute error ORA-1460 Exiting Query +Test 1.6: Type: AFC. Length: strlen+1 + Querying: + :1: + :abc : + :: + + +*** NULL data tests against CHAR *** +Test 2.1: Type: default. Length: default + Querying: +Test 2.2: Type: AFC. Length: default + Querying: +Test 2.3: Type: AFC: Length: 0 + Querying: +Test 2.4: Type: AFC: Length: strlen + Querying: +Test 2.5: Type: AFC. Length: strlen-1 + Querying: +Test 2.6: Type: AFC. Length: strlen+1 + Querying: + + +*** Non-null Data Tests against VARCHAR2*** +Test 3.1: Type: default. Length: default + Querying: + :2: + :: + :abc: +Test 3.2: Type: AFC. Length: default + Querying: + :2: + :: + :abc: +Test 3.3: Type: AFC: Length: 0 + Querying: + Oci_execute error ORA-1460 Exiting Query +Test 3.4: Type: AFC: Length: strlen + Querying: + :2: + :: + :abc: +Test 3.5: Type: AFC. Length: strlen-1 + Querying: + Oci_execute error ORA-1460 Exiting Query +Test 3.6: Type: AFC. Length: strlen+1 + Querying: + :2: + :: + :abc: + + +*** NULL data tests against VARCHAR2 *** +Test 4.1: Type: default. Length: default + Querying: +Test 4.2: Type: AFC. Length: default + Querying: +Test 4.3: Type: AFC: Length: 0 + Querying: +Test 4.4: Type: AFC: Length: strlen + Querying: +Test 4.5: Type: AFC. Length: strlen-1 + Querying: +Test 4.6: Type: AFC. Length: strlen+1 + Querying: +Done diff --git a/ext/oci8/tests/bind_char_2.phpt b/ext/oci8/tests/bind_char_2.phpt new file mode 100644 index 0000000000..ccf7b5870f --- /dev/null +++ b/ext/oci8/tests/bind_char_2.phpt @@ -0,0 +1,115 @@ +--TEST-- +SELECT oci_bind_by_name with SQLT_AFC aka CHAR and dates +--SKIPIF-- + +--FILE-- + +--EXPECT-- +Test 1.1: Type: default. Length: default + Querying: + :1: + :2008-04-20: +Test 1.2: Type: AFC. Length: default + Querying: + :1: + :2008-04-20: +Test 1.3: Type: AFC: Length: 0 + Querying: + Oci_execute error ORA-1460 Exiting Query +Test 1.4: Type: AFC: Length: strlen + Querying: + :1: + :2008-04-20: +Test 1.5: Type: AFC. Length: strlen-1 + Querying: + Oci_execute error ORA-1460 Exiting Query +Test 1.6: Type: AFC. Length: strlen+1 + Querying: + :1: + :2008-04-20: +Done diff --git a/ext/oci8/tests/bind_char_3.phpt b/ext/oci8/tests/bind_char_3.phpt new file mode 100644 index 0000000000..a339aa94ff --- /dev/null +++ b/ext/oci8/tests/bind_char_3.phpt @@ -0,0 +1,336 @@ +--TEST-- +PL/SQL oci_bind_by_name with SQLT_AFC aka CHAR to CHAR parameter +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +Test 1.1 In Length: default. In Type: default. Out Length: default. Out Type: default + Executing: + Oci_execute error ORA-6502 +string(3) "abc" +NULL +Test 1.2 In Length: default. In Type: default. Out Length: 10. Out Type: default + Executing: +string(3) "abc" +string(3) "abc" +Test 1.3 In Length: -1. In Type: AFC. Out Length: 10. Out Type: default + Executing: +string(3) "abc" +string(3) "abc" +Test 1.4 In Length: -1. In Type: AFC. Out Length: 10. Out Type: AFC + Executing: +string(3) "abc" +string(10) "abc " +Test 1.5 In Length: strlen. In Type: AFC. Out Length: strlen(input). Out Type: AFC + Executing: +string(3) "abc" +string(3) "abc" +Test 1.6 In Length: strlen. In Type: AFC. Out Length: strlen(input)-1. Out Type: AFC + Executing: + Oci_execute error ORA-6502 +string(3) "abc" +string(3) "abc" +Test 1.7 In Length: strlen. In Type: AFC. Out Length: strlen(input)+1. Out Type: AFC + Executing: +string(3) "abc" +string(4) "abc " + + +Tests with '' + +Test 2.1 In Length: -1. In Type: AFC. Out Length: 10. Out Type: AFC + Executing: +string(0) "" +NULL +Test 2.2 In Length: default. In Type: default. Out Length: 10. Out Type: default + Executing: +string(0) "" +NULL +Test 2.3 In Length: -1. In Type: AFC. Out Length: 10. Out Type: default + Executing: +string(0) "" +NULL +Test 2.4 In Length: -1. In Type: AFC. Out Length: 10. Out Type: AFC + Executing: +string(0) "" +NULL +Test 2.5 In Length: -1. In Type: AFC. Out Length: 0. Out Type: AFC + Executing: +string(0) "" +NULL +Test 2.6 In Length: 0. In Type: AFC. Out Length: 0. Out Type: AFC + Executing: +string(0) "" +NULL +Test 2.7 In Length: 1. In Type: AFC. Out Length: 1. Out Type: AFC + Executing: +string(0) "" +NULL + + +Tests with NULL +Test 3.1 In Length: -1. In Type: AFC. Out Length: 10. Out Type: AFC + Executing: +NULL +NULL +Test 3.2 In Length: default. In Type: default. Out Length: 10. Out Type: default + Executing: +NULL +NULL +Test 3.3 In Length: -1. In Type: AFC. Out Length: 10. Out Type: default + Executing: +NULL +NULL +Test 3.4 In Length: -1. In Type: AFC. Out Length: 10. Out Type: AFC + Executing: +NULL +NULL +Test 3.5 In Length: -1. In Type: AFC. Out Length: 0. Out Type: AFC + Executing: +NULL +NULL +Test 3.6 In Length: -1. In Type: AFC. Out Length: 1. Out Type: AFC + Executing: +NULL +NULL +Done diff --git a/ext/oci8/tests/bind_char_4.phpt b/ext/oci8/tests/bind_char_4.phpt new file mode 100644 index 0000000000..2357163990 --- /dev/null +++ b/ext/oci8/tests/bind_char_4.phpt @@ -0,0 +1,338 @@ +--TEST-- +PL/SQL oci_bind_by_name with SQLT_AFC aka CHAR to VARCHAR2 parameter +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +Test 1.1 In Length: default. In Type: default. Out Length: default. Out Type: default + Executing: + Oci_execute error ORA-6502 +string(3) "abc" +NULL +Test 1.2 In Length: default. In Type: default. Out Length: 10. Out Type: default + Executing: +string(3) "abc" +string(3) "abc" +Test 1.3 In Length: -1. In Type: AFC. Out Length: 10. Out Type: default + Executing: +string(3) "abc" +string(3) "abc" +Test 1.4 In Length: -1. In Type: AFC. Out Length: 10. Out Type: AFC + Executing: +string(3) "abc" +string(10) "abc " +Test 1.5 In Length: strlen. In Type: AFC. Out Length: strlen(input). Out Type: AFC + Executing: +string(3) "abc" +string(3) "abc" +Test 1.6 In Length: strlen. In Type: AFC. Out Length: strlen(input)-1. Out Type: AFC + Executing: + Oci_execute error ORA-6502 +string(3) "abc" +string(3) "abc" +Test 1.7 In Length: strlen. In Type: AFC. Out Length: strlen(input)+1. Out Type: AFC + Executing: +string(3) "abc" +string(4) "abc " + + +Tests with '' + +Test 2.1 In Length: -1. In Type: AFC. Out Length: 10. Out Type: AFC + Executing: +string(0) "" +NULL +Test 2.2 In Length: default. In Type: default. Out Length: 10. Out Type: default + Executing: +string(0) "" +NULL +Test 2.3 In Length: -1. In Type: AFC. Out Length: 10. Out Type: default + Executing: +string(0) "" +NULL +Test 2.4 In Length: -1. In Type: AFC. Out Length: 10. Out Type: AFC + Executing: +string(0) "" +NULL +Test 2.5 In Length: -1. In Type: AFC. Out Length: 0. Out Type: AFC + Executing: +string(0) "" +NULL +Test 2.6 In Length: 0. In Type: AFC. Out Length: 0. Out Type: AFC + Executing: +string(0) "" +NULL +Test 2.7 In Length: 1. In Type: AFC. Out Length: 1. Out Type: AFC + Executing: +string(0) "" +NULL + + +Tests with NULL +Test 3.1 In Length: -1. In Type: AFC. Out Length: 10. Out Type: AFC + Executing: +NULL +NULL +Test 3.2 In Length: default. In Type: default. Out Length: 10. Out Type: default + Executing: +NULL +NULL +Test 3.3 In Length: -1. In Type: AFC. Out Length: 10. Out Type: default + Executing: +NULL +NULL +Test 3.4 In Length: -1. In Type: AFC. Out Length: 10. Out Type: AFC + Executing: +NULL +NULL +Test 3.5 In Length: -1. In Type: AFC. Out Length: 0. Out Type: AFC + Executing: +NULL +NULL +Test 3.6 In Length: -1. In Type: AFC. Out Length: 1. Out Type: AFC + Executing: +NULL +NULL +Done diff --git a/ext/oci8/tests/bug41069.phpt b/ext/oci8/tests/bug41069.phpt new file mode 100644 index 0000000000..b3a1b9969c --- /dev/null +++ b/ext/oci8/tests/bug41069.phpt @@ -0,0 +1,275 @@ +--TEST-- +Bug #41069 (Oracle crash with certain data over a DB-link when prefetch memory limit used - Oracle bug 6039623) +--SKIPIF-- + +--INI-- +oci8.default_prefetch=5 +--FILE-- + +--EXPECT-- +Test 1: non-DB link case that always worked +array(3) { + [0]=> + array(13) { + ["C1"]=> + string(3) "111" + ["C2"]=> + string(7) "aaaaaaa" + ["C3"]=> + NULL + ["C4"]=> + NULL + ["C5"]=> + string(1) "b" + ["C6"]=> + string(1) "c" + ["C7"]=> + NULL + ["C8"]=> + NULL + ["C9"]=> + string(10) "01/17/2008" + ["C10"]=> + string(10) "01/07/2017" + ["C12"]=> + string(4) "2222" + ["C13"]=> + NULL + ["C15"]=> + string(10) "zzzzzzzzzz" + } + [1]=> + array(13) { + ["C1"]=> + string(3) "112" + ["C2"]=> + string(7) "aaaaaaa" + ["C3"]=> + string(8) "bbbbbbbb" + ["C4"]=> + string(7) "ccccccc" + ["C5"]=> + string(1) "d" + ["C6"]=> + string(1) "e" + ["C7"]=> + string(7) "rrrrrrr" + ["C8"]=> + NULL + ["C9"]=> + string(10) "04/16/2007" + ["C10"]=> + string(10) "04/16/2007" + ["C12"]=> + string(4) "2223" + ["C13"]=> + string(8) "xxxxxxxx" + ["C15"]=> + string(8) "zzzzzzzz" + } + [2]=> + array(13) { + ["C1"]=> + string(3) "113" + ["C2"]=> + string(7) "aaaaaaa" + ["C3"]=> + string(10) "bbbbbbbbbb" + ["C4"]=> + string(6) "cccccc" + ["C5"]=> + string(1) "e" + ["C6"]=> + string(1) "f" + ["C7"]=> + string(4) "dddd" + ["C8"]=> + NULL + ["C9"]=> + string(10) "12/04/2006" + ["C10"]=> + string(10) "12/04/2006" + ["C12"]=> + string(4) "2224" + ["C13"]=> + NULL + ["C15"]=> + string(7) "zzzzzzz" + } +} +Test 2: Should not crash +array(3) { + [0]=> + array(13) { + ["C1"]=> + string(3) "111" + ["C2"]=> + string(7) "aaaaaaa" + ["C3"]=> + NULL + ["C4"]=> + NULL + ["C5"]=> + string(1) "b" + ["C6"]=> + string(1) "c" + ["C7"]=> + NULL + ["C8"]=> + NULL + ["C9"]=> + string(10) "01/17/2008" + ["C10"]=> + string(10) "01/07/2017" + ["C12"]=> + string(4) "2222" + ["C13"]=> + NULL + ["C15"]=> + string(10) "zzzzzzzzzz" + } + [1]=> + array(13) { + ["C1"]=> + string(3) "112" + ["C2"]=> + string(7) "aaaaaaa" + ["C3"]=> + string(8) "bbbbbbbb" + ["C4"]=> + string(7) "ccccccc" + ["C5"]=> + string(1) "d" + ["C6"]=> + string(1) "e" + ["C7"]=> + string(7) "rrrrrrr" + ["C8"]=> + NULL + ["C9"]=> + string(10) "04/16/2007" + ["C10"]=> + string(10) "04/16/2007" + ["C12"]=> + string(4) "2223" + ["C13"]=> + string(8) "xxxxxxxx" + ["C15"]=> + string(8) "zzzzzzzz" + } + [2]=> + array(13) { + ["C1"]=> + string(3) "113" + ["C2"]=> + string(7) "aaaaaaa" + ["C3"]=> + string(10) "bbbbbbbbbb" + ["C4"]=> + string(6) "cccccc" + ["C5"]=> + string(1) "e" + ["C6"]=> + string(1) "f" + ["C7"]=> + string(4) "dddd" + ["C8"]=> + NULL + ["C9"]=> + string(10) "12/04/2006" + ["C10"]=> + string(10) "12/04/2006" + ["C12"]=> + string(4) "2224" + ["C13"]=> + NULL + ["C15"]=> + string(7) "zzzzzzz" + } +} +Done