Bugfix - remove unused vars in oracle driver, catch param mismatch in statement:execute()

Sat, 06 Dec 2008 08:40:10 +0000

author
nrich@ii.net
date
Sat, 06 Dec 2008 08:40:10 +0000
changeset 19
b5ec612be4da
parent 18
b705ba343e94
child 20
5ab0b30f8fbd

Bugfix - remove unused vars in oracle driver, catch param mismatch in statement:execute()

dbd/db2/statement.c file | annotate | diff | comparison | revisions
dbd/oracle/statement.c file | annotate | diff | comparison | revisions
--- a/dbd/db2/statement.c	Sat Dec 06 07:35:31 2008 +0000
+++ b/dbd/db2/statement.c	Sat Dec 06 08:40:10 2008 +0000
@@ -65,6 +65,7 @@
     int offset = 0;
     resultset_t *resultset = NULL; 
     bindparams_t *bind; /* variable to read the results */
+    SQLSMALLINT num_params;
 
     SQLCHAR message[SQL_MAX_MESSAGE_LENGTH + 1];
     SQLCHAR sqlstate[SQL_SQLSTATE_SIZE + 1];
@@ -77,6 +78,26 @@
 	return 2;
     }
 
+    rc = SQLNumParams(statement->stmt, &num_params);
+    if (rc != SQL_SUCCESS) {
+        SQLGetDiagRec(SQL_HANDLE_STMT, statement->stmt, 1, sqlstate, &sqlcode, message, SQL_MAX_MESSAGE_LENGTH + 1, &length);
+
+        lua_pushboolean(L, 0);
+        lua_pushfstring(L, DBI_ERR_PREP_STATEMENT, message);
+        return 2;
+    }
+
+    if (num_params != n-1) {
+        /*
+	 * SQLExecute does not handle this condition,
+ 	 * and the client library will fill unset params
+	 * with NULLs
+	 */
+	lua_pushboolean(L, 0);
+        lua_pushfstring(L, DBI_ERR_PARAM_MISCOUNT, num_params, n-1);
+	return 2;
+    }
+
     for (p = 2; p <= n; p++) {
 	int i = p - 1;
 	int type = lua_type(L, p);
--- a/dbd/oracle/statement.c	Sat Dec 06 07:35:31 2008 +0000
+++ b/dbd/oracle/statement.c	Sat Dec 06 08:40:10 2008 +0000
@@ -52,8 +52,6 @@
     int p;
     int errflag = 0;
     const char *errstr = NULL;
-    int expected_params;
-    int num_bind_params = n - 1;
     int num_columns;
     int rc;
 

mercurial