From adcefcebf9a3aa52d9b035d4ede6a8a27dcb99ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Kocsis?= Date: Wed, 26 Jul 2023 15:17:32 +0200 Subject: [PATCH 1/4] Add more test coverage for ext/odbc --- ext/odbc/tests/odbc_close_all_001.phpt | 38 +++++ ext/odbc/tests/odbc_commit_001.phpt | 31 ++++ ext/odbc/tests/odbc_cursor_001.phpt | 29 ++++ ext/odbc/tests/odbc_fetch_array_001.phpt | 46 ++++++ ext/odbc/tests/odbc_fetch_into_001.phpt | 59 +++++++ ext/odbc/tests/odbc_fetch_object_001.phpt | 46 ++++++ ext/odbc/tests/odbc_fetch_row_001.phpt | 52 +++++++ ext/odbc/tests/odbc_field_len_001.phpt | 43 ++++++ ext/odbc/tests/odbc_field_name_001.phpt | 42 +++++ ext/odbc/tests/odbc_field_num_001.phpt | 34 ++++ ext/odbc/tests/odbc_field_precision_001.phpt | 42 +++++ ext/odbc/tests/odbc_field_scale_001.phpt | 42 +++++ ext/odbc/tests/odbc_field_type_001.phpt | 42 +++++ ext/odbc/tests/odbc_gettypeinfo_001.phpt | 154 +++++++++++++++++++ ext/odbc/tests/odbc_longreadlen_001.phpt | 31 ++++ ext/odbc/tests/odbc_num_fields_001.phpt | 35 +++++ ext/odbc/tests/odbc_num_rows_001.phpt | 37 +++++ ext/odbc/tests/odbc_primarykeys_001.phpt | 37 +++++ ext/odbc/tests/odbc_rollback_001.phpt | 31 ++++ ext/odbc/tests/odbc_setoption_001.phpt | 24 +++ ext/odbc/tests/odbc_setoption_002.phpt | 25 +++ 21 files changed, 920 insertions(+) create mode 100644 ext/odbc/tests/odbc_close_all_001.phpt create mode 100644 ext/odbc/tests/odbc_commit_001.phpt create mode 100644 ext/odbc/tests/odbc_cursor_001.phpt create mode 100644 ext/odbc/tests/odbc_fetch_array_001.phpt create mode 100644 ext/odbc/tests/odbc_fetch_into_001.phpt create mode 100644 ext/odbc/tests/odbc_fetch_object_001.phpt create mode 100644 ext/odbc/tests/odbc_fetch_row_001.phpt create mode 100644 ext/odbc/tests/odbc_field_len_001.phpt create mode 100644 ext/odbc/tests/odbc_field_name_001.phpt create mode 100644 ext/odbc/tests/odbc_field_num_001.phpt create mode 100644 ext/odbc/tests/odbc_field_precision_001.phpt create mode 100644 ext/odbc/tests/odbc_field_scale_001.phpt create mode 100644 ext/odbc/tests/odbc_field_type_001.phpt create mode 100644 ext/odbc/tests/odbc_gettypeinfo_001.phpt create mode 100644 ext/odbc/tests/odbc_longreadlen_001.phpt create mode 100644 ext/odbc/tests/odbc_num_fields_001.phpt create mode 100644 ext/odbc/tests/odbc_num_rows_001.phpt create mode 100644 ext/odbc/tests/odbc_primarykeys_001.phpt create mode 100644 ext/odbc/tests/odbc_rollback_001.phpt create mode 100644 ext/odbc/tests/odbc_setoption_001.phpt create mode 100644 ext/odbc/tests/odbc_setoption_002.phpt diff --git a/ext/odbc/tests/odbc_close_all_001.phpt b/ext/odbc/tests/odbc_close_all_001.phpt new file mode 100644 index 0000000000000..9641ac4bd7e4a --- /dev/null +++ b/ext/odbc/tests/odbc_close_all_001.phpt @@ -0,0 +1,38 @@ +--TEST-- +odbc_close_all(): Basic test +--EXTENSIONS-- +odbc +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +resource(5) of type (odbc link) +resource(7) of type (odbc link persistent) +resource(8) of type (odbc result) +resource(9) of type (odbc result) +resource(5) of type (Unknown) +resource(7) of type (Unknown) +resource(8) of type (Unknown) +resource(9) of type (Unknown) diff --git a/ext/odbc/tests/odbc_commit_001.phpt b/ext/odbc/tests/odbc_commit_001.phpt new file mode 100644 index 0000000000000..5db0b0627e5b8 --- /dev/null +++ b/ext/odbc/tests/odbc_commit_001.phpt @@ -0,0 +1,31 @@ +--TEST-- +odbc_commit(): Basic test for odbc_commit() +--EXTENSIONS-- +odbc +--SKIPIF-- + +--FILE-- + +--CLEAN-- + +--EXPECT-- +bool(true) +string(1) "1" diff --git a/ext/odbc/tests/odbc_cursor_001.phpt b/ext/odbc/tests/odbc_cursor_001.phpt new file mode 100644 index 0000000000000..b7111393d8341 --- /dev/null +++ b/ext/odbc/tests/odbc_cursor_001.phpt @@ -0,0 +1,29 @@ +--TEST-- +Test odbc_cursor() +--EXTENSIONS-- +odbc +--SKIPIF-- + +--FILE-- + +--CLEAN-- + +--EXPECTF-- +string(%d) "SQL_CUR%s" diff --git a/ext/odbc/tests/odbc_fetch_array_001.phpt b/ext/odbc/tests/odbc_fetch_array_001.phpt new file mode 100644 index 0000000000000..b212adcb1f49b --- /dev/null +++ b/ext/odbc/tests/odbc_fetch_array_001.phpt @@ -0,0 +1,46 @@ +--TEST-- +odbc_fetch_array(): Getting data from query +--EXTENSIONS-- +odbc +--SKIPIF-- + +--FILE-- + +--CLEAN-- + +--EXPECTF-- +array(1) { + ["foo"]=> + string(1) "1" +} +array(1) { + ["foo"]=> + string(1) "2" +} +array(1) { + ["foo"]=> + string(1) "3" +} +bool(false) diff --git a/ext/odbc/tests/odbc_fetch_into_001.phpt b/ext/odbc/tests/odbc_fetch_into_001.phpt new file mode 100644 index 0000000000000..5053552ce5da7 --- /dev/null +++ b/ext/odbc/tests/odbc_fetch_into_001.phpt @@ -0,0 +1,59 @@ +--TEST-- +odbc_fetch_into(): Getting data from query +--EXTENSIONS-- +odbc +--SKIPIF-- + +--FILE-- + +--CLEAN-- + +--EXPECTF-- +int(1) +array(1) { + [0]=> + string(1) "1" +} +int(1) +array(1) { + [0]=> + string(1) "2" +} +int(1) +array(1) { + [0]=> + string(1) "3" +} +bool(false) +array(0) { +} diff --git a/ext/odbc/tests/odbc_fetch_object_001.phpt b/ext/odbc/tests/odbc_fetch_object_001.phpt new file mode 100644 index 0000000000000..4ea407562eb75 --- /dev/null +++ b/ext/odbc/tests/odbc_fetch_object_001.phpt @@ -0,0 +1,46 @@ +--TEST-- +odbc_fetch_object(): Getting data from query +--EXTENSIONS-- +odbc +--SKIPIF-- + +--FILE-- + +--CLEAN-- + +--EXPECTF-- +object(stdClass)#%d (%d) { + ["foo"]=> + string(1) "1" +} +object(stdClass)#%d (%d) { + ["foo"]=> + string(1) "2" +} +object(stdClass)#%d (%d) { + ["foo"]=> + string(1) "3" +} +bool(false) diff --git a/ext/odbc/tests/odbc_fetch_row_001.phpt b/ext/odbc/tests/odbc_fetch_row_001.phpt new file mode 100644 index 0000000000000..4cecb513a067f --- /dev/null +++ b/ext/odbc/tests/odbc_fetch_row_001.phpt @@ -0,0 +1,52 @@ +--TEST-- +odbc_fetch_row(): Getting data from query +--EXTENSIONS-- +odbc +--SKIPIF-- + +--FILE-- + +--CLEAN-- + +--EXPECTF-- +bool(false) +bool(true) +string(1) "1" +bool(true) +string(1) "2" +bool(true) +string(1) "3" +bool(false) diff --git a/ext/odbc/tests/odbc_field_len_001.phpt b/ext/odbc/tests/odbc_field_len_001.phpt new file mode 100644 index 0000000000000..b4697fff75f25 --- /dev/null +++ b/ext/odbc/tests/odbc_field_len_001.phpt @@ -0,0 +1,43 @@ +--TEST-- +odbc_field_len(): Getting the length of the field +--EXTENSIONS-- +odbc +--SKIPIF-- + +--FILE-- +getMessage() . "\n"; +} +var_dump(odbc_field_len($res, 1)); +var_dump(odbc_field_len($res, 2)); +var_dump(odbc_field_len($res, 3)); +var_dump(odbc_field_len($res, 4)); + +odbc_close($conn); +?> +--CLEAN-- + +--EXPECTF-- +odbc_field_len(): Argument #2 ($field) must be greater than 0 +int(10) +int(2147483647) +int(50) + +Warning: odbc_field_len(): Field index larger than number of fields in %s on line %d +bool(false) diff --git a/ext/odbc/tests/odbc_field_name_001.phpt b/ext/odbc/tests/odbc_field_name_001.phpt new file mode 100644 index 0000000000000..da34da9e022e1 --- /dev/null +++ b/ext/odbc/tests/odbc_field_name_001.phpt @@ -0,0 +1,42 @@ +--TEST-- +odbc_field_name(): Getting the name of the field +--EXTENSIONS-- +odbc +--SKIPIF-- + +--FILE-- +getMessage() . "\n"; +} +var_dump(odbc_field_name($res, 1)); +var_dump(odbc_field_name($res, 2)); +var_dump(odbc_field_name($res, 3)); +var_dump(odbc_field_name($res, 4)); + +?> +--CLEAN-- + +--EXPECTF-- +odbc_field_name(): Argument #2 ($field) must be greater than 0 +string(3) "foo" +string(3) "bar" +string(3) "baz" + +Warning: odbc_field_name(): Field index larger than number of fields in %s on line %d +bool(false) diff --git a/ext/odbc/tests/odbc_field_num_001.phpt b/ext/odbc/tests/odbc_field_num_001.phpt new file mode 100644 index 0000000000000..ab4bbcc4d00b3 --- /dev/null +++ b/ext/odbc/tests/odbc_field_num_001.phpt @@ -0,0 +1,34 @@ +--TEST-- +odbc_field_scale(): Getting the scale of the field +--EXTENSIONS-- +odbc +--SKIPIF-- + +--FILE-- + +--CLEAN-- + +--EXPECTF-- +int(1) +int(2) +int(3) +bool(false) diff --git a/ext/odbc/tests/odbc_field_precision_001.phpt b/ext/odbc/tests/odbc_field_precision_001.phpt new file mode 100644 index 0000000000000..609401ba263c9 --- /dev/null +++ b/ext/odbc/tests/odbc_field_precision_001.phpt @@ -0,0 +1,42 @@ +--TEST-- +odbc_field_precision(): Getting the precision of the field +--EXTENSIONS-- +odbc +--SKIPIF-- + +--FILE-- +getMessage() . "\n"; +} +var_dump(odbc_field_precision($res, 1)); +var_dump(odbc_field_precision($res, 2)); +var_dump(odbc_field_precision($res, 3)); +var_dump(odbc_field_precision($res, 4)); + +?> +--CLEAN-- + +--EXPECTF-- +odbc_field_precision(): Argument #2 ($field) must be greater than 0 +int(10) +int(7) +int(50) + +Warning: odbc_field_precision(): Field index larger than number of fields in %s on line %d +bool(false) diff --git a/ext/odbc/tests/odbc_field_scale_001.phpt b/ext/odbc/tests/odbc_field_scale_001.phpt new file mode 100644 index 0000000000000..3bb2da8e1c2cb --- /dev/null +++ b/ext/odbc/tests/odbc_field_scale_001.phpt @@ -0,0 +1,42 @@ +--TEST-- +odbc_field_scale(): Getting the scale of the field +--EXTENSIONS-- +odbc +--SKIPIF-- + +--FILE-- +getMessage() . "\n"; +} +var_dump(odbc_field_scale($res, 1)); +var_dump(odbc_field_scale($res, 2)); +var_dump(odbc_field_scale($res, 3)); +var_dump(odbc_field_scale($res, 4)); + +?> +--CLEAN-- + +--EXPECTF-- +odbc_field_scale(): Argument #2 ($field) must be greater than 0 +int(0) +int(0) +int(0) + +Warning: odbc_field_scale(): Field index larger than number of fields in %s on line %d +bool(false) diff --git a/ext/odbc/tests/odbc_field_type_001.phpt b/ext/odbc/tests/odbc_field_type_001.phpt new file mode 100644 index 0000000000000..81774c7dbc0ed --- /dev/null +++ b/ext/odbc/tests/odbc_field_type_001.phpt @@ -0,0 +1,42 @@ +--TEST-- +odbc_field_type(): Getting the type of the field +--EXTENSIONS-- +odbc +--SKIPIF-- + +--FILE-- +getMessage() . "\n"; +} +var_dump(odbc_field_type($res, 1)); +var_dump(odbc_field_type($res, 2)); +var_dump(odbc_field_type($res, 3)); +var_dump(odbc_field_type($res, 4)); + +?> +--CLEAN-- + +--EXPECTF-- +odbc_field_type(): Argument #2 ($field) must be greater than 0 +string(3) "int" +string(4) "text" +string(9) "varbinary" + +Warning: odbc_field_type(): Field index larger than number of fields in %s on line %d +bool(false) diff --git a/ext/odbc/tests/odbc_gettypeinfo_001.phpt b/ext/odbc/tests/odbc_gettypeinfo_001.phpt new file mode 100644 index 0000000000000..76b06089181fa --- /dev/null +++ b/ext/odbc/tests/odbc_gettypeinfo_001.phpt @@ -0,0 +1,154 @@ +--TEST-- +odbc_gettypeinfo(): Getting info about data types +--EXTENSIONS-- +odbc +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +array(20) { + ["TYPE_NAME"]=> + string(14) "datetimeoffset" + ["DATA_TYPE"]=> + string(4) "-155" + ["COLUMN_SIZE"]=> + string(2) "34" + ["LITERAL_PREFIX"]=> + string(1) "'" + ["LITERAL_SUFFIX"]=> + string(1) "'" + ["CREATE_PARAMS"]=> + string(5) "scale" + ["NULLABLE"]=> + string(1) "1" + ["CASE_SENSITIVE"]=> + string(1) "0" + ["SEARCHABLE"]=> + string(1) "3" + ["UNSIGNED_ATTRIBUTE"]=> + NULL + ["FIXED_PREC_SCALE"]=> + string(1) "0" + ["AUTO_UNIQUE_VALUE"]=> + NULL + ["LOCAL_TYPE_NAME"]=> + string(14) "datetimeoffset" + ["MINIMUM_SCALE"]=> + string(1) "0" + ["MAXIMUM_SCALE"]=> + string(1) "7" + ["SQL_DATA_TYPE"]=> + string(4) "-155" + ["SQL_DATETIME_SUB"]=> + string(1) "0" + ["NUM_PREC_RADIX"]=> + NULL + ["INTERVAL_PRECISION"]=> + NULL + ["USERTYPE"]=> + string(1) "0" +} +array(20) { + ["TYPE_NAME"]=> + string(4) "char" + ["DATA_TYPE"]=> + string(1) "1" + ["COLUMN_SIZE"]=> + string(4) "8000" + ["LITERAL_PREFIX"]=> + string(1) "'" + ["LITERAL_SUFFIX"]=> + string(1) "'" + ["CREATE_PARAMS"]=> + string(6) "length" + ["NULLABLE"]=> + string(1) "1" + ["CASE_SENSITIVE"]=> + string(1) "0" + ["SEARCHABLE"]=> + string(1) "3" + ["UNSIGNED_ATTRIBUTE"]=> + NULL + ["FIXED_PREC_SCALE"]=> + string(1) "0" + ["AUTO_UNIQUE_VALUE"]=> + NULL + ["LOCAL_TYPE_NAME"]=> + string(4) "char" + ["MINIMUM_SCALE"]=> + NULL + ["MAXIMUM_SCALE"]=> + NULL + ["SQL_DATA_TYPE"]=> + string(1) "1" + ["SQL_DATETIME_SUB"]=> + NULL + ["NUM_PREC_RADIX"]=> + NULL + ["INTERVAL_PRECISION"]=> + NULL + ["USERTYPE"]=> + string(1) "1" +} +array(20) { + ["TYPE_NAME"]=> + string(7) "numeric" + ["DATA_TYPE"]=> + string(1) "2" + ["COLUMN_SIZE"]=> + string(2) "38" + ["LITERAL_PREFIX"]=> + NULL + ["LITERAL_SUFFIX"]=> + NULL + ["CREATE_PARAMS"]=> + string(15) "precision,scale" + ["NULLABLE"]=> + string(1) "1" + ["CASE_SENSITIVE"]=> + string(1) "0" + ["SEARCHABLE"]=> + string(1) "2" + ["UNSIGNED_ATTRIBUTE"]=> + string(1) "0" + ["FIXED_PREC_SCALE"]=> + string(1) "0" + ["AUTO_UNIQUE_VALUE"]=> + string(1) "0" + ["LOCAL_TYPE_NAME"]=> + string(7) "numeric" + ["MINIMUM_SCALE"]=> + string(1) "0" + ["MAXIMUM_SCALE"]=> + string(2) "38" + ["SQL_DATA_TYPE"]=> + string(1) "2" + ["SQL_DATETIME_SUB"]=> + NULL + ["NUM_PREC_RADIX"]=> + string(2) "10" + ["INTERVAL_PRECISION"]=> + NULL + ["USERTYPE"]=> + string(2) "10" +} diff --git a/ext/odbc/tests/odbc_longreadlen_001.phpt b/ext/odbc/tests/odbc_longreadlen_001.phpt new file mode 100644 index 0000000000000..d27fa8bf9581a --- /dev/null +++ b/ext/odbc/tests/odbc_longreadlen_001.phpt @@ -0,0 +1,31 @@ +--TEST-- +Test odbc_longreadlen() +--EXTENSIONS-- +odbc +--SKIPIF-- + +--FILE-- + +--CLEAN-- + +--EXPECT-- +string(4) "what" diff --git a/ext/odbc/tests/odbc_num_fields_001.phpt b/ext/odbc/tests/odbc_num_fields_001.phpt new file mode 100644 index 0000000000000..b815c971e01cd --- /dev/null +++ b/ext/odbc/tests/odbc_num_fields_001.phpt @@ -0,0 +1,35 @@ +--TEST-- +odbc_num_rows(): Getting the number of fields +--EXTENSIONS-- +odbc +--SKIPIF-- + +--FILE-- + +--CLEAN-- + +--EXPECT-- +int(3) +int(3) diff --git a/ext/odbc/tests/odbc_num_rows_001.phpt b/ext/odbc/tests/odbc_num_rows_001.phpt new file mode 100644 index 0000000000000..8c2af1a1f147f --- /dev/null +++ b/ext/odbc/tests/odbc_num_rows_001.phpt @@ -0,0 +1,37 @@ +--TEST-- +odbc_num_rows(): Getting the number of rows +--EXTENSIONS-- +odbc +--SKIPIF-- + +--FILE-- + +--CLEAN-- + +--EXPECT-- +int(3) +int(0) diff --git a/ext/odbc/tests/odbc_primarykeys_001.phpt b/ext/odbc/tests/odbc_primarykeys_001.phpt new file mode 100644 index 0000000000000..17b42c6ff51eb --- /dev/null +++ b/ext/odbc/tests/odbc_primarykeys_001.phpt @@ -0,0 +1,37 @@ +--TEST-- +odbc_primarykeys(): Basic test for odbc_primarykeys() +--EXTENSIONS-- +odbc +--SKIPIF-- + +--XFAIL-- +Doesn't work with MS SQL +--FILE-- + +--CLEAN-- + +--EXPECT-- +bool(false) diff --git a/ext/odbc/tests/odbc_rollback_001.phpt b/ext/odbc/tests/odbc_rollback_001.phpt new file mode 100644 index 0000000000000..6f4cf3d6926d7 --- /dev/null +++ b/ext/odbc/tests/odbc_rollback_001.phpt @@ -0,0 +1,31 @@ +--TEST-- +odbc_rollback(): Basic test for odbc_rollback() +--EXTENSIONS-- +odbc +--SKIPIF-- + +--FILE-- + +--CLEAN-- + +--EXPECT-- +bool(true) +bool(false) diff --git a/ext/odbc/tests/odbc_setoption_001.phpt b/ext/odbc/tests/odbc_setoption_001.phpt new file mode 100644 index 0000000000000..3f2202100aa64 --- /dev/null +++ b/ext/odbc/tests/odbc_setoption_001.phpt @@ -0,0 +1,24 @@ +--TEST-- +odbc_setoption(): Basic test for odbc_setoption() +--EXTENSIONS-- +odbc +--SKIPIF-- + +--FILE-- + +--EXPECT-- +bool(true) +int(0) diff --git a/ext/odbc/tests/odbc_setoption_002.phpt b/ext/odbc/tests/odbc_setoption_002.phpt new file mode 100644 index 0000000000000..e93d45b6fb414 --- /dev/null +++ b/ext/odbc/tests/odbc_setoption_002.phpt @@ -0,0 +1,25 @@ +--TEST-- +odbc_setoption(): Test for odbc_setoption() with persistent connection +--EXTENSIONS-- +odbc +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +Warning: odbc_setoption(): Unable to set option for persistent connection in %s on line %d +bool(false) +int(1) From 24b639cc5040c42325f96d66df767c20413f5ea7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Kocsis?= Date: Mon, 7 Aug 2023 09:55:28 +0200 Subject: [PATCH 2/4] Enable ext/odbc and ext/pdo_odbc tests on Linux in GitHub CI --- .github/actions/setup-x64/action.yml | 2 ++ .github/actions/test-linux/action.yml | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/.github/actions/setup-x64/action.yml b/.github/actions/setup-x64/action.yml index 91cf7ea51c356..bec213375b7c5 100644 --- a/.github/actions/setup-x64/action.yml +++ b/.github/actions/setup-x64/action.yml @@ -12,6 +12,8 @@ runs: # Ensure local_infile tests can run. mysql -uroot -proot -e "SET GLOBAL local_infile = true" docker exec sql1 /opt/mssql-tools/bin/sqlcmd -S 127.0.0.1 -U SA -P "" -Q "create login pdo_test with password='password', check_policy=off; create user pdo_test for login pdo_test; grant alter, control to pdo_test;" + docker exec sql1 /opt/mssql-tools/bin/sqlcmd -S 127.0.0.1 -U SA -P "" -Q "create login odbc_test with password='password', check_policy=off; create user odbc_test for login odbc_test; grant alter, control, delete to odbc_test;" + docker exec sql1 /opt/mssql-tools/bin/sqlcmd -S 127.0.0.1 -U SA -P "" -Q "ALTER SERVER ROLE sysadmin ADD MEMBER odbc_test;" sudo locale-gen de_DE ./.github/scripts/setup-slapd.sh diff --git a/.github/actions/test-linux/action.yml b/.github/actions/test-linux/action.yml index 9b7d0d100608f..7657ff8c85ad2 100644 --- a/.github/actions/test-linux/action.yml +++ b/.github/actions/test-linux/action.yml @@ -30,6 +30,10 @@ runs: export PDO_OCI_TEST_DSN="oci:dbname=localhost/XEPDB1;charset=AL32UTF8" export PGSQL_TEST_CONNSTR="host=postgres dbname=test port=5432 user=postgres password=postgres" export PDO_PGSQL_TEST_DSN="host=postgres dbname=test port=5432 user=postgres password=postgres" + export ODBC_TEST_USER="odbc_test" + export ODBC_TEST_PASS="password" + export ODBC_TEST_DSN="Driver={ODBC Driver 17 for SQL Server};Server=127.0.0.1;Database=master;uid=$ODBC_TEST_USER;pwd=$ODBC_TEST_PASS" + export PDO_ODBC_TEST_DSN="odbc:$ODBC_TEST_DSN" export SKIP_IO_CAPTURE_TESTS=1 export TEST_PHP_JUNIT=junit.out.xml export STACK_LIMIT_DEFAULTS_CHECK=1 From 6024e4aabfcc7e25e5778cee4324159323c6da53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Kocsis?= Date: Tue, 8 Aug 2023 08:48:50 +0200 Subject: [PATCH 3/4] Improve and fix ext/odbc tests Some test failures are fixed, parallelization is enabled, section order is fixed. --- ext/odbc/tests/CONFLICTS | 1 - ext/odbc/tests/bug44618.phpt | 8 ++- ext/odbc/tests/bug47803.phpt | 32 +++++---- ext/odbc/tests/bug60616.phpt | 42 +++++++----- ext/odbc/tests/bug68087.phpt | 18 ++---- ext/odbc/tests/bug69354.phpt | 19 +++--- ext/odbc/tests/bug69975.phpt | 21 +++--- ext/odbc/tests/bug71171.phpt | 21 +++--- ext/odbc/tests/bug73448.phpt | 2 + ext/odbc/tests/bug73725.phpt | 27 ++++---- ext/odbc/tests/odbc_columns_001.phpt | 9 +++ ext/odbc/tests/odbc_data_source_001.phpt | 8 +-- ext/odbc/tests/odbc_exec_001.phpt | 26 ++------ ext/odbc/tests/odbc_exec_002.phpt | 13 ++-- ext/odbc/tests/odbc_fetch_array_001.phpt | 10 ++- ext/odbc/tests/odbc_fetch_into_001.phpt | 12 ++-- ext/odbc/tests/odbc_fetch_object_001.phpt | 8 +-- ext/odbc/tests/odbc_fetch_row_001.phpt | 8 +-- ext/odbc/tests/odbc_field_len_001.phpt | 1 - ext/odbc/tests/odbc_field_name_001.phpt | 1 - ext/odbc/tests/odbc_field_num_001.phpt | 1 - ext/odbc/tests/odbc_field_precision_001.phpt | 1 - ext/odbc/tests/odbc_field_scale_001.phpt | 1 - ext/odbc/tests/odbc_field_type_001.phpt | 1 - ext/odbc/tests/odbc_free_result_001.phpt | 13 ++-- ext/odbc/tests/odbc_num_fields_001.phpt | 2 +- ext/odbc/tests/odbc_num_rows_001.phpt | 4 +- ext/odbc/tests/odbc_primarykeys_001.phpt | 68 ++++++++++++++++++-- ext/pdo/tests/bug_36798.phpt | 2 + ext/pdo_odbc/tests/bug80783a.phpt | 4 ++ 30 files changed, 207 insertions(+), 177 deletions(-) delete mode 100644 ext/odbc/tests/CONFLICTS diff --git a/ext/odbc/tests/CONFLICTS b/ext/odbc/tests/CONFLICTS deleted file mode 100644 index a3722b55c518a..0000000000000 --- a/ext/odbc/tests/CONFLICTS +++ /dev/null @@ -1 +0,0 @@ -odbc diff --git a/ext/odbc/tests/bug44618.phpt b/ext/odbc/tests/bug44618.phpt index efead0e995189..ee7b10a7e908e 100644 --- a/ext/odbc/tests/bug44618.phpt +++ b/ext/odbc/tests/bug44618.phpt @@ -3,7 +3,13 @@ Bug #44618 (Fetching may rely on uninitialized data) --EXTENSIONS-- odbc --SKIPIF-- - + --FILE-- 7, 'name'=>'test 7'), array('id'=>6, 'name'=>'test 6'), ); -$sql = "UPDATE FOO +$sql = "UPDATE bug47803 SET [PAR_CHR] = ? WHERE [PAR_ID] = ?"; $result = odbc_prepare($link, $sql); @@ -69,7 +68,7 @@ foreach ($upd_params as &$k) { } odbc_free_result($result); -$sql = "SELECT * FROM FOO WHERE [PAR_ID] = ?"; +$sql = "SELECT * FROM bug47803 WHERE [PAR_ID] = ?"; $result = odbc_prepare($link, $sql); if (!$result) { print ('[sql] prep: '.$sql); @@ -89,6 +88,17 @@ out: if ($result) odbc_free_result($result); odbc_close($link); +?> +--CLEAN-- + --EXPECT-- array(3) { @@ -171,15 +181,3 @@ array(3) { ["PAR_CHR"]=> string(6) "test 7" } ---CLEAN-- - diff --git a/ext/odbc/tests/bug60616.phpt b/ext/odbc/tests/bug60616.phpt index 468d3d5234a42..9c060ebc39f36 100644 --- a/ext/odbc/tests/bug60616.phpt +++ b/ext/odbc/tests/bug60616.phpt @@ -2,12 +2,23 @@ odbc_exec(): Getting accurate unicode data from query --EXTENSIONS-- odbc +mbstring --SKIPIF-- - --FILE-- ---EXPECT-- -EUC-JP matched -ASCII matched --CLEAN-- +--EXPECT-- +EUC-JP matched +ASCII matched + diff --git a/ext/odbc/tests/bug68087.phpt b/ext/odbc/tests/bug68087.phpt index 6d4d4cc0b2bd6..250df2ef5acee 100644 --- a/ext/odbc/tests/bug68087.phpt +++ b/ext/odbc/tests/bug68087.phpt @@ -14,14 +14,11 @@ $id_2_date = '2014-09-24'; $conn = odbc_connect($dsn, $user, $pass); -@odbc_exec($conn, 'CREATE DATABASE odbcTEST'); +odbc_exec($conn, 'CREATE TABLE bug68087 (ID INT, VARCHAR_COL VARCHAR(100), DATE_COL DATE)'); -odbc_exec($conn, 'CREATE TABLE FOO (ID INT, VARCHAR_COL VARCHAR(100), DATE_COL DATE)'); +odbc_exec($conn, "INSERT INTO bug68087(ID, VARCHAR_COL, DATE_COL) VALUES (1, 'hello', '$id_1_date'), (2, 'helloagain', '$id_2_date')"); -odbc_exec($conn, "INSERT INTO FOO(ID, VARCHAR_COL, DATE_COL) VALUES (1, 'hello', '$id_1_date')"); -odbc_exec($conn, "INSERT INTO FOO(ID, VARCHAR_COL, DATE_COL) VALUES (2, 'helloagain', '$id_2_date')"); - -$res = odbc_exec($conn, 'SELECT * FROM FOO ORDER BY ID ASC'); +$res = odbc_exec($conn, 'SELECT * FROM bug68087 ORDER BY ID ASC'); while(odbc_fetch_row($res)) { $id = odbc_result($res, "ID"); @@ -44,16 +41,15 @@ while(odbc_fetch_row($res)) { } ?> ---EXPECT-- -Date_1 matched -Date_2 matched --CLEAN-- +--EXPECT-- +Date_1 matched +Date_2 matched diff --git a/ext/odbc/tests/bug69354.phpt b/ext/odbc/tests/bug69354.phpt index 3aab7aa4e9393..47933576130ab 100644 --- a/ext/odbc/tests/bug69354.phpt +++ b/ext/odbc/tests/bug69354.phpt @@ -11,13 +11,11 @@ include 'config.inc'; $conn = odbc_connect($dsn, $user, $pass); -@odbc_exec($conn, 'CREATE DATABASE odbcTEST'); +odbc_exec($conn, 'CREATE TABLE bug69354 (ID INT, VARCHAR_COL VARCHAR(100))'); -odbc_exec($conn, 'CREATE TABLE FOO (ID INT, VARCHAR_COL VARCHAR(100))'); +odbc_exec($conn, "INSERT INTO bug69354(ID, VARCHAR_COL) VALUES (1, '" . str_repeat("a", 100) . "')"); -odbc_exec($conn, "INSERT INTO FOO(ID, VARCHAR_COL) VALUES (1, '" . str_repeat("a", 100) . "')"); - -$res = odbc_exec($conn,"select VARCHAR_COL from FOO"); +$res = odbc_exec($conn,"SELECT VARCHAR_COL FROM bug69354"); if ($res) { if (odbc_fetch_row($res)) { $ret = odbc_result($res,'varchar_col'); @@ -27,17 +25,16 @@ if ($res) { } } ?> ---EXPECT-- -100 -a -a --CLEAN-- +--EXPECT-- +100 +a +a diff --git a/ext/odbc/tests/bug69975.phpt b/ext/odbc/tests/bug69975.phpt index 3617ee7198062..4ab0613eae947 100644 --- a/ext/odbc/tests/bug69975.phpt +++ b/ext/odbc/tests/bug69975.phpt @@ -9,26 +9,25 @@ odbc include 'config.inc'; $conn = odbc_connect($dsn, $user, $pass); -@odbc_exec($conn, 'CREATE DATABASE odbcTEST'); -odbc_exec($conn, 'CREATE TABLE FOO (ID INT, VARCHAR_COL NVARCHAR(MAX))'); -odbc_exec($conn, "INSERT INTO FOO VALUES (1, 'foo')"); +odbc_exec($conn, 'CREATE TABLE bug69975 (ID INT, VARCHAR_COL NVARCHAR(MAX))'); +odbc_exec($conn, "INSERT INTO bug69975 VALUES (1, 'foo')"); -$result = odbc_exec($conn, "SELECT VARCHAR_COL FROM FOO"); +$result = odbc_exec($conn, "SELECT VARCHAR_COL FROM bug69975"); var_dump(odbc_fetch_array($result)); echo "ready"; ?> +--CLEAN-- + --EXPECT-- array(1) { ["VARCHAR_COL"]=> string(3) "foo" } ready ---CLEAN-- - diff --git a/ext/odbc/tests/bug71171.phpt b/ext/odbc/tests/bug71171.phpt index d2cef550e3b31..029c31962f6f4 100644 --- a/ext/odbc/tests/bug71171.phpt +++ b/ext/odbc/tests/bug71171.phpt @@ -11,33 +11,30 @@ include 'config.inc'; $conn = odbc_connect($dsn, $user, $pass); -@odbc_exec($conn, 'CREATE DATABASE odbcTEST'); +odbc_exec($conn, 'CREATE TABLE bug71171 (ID INT, VARCHAR_COL NVARCHAR(40))'); -odbc_exec($conn, 'CREATE TABLE FOO (ID INT, VARCHAR_COL NVARCHAR(40))'); +odbc_exec($conn, "INSERT INTO bug71171(ID, VARCHAR_COL) VALUES (1, '" . chr(0x81) . "')"); -odbc_exec($conn, "INSERT INTO FOO(ID, VARCHAR_COL) VALUES (1, '" . chr(0x81) . "')"); - -$res = odbc_exec($conn,"SELECT ID FROM FOO WHERE VARCHAR_COL = '" . chr(0x81) . "'"); +$res = odbc_exec($conn,"SELECT ID FROM bug71171 WHERE VARCHAR_COL = '" . chr(0x81) . "'"); if ($res) { while($record = odbc_fetch_array($res)) var_dump($record); } odbc_close($conn); ?> ---EXPECT-- -array(1) { - ["ID"]=> - string(1) "1" -} --CLEAN-- +--EXPECT-- +array(1) { + ["ID"]=> + string(1) "1" +} diff --git a/ext/odbc/tests/bug73448.phpt b/ext/odbc/tests/bug73448.phpt index eae5aa8ec0e98..8ec4456323214 100644 --- a/ext/odbc/tests/bug73448.phpt +++ b/ext/odbc/tests/bug73448.phpt @@ -4,6 +4,8 @@ Bug #73448 odbc_errormsg returns trash, always 513 bytes odbc --SKIPIF-- +--CONFLICTS-- +odbc --FILE-- +--CLEAN-- + --EXPECT-- array(3) { @@ -38,18 +48,7 @@ array(3) { ["i"]=> string(3) "102" ["txt"]=> - string(12) "Müsliriegel" + string(17) "Lorem ipsum dolor" ["k"]=> string(2) "34" } ---CLEAN-- - diff --git a/ext/odbc/tests/odbc_columns_001.phpt b/ext/odbc/tests/odbc_columns_001.phpt index 489d2ccd84ef0..920735b791003 100644 --- a/ext/odbc/tests/odbc_columns_001.phpt +++ b/ext/odbc/tests/odbc_columns_001.phpt @@ -4,6 +4,8 @@ odbc_columns(): Basic test odbc --SKIPIF-- +--CONFLICTS-- +odbc --FILE-- +--CLEAN-- + --EXPECTF-- resource(%d) of type (odbc result) diff --git a/ext/odbc/tests/odbc_data_source_001.phpt b/ext/odbc/tests/odbc_data_source_001.phpt index b546de2cd9d8c..be3c1226b68b9 100644 --- a/ext/odbc/tests/odbc_data_source_001.phpt +++ b/ext/odbc/tests/odbc_data_source_001.phpt @@ -4,10 +4,10 @@ odbc_data_source(): Basic test odbc --SKIPIF-- --FILE-- --FILE-- --EXPECTF-- -Warning: odbc_exec(): Argument #3 must be of type int, string given in %s on line %d - -Warning: odbc_exec(): SQL error: %s in %s on line %d - -Warning: odbc_exec(): Argument #3 must be of type int, string given in %s on line %d - -Warning: odbc_exec(): SQL error: %s in %s on line %d - -Warning: odbc_exec(): SQL error: %s in %s on line %d - -Warning: odbc_exec(): SQL error: %s in %s on line %d - Warning: odbc_exec(): SQL error: %s in %s on line %d Warning: odbc_exec(): SQL error: %s in %s on line %d diff --git a/ext/odbc/tests/odbc_exec_002.phpt b/ext/odbc/tests/odbc_exec_002.phpt index 44c1baad5ac8e..347d633905384 100644 --- a/ext/odbc/tests/odbc_exec_002.phpt +++ b/ext/odbc/tests/odbc_exec_002.phpt @@ -11,14 +11,10 @@ include 'config.inc'; $conn = odbc_connect($dsn, $user, $pass); -odbc_exec($conn, 'CREATE DATABASE odbcTEST'); +odbc_exec($conn, 'CREATE TABLE exec2 (TEST INT)'); +odbc_exec($conn, 'INSERT INTO exec2 VALUES (1), (2)'); -odbc_exec($conn, 'CREATE TABLE FOO (TEST INT)'); - -odbc_exec($conn, 'INSERT INTO FOO VALUES (1)'); -odbc_exec($conn, 'INSERT INTO FOO VALUES (2)'); - -$res = odbc_exec($conn, 'SELECT * FROM FOO'); +$res = odbc_exec($conn, 'SELECT * FROM exec2'); var_dump(odbc_fetch_row($res)); var_dump(odbc_result($res, 'test')); @@ -28,8 +24,7 @@ var_dump(odbc_fetch_array($res)); --EXPECT-- bool(true) diff --git a/ext/odbc/tests/odbc_fetch_array_001.phpt b/ext/odbc/tests/odbc_fetch_array_001.phpt index b212adcb1f49b..bf13ed25e4d64 100644 --- a/ext/odbc/tests/odbc_fetch_array_001.phpt +++ b/ext/odbc/tests/odbc_fetch_array_001.phpt @@ -12,15 +12,13 @@ include 'config.inc'; $conn = odbc_connect($dsn, $user, $pass); odbc_exec($conn, 'CREATE TABLE fetch_array (foo INT)'); -odbc_exec($conn, 'INSERT INTO fetch_array VALUES (1)'); -odbc_exec($conn, 'INSERT INTO fetch_array VALUES (2)'); -odbc_exec($conn, 'INSERT INTO fetch_array VALUES (3)'); +odbc_exec($conn, 'INSERT INTO fetch_array VALUES (1), (2)'); $res = odbc_exec($conn, 'SELECT * FROM fetch_array'); -var_dump(odbc_fetch_array($res, 1)); var_dump(odbc_fetch_array($res)); -var_dump(odbc_fetch_array($res, 3)); +var_dump(odbc_fetch_array($res, 0)); +var_dump(odbc_fetch_array($res, 2)); var_dump(odbc_fetch_array($res, 4)); ?> @@ -41,6 +39,6 @@ array(1) { } array(1) { ["foo"]=> - string(1) "3" + string(1) "2" } bool(false) diff --git a/ext/odbc/tests/odbc_fetch_into_001.phpt b/ext/odbc/tests/odbc_fetch_into_001.phpt index 5053552ce5da7..19f7f79268c58 100644 --- a/ext/odbc/tests/odbc_fetch_into_001.phpt +++ b/ext/odbc/tests/odbc_fetch_into_001.phpt @@ -12,15 +12,10 @@ include 'config.inc'; $conn = odbc_connect($dsn, $user, $pass); odbc_exec($conn, 'CREATE TABLE fetch_into (foo INT)'); -odbc_exec($conn, 'INSERT INTO fetch_into VALUES (1)'); -odbc_exec($conn, 'INSERT INTO fetch_into VALUES (2)'); -odbc_exec($conn, 'INSERT INTO fetch_into VALUES (3)'); +odbc_exec($conn, 'INSERT INTO fetch_into VALUES (1), (2)'); $res = odbc_exec($conn, 'SELECT * FROM fetch_into'); -$arr = []; -var_dump(odbc_fetch_into($res, $arr, 1)); -var_dump($arr); $arr = []; var_dump(odbc_fetch_into($res, $arr)); var_dump($arr); @@ -28,6 +23,9 @@ $arr = []; var_dump(odbc_fetch_into($res, $arr, 0)); var_dump($arr); $arr = []; +var_dump(odbc_fetch_into($res, $arr, 2)); +var_dump($arr); +$arr = []; var_dump(odbc_fetch_into($res, $arr, 4)); var_dump($arr); @@ -52,7 +50,7 @@ array(1) { int(1) array(1) { [0]=> - string(1) "3" + string(1) "2" } bool(false) array(0) { diff --git a/ext/odbc/tests/odbc_fetch_object_001.phpt b/ext/odbc/tests/odbc_fetch_object_001.phpt index 4ea407562eb75..62a8fc3b2c7e5 100644 --- a/ext/odbc/tests/odbc_fetch_object_001.phpt +++ b/ext/odbc/tests/odbc_fetch_object_001.phpt @@ -12,15 +12,13 @@ include 'config.inc'; $conn = odbc_connect($dsn, $user, $pass); odbc_exec($conn, 'CREATE TABLE fetch_object (foo INT)'); -odbc_exec($conn, 'INSERT INTO fetch_object VALUES (1)'); -odbc_exec($conn, 'INSERT INTO fetch_object VALUES (2)'); -odbc_exec($conn, 'INSERT INTO fetch_object VALUES (3)'); +odbc_exec($conn, 'INSERT INTO fetch_object VALUES (1), (2)'); $res = odbc_exec($conn, 'SELECT * FROM fetch_object'); -var_dump(odbc_fetch_object($res, 1)); var_dump(odbc_fetch_object($res)); var_dump(odbc_fetch_object($res, 0)); +var_dump(odbc_fetch_object($res, 2)); var_dump(odbc_fetch_object($res, 4)); ?> @@ -41,6 +39,6 @@ object(stdClass)#%d (%d) { } object(stdClass)#%d (%d) { ["foo"]=> - string(1) "3" + string(1) "2" } bool(false) diff --git a/ext/odbc/tests/odbc_fetch_row_001.phpt b/ext/odbc/tests/odbc_fetch_row_001.phpt index 4cecb513a067f..4e5e6b69d5b88 100644 --- a/ext/odbc/tests/odbc_fetch_row_001.phpt +++ b/ext/odbc/tests/odbc_fetch_row_001.phpt @@ -13,9 +13,7 @@ $conn = odbc_connect($dsn, $user, $pass); odbc_exec($conn, 'CREATE TABLE fetch_row (test INT)'); -odbc_exec($conn, 'INSERT INTO fetch_row VALUES (1)'); -odbc_exec($conn, 'INSERT INTO fetch_row VALUES (2)'); -odbc_exec($conn, 'INSERT INTO fetch_row VALUES (3)'); +odbc_exec($conn, 'INSERT INTO fetch_row VALUES (1), (2)'); $res = odbc_exec($conn, 'SELECT * FROM fetch_row'); @@ -27,7 +25,7 @@ var_dump(odbc_result($res, 'test')); var_dump(odbc_fetch_row($res, null)); var_dump(odbc_result($res, 'test')); -var_dump(odbc_fetch_row($res, 3)); +var_dump(odbc_fetch_row($res, 2)); var_dump(odbc_result($res, 'test')); var_dump(odbc_fetch_row($res, 4)); @@ -48,5 +46,5 @@ string(1) "1" bool(true) string(1) "2" bool(true) -string(1) "3" +string(1) "2" bool(false) diff --git a/ext/odbc/tests/odbc_field_len_001.phpt b/ext/odbc/tests/odbc_field_len_001.phpt index b4697fff75f25..81b6fe9344fd8 100644 --- a/ext/odbc/tests/odbc_field_len_001.phpt +++ b/ext/odbc/tests/odbc_field_len_001.phpt @@ -12,7 +12,6 @@ include 'config.inc'; $conn = odbc_connect($dsn, $user, $pass); odbc_exec($conn, 'CREATE TABLE field_len (foo INT, bar TEXT, baz VARBINARY(50))'); -odbc_exec($conn, "INSERT INTO field_len VALUES (1, 'bar', CONVERT(VARBINARY(50), 'baz'))"); $res = odbc_exec($conn, 'SELECT * FROM field_len'); try { diff --git a/ext/odbc/tests/odbc_field_name_001.phpt b/ext/odbc/tests/odbc_field_name_001.phpt index da34da9e022e1..f26e9cd205629 100644 --- a/ext/odbc/tests/odbc_field_name_001.phpt +++ b/ext/odbc/tests/odbc_field_name_001.phpt @@ -12,7 +12,6 @@ include 'config.inc'; $conn = odbc_connect($dsn, $user, $pass); odbc_exec($conn, 'CREATE TABLE field_name (foo INT, bar INT, baz INT)'); -odbc_exec($conn, 'INSERT INTO field_name VALUES (1, 2, 3)'); $res = odbc_exec($conn, 'SELECT * FROM field_name'); try { diff --git a/ext/odbc/tests/odbc_field_num_001.phpt b/ext/odbc/tests/odbc_field_num_001.phpt index ab4bbcc4d00b3..3191f939fc243 100644 --- a/ext/odbc/tests/odbc_field_num_001.phpt +++ b/ext/odbc/tests/odbc_field_num_001.phpt @@ -12,7 +12,6 @@ include 'config.inc'; $conn = odbc_connect($dsn, $user, $pass); odbc_exec($conn, 'CREATE TABLE field_num (foo INT, bar REAL, baz VARBINARY(50))'); -odbc_exec($conn, "INSERT INTO field_num VALUES (1, 3.14, CONVERT(VARBINARY(50), 'baz'))"); $res = odbc_exec($conn, 'SELECT * FROM field_num'); var_dump(odbc_field_num($res, "foo")); diff --git a/ext/odbc/tests/odbc_field_precision_001.phpt b/ext/odbc/tests/odbc_field_precision_001.phpt index 609401ba263c9..ccbe851f1d6b2 100644 --- a/ext/odbc/tests/odbc_field_precision_001.phpt +++ b/ext/odbc/tests/odbc_field_precision_001.phpt @@ -12,7 +12,6 @@ include 'config.inc'; $conn = odbc_connect($dsn, $user, $pass); odbc_exec($conn, 'CREATE TABLE field_precision (foo INT, bar REAL, baz VARBINARY(50))'); -odbc_exec($conn, "INSERT INTO field_precision VALUES (1, 3.14, CONVERT(VARBINARY(50), 'baz'))"); $res = odbc_exec($conn, 'SELECT * FROM field_precision'); try { diff --git a/ext/odbc/tests/odbc_field_scale_001.phpt b/ext/odbc/tests/odbc_field_scale_001.phpt index 3bb2da8e1c2cb..5fef7c2d9e6a1 100644 --- a/ext/odbc/tests/odbc_field_scale_001.phpt +++ b/ext/odbc/tests/odbc_field_scale_001.phpt @@ -12,7 +12,6 @@ include 'config.inc'; $conn = odbc_connect($dsn, $user, $pass); odbc_exec($conn, 'CREATE TABLE field_scale (foo INT, bar REAL, baz VARBINARY(50))'); -odbc_exec($conn, "INSERT INTO field_scale VALUES (1, 3.14, CONVERT(VARBINARY(50), 'baz'))"); $res = odbc_exec($conn, 'SELECT * FROM field_scale'); try { diff --git a/ext/odbc/tests/odbc_field_type_001.phpt b/ext/odbc/tests/odbc_field_type_001.phpt index 81774c7dbc0ed..374136c4e47b2 100644 --- a/ext/odbc/tests/odbc_field_type_001.phpt +++ b/ext/odbc/tests/odbc_field_type_001.phpt @@ -12,7 +12,6 @@ include 'config.inc'; $conn = odbc_connect($dsn, $user, $pass); odbc_exec($conn, 'CREATE TABLE field_type (foo INT, bar TEXT, baz VARBINARY(50))'); -odbc_exec($conn, "INSERT INTO field_type VALUES (1, 'bar', CONVERT(VARBINARY(50), 'baz'))"); $res = odbc_exec($conn, 'SELECT * FROM field_type'); try { diff --git a/ext/odbc/tests/odbc_free_result_001.phpt b/ext/odbc/tests/odbc_free_result_001.phpt index 653e5a0d9facb..8fc4075581a2f 100644 --- a/ext/odbc/tests/odbc_free_result_001.phpt +++ b/ext/odbc/tests/odbc_free_result_001.phpt @@ -11,15 +11,11 @@ include 'config.inc'; $conn = odbc_connect($dsn, $user, $pass); -odbc_exec($conn, 'CREATE DATABASE odbcTEST'); +odbc_exec($conn, 'CREATE TABLE free_result (TEST INT NOT NULL)'); -odbc_exec($conn, 'CREATE TABLE FOO (TEST INT NOT NULL)'); -odbc_exec($conn, 'ALTER TABLE FOO ADD PRIMARY KEY (TEST)'); +odbc_exec($conn, 'INSERT INTO free_result VALUES (1), (2)'); -odbc_exec($conn, 'INSERT INTO FOO VALUES (1)'); -odbc_exec($conn, 'INSERT INTO FOO VALUES (2)'); - -$res = odbc_exec($conn, 'SELECT * FROM FOO'); +$res = odbc_exec($conn, 'SELECT * FROM free_result'); var_dump(odbc_fetch_row($res)); var_dump(odbc_result($res, 'test')); @@ -44,8 +40,7 @@ try { --EXPECT-- bool(true) diff --git a/ext/odbc/tests/odbc_num_fields_001.phpt b/ext/odbc/tests/odbc_num_fields_001.phpt index b815c971e01cd..f5c55d583a2dd 100644 --- a/ext/odbc/tests/odbc_num_fields_001.phpt +++ b/ext/odbc/tests/odbc_num_fields_001.phpt @@ -1,5 +1,5 @@ --TEST-- -odbc_num_rows(): Getting the number of fields +odbc_num_fields(): Getting the number of fields --EXTENSIONS-- odbc --SKIPIF-- diff --git a/ext/odbc/tests/odbc_num_rows_001.phpt b/ext/odbc/tests/odbc_num_rows_001.phpt index 8c2af1a1f147f..342762f920f7c 100644 --- a/ext/odbc/tests/odbc_num_rows_001.phpt +++ b/ext/odbc/tests/odbc_num_rows_001.phpt @@ -12,9 +12,7 @@ include 'config.inc'; $conn = odbc_connect($dsn, $user, $pass); odbc_exec($conn, 'CREATE TABLE num_rows (test INT)'); -odbc_exec($conn, 'INSERT INTO num_rows VALUES (1)'); -odbc_exec($conn, 'INSERT INTO num_rows VALUES (2)'); -odbc_exec($conn, 'INSERT INTO num_rows VALUES (3)'); +odbc_exec($conn, 'INSERT INTO num_rows VALUES (1), (2), (3)'); $res = odbc_exec($conn, 'SELECT * FROM num_rows'); var_dump(odbc_num_rows($res)); diff --git a/ext/odbc/tests/odbc_primarykeys_001.phpt b/ext/odbc/tests/odbc_primarykeys_001.phpt index 17b42c6ff51eb..543a22733da71 100644 --- a/ext/odbc/tests/odbc_primarykeys_001.phpt +++ b/ext/odbc/tests/odbc_primarykeys_001.phpt @@ -3,9 +3,20 @@ odbc_primarykeys(): Basic test for odbc_primarykeys() --EXTENSIONS-- odbc --SKIPIF-- - ---XFAIL-- -Doesn't work with MS SQL + --FILE-- ---EXPECT-- +--EXPECTF-- +bool(false) +bool(false) bool(false) +array(%d) { + ["TABLE_CAT"]=> + string(%d) "PrimarykeysTest" + ["TABLE_SCHEM"]=> + string(%d) "dbo" + ["TABLE_NAME"]=> + string(%d) "primarykeys" + ["COLUMN_NAME"]=> + string(%d) "test" + ["KEY_SEQ"]=> + string(%d) "1" + ["PK_NAME"]=> + string(%d) "primarykeys_pk" +} +array(%d) { + ["TABLE_CAT"]=> + string(%d) "PrimarykeysTest" + ["TABLE_SCHEM"]=> + string(%d) "dbo" + ["TABLE_NAME"]=> + string(%d) "primarykeys" + ["COLUMN_NAME"]=> + string(%d) "test" + ["KEY_SEQ"]=> + string(%d) "1" + ["PK_NAME"]=> + string(%d) "primarykeys_pk" +} diff --git a/ext/pdo/tests/bug_36798.phpt b/ext/pdo/tests/bug_36798.phpt index dea1a5b92a23c..da258bc87d34d 100644 --- a/ext/pdo/tests/bug_36798.phpt +++ b/ext/pdo/tests/bug_36798.phpt @@ -13,6 +13,8 @@ if (!strncasecmp(getenv('PDOTEST_DSN'), 'oci', strlen('oci'))){ if (!strpos(strtolower(getenv('PDOTEST_DSN')), 'charset=we8mswin1252')) die('skip expected output valid for Oracle with WE8MSWIN1252 character set'); } elseif (!strncasecmp(getenv('PDOTEST_DSN'), 'dblib', strlen('dblib'))) { die('skip not for pdo_dblib'); +} elseif (!strncasecmp(getenv('PDOTEST_DSN'), 'odbc', strlen('odbc'))) { + die('skip not for pdo_odbc'); } ?> diff --git a/ext/pdo_odbc/tests/bug80783a.phpt b/ext/pdo_odbc/tests/bug80783a.phpt index e070cd30c3f36..ba2c3e960d9fb 100644 --- a/ext/pdo_odbc/tests/bug80783a.phpt +++ b/ext/pdo_odbc/tests/bug80783a.phpt @@ -6,6 +6,10 @@ pdo_odbc --FILE-- Date: Tue, 22 Aug 2023 11:01:28 +0200 Subject: [PATCH 4/4] Expose PDO_ODBC_TYPE to userland --- UPGRADING | 3 +++ ext/pdo_odbc/pdo_odbc.c | 3 +++ ext/pdo_odbc/pdo_odbc.stub.php | 9 +++++++++ ext/pdo_odbc/pdo_odbc_arginfo.h | 9 +++++++++ ext/pdo_odbc/tests/bug80783a.phpt | 3 ++- 5 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 ext/pdo_odbc/pdo_odbc.stub.php create mode 100644 ext/pdo_odbc/pdo_odbc_arginfo.h diff --git a/UPGRADING b/UPGRADING index 3e8f694c801eb..5696920d96a7a 100644 --- a/UPGRADING +++ b/UPGRADING @@ -497,6 +497,9 @@ PHP 8.3 UPGRADE NOTES - PCNTL: . SIGINFO +- PDO_ODBC + . PDO_ODBC_TYPE + - PGSQL: . PGSQL_TRACE_SUPPRESS_TIMESTAMPS . PGSQL_TRACE_REGRESS_MODE diff --git a/ext/pdo_odbc/pdo_odbc.c b/ext/pdo_odbc/pdo_odbc.c index 98e684bc5a95b..8e090a397f061 100644 --- a/ext/pdo_odbc/pdo_odbc.c +++ b/ext/pdo_odbc/pdo_odbc.c @@ -25,6 +25,7 @@ #include "pdo/php_pdo_driver.h" #include "php_pdo_odbc.h" #include "php_pdo_odbc_int.h" +#include "pdo_odbc_arginfo.h" /* {{{ pdo_odbc_deps[] */ static const zend_module_dep pdo_odbc_deps[] = { @@ -96,6 +97,8 @@ PHP_MINIT_FUNCTION(pdo_odbc) } #endif + register_pdo_odbc_symbols(module_number); + REGISTER_PDO_CLASS_CONST_LONG("ODBC_ATTR_USE_CURSOR_LIBRARY", PDO_ODBC_ATTR_USE_CURSOR_LIBRARY); REGISTER_PDO_CLASS_CONST_LONG("ODBC_ATTR_ASSUME_UTF8", PDO_ODBC_ATTR_ASSUME_UTF8); REGISTER_PDO_CLASS_CONST_LONG("ODBC_SQL_USE_IF_NEEDED", SQL_CUR_USE_IF_NEEDED); diff --git a/ext/pdo_odbc/pdo_odbc.stub.php b/ext/pdo_odbc/pdo_odbc.stub.php new file mode 100644 index 0000000000000..745be283375da --- /dev/null +++ b/ext/pdo_odbc/pdo_odbc.stub.php @@ -0,0 +1,9 @@ +