| 5242 | } |
| 5243 | |
| 5244 | static int create_sp_int(SP sp, char **err) |
| 5245 | { |
| 5246 | Lua lua; |
| 5247 | |
| 5248 | sp->mspace = lua_mem_init(); |
| 5249 | lua = lua_newstate(lua_alloc, sp->mspace); |
| 5250 | |
| 5251 | lua_setsp(lua, sp); |
| 5252 | luaL_openlibs(lua); |
| 5253 | lua_atpanic(lua, l_panic); |
| 5254 | |
| 5255 | sp->lua = lua; |
| 5256 | sp->max_num_instructions = gbl_max_lua_instructions; |
| 5257 | LIST_INIT(&sp->dbstmts); |
| 5258 | LIST_INIT(&sp->tmptbls); |
| 5259 | |
| 5260 | init_db_funcs(lua); |
| 5261 | init_dbtable_funcs(lua); |
| 5262 | init_dbstmt_funcs(lua); |
| 5263 | init_dbthread_funcs(lua); |
| 5264 | init_dbconsumer_funcs(lua); |
| 5265 | init_dbtypes(lua); |
| 5266 | add_thd_funcs(lua); |
| 5267 | |
| 5268 | lua_newtable(lua); |
| 5269 | lua_setglobal(lua, "_SP"); |
| 5270 | |
| 5271 | if (!gbl_allow_lua_print) { |
| 5272 | if (luaL_dostring(lua, "function print(...) end") != 0) { |
| 5273 | *err = strdup(lua_tostring(lua, -1)); |
| 5274 | close_sp_int(sp, 1); |
| 5275 | return -1; |
| 5276 | } |
| 5277 | } |
| 5278 | |
| 5279 | if(!gbl_allow_lua_dynamic_libs) |
| 5280 | disable_global_variables(lua); |
| 5281 | |
| 5282 | sp->had_allow_lua_dynamic_libs = gbl_allow_lua_dynamic_libs; |
| 5283 | |
| 5284 | /* To be given as lrl value. */ |
| 5285 | lua_sethook(lua, InstructionCountHook, LUA_MASKCOUNT, 1); |
| 5286 | return 0; |
| 5287 | } |
| 5288 | |
| 5289 | static SP create_sp(char **err) |
| 5290 | { |
no test coverage detected