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

Function dbtable_emit_int

lua/sp.c:2571–2600  ·  view source on GitHub ↗

dbtable_emit = db_exec + dbstmt_emit

Source from the content-addressed store, hash-verified

2569
2570// dbtable_emit = db_exec + dbstmt_emit
2571static int dbtable_emit_int(Lua L, dbtable_t *table)
2572{
2573 char n1[MAXTABLELEN] = {0}, separator[2], n2[MAXTABLELEN];
2574 query_tbl_name(table->table_name, n1, separator, n2);
2575
2576 char sql[128];
2577 sprintf(sql, "select * from %s%s\"%s\"", n1, separator, n2);
2578
2579 lua_getglobal(L, "db");
2580 lua_pushstring(L, sql);
2581 db_exec(L);
2582 if (lua_isnumber(L, -1) && lua_tonumber(L, -1) == 0) {
2583 /*
2584 ** Lua stack:
2585 ** 1. number
2586 ** 2. stmt
2587 ** 3. sql string
2588 ** 4. db
2589 */
2590 lua_pop(L, 1);
2591 lua_insert(L, 1);
2592 lua_settop(L, 1);
2593 /*
2594 ** Lua stack:
2595 ** 1. stmt
2596 */
2597 return dbstmt_emit(L);
2598 }
2599 return 1;
2600}
2601
2602static int dbtable_emit(Lua L)
2603{

Callers 2

dbtable_emitFunction · 0.85
emit_resultFunction · 0.85

Calls 8

query_tbl_nameFunction · 0.85
lua_pushstringFunction · 0.85
db_execFunction · 0.85
lua_isnumberFunction · 0.85
lua_tonumberFunction · 0.85
lua_insertFunction · 0.85
lua_settopFunction · 0.85
dbstmt_emitFunction · 0.85

Tested by

no test coverage detected