diff options
author | Matteo Beccati <mbeccati@php.net> | 2013-05-31 16:26:38 +0200 |
---|---|---|
committer | Matteo Beccati <mbeccati@php.net> | 2013-05-31 16:26:38 +0200 |
commit | 598e2690b81a145589f6dfe06f77d9e3b66a7853 (patch) | |
tree | eba255d683b985b3c34d4eeb7218cc6b19aadbe5 | |
parent | 1c623e3b07128e78362911ff5754e7eee57fa8bb (diff) | |
parent | bf4a034e3e506799ecf4d20247533eec4ee94875 (diff) | |
download | php-git-598e2690b81a145589f6dfe06f77d9e3b66a7853.tar.gz |
Merge branch 'pull-request/309' into PHP-5.3
-rw-r--r-- | NEWS | 8 | ||||
-rw-r--r-- | ext/pdo_firebird/firebird_statement.c | 11 | ||||
-rw-r--r-- | ext/pdo_firebird/tests/bug_62024.phpt | 51 | ||||
-rw-r--r-- | ext/pdo_firebird/tests/bug_64037.phpt | 45 |
4 files changed, 110 insertions, 5 deletions
@@ -2,8 +2,14 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ?? ??? 2013, PHP 5.3.27 +- PDO_firebird: + . Fixed bug #64037 (Firebird return wrong value for numeric field). + (Matheus Degiovani, Matteo) + . Fixed bug #62024 (Cannot insert second row with null using parametrized + query). (patch by james@kenjim.com, Matheus Degiovani, Matteo) + - PDO_pgsql: - . Fixed Bug #64949 (Buffer overflow in _pdo_pgsql_error). (Remi) + . Fixed bug #64949 (Buffer overflow in _pdo_pgsql_error). (Remi) ?? ??? 2013, PHP 5.3.26 diff --git a/ext/pdo_firebird/firebird_statement.c b/ext/pdo_firebird/firebird_statement.c index 5c3e435f7b..2b57cd8ba6 100644 --- a/ext/pdo_firebird/firebird_statement.c +++ b/ext/pdo_firebird/firebird_statement.c @@ -344,7 +344,7 @@ static int firebird_stmt_get_col(pdo_stmt_t *stmt, int colno, char **ptr, /* {{ if (n >= 0) { *len = slprintf(*ptr, CHAR_BUF_LEN, "%" LL_MASK "d.%0*" LL_MASK "d", n / f, -var->sqlscale, n % f); - } else if (n < -f) { + } else if (n <= -f) { *len = slprintf(*ptr, CHAR_BUF_LEN, "%" LL_MASK "d.%0*" LL_MASK "d", n / f, -var->sqlscale, -n % f); } else { @@ -535,12 +535,14 @@ static int firebird_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_dat int force_null; case IS_LONG: - var->sqltype = sizeof(long) == 8 ? SQL_INT64 : SQL_LONG; + /* keep the allow-NULL flag */ + var->sqltype = (sizeof(long) == 8 ? SQL_INT64 : SQL_LONG) | (var->sqltype & 1); var->sqldata = (void*)&Z_LVAL_P(param->parameter); var->sqllen = sizeof(long); break; case IS_DOUBLE: - var->sqltype = SQL_DOUBLE; + /* keep the allow-NULL flag */ + var->sqltype = SQL_DOUBLE | (var->sqltype & 1); var->sqldata = (void*)&Z_DVAL_P(param->parameter); var->sqllen = sizeof(double); break; @@ -560,7 +562,8 @@ static int firebird_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_dat force_null = (Z_STRLEN_P(param->parameter) == 0); } if (!force_null) { - var->sqltype = SQL_TEXT; + /* keep the allow-NULL flag */ + var->sqltype = SQL_TEXT | (var->sqltype & 1); var->sqldata = Z_STRVAL_P(param->parameter); var->sqllen = Z_STRLEN_P(param->parameter); break; diff --git a/ext/pdo_firebird/tests/bug_62024.phpt b/ext/pdo_firebird/tests/bug_62024.phpt new file mode 100644 index 0000000000..e046879c22 --- /dev/null +++ b/ext/pdo_firebird/tests/bug_62024.phpt @@ -0,0 +1,51 @@ +--TEST-- +Bug #62024 Cannot insert second row with null using parametrized query (Firebird PDO) +--SKIPIF-- +<?php extension_loaded("pdo_firebird") or die("skip"); ?> +<?php function_exists("ibase_query") or die("skip"); ?> +--FILE-- +<?php + +require("testdb.inc"); + +$dbh = new PDO("firebird:dbname=$test_base",$user,$password) or die; +$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING); +$value = '2'; +@$dbh->exec('DROP TABLE test_insert'); +$dbh->exec("CREATE TABLE test_insert (ID INTEGER NOT NULL, TEXT VARCHAR(10))"); + +$dbh->commit(); + +//start actual test + +$sql = "insert into test_insert (id, text) values (?, ?)"; +$sttmt = $dbh->prepare($sql); + +$args_ok = array(1, "test1"); +$args_err = array(2, null); + +$res = $sttmt->execute($args_ok); +var_dump($res); + +$res = $sttmt->execute($args_err); +var_dump($res); + +$dbh->commit(); + + +//teardown test data +$sttmt = $dbh->prepare('DELETE FROM test_insert'); +$sttmt->execute(); + +$dbh->commit(); + +$dbh->exec('DROP TABLE test_insert'); + +unset($sttmt); +unset($dbh); + +?> +--EXPECT-- +bool(true) +bool(true) + diff --git a/ext/pdo_firebird/tests/bug_64037.phpt b/ext/pdo_firebird/tests/bug_64037.phpt new file mode 100644 index 0000000000..f7b53e57a3 --- /dev/null +++ b/ext/pdo_firebird/tests/bug_64037.phpt @@ -0,0 +1,45 @@ +--TEST-- +Bug #64037 Firebird return wrong value for numeric field +--SKIPIF-- +<?php extension_loaded("pdo_firebird") or die("skip"); ?> +<?php function_exists("ibase_query") or die("skip"); ?> +--FILE-- +<?php + +require("testdb.inc"); + +$dbh = new PDO("firebird:dbname=$test_base",$user,$password) or die; +$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING); +$value = '2'; +@$dbh->exec('DROP TABLE price'); +$dbh->exec("CREATE TABLE PRICE (ID INTEGER NOT NULL, TEXT VARCHAR(10), COST NUMERIC(15, 2))"); +$dbh->exec("INSERT INTO PRICE (ID, TEXT, COST) VALUES (1, 'test', -1.0)"); +$dbh->exec("INSERT INTO PRICE (ID, TEXT, COST) VALUES (2, 'test', -0.99)"); +$dbh->exec("INSERT INTO PRICE (ID, TEXT, COST) VALUES (3, 'test', -1.01)"); + +$dbh->commit(); + +$query = "SELECT * from price order by ID"; +$stmt = $dbh->prepare($query); +$stmt->execute(); +$rows = $stmt->fetchAll(); +var_dump($rows[0]['COST']); +var_dump($rows[1]['COST']); +var_dump($rows[2]['COST']); + + +$stmt = $dbh->prepare('DELETE FROM price'); +$stmt->execute(); + +$dbh->commit(); + +$dbh->exec('DROP TABLE price'); + +unset($stmt); +unset($dbh); + +?> +--EXPECT-- +string(5) "-1.00" +string(5) "-0.99" +string(5) "-1.01"
\ No newline at end of file |