MCPcopy Create free account
hub / github.com/bloomberg/comdb2 / db_num_columns

Function db_num_columns

lua/sp.c:4298–4327  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4296}
4297
4298static 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
4329static int db_reset(lua_State *lua)
4330{

Callers

nothing calls this directly

Calls 7

luaL_checkudataFunction · 0.85
luaL_checknumberFunction · 0.85
override_countFunction · 0.85
luaL_errorFunction · 0.85
freeFunction · 0.85
new_col_infoFunction · 0.85
lua_pushintegerFunction · 0.85

Tested by

no test coverage detected