| 4296 | } |
| 4297 | |
| 4298 | static int db_num_columns(Lua L) |
| 4299 | { |
| 4300 | luaL_checkudata(L, 1, dbtypes.db); |
| 4301 | int num_cols = luaL_checknumber(L, 2); |
| 4302 | SP sp = getsp(L); |
| 4303 | SP parent = sp->parent; |
| 4304 | struct sqlclntstate *parent_clnt = parent->clnt; |
| 4305 | int num = override_count(parent_clnt); |
| 4306 | if (num && num != num_cols) { |
| 4307 | return luaL_error( |
| 4308 | L, "attempt to change number of columns for typed-statement"); |
| 4309 | } |
| 4310 | Pthread_mutex_lock(parent->emit_mutex); |
| 4311 | if (parent_clnt->osql.sent_column_data) { |
| 4312 | Pthread_mutex_unlock(parent->emit_mutex); |
| 4313 | return luaL_error(L, "attempt to change number of columns"); |
| 4314 | } |
| 4315 | if (num_cols < parent->ntypes) { |
| 4316 | for (int i = num_cols - 1; i < parent->ntypes; ++i) { |
| 4317 | free(parent->clntname[i]); |
| 4318 | parent->clntname[i] = NULL; |
| 4319 | } |
| 4320 | parent->ntypes = num_cols; |
| 4321 | } else { |
| 4322 | new_col_info(sp, num_cols); |
| 4323 | } |
| 4324 | Pthread_mutex_unlock(parent->emit_mutex); |
| 4325 | lua_pushinteger(L, 0); |
| 4326 | return 1; |
| 4327 | } |
| 4328 | |
| 4329 | static int db_reset(lua_State *lua) |
| 4330 | { |
nothing calls this directly
no test coverage detected