# HG changeset patch # User nrich@ii.net # Date 1228552810 0 # Node ID b5ec612be4da300b756e72d53bf2258dfa06c71c # Parent b705ba343e94b8077b43846ad121d9c4a1f70b9c Bugfix - remove unused vars in oracle driver, catch param mismatch in statement:execute() diff -r b705ba343e94 -r b5ec612be4da dbd/db2/statement.c --- 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); diff -r b705ba343e94 -r b5ec612be4da dbd/oracle/statement.c --- 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;