summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStanley Sufficool <ssufficool@php.net>2013-10-05 09:54:45 -0700
committerStanley Sufficool <ssufficool@php.net>2013-10-05 10:06:42 -0700
commit5ce23f39d51b1fc53a731d9fd7d419714d3de9fb (patch)
tree7b09f71336fe084bf61a2ce3f8ac6d7cff02f43c
parent93f3ba66a7e238f82706cc38006836022a53aeb4 (diff)
downloadphp-git-5ce23f39d51b1fc53a731d9fd7d419714d3de9fb.tar.gz
FIX BUG #65219 - USE DB not being sent for FreeTDS version < 0.92
FreeTDS <0.92 does not support DBSETLDBNAME option and therefore will not work with SQL Azure. Fallback to dbuse command in letter versions.
-rw-r--r--ext/pdo_dblib/dblib_driver.c30
1 files changed, 12 insertions, 18 deletions
diff --git a/ext/pdo_dblib/dblib_driver.c b/ext/pdo_dblib/dblib_driver.c
index 2aaf3975db..13444b89c3 100644
--- a/ext/pdo_dblib/dblib_driver.c
+++ b/ext/pdo_dblib/dblib_driver.c
@@ -350,9 +350,10 @@ static int pdo_dblib_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRMLS_
DBSETLAPP(H->login, vars[1].optval);
+/* DBSETLDBNAME is only available in FreeTDS 0.92 or above */
#ifdef DBSETLDBNAME
if (vars[3].optval) {
- DBSETLDBNAME(H->login, vars[3].optval);
+ if(FAIL == DBSETLDBNAME(H->login, vars[3].optval)) goto cleanup;
}
#endif
@@ -362,6 +363,16 @@ static int pdo_dblib_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRMLS_
goto cleanup;
}
+/*
+ * FreeTDS < 0.92 does not support the DBSETLDBNAME option
+ * Send use database here after login (Will not work with SQL Azure)
+ */
+#ifndef DBSETLDBNAME
+ if (vars[3].optval) {
+ if(FAIL == dbuse(H->link, vars[3].optval)) goto gleanup;
+ }
+#endif
+
#if PHP_DBLIB_IS_MSSQL
/* dblib do not return more than this length from text/image */
DBSETOPT(H->link, DBTEXTLIMIT, "2147483647");
@@ -377,23 +388,6 @@ static int pdo_dblib_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRMLS_
dbh->max_escaped_char_length = 2;
dbh->alloc_own_columns = 1;
-#if 0
- /* Cache the supported data types from the servers systypes table */
- if(dbcmd(H->link, "select usertype, name from systypes order by usertype") != FAIL) {
- if(dbsqlexec(H->link) != FAIL) {
- dbresults(H->link);
- while (dbnextrow(H->link) == SUCCESS) {
- val = dbdata(H->link, 1);
- add_index_string(pdo_dblib_datatypes, *val, dbdata(H->link, 2), 1);
- }
- }
- /* Throw out any remaining resultsets */
- dbcancel(H-link);
- }
-#endif
-
-
-
cleanup:
for (i = 0; i < nvars; i++) {
if (vars[i].freeme) {