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

Function new_temp_table

lua/sp.c:1273–1310  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1271}
1272
1273static int new_temp_table(Lua lua)
1274{
1275 if (!lua_isstring(lua, 1))
1276 return luabb_error(lua, NULL, "bad argument to 'table'");
1277 if (!lua_istable(lua, 2))
1278 return luabb_error(lua, NULL, "bad argument to 'table'");
1279
1280 const char *name;
1281 pthread_mutex_t *lk;
1282
1283 SP sp = getsp(lua);
1284 sp->clnt->skip_peer_chk = 1;
1285 int rc = create_temp_table(lua, &lk, &name);
1286 sp->clnt->skip_peer_chk = 0;
1287 if (rc == 0) {
1288 // success - create dbtable
1289 dbtable_t *table;
1290 new_lua_t(table, dbtable_t, DBTYPES_DBTABLE);
1291 table->is_temp_tbl = 1;
1292 table->parent = sp->parent;
1293 strcpy(table->table_name, name);
1294
1295 // add to list of tmp tbls
1296 tmptbl_info_t *tmp = malloc(sizeof(tmptbl_info_t));
1297 tmp->lk = lk;
1298 tmp->sql = NULL;
1299 strcpy(tmp->name, name);
1300 LIST_INSERT_HEAD(&sp->tmptbls, tmp, entries);
1301 } else {
1302 // make this fatal for sp
1303 // temptable name may shadow real tbl name and bad things
1304 // will happen if sloppy sp keeps using tbl name
1305 sp->thd->dbopen_gen = -1;
1306 return luaL_error(lua, sp->error);
1307 }
1308 lua_pushinteger(lua, 0);
1309 return 2;
1310}
1311
1312static int disable_global_variables(lua_State *lua)
1313{

Callers 1

db_tableFunction · 0.85

Calls 6

lua_isstringFunction · 0.85
luabb_errorFunction · 0.85
create_temp_tableFunction · 0.85
mallocFunction · 0.85
luaL_errorFunction · 0.85
lua_pushintegerFunction · 0.85

Tested by

no test coverage detected