Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug(tianmu): throw exception while execute a union sql #671

Closed
3 tasks done
lujiashun opened this issue Oct 10, 2022 · 5 comments
Closed
3 tasks done

bug(tianmu): throw exception while execute a union sql #671

lujiashun opened this issue Oct 10, 2022 · 5 comments
Assignees
Labels
A-bug Something isn't working C-stonedb-8.0 associated with stonedb 8.0

Comments

@lujiashun
Copy link

lujiashun commented Oct 10, 2022

Have you read the Contributing Guidelines on issues?

Please confirm if bug report does NOT exists already ?

  • I confirm there is no existing issue for this

Describe the problem

execute UNION sql reports "ERROR 1105 (HY000): Tianmu out of memory error", and mysqld throw exception.

backtrace

#0  0x00007f2ed373c672 in __cxa_throw () from /lib/x86_64-linux-gnu/libstdc++.so.6
#1  0x00007f2ed3730522 in ?? () from /lib/x86_64-linux-gnu/libstdc++.so.6
#2  0x0000560aa6219122 in Tianmu::core::TempTable::Union (this=0x7f2968ad2450, t=0x7f2968ad4990, all=0)
    at /data/codebase/stonedb80/stonedb/storage/tianmu/core/temp_table.cpp:1293
#3  0x0000560aa61997d5 in Tianmu::core::Query::Preexecute (this=0x7f2ea41fce80, qu=...,
    sender=0x7f296800e6d0, display_now=true)
    at /data/codebase/stonedb80/stonedb/storage/tianmu/core/query.cpp:869
#4  0x0000560aa616b60c in Tianmu::core::Engine::Execute (this=0x560aabe34af0, thd=0x7f2968001040,
    lex=0x7f29680043c0, result_output=0x7f2968b61660, unit_for_union=0x7f29689a4d80)
    at /data/codebase/stonedb80/stonedb/storage/tianmu/core/engine_execute.cpp:431
#5  0x0000560aa616a5f5 in Tianmu::core::Engine::HandleSelect (this=0x560aabe34af0, thd=0x7f2968001040,
    lex=0x7f29680043c0, result=@0x7f2ea41fd318: 0x7f2968b61660, setup_tables_done_option=0,
    res=@0x7f2ea41fd308: 0, optimize_after_tianmu=@0x7f2ea41fd310: 1,
    tianmu_free_join=@0x7f2ea41fd30c: 0, with_insert=1)
    at /data/codebase/stonedb80/stonedb/storage/tianmu/core/engine_execute.cpp:187
#6  0x0000560aa6084729 in Tianmu::dbhandler::TIANMU_HandleSelect (thd=0x7f2968001040,
    lex=0x7f29680043c0, result=@0x7f2ea41fd318: 0x7f2968b61660, setup_tables_done_option=0,
    res=@0x7f2ea41fd308: 0, optimize_after_tianmu=@0x7f2ea41fd310: 1,
    tianmu_free_join=@0x7f2ea41fd30c: 0, with_insert=1)
--Type <RET> for more, q to quit, c to continue without paging--
   mu/handler/ha_my_tianmu.cpp:81
#7  0x0000560aa4599950 in Sql_cmd_create_table::execute (this=0x7f2968ab4300, thd=0x7f2968001040)
    at /data/codebase/stonedb80/stonedb/sql/sql_cmd_ddl_table.cc:410
#8  0x0000560aa3e38c06 in mysql_execute_command (thd=0x7f2968001040, first_level=true)
    at /data/codebase/stonedb80/stonedb/sql/sql_parse.cc:3577
#9  0x0000560aa3e3e4e2 in dispatch_sql_command (thd=0x7f2968001040, parser_state=0x7f2ea41feb90)
    at /data/codebase/stonedb80/stonedb/sql/sql_parse.cc:5239
#10 0x0000560aa3e33f61 in dispatch_command (thd=0x7f2968001040, com_data=0x7f2ea41ff4e0, command=COM_QUERY)
    at /data/codebase/stonedb80/stonedb/sql/sql_parse.cc:1959
#11 0x0000560aa3e31fd8 in do_command (thd=0x7f2968001040) at /data/codebase/stonedb80/stonedb/sql/sql_parse.cc:1362
#12 0x0000560aa406e8f7 in handle_connection (arg=0x560aae4d9060)
    at /data/codebase/stonedb80/stonedb/sql/conn_handler/connection_handler_per_thread.cc:302
#13 0x0000560aa5f90678 in pfs_spawn_thread (arg=0x560aae505830) at /data/codebase/stonedb80/stonedb/storage/perfschema/pfs.cc:2942
#14 0x00007f2ed4548609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#15 0x00007f2ed3453133 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Expected behavior

operation of "create table" is OK ,and can show the correct result when select the table;

How To Reproduce

CREATE TABLE t1 (f1 VARCHAR(255) CHARACTER SET utf8 )engine=tianmu;
insert into t1 values  ("1") ,("2"),("3");
SELECT LEFT(f1,171) AS f2 FROM t1 UNION SELECT LEFT(f1,171) AS f2 FROM t1;

Environment

root@ub01:~# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.4 LTS
Release: 20.04
Codename: focal

Are you interested in submitting a PR to solve the problem?

  • Yes, I will!
@lujiashun lujiashun added the A-bug Something isn't working label Oct 10, 2022
@lujiashun lujiashun self-assigned this Oct 10, 2022
@lujiashun lujiashun changed the title bug(StoneDB 8.0): throw exception while execute CTAS(with uninon) bug(StoneDB 8.0): throw exception while execute CTAS(with union) Oct 10, 2022
@lujiashun lujiashun added the C-stonedb-8.0 associated with stonedb 8.0 label Oct 10, 2022
@lujiashun
Copy link
Author

