From b906cb1bc2371fa0b3e52e0bd21ef6734db73d9a Mon Sep 17 00:00:00 2001 From: Yasuo Ohgaki Date: Fri, 30 Mar 2012 09:45:33 +0900 Subject: [PATCH 1/3] Implement Request #47570 libpq's PG_VERSION should be exported to userland --- ext/pgsql/pgsql.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c index d8127af8c107b..54a86a827610c 100644 --- a/ext/pgsql/pgsql.c +++ b/ext/pgsql/pgsql.c @@ -934,6 +934,11 @@ PHP_MINIT_FUNCTION(pgsql) le_result = zend_register_list_destructors_ex(_free_result, NULL, "pgsql result", module_number); le_lofp = zend_register_list_destructors_ex(_free_ptr, NULL, "pgsql large object", module_number); le_string = zend_register_list_destructors_ex(_free_ptr, NULL, "pgsql string", module_number); +#if HAVE_PG_CONFIG_H + /* PG_VERSION - libpq version */ + REGISTER_STRING_CONSTANT("PGSQL_LIBPQ_VERSION", PG_VERSION, CONST_CS | CONST_PERSISTENT); + REGISTER_STRING_CONSTANT("PGSQL_LIBPQ_VERSION_STR", PG_VERSION_STR, CONST_CS | CONST_PERSISTENT); +#endif /* For connection option */ REGISTER_LONG_CONSTANT("PGSQL_CONNECT_FORCE_NEW", PGSQL_CONNECT_FORCE_NEW, CONST_CS | CONST_PERSISTENT); /* For pg_fetch_array() */ @@ -1048,6 +1053,7 @@ PHP_MINFO_FUNCTION(pgsql) php_info_print_table_header(2, "PostgreSQL Support", "enabled"); #if HAVE_PG_CONFIG_H php_info_print_table_row(2, "PostgreSQL(libpq) Version", PG_VERSION); + php_info_print_table_row(2, "PostgreSQL(libpq) ", PG_VERSION_STR); #ifdef HAVE_PGSQL_WITH_MULTIBYTE_SUPPORT php_info_print_table_row(2, "Multibyte character support", "enabled"); #else From 67ba12188f88c06842aa0bd2a7fe151b9bf1396b Mon Sep 17 00:00:00 2001 From: Yasuo Ohgaki Date: Tue, 17 Apr 2012 16:34:47 +0900 Subject: [PATCH 2/3] Add NEWS --- NEWS | 1 + 1 file changed, 1 insertion(+) diff --git a/NEWS b/NEWS index 2eafb98f70a1c..c862a6f4d63f3 100644 --- a/NEWS +++ b/NEWS @@ -788,6 +788,7 @@ PHP NEWS - Postgres: . Fixed bug #60244 (pg_fetch_* functions do not validate that row param is >0). (Ilia) + . Added PGSQL_LIBPQ_VERSION/PGSQL_LIBPQ_VERSION_STR constants. (Yasuo) - Reflection: . Fixed bug #60367 (Reflection and Late Static Binding). (Laruence) From 91737e3873501f0a10658ab8fef9629c916470f1 Mon Sep 17 00:00:00 2001 From: Sherif Ramadan Date: Sun, 6 Jan 2013 00:29:53 -0500 Subject: [PATCH 3/3] Fixes Bug #63916 PDO::PARAM_INT casts to 32bit int internally even on 64bit builds in pdo_sqlite. --- ext/pdo/tests/bug_63916.phpt | 26 ++++++++++++++++++++++++++ ext/pdo_sqlite/sqlite_statement.c | 10 ++++++++-- 2 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 ext/pdo/tests/bug_63916.phpt diff --git a/ext/pdo/tests/bug_63916.phpt b/ext/pdo/tests/bug_63916.phpt new file mode 100644 index 0000000000000..6f130cbd3dd75 --- /dev/null +++ b/ext/pdo/tests/bug_63916.phpt @@ -0,0 +1,26 @@ +--TEST-- +Bug #63916 PDO::PARAM_INT casts to 32bit int internally even on 64bit builds in pdo_sqlite +--SKIPIF-- + +--FILE-- +query('CREATE TABLE users (id INTEGER NOT NULL, num INTEGER NOT NULL, PRIMARY KEY(id))'); + +$stmt = $conn->prepare('insert into users (id, num) values (:id, :num)'); +$stmt->bindValue(':id', 1, PDO::PARAM_INT); +$stmt->bindValue(':num', $num, PDO::PARAM_INT); +$stmt->execute(); + +$stmt = $conn->query('SELECT num FROM users'); +$result = $stmt->fetchAll(PDO::FETCH_COLUMN); + +var_dump($num,$result[0]); + +?> +--EXPECT-- +int(100004313234244) +string(15) "100004313234244" diff --git a/ext/pdo_sqlite/sqlite_statement.c b/ext/pdo_sqlite/sqlite_statement.c index d5b4df1fda0cb..19f12fe7e54ed 100644 --- a/ext/pdo_sqlite/sqlite_statement.c +++ b/ext/pdo_sqlite/sqlite_statement.c @@ -112,8 +112,14 @@ static int pdo_sqlite_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_d } } else { convert_to_long(param->parameter); - if (SQLITE_OK == sqlite3_bind_int(S->stmt, param->paramno + 1, Z_LVAL_P(param->parameter))) { - return 1; + if (LONG_MAX > 2147483647) { + if (SQLITE_OK == sqlite3_bind_int64(S->stmt, param->paramno + 1, Z_LVAL_P(param->parameter))) { + return 1; + } + } else { + if (SQLITE_OK == sqlite3_bind_int(S->stmt, param->paramno + 1, Z_LVAL_P(param->parameter))) { + return 1; + } } } pdo_sqlite_error_stmt(stmt);