[PHP-CVS] svn: /php/php-src/trunk/ext/pdo_dblib/ dblib_stmt.c

2010-09-28 Thread Stanley Sufficool
ssufficool   Wed, 29 Sep 2010 00:55:43 +

Revision: http://svn.php.net/viewvc?view=revision&revision=303838

Log:
Remove non C90 quotes

Changed paths:
U   php/php-src/trunk/ext/pdo_dblib/dblib_stmt.c

Modified: php/php-src/trunk/ext/pdo_dblib/dblib_stmt.c
===
--- php/php-src/trunk/ext/pdo_dblib/dblib_stmt.c2010-09-29 00:49:28 UTC 
(rev 303837)
+++ php/php-src/trunk/ext/pdo_dblib/dblib_stmt.c2010-09-29 00:55:43 UTC 
(rev 303838)
@@ -63,15 +63,12 @@
case 108: return "numeric";
case 122: return "smallmoney";
case 127: return "bigint";
-   //case 240: return "hierarchyid";
case 240: return "geometry";
-   //case 240: return "geography";
case 165: return "varbinary";
case 167: return "varchar";
case 173: return "binary";
case 175: return "char";
case 189: return "timestamp";
-   //case 231: return "sysname";
case 231: return "nvarchar";
case 239: return "nchar";
case 241: return "xml";

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP-CVS] svn: /php/php-src/trunk/ext/pdo_dblib/ dblib_stmt.c

2010-09-28 Thread Stanley Sufficool
Will do. Thanks.

On Sun, Sep 26, 2010 at 2:34 PM, Kalle Sommer Nielsen  wrote:
> Hi Stanley
>
> 2010/9/26 Stanley Sufficool :
>> ssufficool                               Sun, 26 Sep 2010 20:16:25 +
>>
>> Revision: http://svn.php.net/viewvc?view=revision&revision=303771
>>
>> Log:
>> Update getColumnMeta native types for SQL Server 2008
>>
>> Changed paths:
>>    U   php/php-src/trunk/ext/pdo_dblib/dblib_stmt.c
>>
>> Modified: php/php-src/trunk/ext/pdo_dblib/dblib_stmt.c
>> ===
>> --- php/php-src/trunk/ext/pdo_dblib/dblib_stmt.c        2010-09-26 16:20:11 
>> UTC (rev 303770)
>> +++ php/php-src/trunk/ext/pdo_dblib/dblib_stmt.c        2010-09-26 20:16:25 
>> UTC (rev 303771)
>> @@ -35,60 +35,47 @@
>>
>>  /* {{{ pdo_dblib_get_field_name
>>  *
>> +               case 127: return "bigint";
>> +               //case 240: return "hierarchyid";
>> +               case 240: return "geometry";
>> +               //case 240: return "geography";
>> +               case 165: return "varbinary";
>> +               case 167: return "varchar";
>> +               case 173: return "binary";
>> +               case 175: return "char";
>> +               case 189: return "timestamp";
>> +               //case 231: return "sysname";
>
> Please use C multi line comments ( /* */ ) or #if 0 blocks for C90
> compatiblity :)
>
> --
> regards,
>
> Kalle Sommer Nielsen
> ka...@php.net
>

--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-CVS] svn: /php/php-src/trunk/ext/pdo_dblib/ dblib_stmt.c

2010-09-26 Thread Kalle Sommer Nielsen
Hi Stanley

2010/9/26 Stanley Sufficool :
> ssufficool                               Sun, 26 Sep 2010 20:16:25 +
>
> Revision: http://svn.php.net/viewvc?view=revision&revision=303771
>
> Log:
> Update getColumnMeta native types for SQL Server 2008
>
> Changed paths:
>    U   php/php-src/trunk/ext/pdo_dblib/dblib_stmt.c
>
> Modified: php/php-src/trunk/ext/pdo_dblib/dblib_stmt.c
> ===
> --- php/php-src/trunk/ext/pdo_dblib/dblib_stmt.c        2010-09-26 16:20:11 
> UTC (rev 303770)
> +++ php/php-src/trunk/ext/pdo_dblib/dblib_stmt.c        2010-09-26 20:16:25 
> UTC (rev 303771)
> @@ -35,60 +35,47 @@
>
>  /* {{{ pdo_dblib_get_field_name
>  *
> +               case 127: return "bigint";
> +               //case 240: return "hierarchyid";
> +               case 240: return "geometry";
> +               //case 240: return "geography";
> +               case 165: return "varbinary";
> +               case 167: return "varchar";
> +               case 173: return "binary";
> +               case 175: return "char";
> +               case 189: return "timestamp";
> +               //case 231: return "sysname";

Please use C multi line comments ( /* */ ) or #if 0 blocks for C90
compatiblity :)