can not reproduced now. close it for the time being. reopen if reproduced later.

@lujiashun
Copy link
Author

lujiashun commented Oct 11, 2022

in this case, max_length intial value(Line515) is 513,precision is 675,actual_size(Line524) is 3;
max_length in Line 524 is 515-675+3, it is a negative value

504:void TempTable::VerifyAttrsSizes()  // verifies attr[i].field_size basing on the
505-                                    // current multiindex contents
506-{
507-  for (uint i = 0; i < attrs.size(); i++)
508-    if (ATI::IsStringType(attrs[i]->TypeName())) {
509-      // reduce string size when column defined too large to reduce allocated
510-      // temp memory
511-      if (attrs[i]->term.vc->MaxStringSize() < STRING_LENGTH_THRESHOLD) {
512-        attrs[i]->OverrideStringSize(attrs[i]->term.vc->MaxStringSize());
513-      } else {
514-        vcolumn::VirtualColumn *vc = attrs[i]->term.vc;
515-        int max_length = attrs[i]->term.vc->MaxStringSize();
516-        if (dynamic_cast<vcolumn::ExpressionColumn *>(vc)) {
517-          auto &var_map = dynamic_cast<vcolumn::ExpressionColumn *>(vc)->GetVarMap();
518-          for (auto &it : var_map) {
519-            PhysicalColumn *column = it.GetTabPtr()->GetColumn(it.col_ndx);
520-            ColumnType ct = column->Type();
521-            uint precision = ct.GetPrecision();
522-            if (precision >= STRING_LENGTH_THRESHOLD) {
523-              uint actual_size = column->MaxStringSize() * ct.GetCollation().collation->mbmaxlen;
524-              if (actual_size < precision) max_length += (actual_size - precision);
525-            }
526-          }
527-        }
528-        attrs[i]->OverrideStringSize(max_length);
529-      }
530-    }
531-}

@lujiashun lujiashun changed the title bug(StoneDB 8.0): throw exception while execute CTAS(with union) bug(tianmu): throw exception while execute CTAS(with union) Oct 11, 2022
@lujiashun lujiashun changed the title bug(tianmu): throw exception while execute CTAS(with union) bug(tianmu): throw exception while execute UNION sql Oct 11, 2022
@lujiashun lujiashun changed the title bug(tianmu): throw exception while execute UNION sql bug(tianmu): throw exception while execute a UNION sql Oct 11, 2022
@lujiashun lujiashun changed the title bug(tianmu): throw exception while execute a UNION sql bug(tianmu): throw exception while execute a union sql Oct 11, 2022
@hustjieke hustjieke added this to the stonedb_8.0_v1.0.0 milestone Oct 12, 2022
@hustjieke hustjieke moved this from Done to In Progress in StoneDB for MySQL 8.0 Oct 12, 2022
@lujiashun
Copy link
Author

(gdb) b VerifyAttrsSizes
c
Breakpoint 1 at 0x55555b655f48: file /data/codebase/stonedb80/stonedb/storage/tianmu/core/temp_table_low.cpp, line 506.
(gdb) c
Continuing.
[Switching to Thread 0x7fffc8491700 (LWP 1788691)]

Thread 187 "connection" hit Breakpoint 1, Tianmu::core::TempTable::VerifyAttrsSizes (this=0x7ffa84aa03a0)
    at /data/codebase/stonedb80/stonedb/storage/tianmu/core/temp_table_low.cpp:506
