From 6d0dec27fa243f20a85c5f4a711c895ef8766dcf Mon Sep 17 00:00:00 2001 From: Tom Van Looy Date: Fri, 25 Dec 2015 11:13:28 +0100 Subject: Remove leftovers of TSRMLS in docs --- ext/pdo_odbc/php_pdo_odbc.h | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'ext/pdo_odbc') diff --git a/ext/pdo_odbc/php_pdo_odbc.h b/ext/pdo_odbc/php_pdo_odbc.h index fb0be1b0b9..7021d912f9 100644 --- a/ext/pdo_odbc/php_pdo_odbc.h +++ b/ext/pdo_odbc/php_pdo_odbc.h @@ -47,16 +47,6 @@ ZEND_BEGIN_MODULE_GLOBALS(pdo_odbc) ZEND_END_MODULE_GLOBALS(pdo_odbc) */ -/* In every utility function you add that needs to use variables - in php_pdo_odbc_globals, call TSRMLS_FETCH(); after declaring other - variables used by that function, or better yet, pass in - after the last function argument and declare your utility function - with after the last declared argument. Always refer to - the globals in your function as PDO_ODBC_G(variable). You are - encouraged to rename these macros something shorter, see - examples in any other php module directory. -*/ - #ifdef ZTS #define PDO_ODBC_G(v) TSRMG(pdo_odbc_globals_id, zend_pdo_odbc_globals *, v) #else -- cgit v1.2.1 From 49493a2dcfb2cd1758b69b13d9006ead3be0e066 Mon Sep 17 00:00:00 2001 From: Lior Kaplan Date: Fri, 1 Jan 2016 19:19:27 +0200 Subject: Happy new year (Update copyright to 2016) --- ext/pdo_odbc/odbc_driver.c | 2 +- ext/pdo_odbc/odbc_stmt.c | 2 +- ext/pdo_odbc/pdo_odbc.c | 2 +- ext/pdo_odbc/php_pdo_odbc.h | 2 +- ext/pdo_odbc/php_pdo_odbc_int.h | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) (limited to 'ext/pdo_odbc') diff --git a/ext/pdo_odbc/odbc_driver.c b/ext/pdo_odbc/odbc_driver.c index 08fafa6a34..f274bf98eb 100644 --- a/ext/pdo_odbc/odbc_driver.c +++ b/ext/pdo_odbc/odbc_driver.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2015 The PHP Group | + | Copyright (c) 1997-2016 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.0 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/ext/pdo_odbc/odbc_stmt.c b/ext/pdo_odbc/odbc_stmt.c index 2b88df81a0..a2a2e2c3c3 100644 --- a/ext/pdo_odbc/odbc_stmt.c +++ b/ext/pdo_odbc/odbc_stmt.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2015 The PHP Group | + | Copyright (c) 1997-2016 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.0 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/ext/pdo_odbc/pdo_odbc.c b/ext/pdo_odbc/pdo_odbc.c index 71b8d489b2..caab771fff 100644 --- a/ext/pdo_odbc/pdo_odbc.c +++ b/ext/pdo_odbc/pdo_odbc.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2015 The PHP Group | + | Copyright (c) 1997-2016 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.0 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/ext/pdo_odbc/php_pdo_odbc.h b/ext/pdo_odbc/php_pdo_odbc.h index 0d296afa2f..d58b795627 100644 --- a/ext/pdo_odbc/php_pdo_odbc.h +++ b/ext/pdo_odbc/php_pdo_odbc.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2015 The PHP Group | + | Copyright (c) 1997-2016 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.0 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/ext/pdo_odbc/php_pdo_odbc_int.h b/ext/pdo_odbc/php_pdo_odbc_int.h index a30ee2be20..d65ae27526 100644 --- a/ext/pdo_odbc/php_pdo_odbc_int.h +++ b/ext/pdo_odbc/php_pdo_odbc_int.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2015 The PHP Group | + | Copyright (c) 1997-2016 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.0 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | -- cgit v1.2.1 From 93dc91b386b53bdd317ea6abd70640e2bbfbaf73 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Sat, 30 Jan 2016 14:56:17 +0100 Subject: Remove version checks PHP_VERSION_ID PHP_API_VERSION ZEND_MODULE_API_NO PHP_MAJOR_VERSION, PHP_MINOR_VERSION ZEND_ENGINE_2 I've left litespeed alone, as it seems to genuinely maintain support for many PHP versions. --- ext/pdo_odbc/pdo_odbc.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'ext/pdo_odbc') diff --git a/ext/pdo_odbc/pdo_odbc.c b/ext/pdo_odbc/pdo_odbc.c index 04326a4a87..0c76ccc25e 100644 --- a/ext/pdo_odbc/pdo_odbc.c +++ b/ext/pdo_odbc/pdo_odbc.c @@ -37,12 +37,10 @@ const zend_function_entry pdo_odbc_functions[] = { /* }}} */ /* {{{ pdo_odbc_deps[] */ -#if ZEND_MODULE_API_NO >= 20050922 static const zend_module_dep pdo_odbc_deps[] = { ZEND_MOD_REQUIRED("pdo") ZEND_MOD_END }; -#endif /* }}} */ /* {{{ pdo_odbc_module_entry */ -- cgit v1.2.1 From 3edd33083c59fcbded55a272abee18ae2946d9ce Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Thu, 10 Mar 2016 08:24:33 +0100 Subject: fix invalid pointer on 64-bit --- ext/pdo_odbc/odbc_driver.c | 2 +- ext/pdo_odbc/pdo_odbc.c | 4 ++-- ext/pdo_odbc/php_pdo_odbc_int.h | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) (limited to 'ext/pdo_odbc') diff --git a/ext/pdo_odbc/odbc_driver.c b/ext/pdo_odbc/odbc_driver.c index eca9544f9f..3a9300c5cd 100644 --- a/ext/pdo_odbc/odbc_driver.c +++ b/ext/pdo_odbc/odbc_driver.c @@ -393,7 +393,7 @@ static int pdo_odbc_handle_factory(pdo_dbh_t *dbh, zval *driver_options) /* {{{ pdo_odbc_db_handle *H; RETCODE rc; int use_direct = 0; - SQLUINTEGER cursor_lib; + zend_ulong cursor_lib; H = pecalloc(1, sizeof(*H), dbh->is_persistent); diff --git a/ext/pdo_odbc/pdo_odbc.c b/ext/pdo_odbc/pdo_odbc.c index 04326a4a87..2cc42934c3 100644 --- a/ext/pdo_odbc/pdo_odbc.c +++ b/ext/pdo_odbc/pdo_odbc.c @@ -66,8 +66,8 @@ ZEND_GET_MODULE(pdo_odbc) #endif #ifdef SQL_ATTR_CONNECTION_POOLING -SQLUINTEGER pdo_odbc_pool_on = SQL_CP_OFF; -SQLUINTEGER pdo_odbc_pool_mode = SQL_CP_ONE_PER_HENV; +zend_ulong pdo_odbc_pool_on = SQL_CP_OFF; +zend_ulong pdo_odbc_pool_mode = SQL_CP_ONE_PER_HENV; #endif #if defined(DB2CLI_VER) && !defined(PHP_WIN32) diff --git a/ext/pdo_odbc/php_pdo_odbc_int.h b/ext/pdo_odbc/php_pdo_odbc_int.h index ce7c786b5f..5306c96822 100644 --- a/ext/pdo_odbc/php_pdo_odbc_int.h +++ b/ext/pdo_odbc/php_pdo_odbc_int.h @@ -176,8 +176,8 @@ void pdo_odbc_init_error_table(void); void pdo_odbc_fini_error_table(void); #ifdef SQL_ATTR_CONNECTION_POOLING -extern SQLUINTEGER pdo_odbc_pool_on; -extern SQLUINTEGER pdo_odbc_pool_mode; +extern zend_ulong pdo_odbc_pool_on; +extern zend_ulong pdo_odbc_pool_mode; #endif enum { -- cgit v1.2.1 From ce9a582d0788b5378ec5a5bbbf87740d23cc913d Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Thu, 10 Mar 2016 08:24:33 +0100 Subject: fix invalid pointer on 64-bit --- ext/pdo_odbc/odbc_driver.c | 2 +- ext/pdo_odbc/pdo_odbc.c | 4 ++-- ext/pdo_odbc/php_pdo_odbc_int.h | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) (limited to 'ext/pdo_odbc') diff --git a/ext/pdo_odbc/odbc_driver.c b/ext/pdo_odbc/odbc_driver.c index eca9544f9f..3a9300c5cd 100644 --- a/ext/pdo_odbc/odbc_driver.c +++ b/ext/pdo_odbc/odbc_driver.c @@ -393,7 +393,7 @@ static int pdo_odbc_handle_factory(pdo_dbh_t *dbh, zval *driver_options) /* {{{ pdo_odbc_db_handle *H; RETCODE rc; int use_direct = 0; - SQLUINTEGER cursor_lib; + zend_ulong cursor_lib; H = pecalloc(1, sizeof(*H), dbh->is_persistent); diff --git a/ext/pdo_odbc/pdo_odbc.c b/ext/pdo_odbc/pdo_odbc.c index 0c76ccc25e..f470b77400 100644 --- a/ext/pdo_odbc/pdo_odbc.c +++ b/ext/pdo_odbc/pdo_odbc.c @@ -64,8 +64,8 @@ ZEND_GET_MODULE(pdo_odbc) #endif #ifdef SQL_ATTR_CONNECTION_POOLING -SQLUINTEGER pdo_odbc_pool_on = SQL_CP_OFF; -SQLUINTEGER pdo_odbc_pool_mode = SQL_CP_ONE_PER_HENV; +zend_ulong pdo_odbc_pool_on = SQL_CP_OFF; +zend_ulong pdo_odbc_pool_mode = SQL_CP_ONE_PER_HENV; #endif #if defined(DB2CLI_VER) && !defined(PHP_WIN32) diff --git a/ext/pdo_odbc/php_pdo_odbc_int.h b/ext/pdo_odbc/php_pdo_odbc_int.h index ce7c786b5f..5306c96822 100644 --- a/ext/pdo_odbc/php_pdo_odbc_int.h +++ b/ext/pdo_odbc/php_pdo_odbc_int.h @@ -176,8 +176,8 @@ void pdo_odbc_init_error_table(void); void pdo_odbc_fini_error_table(void); #ifdef SQL_ATTR_CONNECTION_POOLING -extern SQLUINTEGER pdo_odbc_pool_on; -extern SQLUINTEGER pdo_odbc_pool_mode; +extern zend_ulong pdo_odbc_pool_on; +extern zend_ulong pdo_odbc_pool_mode; #endif enum { -- cgit v1.2.1 From 4df5f79ab52813d3d3d36737628a4f14384c0fa8 Mon Sep 17 00:00:00 2001 From: Elizabeth Marie Smith Date: Thu, 14 Jan 2016 13:19:20 +0100 Subject: Fix ODBC bug for varchars returning with length zero --- ext/pdo_odbc/odbc_stmt.c | 18 +++++++++++++++ ext/pdo_odbc/tests/max_columns.phpt | 46 +++++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 ext/pdo_odbc/tests/max_columns.phpt (limited to 'ext/pdo_odbc') diff --git a/ext/pdo_odbc/odbc_stmt.c b/ext/pdo_odbc/odbc_stmt.c index 6233e63c87..904c345f1b 100644 --- a/ext/pdo_odbc/odbc_stmt.c +++ b/ext/pdo_odbc/odbc_stmt.c @@ -574,6 +574,24 @@ static int odbc_stmt_describe(pdo_stmt_t *stmt, int colno) sizeof(S->cols[colno].colname)-1, &colnamelen, &S->cols[colno].coltype, &colsize, NULL, NULL); + /* This fixes a known issue with SQL Server and (max) lengths, + may affect others as well. If we are SQL_VARCHAR, + SQL_VARBINARY, or SQL_WVARCHAR (or any of the long variations) + and zero is returned from colsize then consider it long */ + if (0 == colsize && + (S->cols[colno].coltype == SQL_VARCHAR || + S->cols[colno].coltype == SQL_LONGVARCHAR || +#ifdef SQL_WVARCHAR + S->cols[colno].coltype == SQL_WVARCHAR || +#endif +#ifdef SQL_WLONGVARCHAR + S->cols[colno].coltype == SQL_WLONGVARCHAR || +#endif + S->cols[colno].coltype == SQL_VARBINARY || + S->cols[colno].coltype == SQL_LONGVARBINARY)) { + S->going_long = 1; + } + if (rc != SQL_SUCCESS) { pdo_odbc_stmt_error("SQLDescribeCol"); if (rc != SQL_SUCCESS_WITH_INFO) { diff --git a/ext/pdo_odbc/tests/max_columns.phpt b/ext/pdo_odbc/tests/max_columns.phpt new file mode 100644 index 0000000000..301fa764ca --- /dev/null +++ b/ext/pdo_odbc/tests/max_columns.phpt @@ -0,0 +1,46 @@ +--TEST-- +PDO ODBC varying character with max/no length +--SKIPIF-- + +--FILE-- +setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT); + +if (false === $db->exec('CREATE TABLE TEST (id INT NOT NULL PRIMARY KEY, data varchar(max))')) { + if (false === $db->exec('CREATE TABLE TEST (id INT NOT NULL PRIMARY KEY, data longtext)')) { + if (false === $db->exec('CREATE TABLE TEST (id INT NOT NULL PRIMARY KEY, data CLOB)')) { + die("BORK: don't know how to create a long column here:\n" . implode(", ", $db->errorInfo())); + } + } +} + +$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + +$sizes = array(32, 64, 128, 253, 254, 255, 256, 257, 258, 512, 1024, 2048, 3998, 3999, 4000); + +$db->beginTransaction(); +$insert = $db->prepare('INSERT INTO TEST VALUES (?, ?)'); +foreach ($sizes as $num) { + $insert->execute(array($num, str_repeat('i', $num))); +} +$insert = null; +$db->commit(); + +foreach ($db->query('SELECT id, data from TEST') as $row) { + $expect = str_repeat('i', $row[0]); + if (strcmp($expect, $row[1])) { + echo "Failed on size $row[id]:\n"; + printf("Expected %d bytes, got %d\n", strlen($expect), strlen($row['data'])); + echo bin2hex($expect) . "\n"; + echo bin2hex($row['data']) . "\n"; + } +} + +echo "Finished\n"; + +--EXPECT-- +Finished -- cgit v1.2.1