-- 
regards,

Kalle Sommer Nielsen
ka...@php.net

--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] svn: /php/php-src/trunk/ext/pdo_dblib/ dblib_stmt.c

2010-09-26 Thread Stanley Sufficool
ssufficool   Sun, 26 Sep 2010 20:16:25 +

Revision: http://svn.php.net/viewvc?view=revision&revision=303771

Log:
Update getColumnMeta native types for SQL Server 2008

Changed paths:
U   php/php-src/trunk/ext/pdo_dblib/dblib_stmt.c

Modified: php/php-src/trunk/ext/pdo_dblib/dblib_stmt.c
===
--- php/php-src/trunk/ext/pdo_dblib/dblib_stmt.c2010-09-26 16:20:11 UTC 
(rev 303770)
+++ php/php-src/trunk/ext/pdo_dblib/dblib_stmt.c2010-09-26 20:16:25 UTC 
(rev 303771)
@@ -35,60 +35,47 @@

 /* {{{ pdo_dblib_get_field_name
  *
- * Taken from php_mssql_get_field_name
+ * Updated for MSSQL 2008 SR2 extended types
  *
  */
 static char *pdo_dblib_get_field_name(int type)
 {
switch (type) {
-   case SQLBINARY:
-   case SQLVARBINARY:
-   return "blob";
-   break;
-   case SQLCHAR:
-   case SQLVARCHAR:
-   return "char";
-   break;
-   case SQLTEXT:
-   return "text";
-   break;
-   case SQLDATETIME:
-   case SQLDATETIM4:
-   case SQLDATETIMN:
-   return "datetime";
-   break;
-   case SQLDECIMAL:
-   case SQLFLT4:
-   case SQLFLT8:
-   case SQLFLTN:
-   return "real";
-   break;
-   case SQLINT1:
-   case SQLINT2:
-   case SQLINT4:
-   case SQLINTN:
-   return "int";
-   break;
-   case SQLNUMERIC:
-   return "numeric";
-   break;
-   case SQLMONEY:
-   case SQLMONEY4:
-   case SQLMONEYN:
-   return "money";
-   break;
-   case SQLBIT:
-   return "bit";
-   break;
-   case SQLIMAGE:
-   return "image";
-   break;
-#ifdef SQLUNIQUE
-   case SQLUNIQUE:
-   return "uniqueidentifier";
-   break;
-#endif
-   default:
+   case 34: return "image";
+   case 35: return "text";
+   case 36: return "uniqueidentifier";
+   case 40: return "date";
+   case 41: return "time";
+   case 42: return "datetime2";
+   case 43: return "datetimeoffset";
+   case 48: return "tinyint";
+   case 52: return "smallint";
+   case 56: return "int";
+   case 58: return "smalldatetime";
+   case 59: return "real";
+   case 60: return "money";
+   case 61: return "datetime";
+   case 62: return "float";
+   case 98: return "sql_variant";
+   case 99: return "ntext";
+   case 104: return "bit";
+   case 106: return "decimal";
+   case 108: return "numeric";
+   case 122: return "smallmoney";
+   case 127: return "bigint";
+   //case 240: return "hierarchyid";
+   case 240: return "geometry";
+   //case 240: return "geography";
+   case 165: return "varbinary";
+   case 167: return "varchar";
+   case 173: return "binary";
+   case 175: return "char";
+   case 189: return "timestamp";
+   //case 231: return "sysname";
+   case 231: return "nvarchar";
+   case 239: return "nchar";
+   case 241: return "xml";
+   default:
return "unknown";
break;
}

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[PHP-CVS] svn: /php/php-src/trunk/ext/pdo_dblib/ dblib_stmt.c

2010-06-21 Thread Stanley Sufficool
ssufficool   Tue, 22 Jun 2010 02:09:57 +

Revision: http://svn.php.net/viewvc?view=revision&revision=300646

Log:
Fix bug #52134

Bug: http://bugs.php.net/52134 (Open) pdo_dblib returns 40 char strings for int
  
Changed paths:
U   php/php-src/trunk/ext/pdo_dblib/dblib_stmt.c

Modified: php/php-src/trunk/ext/pdo_dblib/dblib_stmt.c
===
--- php/php-src/trunk/ext/pdo_dblib/dblib_stmt.c2010-06-22 00:38:47 UTC 
(rev 300645)
+++ php/php-src/trunk/ext/pdo_dblib/dblib_stmt.c2010-06-22 02:09:57 UTC 
(rev 300646)
@@ -236,7 +236,7 @@
case SQLMONEY4:
case SQLMONEYN: {
DBFLT8 money_value;
-   dbconvert(NULL, coltype, *ptr, *len, SQLFLT8, 
(LPBYTE)&money_value, tmp_len);
+   dbconvert(NULL, coltype, *ptr, *len, SQLFLT8, 
(LPBYTE)&money_value, 8);
*len = spprintf(&tmp_ptr, 0, "%.4f", money_value);
*ptr = tmp_ptr;
break;
@@ -245,14 +245,8 @@
if (dbwillconvert(coltype, SQLCHAR)) {
tmp_len = 32 + (2 * (*len));
tmp_ptr = emalloc(tmp_len);
-
-   *len = dbconvert(NULL, coltype, *ptr, *len, 
SQLCHAR, tmp_ptr, tmp_len);
-
-   if (*len >= 0) {
-   tmp_ptr[*len] = '\0';
-   }
+   *len = dbconvert(NULL, coltype, *ptr, *len, 
SQLCHAR, tmp_ptr, -1);
*ptr = tmp_ptr;
-   *len = tmp_len;
} else {
*len = 0;
*ptr = NULL;

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[PHP-CVS] svn: /php/php-src/trunk/ext/pdo_dblib/ dblib_stmt.c

2010-06-20 Thread Stanley Sufficool
ssufficool   Mon, 21 Jun 2010 06:54:10 +

Revision: http://svn.php.net/viewvc?view=revision&revision=300627

Log:
Fix bug #45876 adding get column meta

Bug: http://bugs.php.net/45876 (Assigned) PDO: DBLIB does not support 
getColumnMeta
  
Changed paths:
U   php/php-src/trunk/ext/pdo_dblib/dblib_stmt.c

Modified: php/php-src/trunk/ext/pdo_dblib/dblib_stmt.c
===
--- php/php-src/trunk/ext/pdo_dblib/dblib_stmt.c2010-06-21 01:59:52 UTC 
(rev 300626)
+++ php/php-src/trunk/ext/pdo_dblib/dblib_stmt.c2010-06-21 06:54:10 UTC 
(rev 300627)
@@ -32,6 +32,69 @@
 #include "php_pdo_dblib_int.h"
 #include "zend_exceptions.h"

+
+/* {{{ pdo_dblib_get_field_name
+ *
+ * Taken from php_mssql_get_field_name
+ *
+ */
+static char *pdo_dblib_get_field_name(int type)
+{
+   switch (type) {
+   case SQLBINARY:
+   case SQLVARBINARY:
+   return "blob";
+   break;
+   case SQLCHAR:
+   case SQLVARCHAR:
+   return "char";
+   break;
+   case SQLTEXT:
+   return "text";
+   break;
+   case SQLDATETIME:
+   case SQLDATETIM4:
+   case SQLDATETIMN:
+   return "datetime";
+   break;
+   case SQLDECIMAL:
+   case SQLFLT4:
+   case SQLFLT8:
+   case SQLFLTN:
+   return "real";
+   break;
+   case SQLINT1:
+   case SQLINT2:
+   case SQLINT4:
+   case SQLINTN:
+   return "int";
+   break;
+   case SQLNUMERIC:
+   return "numeric";
+   break;
+   case SQLMONEY:
+   case SQLMONEY4:
+   case SQLMONEYN:
+   return "money";
+   break;
+   case SQLBIT:
+   return "bit";
+   break;
+   case SQLIMAGE:
+   return "image";
+   break;
+#ifdef SQLUNIQUE
+   case SQLUNIQUE:
+   return "uniqueidentifier";
+   break;
+#endif
+   default:
+   return "unknown";
+   break;
+   }
+}
+/* }}} */
+
 static int dblib_dblib_stmt_cursor_closer(pdo_stmt_t *stmt TSRMLS_DC)
 {
pdo_dblib_stmt *S = (pdo_dblib_stmt*)stmt->driver_data;
@@ -207,7 +270,26 @@
return 1;
 }

+static int pdo_dblib_stmt_get_column_meta(pdo_stmt_t *stmt, long colno, zval 
*return_value TSRMLS_DC)
+{
+   pdo_dblib_stmt *S = (pdo_dblib_stmt*)stmt->driver_data;
+   pdo_dblib_db_handle *H = S->H;
+
+   array_init(return_value);

+   DBTYPEINFO* dbtypeinfo;
+   dbtypeinfo = dbcoltypeinfo(H->link, colno+1);
+
+   add_assoc_long(return_value, "max_length", dbcollen(H->link, colno+1) );
+   add_assoc_long(return_value, "precision", (int) dbtypeinfo->precision );
+   add_assoc_long(return_value, "scale", (int) dbtypeinfo->scale );
+   add_assoc_string(return_value, "column_source", dbcolsource(H->link, 
colno+1), 1);
+   add_assoc_string(return_value, "native_type", 
pdo_dblib_get_field_name(dbcoltype(H->link, colno+1)), 1);
+
+   return 1;
+}
+
+
 struct pdo_stmt_methods dblib_stmt_methods = {
pdo_dblib_stmt_dtor,
pdo_dblib_stmt_execute,
@@ -217,7 +299,7 @@
pdo_dblib_stmt_param_hook,
NULL, /* set attr */
NULL, /* get attr */
-   NULL, /* meta */
+   pdo_dblib_stmt_get_column_meta, /* meta */
pdo_dblib_stmt_next_rowset, /* nextrow */
dblib_dblib_stmt_cursor_closer
 };

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[PHP-CVS] svn: /php/php-src/trunk/ext/pdo_dblib/ dblib_stmt.c

2010-06-02 Thread Felipe Pena
felipe   Wed, 02 Jun 2010 12:20:38 +

Revision: http://svn.php.net/viewvc?view=revision&revision=300089

Log:
- Fixed build and next_rowset prototype

Changed paths:
U   php/php-src/trunk/ext/pdo_dblib/dblib_stmt.c

Modified: php/php-src/trunk/ext/pdo_dblib/dblib_stmt.c
===
--- php/php-src/trunk/ext/pdo_dblib/dblib_stmt.c2010-06-02 10:07:26 UTC 
(rev 300088)
+++ php/php-src/trunk/ext/pdo_dblib/dblib_stmt.c2010-06-02 12:20:38 UTC 
(rev 300089)
@@ -50,14 +50,14 @@
 {
pdo_dblib_stmt *S = (pdo_dblib_stmt*)stmt->driver_data;

-   dblib_dblib_stmt_cursor_closer(stmt);
+   dblib_dblib_stmt_cursor_closer(stmt TSRMLS_CC);

efree(S);

return 1;
 }

-static int pdo_dblib_stmt_next_rowset(pdo_stmt_t *stmt)
+static int pdo_dblib_stmt_next_rowset(pdo_stmt_t *stmt TSRMLS_DC)
 {
pdo_dblib_stmt *S = (pdo_dblib_stmt*)stmt->driver_data;
pdo_dblib_db_handle *H = S->H;
@@ -77,7 +77,6 @@

 static int pdo_dblib_stmt_execute(pdo_stmt_t *stmt TSRMLS_DC)
 {
-   pdo_dbh_t *dbh = stmt->dbh;
pdo_dblib_stmt *S = (pdo_dblib_stmt*)stmt->driver_data;
pdo_dblib_db_handle *H = S->H;
RETCODE ret;
@@ -92,7 +91,7 @@
return 0;
}

-   ret = pdo_dblib_stmt_next_rowset(stmt);
+   ret = pdo_dblib_stmt_next_rowset(stmt TSRMLS_CC);

if (ret == 0) {
return 0;
@@ -109,7 +108,6 @@
 {

RETCODE ret;
-   int i;

pdo_dblib_stmt *S = (pdo_dblib_stmt*)stmt->driver_data;
pdo_dblib_db_handle *H = S->H;

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[PHP-CVS] svn: /php/php-src/trunk/ext/pdo_dblib/ dblib_stmt.c php_pdo_dblib_int.h

2010-05-31 Thread Stanley Sufficool
ssufficool   Mon, 31 May 2010 18:38:22 +

Revision: http://svn.php.net/viewvc?view=revision&revision=32

Log:
Fix bug #50755 & Enable multiple rowsets [DOC]

Bug: http://bugs.php.net/50755 (Open) PDO DBLIB Fails with OOM
  
Changed paths:
U   php/php-src/trunk/ext/pdo_dblib/dblib_stmt.c
U   php/php-src/trunk/ext/pdo_dblib/php_pdo_dblib_int.h

Modified: php/php-src/trunk/ext/pdo_dblib/dblib_stmt.c
===
--- php/php-src/trunk/ext/pdo_dblib/dblib_stmt.c	2010-05-31 18:26:19 UTC (rev 31)
+++ php/php-src/trunk/ext/pdo_dblib/dblib_stmt.c	2010-05-31 18:38:22 UTC (rev 32)
@@ -32,36 +32,46 @@
 #include "php_pdo_dblib_int.h"
 #include "zend_exceptions.h"

-static void free_rows(pdo_dblib_stmt *S TSRMLS_DC)
+static int dblib_dblib_stmt_cursor_closer(pdo_stmt_t *stmt TSRMLS_DC)
 {
-	int i, j;
+	pdo_dblib_stmt *S = (pdo_dblib_stmt*)stmt->driver_data;
+	pdo_dblib_db_handle *H = S->H;
+
+	/* Cancel any pending results */
+	dbcancel(H->link);
+
+	efree(stmt->columns);
+	stmt->columns = NULL;

-	for (i = 0; i < S->nrows; i++) {
-		for (j = 0; j < S->ncols; j++) {
-			pdo_dblib_colval *val = &S->rows[i] + j;
-			if (val->data) {
-efree(val->data);
-val->data = NULL;
-			}
-		}
-	}
-	efree(S->rows);
-	S->rows = NULL;
-	S->nrows = 0;
+	return 1;
 }

 static int pdo_dblib_stmt_dtor(pdo_stmt_t *stmt TSRMLS_DC)
 {
 	pdo_dblib_stmt *S = (pdo_dblib_stmt*)stmt->driver_data;

-	if (S->rows) {
-		free_rows(S TSRMLS_CC);
-	}
-	if (S->cols) {
-		efree(S->cols);
-	}
+	dblib_dblib_stmt_cursor_closer(stmt);
+
 	efree(S);
+
+	return 1;
+}

+static int pdo_dblib_stmt_next_rowset(pdo_stmt_t *stmt)
+{
+	pdo_dblib_stmt *S = (pdo_dblib_stmt*)stmt->driver_data;
+	pdo_dblib_db_handle *H = S->H;
+	RETCODE ret;
+
+	ret = dbresults(H->link);
+
+	if (ret == FAIL || ret == NO_MORE_RESULTS) {
+		return 0;
+	}
+
+	stmt->row_count = DBCOUNT(H->link);
+	stmt->column_count = dbnumcols(H->link);
+
 	return 1;
 }

@@ -70,180 +80,59 @@
 	pdo_dbh_t *dbh = stmt->dbh;
 	pdo_dblib_stmt *S = (pdo_dblib_stmt*)stmt->driver_data;
 	pdo_dblib_db_handle *H = S->H;
-	RETCODE resret, ret;
-	int i, j;
-	int arows;
-	unsigned int size;
+	RETCODE ret;

-	dbsetuserdata(H->link, &S->err);
-
-	if (S->rows) {
-		/* clean them up */
-		free_rows(S TSRMLS_CC);
-	}
-
+	dbsetuserdata(H->link, (BYTE*) &S->err);
+
 	if (FAIL == dbcmd(H->link, stmt->active_query_string)) {
 		return 0;
 	}
+
 	if (FAIL == dbsqlexec(H->link)) {
 		return 0;
 	}

-	resret = dbresults(H->link);
-	if (resret == FAIL) {
+	ret = pdo_dblib_stmt_next_rowset(stmt);
+
+	if (ret == 0) {
 		return 0;
 	}
-
-	ret = dbnextrow(H->link);
-
+
 	stmt->row_count = DBCOUNT(H->link);
-
-if (ret == NO_MORE_ROWS) {
-   return 1;
-}
-
-	if (!S->cols) {
-		S->ncols = dbnumcols(H->link);
-
-		if (S->ncols <= 0) {
-			return 1;
-		}
-
-		S->cols = ecalloc(S->ncols, sizeof(pdo_dblib_col));
-		stmt->column_count = S->ncols;
+	stmt->column_count = dbnumcols(H->link);

-		for (i = 0, j = 0; i < S->ncols; i++) {
-			char *tmp = NULL;
-
-			S->cols[i].coltype = dbcoltype(H->link, i+1);
-			S->cols[i].name = (char*)dbcolname(H->link, i+1);
-
-			if (!strlen(S->cols[i].name)) {
-if (j) {
-	spprintf(&tmp, 0, "computed%d", j++);
-	strlcpy(S->cols[i].name, tmp, strlen(tmp)+1);
-	efree(tmp);
-} else {
-	S->cols[i].name = "computed";
-	j++;
-}
-			}
-
-			S->cols[i].source = (char*)dbcolsource(H->link, i+1);
-			tmp = estrdup(S->cols[i].source ? S->cols[i].source : "");
-			S->cols[i].source = tmp;
-			efree(tmp);
-
-			S->cols[i].maxlen = dbcollen(H->link, i+1);
-		}
-	}
-
-	arows = 100;
-	size = S->ncols * sizeof(pdo_dblib_colval);
-	S->rows = safe_emalloc(arows, size, 0);
-
-	/* let's fetch all the data */
-	do {
-		if (S->nrows >= arows) {
-			arows *= 2;
-			S->rows = erealloc(S->rows, arows * size);
-		}
-		for (i = 0; i < S->ncols; i++) {
-			pdo_dblib_colval *val = &S->rows[S->nrows * S->ncols + i];
-
-			if (dbdatlen(H->link, i+1) == 0 && dbdata(H->link, i+1) == NULL) {
-val->len = 0;
-val->data = NULL;
-			} else {
-switch (S->cols[i].coltype) {
-	case SQLCHAR:
-	case SQLTEXT:
-	case SQLVARBINARY:
-	case SQLBINARY:
-	case SQLIMAGE:
-		val->len = dbdatlen(H->link, i+1);
-		val->data = emalloc(val->len + 1);
-		memcpy(val->data, dbdata(H->link, i+1), val->len);
-		val->data[val->len] = '\0';
-		break;
-	case SQLMONEY:
-	case SQLMONEY4:
-	case SQLMONEYN: {
-		DBFLT8 money_value;
-		dbconvert(NULL, S->cols[i].coltype, dbdata(H->link, i+1), dbdatlen(H->link, i+1), SQLFLT8, (LPBYTE)&money_value, val->len);
-		val->len = spprintf(val->data, 0, "%.4f", money_value);
-		}
-		break;
-	default:
-		if (dbwillconvert(S->cols[i].coltype, SQLCHAR)) {
-			val->len = 32 + (2 * dbdatlen(H->link, i+1));
-			val->data = emalloc(val->len);
-
-			val->len = dbconvert(NULL, S->cols[i].