dbd/db2/statement.c

changeset 25
2cc3feba9277
parent 23
a4825c3e65e9
child 26
cf847efefdb5
equal deleted inserted replaced
24:abb9499bef51 25:2cc3feba9277
1 #include "dbd_db2.h" 1 #include "dbd_db2.h"
2
3 #define BIND_BUFFER_SIZE 1024
2 4
3 static lua_push_type_t db2_to_lua_push(unsigned int db2_type, int len) { 5 static lua_push_type_t db2_to_lua_push(unsigned int db2_type, int len) {
4 lua_push_type_t lua_type; 6 lua_push_type_t lua_type;
5 7
6 if (len == SQL_NULL_DATA) 8 if (len == SQL_NULL_DATA)
78 int p; 80 int p;
79 int i; 81 int i;
80 int errflag = 0; 82 int errflag = 0;
81 const char *errstr = NULL; 83 const char *errstr = NULL;
82 SQLRETURN rc = SQL_SUCCESS; 84 SQLRETURN rc = SQL_SUCCESS;
83 unsigned char b[1024]; 85 unsigned char b[BIND_BUFFER_SIZE];
84 unsigned char *buffer = &b[0]; 86 unsigned char *buffer = &b[0];
85 int offset = 0; 87 int offset = 0;
86 resultset_t *resultset = NULL; 88 resultset_t *resultset = NULL;
87 bindparams_t *bind; /* variable to read the results */ 89 bindparams_t *bind; /* variable to read the results */
88 SQLSMALLINT num_params; 90 SQLSMALLINT num_params;
114 * with NULLs 116 * with NULLs
115 */ 117 */
116 lua_pushboolean(L, 0); 118 lua_pushboolean(L, 0);
117 lua_pushfstring(L, DBI_ERR_PARAM_MISCOUNT, num_params, n-1); 119 lua_pushfstring(L, DBI_ERR_PARAM_MISCOUNT, num_params, n-1);
118 return 2; 120 return 2;
121 }
122
123 if (num_params > (BIND_BUFFER_SIZE/sizeof(double))) {
124 luaL_error(L, "Too many bind params: %d", num_params);
119 } 125 }
120 126
121 for (p = 2; p <= n; p++) { 127 for (p = 2; p <= n; p++) {
122 int i = p - 1; 128 int i = p - 1;
123 int type = lua_type(L, p); 129 int type = lua_type(L, p);

mercurial