506     {
(gdb) n
507       for (uint i = 0; i < attrs.size(); i++)
(gdb) n
508         if (ATI::IsStringType(attrs[i]->TypeName())) {
(gdb) n
511           if (attrs[i]->term.vc->MaxStringSize() < STRING_LENGTH_THRESHOLD) {
(gdb) n
512             attrs[i]->OverrideStringSize(attrs[i]->term.vc->MaxStringSize());
(gdb) n
507       for (uint i = 0; i < attrs.size(); i++)
(gdb) n
531     }
(gdb) c
Continuing.

Thread 187 "connection" hit Breakpoint 1, Tianmu::core::TempTable::VerifyAttrsSizes (this=0x7ffa84a9fbd0)
    at /data/codebase/stonedb80/stonedb/storage/tianmu/core/temp_table_low.cpp:506
506     {
(gdb) n
507       for (uint i = 0; i < attrs.size(); i++)
(gdb) n
508         if (ATI::IsStringType(attrs[i]->TypeName())) {
(gdb) n
511           if (attrs[i]->term.vc->MaxStringSize() < STRING_LENGTH_THRESHOLD) {
(gdb) n
514             vcolumn::VirtualColumn *vc = attrs[i]->term.vc;
(gdb) n
515             int max_length = attrs[i]->term.vc->MaxStringSize();
(gdb) c
Continuing.

Thread 187 "connection" hit Breakpoint 1, Tianmu::core::TempTable::VerifyAttrsSizes (this=0x7ffa84a9fbd0)
    at /data/codebase/stonedb80/stonedb/storage/tianmu/core/temp_table_low.cpp:506
506     {
(gdb) n
507       for (uint i = 0; i < attrs.size(); i++)
(gdb) bt
#0  Tianmu::core::TempTable::VerifyAttrsSizes (this=0x7ffa84a9fb40) at /data/codebase/stonedb80/stonedb/storage/tianmu/core/temp_table_low.cpp:507
#1  0x000055555b63cf70 in Tianmu::core::TempTable::Materialize (this=0x7ffa84a9fb40, in_subq=false, sender=0x0, lazy=false)
    at /data/codebase/stonedb80/stonedb/storage/tianmu/core/temp_table.cpp:1914
#2  0x000055555b637fa7 in Tianmu::core::TempTable::Union (this=0x7ffa84a9fb40, t=0x7ffa84aa0310, all=0)
    at /data/codebase/stonedb80/stonedb/storage/tianmu/core/temp_table.cpp:1247
#3  0x000055555b5b8e79 in Tianmu::core::Query::Preexecute (this=0x7fffc848c180, qu=..., sender=0x7ffa84028b50, display_now=true)
    at /data/codebase/stonedb80/stonedb/storage/tianmu/core/query.cpp:870
#4  0x000055555b554c9d in Tianmu::core::Engine::Execute (this=0x55556123fec0, thd=0x7ffa84001040, lex=0x7ffa840043c0, result_output=0x7ffa84998440,
    unit_for_union=0x7ffa84993e00) at /data/codebase/stonedb80/stonedb/storage/tianmu/core/engine.cpp:2342
#5  0x000055555b553f2d in Tianmu::core::Engine::Handle_Query (this=0x55556123fec0, thd=0x7ffa84001040, qe=0x7ffa84993e00,
    result=@0x7ffa84998430: 0x7ffa84998440, setup_tables_done_option=0, res=@0x7fffc848c620: 0, optimize_after_tianmu=@0x7fffc848c690: 1,
    tianmu_free_join=@0x7fffc848c624: 0, with_insert=0) at /data/codebase/stonedb80/stonedb/storage/tianmu/core/engine.cpp:2149
#6  0x000055555b4a5d0c in Tianmu::DBHandler::Tianm_Handle_Query (thd=0x7ffa84001040, qe=0x7ffa84993e00, result=@0x7ffa84998430: 0x7ffa84998440,
    setup_tables_done_option=0, res=@0x7fffc848c620: 0, optimize_after_tianmu=@0x7fffc848c690: 1, tianmu_free_join=@0x7fffc848c624: 0, with_insert=0)
    at /data/codebase/stonedb80/stonedb/storage/tianmu/handler/ha_my_tianmu.cpp:88
#7  0x00005555592e66aa in Sql_cmd_dml::execute (this=0x7ffa84998408, thd=0x7ffa84001040) at /data/codebase/stonedb80/stonedb/sql/sql_select.cc:561
#8  0x000055555925d73d in mysql_execute_command (thd=0x7ffa84001040, first_level=true) at /data/codebase/stonedb80/stonedb/sql/sql_parse.cc:4604
#9  0x000055555925fa28 in dispatch_sql_command (thd=0x7ffa84001040, parser_state=0x7fffc848db90)
    at /data/codebase/stonedb80/stonedb/sql/sql_parse.cc:5239
#10 0x00005555592554a7 in dispatch_command (thd=0x7ffa84001040, com_data=0x7fffc848e4e0, command=COM_QUERY)
    at /data/codebase/stonedb80/stonedb/sql/sql_parse.cc:1959
#11 0x000055555925351e in do_command (thd=0x7ffa84001040) at /data/codebase/stonedb80/stonedb/sql/sql_parse.cc:1362
#12 0x000055555948fe3d in handle_connection (arg=0x555560f48f70)
    at /data/codebase/stonedb80/stonedb/sql/conn_handler/connection_handler_per_thread.cc:302
#13 0x000055555b3b1c06 in pfs_spawn_thread (arg=0x555563888b10) at /data/codebase/stonedb80/stonedb/storage/perfschema/pfs.cc:2942
#14 0x00007ffff7fa5609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#15 0x00007ffff6eb0133 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
(gdb) c
Continuing.

Thread 187 "connection" hit Breakpoint 1, Tianmu::core::TempTable::VerifyAttrsSizes (this=0x7ffa84aa03a0)
    at /data/codebase/stonedb80/stonedb/storage/tianmu/core/temp_table_low.cpp:506
506     {
(gdb) c
Continuing.

Thread 187 "connection" hit Breakpoint 1, Tianmu::core::TempTable::VerifyAttrsSizes (this=0x7ffa84aa03a0)
    at /data/codebase/stonedb80/stonedb/storage/tianmu/core/temp_table_low.cpp:506
506     {
(gdb) n
507       for (uint i = 0; i < attrs.size(); i++)
(gdb) n
508         if (ATI::IsStringType(attrs[i]->TypeName())) {
(gdb) n
511           if (attrs[i]->term.vc->MaxStringSize() < STRING_LENGTH_THRESHOLD) {
(gdb) n
514             vcolumn::VirtualColumn *vc = attrs[i]->term.vc;
(gdb) p vc
$1 = (Tianmu::vcolumn::VirtualColumn *) 0x55556122ecd0
(gdb) p *vc
$2 = {<Tianmu::vcolumn::VirtualColumnBase> = {<Tianmu::core::Column> = {ct = {type = Tianmu::common::CT::BYTEINT, precision = 32767,
        scale = 1629726064, internal_size = 21845, display_size = 1629725376, collation = {collation = 0x30, derivation = 33,
          repertoire = 0}, fmt = 16, flag = std::bitset}},
    _vptr.VirtualColumnBase = 0x55555e86e7e8 <vtable for Tianmu::system::MagMemoryPolicy+16>, mind = 0x657a69735f6567,
    conn_info = 0x401, var_map = std::vector of length 2345628952371, capacity 0 = {<error reading variable>
(gdb) p (vcolumn::ExpressionColumn *)vc
$3 = (Tianmu::vcolumn::ExpressionColumn *) 0x55556122ecd0
(gdb) p *(vcolumn::ExpressionColumn *)vc
$4 = {<Tianmu::vcolumn::VirtualColumn> = {<Tianmu::vcolumn::VirtualColumnBase> = {<Tianmu::core::Column> = {ct = {type = Tianmu::common::CT::BYTEINT,
          precision = 32767, scale = 1629726064, internal_size = 21845, display_size = 1629725376, collation = {collation = 0x30, derivation = 33,
            repertoire = 0}, fmt = 16, flag = std::bitset}}, _vptr.VirtualColumnBase = 0x55555e86e7e8 <vtable for Tianmu::system::MagMemoryPolicy+16>,
      mind = 0x657a69735f6567, conn_info = 0x401, var_map = std::vector of length 2345628952371, capacity 0 = {<error reading variable>
(gdb) n
515             int max_length = attrs[i]->term.vc->MaxStringSize();
(gdb) n
516             if (dynamic_cast<vcolumn::ExpressionColumn *>(vc)) {
(gdb) n
517               auto &var_map = dynamic_cast<vcolumn::ExpressionColumn *>(vc)->GetVarMap();
(gdb) n
518               for (auto &it : var_map) {
(gdb) p var_map
$5 = std::vector of length 1, capacity 1 = {{var = {tab = -1, col = 0}, col_ndx = 0, dim = 0, tabp = 0x7fffc848ba70, tab =
    std::weak_ptr<Tianmu::core::JustATable> (use count 5, weak count 3) = {get() = 0x7ffa8400e580}}}
(gdb) n
519                 PhysicalColumn *column = it.GetTabPtr()->GetColumn(it.col_ndx);
(gdb) n
p520                ColumnType ct = column->Type();
(gdb) p column
$6 = (Tianmu::core::PhysicalColumn *) 0x7ffa84a9ba60
(gdb) p *column
$7 = {<Tianmu::core::Column> = {ct = {type = Tianmu::common::CT::VARCHAR, precision = 765, scale = 0, internal_size = 765, display_size = 255,
      collation = {collation = 0x55555eaa2d60 <my_charset_utf8_general_ci>, derivation = DERIVATION_IMPLICIT, repertoire = 3},
      fmt = Tianmu::common::PackFmt::DEFAULT, flag = std::bitset}}, _vptr.PhysicalColumn = 0x55555e879fc0 <vtable for Tianmu::core::RCAttr+360>,
  is_unique = false, is_unique_updated = false}
(gdb) n
521                 uint precision = ct.GetPrecision();
(gdb) n
522                 if (precision >= STRING_LENGTH_THRESHOLD) {
(gdb) p precision
$8 = 765
(gdb) p max_length
$9 = 540
(gdb) n
523                   uint actual_size = column->MaxStringSize() * ct.GetCollation().collation->mbmaxlen;
(gdb) n
524                   if (actual_size < precision) max_length += (actual_size - precision);
(gdb)
518               for (auto &it : var_map) {
(gdb)
528             attrs[i]->OverrideStringSize(max_length);
(gdb) p (vcolumn::ExpressionColumn *)vc->expr_
There is no member or method named expr_.
(gdb) p ((vcolumn::ExpressionColumn *)vc)->expr_
$10 = (Tianmu::core::MysqlExpression *) 0x7ffa8402be10
(gdb) p *((vcolumn::ExpressionColumn *)vc)->expr_
$11 = {_vptr.MysqlExpression = 0x55555e879590 <vtable for Tianmu::core::MysqlExpression+16>, type = {
    valtype = Tianmu::core::DataType::ValueType::VT_STRING, attrtype = Tianmu::common::CT::STRING, fixscale = 0, fixmax = -1, collation = {
      collation = 0x55555eaa2d60 <my_charset_utf8_general_ci>, derivation = DERIVATION_IMPLICIT, repertoire = 3}, precision = 540}, item =
    0x7ffa84999ab0, mysql_type = STRING_RESULT, decimal_precision = 0, decimal_scale = 0, item2varid = 0x0,
  tianmu_fields_cache = std::map with 1 element = {[{tab = -1, col = 0}] = std::set with 1 element = {[0] = 0x7ffa84023b68}},
  vars = std::set with 1 element = {[0] = {tab = -1, col = 0}}, deterministic = true}
(gdb) p ((vcolumn::ExpressionColumn *)vc)->expr_.item
$12 = (Item *) 0x7ffa84999ab0
(gdb) p *((vcolumn::ExpressionColumn *)vc)->expr_.item
$13 = {<Parse_tree_node_tmpl<Parse_context>> = {_vptr.Parse_tree_node_tmpl = 0x55555e7aee58 <vtable for Item_func_left+16>, contextualized = true},
  next_free = 0x7ffa84999bb8, str_value = {m_ptr = 0x0, m_length = 0, m_charset = 0x55555e933be0 <my_charset_bin>, m_alloced_length = 0,
    m_is_alloced = false}, collation = {collation = 0x55555eaa2d60 <my_charset_utf8_general_ci>, derivation = DERIVATION_IMPLICIT, repertoire = 3},
  item_name = {<Name_string> = {<Simple_cstring> = {m_str = 0x7ffa84993ef0 "f2", m_length = 2}, <No data fields>}, m_is_autogenerated = false},
  orig_name = {<Name_string> = {<Simple_cstring> = {m_str = 0x0, m_length = 0}, <No data fields>}, m_is_autogenerated = true}, max_length = 540,
  marker = Item::MARKER_NONE, cmp_context = INVALID_RESULT, is_parser_item = true, is_expensive_cache = -1 '\377', m_data_type = 15 '\017',
  fixed = true, decimals = 31 '\037', m_nullable = true, null_value = false, unsigned_flag = false, m_is_window_function = false, hidden = false,
  m_in_check_constraint_exec_ctx = false, derived_used = false, static PROP_SUBQUERY = 1 '\001', static PROP_STORED_PROGRAM = 2 '\002',
  static PROP_AGGREGATION = 4 '\004', static PROP_WINDOW_FUNCTION = 8 '\b', static PROP_ROLLUP_EXPR = 16 '\020', static PROP_GROUPING_FUNC = 32 ' ',
  m_accum_properties = 0 '\000'}

(gdb) p (vcolumn::ExpressionColumn *)vc
$14 = (Tianmu::vcolumn::ExpressionColumn *) 0x7ffa84aa0c10
(gdb) p (vcolumn::ExpressionColumn *)vc->expr_
There is no member or method named expr_.
(gdb) p ((vcolumn::ExpressionColumn *)vc)->expr_
$15 = (Tianmu::core::MysqlExpression *) 0x7ffa8402be10
(gdb) p ((vcolumn::ExpressionColumn *)vc)->expr_->item
$16 = (Item *) 0x7ffa84999ab0
(gdb) call ((vcolumn::ExpressionColumn *)vc)->expr_->item
$17 = (Item *) 0x7ffa84999ab0
(gdb) call dynamic_cast<Item_func*>(((vcolumn::ExpressionColumn *)vc)->expr_->item)
$18 = (Item_func *) 0x7ffa84999ab0
(gdb) p * (Item_func *) 0x7ffa84999ab0
$19 = {<Item_result_field> = {<Item> = {<Parse_tree_node_tmpl<Parse_context>> = {
        _vptr.Parse_tree_node_tmpl = 0x55555e7aee58 <vtable for Item_func_left+16>, contextualized = true}, next_free = 0x7ffa84999bb8, str_value = {
        m_ptr = 0x0, m_length = 0, m_charset = 0x55555e933be0 <my_charset_bin>, m_alloced_length = 0, m_is_alloced = false}, collation = {
        collation = 0x55555eaa2d60 <my_charset_utf8_general_ci>, derivation = DERIVATION_IMPLICIT, repertoire = 3},
      item_name = {<Name_string> = {<Simple_cstring> = {m_str = 0x7ffa84993ef0 "f2", m_length = 2}, <No data fields>}, m_is_autogenerated = false},
      orig_name = {<Name_string> = {<Simple_cstring> = {m_str = 0x0, m_length = 0}, <No data fields>}, m_is_autogenerated = true}, max_length = 540,
      marker = Item::MARKER_NONE, cmp_context = INVALID_RESULT, is_parser_item = true, is_expensive_cache = -1 '\377', m_data_type = 15 '\017',
      fixed = true, decimals = 31 '\037', m_nullable = true, null_value = false, unsigned_flag = false, m_is_window_function = false, hidden = false,
      m_in_check_constraint_exec_ctx = false, derived_used = false, static PROP_SUBQUERY = 1 '\001', static PROP_STORED_PROGRAM = 2 '\002',
      static PROP_AGGREGATION = 4 '\004', static PROP_WINDOW_FUNCTION = 8 '\b', static PROP_ROLLUP_EXPR = 16 '\020',
      static PROP_GROUPING_FUNC = 32 ' ', m_accum_properties = 0 '\000'}, result_field = 0x0}, args = 0x7ffa84999b58, m_embedded_arguments = {
    0x7ffa84999908, 0x7ffa84999a08}, arg_count = 2, null_on_null = true, allowed_arg_cols = 1, used_tables_cache = 1, not_null_tables_cache = 1}
(gdb) p (* (Item_func *) 0x7ffa84999ab0).arg_count
$20 = 2
(gdb) p (* (Item_func *) 0x7ffa84999ab0).args[0]
$21 = (Item *) 0x7ffa84999908
(gdb) p * (* (Item_func *) 0x7ffa84999ab0).args[0]
$22 = {<Parse_tree_node_tmpl<Parse_context>> = {_vptr.Parse_tree_node_tmpl = 0x55555e7aee58 <vtable for Item_func_left+16>, contextualized = true},
  next_free = 0x7ffa84999ab0, str_value = {m_ptr = 0x0, m_length = 0, m_charset = 0x55555e933be0 <my_charset_bin>, m_alloced_length = 0,
    m_is_alloced = false}, collation = {collation = 0x55555eaa2d60 <my_charset_utf8_general_ci>, derivation = DERIVATION_IMPLICIT, repertoire = 3},
  item_name = {<Name_string> = {<Simple_cstring> = {m_str = 0x0, m_length = 0}, <No data fields>}, m_is_autogenerated = true},
  orig_name = {<Name_string> = {<Simple_cstring> = {m_str = 0x0, m_length = 0}, <No data fields>}, m_is_autogenerated = true}, max_length = 570,
  marker = Item::MARKER_NONE, cmp_context = INVALID_RESULT, is_parser_item = true, is_expensive_cache = -1 '\377', m_data_type = 15 '\017',
  fixed = true, decimals = 31 '\037', m_nullable = true, null_value = false, unsigned_flag = false, m_is_window_function = false, hidden = false,
  m_in_check_constraint_exec_ctx = false, derived_used = false, static PROP_SUBQUERY = 1 '\001', static PROP_STORED_PROGRAM = 2 '\002',
  static PROP_AGGREGATION = 4 '\004', static PROP_WINDOW_FUNCTION = 8 '\b', static PROP_ROLLUP_EXPR = 16 '\020', static PROP_GROUPING_FUNC = 32 ' ',
  m_accum_properties = 0 '\000'}
(gdb) call * (* (Item_func *) 0x7ffa84999ab0).args[0]
$23 = {<Parse_tree_node_tmpl<Parse_context>> = {_vptr.Parse_tree_node_tmpl = 0x55555e7aee58 <vtable for Item_func_left+16>, contextualized = true},
  next_free = 0x7ffa84999ab0, str_value = {m_ptr = 0x0, m_length = 0, m_charset = 0x55555e933be0 <my_charset_bin>, m_alloced_length = 0,
    m_is_alloced = false}, collation = {collation = 0x55555eaa2d60 <my_charset_utf8_general_ci>, derivation = DERIVATION_IMPLICIT, repertoire = 3},
  item_name = {<Name_string> = {<Simple_cstring> = {m_str = 0x0, m_length = 0}, <No data fields>}, m_is_autogenerated = true},
  orig_name = {<Name_string> = {<Simple_cstring> = {m_str = 0x0, m_length = 0}, <No data fields>}, m_is_autogenerated = true}, max_length = 570,
  marker = Item::MARKER_NONE, cmp_context = INVALID_RESULT, is_parser_item = true, is_expensive_cache = -1 '\377', m_data_type = 15 '\017',
  fixed = true, decimals = 31 '\037', m_nullable = true, null_value = false, unsigned_flag = false, m_is_window_function = false, hidden = false,
  m_in_check_constraint_exec_ctx = false, derived_used = false, static PROP_SUBQUERY = 1 '\001', static PROP_STORED_PROGRAM = 2 '\002',
  static PROP_AGGREGATION = 4 '\004', static PROP_WINDOW_FUNCTION = 8 '\b', static PROP_ROLLUP_EXPR = 16 '\020', static PROP_GROUPING_FUNC = 32 ' ',
  m_accum_properties = 0 '\000'}
(gdb) call typeid((* (Item_func *) 0x7ffa84999ab0).args[0])
could not find typeinfo symbol for 'Item*'
(gdb) call typeid((* (Item_func *) 0x7ffa84999ab0).args[1])
could not find typeinfo symbol for 'Item*'
(gdb) p * (* (Item_func *) 0x7ffa84999ab0).args[1]
$24 = {<Parse_tree_node_tmpl<Parse_context>> = {_vptr.Parse_tree_node_tmpl = 0x55555e73f468 <vtable for Item_int+16>, contextualized = true},
  next_free = 0x7ffa84999860, str_value = {m_ptr = 0x0, m_length = 0, m_charset = 0x55555e933be0 <my_charset_bin>, m_alloced_length = 0,
    m_is_alloced = false}, collation = {collation = 0x55555e93cce0 <my_charset_latin1>, derivation = DERIVATION_NUMERIC, repertoire = 1},
  item_name = {<Name_string> = {<Simple_cstring> = {m_str = 0x7ffa84999a00 "180", m_length = 3}, <No data fields>}, m_is_autogenerated = true},
  orig_name = {<Name_string> = {<Simple_cstring> = {m_str = 0x0, m_length = 0}, <No data fields>}, m_is_autogenerated = true}, max_length = 4,
  marker = Item::MARKER_NONE, cmp_context = INVALID_RESULT, is_parser_item = true, is_expensive_cache = -1 '\377', m_data_type = 8 '\b', fixed = true,
  decimals = 0 '\000', m_nullable = false, null_value = false, unsigned_flag = false, m_is_window_function = false, hidden = false,
  m_in_check_constraint_exec_ctx = false, derived_used = false, static PROP_SUBQUERY = 1 '\001', static PROP_STORED_PROGRAM = 2 '\002',
  static PROP_AGGREGATION = 4 '\004', static PROP_WINDOW_FUNCTION = 8 '\b', static PROP_ROLLUP_EXPR = 16 '\020', static PROP_GROUPING_FUNC = 32 ' ',
  m_accum_properties = 0 '\000'}
(gdb) call typeid(*((* (Item_func *) 0x7ffa84999ab0).args[1]))
$25 = {_vptr.type_info = 0x7ffff72c2c98 <vtable for __cxxabiv1::__si_class_type_info+16>,
  __name = 0x55555c6760f0 <typeinfo name for Item_int> "8Item_int"}
(gdb) call typeid(*((* (Item_func *) 0x7ffa84999ab0).args[0]))
$26 = {_vptr.type_info = 0x7ffff72c2c98 <vtable for __cxxabiv1::__si_class_type_info+16>,
  __name = 0x55555c69eb00 <typeinfo name for Item_func_left> "14Item_func_left"}
(gdb) p (* (Item_func *) 0x7ffa84999ab0).args[0]
$27 = (Item *) 0x7ffa84999908
(gdb) p  (Item_func_left*) 0x7ffa84999908
$28 = (Item_func_left *) 0x7ffa84999908
(gdb) p  *(Item_func_left*) 0x7ffa84999908
$29 = {<Item_str_func> = {<Item_func> = {<Item_result_field> = {<Item> = {<Parse_tree_node_tmpl<Parse_context>> = {
            _vptr.Parse_tree_node_tmpl = 0x55555e7aee58 <vtable for Item_func_left+16>, contextualized = true}, next_free = 0x7ffa84999ab0,
          str_value = {m_ptr = 0x0, m_length = 0, m_charset = 0x55555e933be0 <my_charset_bin>, m_alloced_length = 0, m_is_alloced = false},
          collation = {collation = 0x55555eaa2d60 <my_charset_utf8_general_ci>, derivation = DERIVATION_IMPLICIT, repertoire = 3},
          item_name = {<Name_string> = {<Simple_cstring> = {m_str = 0x0, m_length = 0}, <No data fields>}, m_is_autogenerated = true},
          orig_name = {<Name_string> = {<Simple_cstring> = {m_str = 0x0, m_length = 0}, <No data fields>}, m_is_autogenerated = true},
          max_length = 570, marker = Item::MARKER_NONE, cmp_context = INVALID_RESULT, is_parser_item = true, is_expensive_cache = -1 '\377',
          m_data_type = 15 '\017', fixed = true, decimals = 31 '\037', m_nullable = true, null_value = false, unsigned_flag = false,
          m_is_window_function = false, hidden = false, m_in_check_constraint_exec_ctx = false, derived_used = false, static PROP_SUBQUERY = 1 '\001',
          static PROP_STORED_PROGRAM = 2 '\002', static PROP_AGGREGATION = 4 '\004', static PROP_WINDOW_FUNCTION = 8 '\b',
          static PROP_ROLLUP_EXPR = 16 '\020', static PROP_GROUPING_FUNC = 32 ' ', m_accum_properties = 0 '\000'}, result_field = 0x0},
      args = 0x7ffa849999b0, m_embedded_arguments = {0x7ffa84023b68, 0x7ffa84999860}, arg_count = 2, null_on_null = true, allowed_arg_cols = 1,
      used_tables_cache = 1, not_null_tables_cache = 1}, <No data fields>}, tmp_value = {m_ptr = 0x0, m_length = 0,
    m_charset = 0x55555e933be0 <my_charset_bin>, m_alloced_length = 0, m_is_alloced = false}}
(gdb) p  (Item_func_left*) 0x7ffa84999908)->args[0]
Junk after end of expression.
(gdb) p  ((Item_func_left*) 0x7ffa84999908)->args[0]
$30 = (Item *) 0x7ffa84023b68
(gdb) call typeid(*  (Item *) 0x7ffa84023b68)
$31 = {_vptr.type_info = 0x7ffff72c2c98 <vtable for __cxxabiv1::__si_class_type_info+16>,
  __name = 0x55555d6e5cc0 <typeinfo name for Tianmu::core::Item_tianmufield> "N6Tianmu4core16Item_tianmufieldE"}
(gdb) p (Tianmu::core::Item_tianmufield*)(0x7ffa84023b68)
$32 = (Tianmu::core::Item_tianmufield *) 0x7ffa84023b68
(gdb) p *(Tianmu::core::Item_tianmufield*)(0x7ffa84023b68)
$33 = {<Item_field> = {<Item_ident> = {<Item> = {<Parse_tree_node_tmpl<Parse_context>> = {
          _vptr.Parse_tree_node_tmpl = 0x55555e878370 <vtable for Tianmu::core::Item_tianmufield+16>, contextualized = true},
        next_free = 0x7ffa84021a08, str_value = {m_ptr = 0x0, m_length = 0, m_charset = 0x55555e933be0 <my_charset_bin>, m_alloced_length = 0,
          m_is_alloced = false}, collation = {collation = 0x55555eaa2d60 <my_charset_utf8_general_ci>, derivation = DERIVATION_IMPLICIT,
          repertoire = 3}, item_name = {<Name_string> = {<Simple_cstring> = {m_str = 0x7ffa84999798 "f1", m_length = 2}, <No data fields>},
          m_is_autogenerated = true}, orig_name = {<Name_string> = {<Simple_cstring> = {m_str = 0x0, m_length = 0}, <No data fields>},
          m_is_autogenerated = true}, max_length = 765, marker = Item::MARKER_NONE, cmp_context = INVALID_RESULT, is_parser_item = false,
        is_expensive_cache = -1 '\377', m_data_type = 15 '\017', fixed = true, decimals = 31 '\037', m_nullable = true, null_value = false,
        unsigned_flag = false, m_is_window_function = false, hidden = false, m_in_check_constraint_exec_ctx = false, derived_used = false,
        static PROP_SUBQUERY = 1 '\001', static PROP_STORED_PROGRAM = 2 '\002', static PROP_AGGREGATION = 4 '\004',
        static PROP_WINDOW_FUNCTION = 8 '\b', static PROP_ROLLUP_EXPR = 16 '\020', static PROP_GROUPING_FUNC = 32 ' ', m_accum_properties = 0 '\000'},
      m_orig_db_name = 0x7ffa84994970 "lujs", m_orig_table_name = 0x7ffa8499a0c8 "t1", m_orig_field_name = 0x7ffa8409ff20 "f1",
      m_alias_of_expr = false, context = 0x7ffa849995b0, db_name = 0x7ffa84994970 "lujs", table_name = 0x7ffa84994300 "t1",
      field_name = 0x7ffa84999798 "f1", cached_table = 0x7ffa84994308, depended_from = 0x0}, table_ref = 0x7ffa84994308, field = 0x7ffa840b5f00,
    result_field = 0x7ffa840b5f00, last_org_destination_field = 0x0, last_destination_field = 0x0, last_org_destination_field_memcpyable = 4294967295,
    last_destination_field_memcpyable = 4294967295, m_base_item_field = 0x7ffa84993da8, item_equal = 0x0, field_index = 0,
    item_equal_all_join_nests = 0x0, no_constant_propagation = false, have_privileges = 0, any_privileges = false, can_use_prefix_key = false},
  varID = std::vector of length 1, capacity 1 = {{tab = -1, col = 0}}, ifield = 0x7ffa84993da8, tianmu_type = {
    valtype = Tianmu::core::DataType::ValueType::VT_STRING, attrtype = Tianmu::common::CT::VARCHAR, fixscale = 0, fixmax = -1, collation = {
      collation = 0x55555eaa2d60 <my_charset_utf8_general_ci>, derivation = DERIVATION_IMPLICIT, repertoire = 3}, precision = 765},
  buf = 0x7ffa84011110, isBufOwner = true, ivalue = 0x7ffa84024320, was_aggregation = false, aggregation_result = STRING_RESULT,
  fullname = "tianmufield of 0x7ffa84993da8\000\000"}
(gdb) p ((Tianmu::core::Item_tianmufield*)(0x7ffa84023b68))->buf
$34 = (Tianmu::core::ValueOrNull *) 0x7ffa84011110
(gdb) p * $32
$35 = {<Item_field> = {<Item_ident> = {<Item> = {<Parse_tree_node_tmpl<Parse_context>> = {
          _vptr.Parse_tree_node_tmpl = 0x55555e878370 <vtable for Tianmu::core::Item_tianmufield+16>, contextualized = true},
        next_free = 0x7ffa84021a08, str_value = {m_ptr = 0x0, m_length = 0, m_charset = 0x55555e933be0 <my_charset_bin>, m_alloced_length = 0,
          m_is_alloced = false}, collation = {collation = 0x55555eaa2d60 <my_charset_utf8_general_ci>, derivation = DERIVATION_IMPLICIT,
          repertoire = 3}, item_name = {<Name_string> = {<Simple_cstring> = {m_str = 0x7ffa84999798 "f1", m_length = 2}, <No data fields>},
          m_is_autogenerated = true}, orig_name = {<Name_string> = {<Simple_cstring> = {m_str = 0x0, m_length = 0}, <No data fields>},
          m_is_autogenerated = true}, max_length = 765, marker = Item::MARKER_NONE, cmp_context = INVALID_RESULT, is_parser_item = false,
        is_expensive_cache = -1 '\377', m_data_type = 15 '\017', fixed = true, decimals = 31 '\037', m_nullable = true, null_value = false,
        unsigned_flag = false, m_is_window_function = false, hidden = false, m_in_check_constraint_exec_ctx = false, derived_used = false,
        static PROP_SUBQUERY = 1 '\001', static PROP_STORED_PROGRAM = 2 '\002', static PROP_AGGREGATION = 4 '\004',
        static PROP_WINDOW_FUNCTION = 8 '\b', static PROP_ROLLUP_EXPR = 16 '\020', static PROP_GROUPING_FUNC = 32 ' ', m_accum_properties = 0 '\000'},
      m_orig_db_name = 0x7ffa84994970 "lujs", m_orig_table_name = 0x7ffa8499a0c8 "t1", m_orig_field_name = 0x7ffa8409ff20 "f1",
      m_alias_of_expr = false, context = 0x7ffa849995b0, db_name = 0x7ffa84994970 "lujs", table_name = 0x7ffa84994300 "t1",
      field_name = 0x7ffa84999798 "f1", cached_table = 0x7ffa84994308, depended_from = 0x0}, table_ref = 0x7ffa84994308, field = 0x7ffa840b5f00,
    result_field = 0x7ffa840b5f00, last_org_destination_field = 0x0, last_destination_field = 0x0, last_org_destination_field_memcpyable = 4294967295,
    last_destination_field_memcpyable = 4294967295, m_base_item_field = 0x7ffa84993da8, item_equal = 0x0, field_index = 0,
    item_equal_all_join_nests = 0x0, no_constant_propagation = false, have_privileges = 0, any_privileges = false, can_use_prefix_key = false},
  varID = std::vector of length 1, capacity 1 = {{tab = -1, col = 0}}, ifield = 0x7ffa84993da8, tianmu_type = {
    valtype = Tianmu::core::DataType::ValueType::VT_STRING, attrtype = Tianmu::common::CT::VARCHAR, fixscale = 0, fixmax = -1, collation = {
      collation = 0x55555eaa2d60 <my_charset_utf8_general_ci>, derivation = DERIVATION_IMPLICIT, repertoire = 3}, precision = 765},
  buf = 0x7ffa84011110, isBufOwner = true, ivalue = 0x7ffa84024320, was_aggregation = false, aggregation_result = STRING_RESULT,
  fullname = "tianmufield of 0x7ffa84993da8\000\000"}
(gdb) p * $34
$36 = {x = -9223372036854775807, sp = 0x0, len = 0, string_owner = false, null = true}
(gdb)

@lujiashun
Copy link
Author

1 tranverse Item_tianmufield which type is VT_STRING use "MysqlExpression::tianmu_fields_cache";
2 assigne Item_tianmufield with string value;
3 get MysqlExpression value,then get length;
4 not sure,try it...

@lujiashun
Copy link
Author

for temp solution, comment the optimization code

lujiashun pushed a commit to lujiashun/stonedb that referenced this issue Oct 25, 2022
…m#671)

[summary]
1 TempTable::VerifyAttrsSizes optimization to reduce the size is
  incorrect,comment the optimization for temp sulution;
lujiashun pushed a commit to lujiashun/stonedb that referenced this issue Oct 25, 2022
…m#671)

[summary]
1 TempTable::VerifyAttrsSizes optimization to reduce the size is
  incorrect,comment the optimization for temp sulution;
lujiashun pushed a commit to lujiashun/stonedb that referenced this issue Oct 25, 2022
…m#671)

[summary]
1 TempTable::VerifyAttrsSizes optimization to reduce the size is
  incorrect,comment the optimization for temp sulution;
lujiashun pushed a commit to lujiashun/stonedb that referenced this issue Oct 25, 2022
…m#671)

[summary]
1 TempTable::VerifyAttrsSizes optimization to reduce the size is
  incorrect,comment the optimization for temp sulution;
mergify bot pushed a commit that referenced this issue Oct 26, 2022
[summary]
1 TempTable::VerifyAttrsSizes optimization to reduce the size is
  incorrect,comment the optimization for temp sulution;
Repository owner moved this from In Progress to Done in StoneDB for MySQL 8.0 Oct 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-bug Something isn't working C-stonedb-8.0 associated with stonedb 8.0
Projects
Development

No branches or pull requests

2 participants