@@ -456,10 +456,9 @@ flex_table_t &output_flex_t::create_flex_table()
456456 throw fmt_error (" Table with name '{}' already exists." , table_name);
457457 }
458458
459- m_tables->emplace_back (table_name);
460- auto &new_table = m_tables->back ();
459+ auto &new_table = m_tables->emplace_back (table_name);
461460
462- lua_pop (lua_state (), 1 );
461+ lua_pop (lua_state (), 1 ); // "name"
463462
464463 // optional "schema" field
465464 lua_getfield (lua_state (), -1 , " schema" );
@@ -609,14 +608,17 @@ void output_flex_t::setup_flex_table_columns(flex_table_t *table)
609608 lua_state (), " sql_type" , -3 , " Column entry" , " " );
610609
611610 auto &column = table->add_column (name, type, sql_type);
611+ lua_pop (lua_state (), 3 ); // "type", "column", "sql_type"
612612
613- column.set_not_null (luaX_get_table_bool (lua_state (), " not_null" , -4 ,
613+ column.set_not_null (luaX_get_table_bool (lua_state (), " not_null" , -1 ,
614614 " Entry 'not_null'" , false ));
615+ lua_pop (lua_state (), 1 ); // "not_null"
615616
616617 column.set_create_only (luaX_get_table_bool (
617- lua_state (), " create_only" , -5 , " Entry 'create_only'" , false ));
618+ lua_state (), " create_only" , -1 , " Entry 'create_only'" , false ));
619+ lua_pop (lua_state (), 1 ); // "create_only"
618620
619- lua_getfield (lua_state (), -6 , " projection" );
621+ lua_getfield (lua_state (), -1 , " projection" );
620622 if (!lua_isnil (lua_state (), -1 )) {
621623 if (column.is_geometry_column () ||
622624 column.type () == table_column_type::area) {
@@ -626,9 +628,8 @@ void output_flex_t::setup_flex_table_columns(flex_table_t *table)
626628 " geometry and area columns." };
627629 }
628630 }
631+ lua_pop (lua_state (), 1 ); // "projection"
629632
630- // stack has: projection, create_only, not_null, sql_type, column, type
631- lua_pop (lua_state (), 6 );
632633 ++num_columns;
633634 });
634635
@@ -1445,7 +1446,7 @@ output_flex_t::output_flex_t(std::shared_ptr<middle_query_t> const &mid,
14451446 log_debug (" - TABLE {}" , qualified_name (table.schema (), table.name ()));
14461447 log_debug (" - columns:" );
14471448 for (auto const &column : table) {
1448- log_debug (" - \ " {}\ " {} ({}) not_null={} create_only={}" ,
1449+ log_debug (R"( - "{}" {} ({}) not_null={} create_only={}) " ,
14491450 column.name (), column.type_name (), column.sql_type_name (),
14501451 column.not_null (), column.create_only ());
14511452 }
0 commit comments