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

Function comdb2_table

lua/sp.c:1236–1271  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1234}
1235
1236static int comdb2_table(Lua lua)
1237{
1238 if (!lua_isstring(lua, 1))
1239 return luabb_error(lua, getsp(lua), "bad argument to 'table'");
1240 const char *table_name = lua_tostring(lua, 1);
1241 while (isspace(*table_name))
1242 ++table_name;
1243 char n1[MAXTABLELEN], n2[MAXTABLELEN];
1244 if (two_part_tbl_name(table_name, n1, n2) != 0) {
1245 return luabb_error(lua, getsp(lua), "bad argument to 'table'");
1246 }
1247
1248 dbtable_t *dbtable;
1249 new_lua_t(dbtable, dbtable_t, DBTYPES_DBTABLE);
1250 strcpy(dbtable->table_name, table_name);
1251
1252 // figure out if dbtable is a tmp-tbl
1253 if (strcasecmp(n1, "temp") == 0) {
1254 dbtable->is_temp_tbl = 1;
1255 } else if (strcmp(n1, "") == 0) {
1256 // not main.tablename or fdb.tablename
1257 // go through tmp tbls
1258 SP sp = getsp(lua);
1259 tmptbl_info_t *tbl;
1260 LIST_FOREACH(tbl, &sp->tmptbls, entries) {
1261 char n3[MAXTABLELEN], n4[MAXTABLELEN];
1262 two_part_tbl_name(tbl->name, n3, n4);
1263 if (strcasecmp(n2, n4) == 0) {
1264 dbtable->is_temp_tbl = 1;
1265 break;
1266 }
1267 }
1268 }
1269 lua_pushinteger(lua, 0);
1270 return 2;
1271}
1272
1273static int new_temp_table(Lua lua)
1274{

Callers 1

db_tableFunction · 0.85

Calls 4

lua_isstringFunction · 0.85
luabb_errorFunction · 0.85
two_part_tbl_nameFunction · 0.85
lua_pushintegerFunction · 0.85

Tested by

no test coverage detected