summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorAnatol Belski <ab@php.net>2014-10-08 09:32:19 +0200
committerAnatol Belski <ab@php.net>2014-10-08 09:32:19 +0200
commit9af9f874c7370bc57564846f333677fac5bed020 (patch)
tree3c2c781e22ba456ab37531785570e113d4a703ea /ext
parent62598740aa8e21b304e28988e74241413d08c81d (diff)
parent9ca16fd80950bc92a4a3b3653304906e42b2d518 (diff)
downloadphp-git-9af9f874c7370bc57564846f333677fac5bed020.tar.gz
Merge remote-tracking branch 'origin/master' into native-tls
* origin/master: Add to NEWS Add to NEWS Fix for bug #68087 (ODBC not reading DATE columns correctly) Add to NEWS Add to NEWS Fix for bug #68114 (Build fails on OS X due to undefined symbols) Micro optimization Improved return by reference handling
Diffstat (limited to 'ext')
-rw-r--r--ext/mysqlnd/config9.m47
-rw-r--r--ext/odbc/php_odbc.c5
-rw-r--r--ext/odbc/tests/bug68087.phpt57
3 files changed, 66 insertions, 3 deletions
diff --git a/ext/mysqlnd/config9.m4 b/ext/mysqlnd/config9.m4
index 816f4431f5..1a0136d8db 100644
--- a/ext/mysqlnd/config9.m4
+++ b/ext/mysqlnd/config9.m4
@@ -58,12 +58,17 @@ dnl
AC_CACHE_CHECK([whether whether compiler supports Decimal32/64/128 types], ac_cv_decimal_fp_supported,[
AC_TRY_RUN( [
#include <stdio.h>
+#include <string.h>
int main(int argc, char **argv) {
typedef float dec32 __attribute__((mode(SD)));
dec32 k = 99.49f;
double d2 = (double)k;
- return 0;
+ const char *check_str = "99.49";
+ char print_str[32];
+
+ snprintf(print_str, 32, "%f", d2);
+ return memcmp(print_str, check_str, 5);
}
],[
ac_cv_decimal_fp_supported=yes
diff --git a/ext/odbc/php_odbc.c b/ext/odbc/php_odbc.c
index 240f164354..fe8c88e7ad 100644
--- a/ext/odbc/php_odbc.c
+++ b/ext/odbc/php_odbc.c
@@ -939,14 +939,15 @@ int odbc_bindcols(odbc_result *result TSRMLS_DC)
SQLUSMALLINT colfieldid;
int charextraalloc;
- colfieldid = SQL_COLUMN_DISPLAY_SIZE;
- charextraalloc = 0;
result->values = (odbc_result_value *) safe_emalloc(sizeof(odbc_result_value), result->numcols, 0);
result->longreadlen = ODBCG(defaultlrl);
result->binmode = ODBCG(defaultbinmode);
for(i = 0; i < result->numcols; i++) {
+ charextraalloc = 0;
+ colfieldid = SQL_COLUMN_DISPLAY_SIZE;
+
rc = SQLColAttributes(result->stmt, (SQLUSMALLINT)(i+1), SQL_COLUMN_NAME,
result->values[i].name, sizeof(result->values[i].name), &colnamelen, 0);
rc = SQLColAttributes(result->stmt, (SQLUSMALLINT)(i+1), SQL_COLUMN_TYPE,
diff --git a/ext/odbc/tests/bug68087.phpt b/ext/odbc/tests/bug68087.phpt
new file mode 100644
index 0000000000..3bc18125a6
--- /dev/null
+++ b/ext/odbc/tests/bug68087.phpt
@@ -0,0 +1,57 @@
+--TEST--
+odbc_exec(): Getting accurate date data from query
+--SKIPIF--
+<?php include 'skipif.inc'; ?>
+--FILE--
+<?php
+
+include 'config.inc';
+
+$id_1_date = '2014-09-23';
+$id_2_date = '2014-09-24';
+
+$conn = odbc_connect($dsn, $user, $pass);
+
+@odbc_exec($conn, 'CREATE DATABASE odbcTEST');
+
+odbc_exec($conn, 'CREATE TABLE FOO (ID INT, VARCHAR_COL VARCHAR(100), DATE_COL 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');
+
+while(odbc_fetch_row($res)) {
+ $id = odbc_result($res, "ID");
+ $varchar_col = odbc_result($res, "VARCHAR_COL");
+ $date = odbc_result($res, "DATE_COL");
+
+ if ($id == 1) {
+ if ($date != $id_1_date) {
+ print "Date_1 mismatched\n";
+ } else {
+ print "Date_1 matched\n";
+ }
+ } else {
+ if ($date != $id_2_date) {
+ print "Date_2 mismatched\n";
+ } else {
+ print "Date_2 matched\n";
+ }
+ }
+}
+
+?>
+--EXPECT--
+Date_1 matched
+Date_2 matched
+--CLEAN--
+<?php
+include 'config.inc';
+
+$conn = odbc_connect($dsn, $user, $pass);
+
+odbc_exec($conn, 'DROP TABLE FOO');
+odbc_exec($conn, 'DROP DATABASE odbcTEST');
+
+?>