summaryrefslogtreecommitdiff
path: root/ext/pdo_dblib
diff options
context:
space:
mode:
authorXinchen Hui <laruence@gmail.com>2016-03-01 10:51:36 +0800
committerXinchen Hui <laruence@gmail.com>2016-03-01 10:51:36 +0800
commitdd47b3b9634447ca0b73c0ae262f653391762ddd (patch)
treef632f3c3ac81988a6a6e5b7cc44e9767f1f8036e /ext/pdo_dblib
parent015dbb26a7e4606c146898225a7e47ffdb96f5c7 (diff)
parent9fc0517328a248825703bef90d631ec687fb0d58 (diff)
downloadphp-git-dd47b3b9634447ca0b73c0ae262f653391762ddd.tar.gz
Merge branch 'PHP-7.0'
* PHP-7.0: Fixed another segfault with file_cache_only now Fixed bugs #71317 and #71504 add test for bug #68957 update NEWS update NEWS Fixed #54648 PDO::MSSQL forces format of datetime fields remove unneeded free parts fix leaks and add one more NULL check add NULL check fix C89 compat fix arg type fix nmake clean in phpize mode
Diffstat (limited to 'ext/pdo_dblib')
-rw-r--r--ext/pdo_dblib/dblib_driver.c7
-rw-r--r--ext/pdo_dblib/dblib_stmt.c21
-rw-r--r--ext/pdo_dblib/tests/bug_54648.phpt26
-rw-r--r--ext/pdo_dblib/tests/bug_68957.phpt29
4 files changed, 78 insertions, 5 deletions
diff --git a/ext/pdo_dblib/dblib_driver.c b/ext/pdo_dblib/dblib_driver.c
index cfb386fa0d..dcbaf55a3f 100644
--- a/ext/pdo_dblib/dblib_driver.c
+++ b/ext/pdo_dblib/dblib_driver.c
@@ -331,9 +331,7 @@ static int pdo_dblib_handle_factory(pdo_dbh_t *dbh, zval *driver_options)
,{"auto",0} /* Only works with FreeTDS. Other drivers will bork */
};
-
- nvers = sizeof(tdsver)/sizeof(tdsver[0]);
-
+
struct pdo_data_src_parser vars[] = {
{ "charset", NULL, 0 }
,{ "appname", "PHP " PDO_DBLIB_FLAVOUR, 0 }
@@ -344,7 +342,8 @@ static int pdo_dblib_handle_factory(pdo_dbh_t *dbh, zval *driver_options)
};
nvars = sizeof(vars)/sizeof(vars[0]);
-
+ nvers = sizeof(tdsver)/sizeof(tdsver[0]);
+
php_pdo_parse_data_source(dbh->data_source, dbh->data_source_len, vars, nvars);
if (driver_options) {
diff --git a/ext/pdo_dblib/dblib_stmt.c b/ext/pdo_dblib/dblib_stmt.c
index 484bfbb560..0eff4945dd 100644
--- a/ext/pdo_dblib/dblib_stmt.c
+++ b/ext/pdo_dblib/dblib_stmt.c
@@ -102,7 +102,7 @@ static int pdo_dblib_stmt_cursor_closer(pdo_stmt_t *stmt)
/* Cancel any pending results */
dbcancel(H->link);
-
+
return 1;
}
@@ -268,6 +268,25 @@ static int pdo_dblib_stmt_get_col(pdo_stmt_t *stmt, int colno, char **ptr,
*ptr = tmp_ptr;
break;
}
+ case SQLDATETIM4:
+ case SQLDATETIME: {
+ DBDATETIME dt;
+ DBDATEREC di;
+
+ dbconvert(H->link, coltype, (BYTE*) *ptr, -1, SQLDATETIME, (LPBYTE) &dt, -1);
+ dbdatecrack(H->link, &di, &dt);
+
+ *len = spprintf((char**) &tmp_ptr, 20, "%d-%02d-%02d %02d:%02d:%02d",
+#ifdef PHP_DBLIB_IS_MSSQL || MSDBLIB
+ di.year, di.month, di.day, di.hour, di.minute, di.second
+#else
+ di.dateyear, di.datemonth+1, di.datedmonth, di.datehour, di.dateminute, di.datesecond
+#endif
+ );
+
+ *ptr = (char*) tmp_ptr;
+ break;
+ }
default:
if (dbwillconvert(coltype, SQLCHAR)) {
tmp_len = 32 + (2 * (*len)); /* FIXME: We allocate more than we need here */
diff --git a/ext/pdo_dblib/tests/bug_54648.phpt b/ext/pdo_dblib/tests/bug_54648.phpt
new file mode 100644
index 0000000000..aa9f292669
--- /dev/null
+++ b/ext/pdo_dblib/tests/bug_54648.phpt
@@ -0,0 +1,26 @@
+--TEST--
+PDO_DBLIB: Does not force correct dateformat
+--SKIPIF--
+<?php
+if (!extension_loaded('pdo_dblib')) die('skip not loaded');
+require dirname(__FILE__) . '/config.inc';
+?>
+--FILE--
+<?php
+require dirname(__FILE__) . '/config.inc';
+$db->query('set dateformat ymd');
+$rs = $db->query("select cast('1950-01-18 23:00:00' as smalldatetime) as sdt, cast('2030-01-01 23:59:59' as datetime) as dt");
+var_dump($rs->fetchAll(PDO::FETCH_ASSOC));
+echo "Done.\n";
+?>
+--EXPECT--
+array(1) {
+ [0]=>
+ array(2) {
+ ["sdt"]=>
+ string(19) "1950-01-18 23:00:00"
+ ["dt"]=>
+ string(19) "2030-01-01 23:59:59"
+ }
+}
+Done.
diff --git a/ext/pdo_dblib/tests/bug_68957.phpt b/ext/pdo_dblib/tests/bug_68957.phpt
new file mode 100644
index 0000000000..3d6e2fd13d
--- /dev/null
+++ b/ext/pdo_dblib/tests/bug_68957.phpt
@@ -0,0 +1,29 @@
+--TEST--
+PDO_DBLIB bug #68957 PDO::query doesn't support several queries
+--SKIPIF--
+<?php
+if (!extension_loaded('pdo_dblib')) die('skip not loaded');
+require dirname(__FILE__) . '/config.inc';
+?>
+--FILE--
+<?php
+require dirname(__FILE__) . '/config.inc';
+
+$query = "declare @myInt int = 1; select @myInt;";
+$stmt = $db->query($query);
+$stmt->nextRowset(); // Added line
+$rows = $stmt->fetchAll();
+print_r($rows);
+
+?>
+--EXPECT--
+Array
+(
+ [0] => Array
+ (
+ [computed0] => 1
+ [0] => 1
+ )
+
+)
+