cvs: pecl /pdo_ids informix_driver.c informix_statement.c php_pdo_informix_int.h
| From: | Kellen Bombardier | Date: | Thu, 16 Mar 2006 21:55:42 +0000 |
| Subject: | cvs: pecl /pdo_ids informix_driver.c informix_statement.c php_pdo_informix_int.h | ||
| Groups: | php.pecl.cvs | ||
| Request: | Send a blank email to pecl-cvs+get-5478@lists.php.net to get a copy of this message | ||
kfbombar Thu Mar 16 21:55:42 2006 UTC
Modified files:
/pecl/pdo_ids informix_driver.c informix_statement.c
php_pdo_informix_int.h
Log:
PECL #6717 Fix for seg fault when executing parameterised query
http://cvs.php.net/viewcvs.cgi/pecl/pdo_ids/informix_driver.c?r1=1.4&r2=1.5&diff_format=u
Index: pecl/pdo_ids/informix_driver.c
diff -u pecl/pdo_ids/informix_driver.c:1.4 pecl/pdo_ids/informix_driver.c:1.5
--- pecl/pdo_ids/informix_driver.c:1.4 Thu Nov 24 05:22:35 2005
+++ pecl/pdo_ids/informix_driver.c Thu Mar 16 21:55:42 2006
@@ -19,7 +19,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: informix_driver.c,v 1.4 2005/11/24 05:22:35 dbs Exp $ */
+/* $Id: informix_driver.c,v 1.5 2006/03/16 21:55:42 kfbombar Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -64,8 +64,10 @@
stmt_handle *stmt_res = (stmt_handle *)stmt->driver_data;
int rc;
SQLSMALLINT param_count;
+ UCHAR server_info[30];
+ SQLSMALLINT server_len = 0;
- // in case we need to convert the statement for positional syntax
+ /* in case we need to convert the statement for positional syntax */
int converted_len = 0;
stmt_res->converted_statement = NULL;
@@ -130,8 +132,19 @@
// we're responsible for setting the column_count for the PDO driver.
stmt->column_count = param_count;
- // attach the methods...we are now live, so errors will no longer immediately
- // force cleanup of the stmt driver-specific storage.
+ /* Get the server information:
+ * server_info is in this form:
+ * 0r.01.0000
+ * where r is the major version
+ */
+ rc = SQLGetInfo(conn_res->hdbc, SQL_DBMS_VER, &server_info, sizeof(server_info),
&server_len);
+ /* making char numbers into integers eg. "10" --> 10 or "09" --> 9 */
+ stmt_res->server_ver = (((server_info[0]-'0')*10) + (server_info[1]-'0'));
+
+ /*
+ * Attach the methods...we are now live, so errors will no longer immediately
+ * force cleanup of the stmt driver-specific storage.
+ */
stmt->methods = &informix_stmt_methods;
return TRUE;
http://cvs.php.net/viewcvs.cgi/pecl/pdo_ids/informix_statement.c?r1=1.5&r2=1.6&diff_format=u
Index: pecl/pdo_ids/informix_statement.c
diff -u pecl/pdo_ids/informix_statement.c:1.5 pecl/pdo_ids/informix_statement.c:1.6
--- pecl/pdo_ids/informix_statement.c:1.5 Mon Mar 6 20:27:59 2006
+++ pecl/pdo_ids/informix_statement.c Thu Mar 16 21:55:42 2006
@@ -19,7 +19,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: informix_statement.c,v 1.5 2006/03/06 20:27:59 kfbombar Exp $ */
+/* $Id: informix_statement.c,v 1.6 2006/03/16 21:55:42 kfbombar Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -96,15 +96,26 @@
param_res = (param_node *)emalloc(sizeof(param_node));
check_stmt_allocation(param_res, "stmt_get_parameter", "Unable to allocate
parameter driver data");
- // get the statement specifics
+ /* get the statement specifics */
stmt_res = (stmt_handle *)stmt->driver_data;
- // NB: The PDO parameter numbers are origin zero, but the SQLDescribeParam()
- // ones start with 1.
- rc = SQLDescribeParam((SQLHSTMT)stmt_res->hstmt, (SQLUSMALLINT)param->paramno + 1,
¶m_res->data_type,
- ¶m_res->param_size, ¶m_res->scale, ¶m_res->nullable);
- check_stmt_error(rc, "SQLDescribeParam");
- // only attach this if we succeed
+ /* checks the server version for correct SQL column meta call */
+ if (stmt_res->server_ver >= 9)
+ {
+ /*
+ * NB: The PDO parameter numbers are origin zero, but the SQLDescribeParam()
+ * ones start with 1.
+ */
+ rc = SQLDescribeParam((SQLHSTMT)stmt_res->hstmt, (SQLUSMALLINT)param->paramno + 1,
¶m_res->data_type,
+ ¶m_res->param_size, ¶m_res->scale, ¶m_res->nullable);
+ check_stmt_error(rc, "SQLDescribeParam");
+ }
+ else
+ {
+ param_res->data_type = SQL_C_CHAR;
+ }
+
+ /* only attach this if we succeed */
param->driver_data = param_res;
// but see if we need to alter this for binary forms or
http://cvs.php.net/viewcvs.cgi/pecl/pdo_ids/php_pdo_informix_int.h?r1=1.2&r2=1.3&diff_format=u
Index: pecl/pdo_ids/php_pdo_informix_int.h
diff -u pecl/pdo_ids/php_pdo_informix_int.h:1.2 pecl/pdo_ids/php_pdo_informix_int.h:1.3
--- pecl/pdo_ids/php_pdo_informix_int.h:1.2 Thu Nov 24 05:22:35 2005
+++ pecl/pdo_ids/php_pdo_informix_int.h Thu Mar 16 21:55:42 2006
@@ -19,7 +19,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_pdo_informix_int.h,v 1.2 2005/11/24 05:22:35 dbs Exp $ */
+/* $Id: php_pdo_informix_int.h,v 1.3 2006/03/16 21:55:42 kfbombar Exp $ */
#ifndef PHP_PDO_INFORMIX_INT_H
#define PHP_PDO_INFORMIX_INT_H
@@ -131,13 +131,13 @@
typedef struct _stmt_handle_struct
{
- SQLHANDLE hstmt; // the statement handle associated with the stmt
-
- int executing; // an executing state flag for error cleanup
- char *converted_statement; // temporary version of the statement with parameter
replacement
- char *lob_buffer; // buffer used for reading in LOB parameters
- column_data *columns; // the column descriptors
- enum pdo_cursor_type cursor_type; // the type of cursor we support.
+ SQLHANDLE hstmt; /* the statement handle associated with the stmt */
+ int executing; /* an executing state flag for error cleanup */
+ char *converted_statement; /* temporary version of the statement with parameter replacement */
+ char *lob_buffer; /* buffer used for reading in LOB parameters */
+ column_data *columns; /* the column descriptors */
+ enum pdo_cursor_type cursor_type; /* the type of cursor we support. */
+ SQLSMALLINT server_ver; /* The server version */
} stmt_handle;