| 1271 | } |
| 1272 | |
| 1273 | static 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 | |
| 1312 | static int disable_global_variables(lua_State *lua) |
| 1313 | { |
no test coverage detected