stonedb icon indicating copy to clipboard operation
stonedb copied to clipboard

bug: [POC] After the tianmu_ini_allowmysqlQuerypath parameter is enabled, the user-defined dynamic function is invoked, and the query result is null

Open adofsauron opened this issue 1 year ago • 23 comments

Describe the problem

SQL


SELECT
	sale.usid AS usid,
	cus.corpname AS corpname,
	sale.iscenicid AS iscenicid,
	salde.itickettypeid AS itickettypeid,
	price.icrowdkindid AS icrowdkindid,
	salde.mactualsaleprice AS mactualsaleprice,
	sum(salde.iamount) AS numb,
	sum(salde.meventmoney) AS mont,
	coalesce(sum(salde.mderatemoney),
	0) AS mderatemoney,
	coalesce(sum(salde.ideratenums),
	0) AS ideratenums,
	coalesce(sum(salde.mhandcharge),
	0) AS mhandcharge,
	saletype.isettlementid AS isettlementid,
	sale.bysalesvouchertype AS bysalesvouchertype
FROM
	STSSALESVOUCHERTAB sale,
	STSSALESVOUCHERDETAILSTAB salde,
	(
		SELECT FIND_TOP_USID(C.USID) AS SUSID,
		C2.CORPNAME AS SCORPNAME,
		C2.BNAME,
		C.USID,
		C.CORPNAME,
		C.IBUSINESSID,
		C.TTLB
	FROM
		CUSTOM C
	LEFT JOIN CUSTOM C2 ON
		C2.USID = C.SUSID
	WHERE
		C.LGTP = '02'
		AND C.USTP = '01'
		AND C.IBUSINESSID = 2) cus,
	EDMTICKETTYPETAB ti,
	EDMCROWDKINDPRICETAB price,
	STSSALESSETTLEMENTTAB saletype
WHERE
	substr(sale.dtmakedate,
	1,
	10) >= '2022-08-18'
	AND substr(sale.dtmakedate,
	1,
	10) <= '2022-08-18'
	AND sale.isalesvoucherid = saletype.isalesvoucherid
	AND sale.iticketstationid = saletype.iticketstationid
	AND price.icrowdkindpriceid = salde.icrowdkindpriceid
	AND sale.isalesvoucherid = salde.isalesvoucherid
	AND sale.iticketstationid = salde.iticketstationid
	AND cus.usid = sale.usid
	AND salde.itickettypeid = ti.itickettypeid
	AND sale.iscenicid IN (1)
	AND cus.ibusinessid <> 1
GROUP BY
	sale.usid,
	cus.corpname,
	saletype.isettlementid,
	salde.mactualsaleprice,
	sale.iscenicid,
	salde.itickettypeid,
	price.icrowdkindid,
	sale.bysalesvouchertype
UNION ALL SELECT
	sale.usid AS usid,
	cus.corpname AS corpname,
	sale.iscenicid AS iscenicid,
	salde.itickettypeid AS itickettypeid,
	price.icrowdkindid AS icrowdkindid,
	salde.mactualsaleprice AS mactualsaleprice,
	sum(salde.iamount) AS numb,
	sum(salde.meventmoney) AS mont,
	coalesce(sum(salde.mderatemoney),
	0) AS mderatemoney,
	coalesce(sum(salde.ideratenums),
	0) AS ideratenums,
	coalesce(sum(salde.mhandcharge),
	0) AS mhandcharge,
	saletype.isettlementid AS isettlementid,
	sale.bysalesvouchertype AS bysalesvouchertype
FROM
	STSSALESVOUCHERTABLIST sale,
	STSSALESVOUCHERDETAILSTABLIST salde,
	(
		SELECT USID,
		CORPNAME,
		IBUSINESSID,
		TTLB,
		FIND_TOP_USID(USID) AS SUSID
	FROM
		CUSTOM
	WHERE
		LGTP = '02'
		AND USTP = '01') cus,
	EDMTICKETTYPETAB ti,
	EDMCROWDKINDPRICETAB price,
	STSSALESSETTLEMENTTABLIST saletype
WHERE
	substr(sale.dtmakedate,
	1,
	10) >= '2022-08-18'
	AND substr(sale.dtmakedate,
	1,
	10) <= '2022-08-18'
	AND sale.isalesvoucherid = saletype.isalesvoucherid
	AND sale.iticketstationid = saletype.iticketstationid
	AND price.icrowdkindpriceid = salde.icrowdkindpriceid
	AND sale.isalesvoucherid = salde.isalesvoucherid
	AND sale.iticketstationid = salde.iticketstationid
	AND cus.usid = sale.usid
	AND salde.itickettypeid = ti.itickettypeid
	AND sale.iscenicid IN (1)
	AND cus.ibusinessid <> 1
GROUP BY
	sale.usid,
	cus.susid,
	saletype.isettlementid,
	salde.mactualsaleprice,
	sale.iscenicid,
	salde.itickettypeid,
	price.icrowdkindid,
	sale.bysalesvouchertype;

Tianmu query result


mysql> SELECT sale.usid AS usid,
    ->        cus.corpname AS corpname,
    ->        sale.iscenicid AS iscenicid,
    ->        salde.itickettypeid AS itickettypeid,
    ->        price.icrowdkindid AS icrowdkindid,
    ->        salde.mactualsaleprice AS mactualsaleprice,
    ->        sum(salde.iamount) AS numb,
    ->        sum(salde.meventmoney) AS mont,
    ->        coalesce(sum(salde.mderatemoney), 0) AS mderatemoney,
    ->        coalesce(sum(salde.ideratenums), 0) AS ideratenums,
    ->        coalesce(sum(salde.mhandcharge), 0) AS mhandcharge,
    ->        saletype.isettlementid AS isettlementid,
    ->        sale.bysalesvouchertype AS bysalesvouchertype
    ->   FROM STSSALESVOUCHERTAB sale,
    ->        STSSALESVOUCHERDETAILSTAB salde,
    ->        (SELECT FIND_TOP_USID(C.USID) AS SUSID,
    ->                C2.CORPNAME AS SCORPNAME,
    ->                C2.BNAME,
    ->                C.USID,
    ->                C.CORPNAME,
    ->                C.IBUSINESSID,
    ->                C.TTLB
    ->           FROM CUSTOM C
    ->           LEFT JOIN CUSTOM C2
    ->             ON C2.USID = C.SUSID
    ->          WHERE C.LGTP = '02'
    ->            AND C.USTP = '01'
    ->            AND C.IBUSINESSID = 2) cus,
    ->        EDMTICKETTYPETAB ti,
    ->        EDMCROWDKINDPRICETAB price,
    ->        STSSALESSETTLEMENTTAB saletype
    ->  WHERE substr(sale.dtmakedate, 1, 10) >= '2022-08-18'
    ->    AND substr(sale.dtmakedate, 1, 10) <= '2022-08-18'
    ->    AND sale.isalesvoucherid = saletype.isalesvoucherid
    ->    AND sale.iticketstationid = saletype.iticketstationid
    ->    AND price.icrowdkindpriceid = salde.icrowdkindpriceid
    ->    AND sale.isalesvoucherid = salde.isalesvoucherid
    ->    AND sale.iticketstationid = salde.iticketstationid
    ->    AND cus.usid = sale.usid
    ->    AND salde.itickettypeid = ti.itickettypeid
    ->    AND sale.iscenicid IN (1)
    ->    AND cus.ibusinessid <> 1
    ->  GROUP BY sale.usid,
    ->           cus.corpname,
    ->           saletype.isettlementid,
    ->           salde.mactualsaleprice,
    ->           sale.iscenicid,
    ->           salde.itickettypeid,
    ->           price.icrowdkindid,
    ->           sale.bysalesvouchertype
    -> UNION ALL
    -> SELECT sale.usid AS usid,
    ->        cus.corpname AS corpname,
    ->        sale.iscenicid AS iscenicid,
    ->        salde.itickettypeid AS itickettypeid,
    ->        price.icrowdkindid AS icrowdkindid,
    ->        salde.mactualsaleprice AS mactualsaleprice,
    ->        sum(salde.iamount) AS numb,
    ->        sum(salde.meventmoney) AS mont,
    ->        coalesce(sum(salde.mderatemoney), 0) AS mderatemoney,
    ->        coalesce(sum(salde.ideratenums), 0) AS ideratenums,
    ->        coalesce(sum(salde.mhandcharge), 0) AS mhandcharge,
    ->        saletype.isettlementid AS isettlementid,
    ->        sale.bysalesvouchertype AS bysalesvouchertype
    ->   FROM STSSALESVOUCHERTABLIST sale,
    ->        STSSALESVOUCHERDETAILSTABLIST salde,
    ->        (SELECT USID,
    ->                CORPNAME,
    ->                IBUSINESSID,
    ->                TTLB,
    ->                FIND_TOP_USID(USID) AS SUSID
    ->           FROM CUSTOM
    ->          WHERE LGTP = '02'
    ->            AND USTP = '01') cus,
    ->        EDMTICKETTYPETAB ti,
    ->        EDMCROWDKINDPRICETAB price,
    ->        STSSALESSETTLEMENTTABLIST saletype
    ->  WHERE substr(sale.dtmakedate, 1, 10) >= '2022-08-18'
    ->    AND substr(sale.dtmakedate, 1, 10) <= '2022-08-18'
    ->    AND sale.isalesvoucherid = saletype.isalesvoucherid
    ->    AND sale.iticketstationid = saletype.iticketstationid
    ->    AND price.icrowdkindpriceid = salde.icrowdkindpriceid
    ->    AND sale.isalesvoucherid = salde.isalesvoucherid
    ->    AND sale.iticketstationid = salde.iticketstationid
    ->    AND cus.usid = sale.usid
    ->    AND salde.itickettypeid = ti.itickettypeid
    ->    AND sale.iscenicid IN (1)
    ->    AND cus.ibusinessid <> 1
    ->  GROUP BY sale.usid,
    ->           cus.susid,
    ->           saletype.isettlementid,
    ->           salde.mactualsaleprice,
    ->           sale.iscenicid,
    ->           salde.itickettypeid,
    ->           price.icrowdkindid,
    ->           sale.bysalesvouchertype;
Empty set, 1 warning (48.15 sec)


Innodb query result

image

Expected behavior

No response

How To Reproduce

No response

Environment

No response

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

  • [X] Yes, I will!

adofsauron avatar Sep 09 '22 11:09 adofsauron

https://blog.csdn.net/adofsauron/article/details/126832951?spm=1001.2014.3001.5501

adofsauron avatar Sep 13 '22 14:09 adofsauron

Index retention

The SELECT query in the upper part is correct

The following SELECT query is correct

But the whole SQL, there is a syntax error

Delete the index

The entire SQL executes without syntax errors

However, the ICROWdKinDID column is NULL in the first half of the SELECT query, resulting in a row less than InnoDB

After Union All joins the lower half of the SELECT, the whole returns EMPTY if there is a result set in the upper half

adofsauron avatar Sep 14 '22 08:09 adofsauron

The POC sentence, when the custom function is called, in the SQL layer, the sentence has become SELECT 't2'. 'get_value' (NULL), the value passed in will become NULL



T:-1 = TABLE_ALIAS(T:0,"employees")
T:-2 = TMP_TABLE(T:4294967295)
VC:-2.0 = CREATE_VC(T:-2,PHYS_COL(T:-1,A:5))
A:-1 = T:-2.ADD_COLUMN(VC:-2.0,LIST,"employee_salary","ALL")
VC:-2.1 = CREATE_VC(T:-2,PHYS_COL(T:-1,A:0))
VC:-2.2 = CREATE_VC(T:-2,EXPR("NULL"))
C:0 = CREATE_CONDS(T:-2,VC:-2.1,=,VC:-2.2,<null>)
T:-2.ADD_CONDS(C:0,WHERE)
T:-2.APPLY_CONDS()
RESULT(T:-2)



(gdb) bt
#0  Tianmu::core::Engine::HandleSelect (this=0x584afd0, thd=0x7f8330011f20, lex=0x7f8330037ed0, result=@0x7f850d022b38: 0x7f8330039788, setup_tables_done_option=0, res=@0x7f850d022b34: 0, 
    optimize_after_tianmu=@0x7f850d022b2c: 0, tianmu_free_join=@0x7f850d022b30: 64922944, with_insert=0)
    at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/storage/tianmu/core/engine_execute.cpp:80
#1  0x0000000002abb3b4 in Tianmu::dbhandler::TIANMU_HandleSelect (thd=0x7f8330011f20, lex=0x7f8330037ed0, result=@0x7f850d022b38: 0x7f8330039788, setup_tables_done_option=0, 
    res=@0x7f850d022b34: 0, optimize_after_tianmu=@0x7f850d022b2c: 0, tianmu_free_join=@0x7f850d022b30: 64922944, with_insert=0)
    at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/storage/tianmu/handler/ha_rcengine.cpp:82
#2  0x00000000022ff727 in execute_sqlcom_select (thd=0x7f8330011f20, all_tables=0x7f83300399c0) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_parse.cc:5182
#3  0x00000000022f954f in mysql_execute_command (thd=0x7f8330011f20, first_level=false) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_parse.cc:2831
#4  0x0000000002264ae8 in sp_instr_stmt::exec_core (this=0x7f833003a2d8, thd=0x7f8330011f20, nextp=0x7f850d024228)
    at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sp_instr.cc:1027
#5  0x000000000226398b in sp_lex_instr::reset_lex_and_exec_core (this=0x7f833003a2d8, thd=0x7f8330011f20, nextp=0x7f850d024228, open_tables=false)
    at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sp_instr.cc:452
#6  0x0000000002264372 in sp_lex_instr::validate_lex_and_execute_core (this=0x7f833003a2d8, thd=0x7f8330011f20, nextp=0x7f850d024228, open_tables=false)
    at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sp_instr.cc:753
#7  0x0000000002264840 in sp_instr_stmt::execute (this=0x7f833003a2d8, thd=0x7f8330011f20, nextp=0x7f850d024228)
    at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sp_instr.cc:938
#8  0x000000000225d505 in sp_head::execute (this=0x7f8330031810, thd=0x7f8330011f20, merge_da_on_success=true) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sp_head.cc:796
#9  0x000000000225e4c7 in sp_head::execute_function (this=0x7f8330031810, thd=0x7f8330011f20, argp=0x7f83300170e0, argcount=1, return_value_fld=0x7f833001e600)
    at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sp_head.cc:1287
#10 0x0000000001d76609 in Item_func_sp::execute_impl (this=0x7f8330017038, thd=0x7f8330011f20) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/item_func.cc:8706
#11 0x0000000001d7635c in Item_func_sp::execute (this=0x7f8330017038) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/item_func.cc:8637
#12 0x0000000001d5d056 in Item_func_sp::val_int (this=0x7f8330017038) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/item_func.h:2741
#13 0x0000000001d07bea in Item::send (this=0x7f8330017038, protocol=0x7f8330012f80, buffer=0x7f850d025620) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/item.cc:7570
#14 0x00000000022ac08f in THD::send_result_set_row (this=0x7f8330011f20, row_items=0x7f83300159d8) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_class.cc:4757
#15 0x00000000022a70fa in Query_result_send::send_data (this=0x7f8330010dd0, items=...) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_class.cc:2742
#16 0x00000000022bf790 in end_send (join=0x7f83300cb760, qep_tab=0x7f83300b9be8, end_of_records=false) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_executor.cc:2936
#17 0x00000000022bce08 in evaluate_join_record (join=0x7f83300cb760, qep_tab=0x7f83300b9a70) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_executor.cc:1652
#18 0x00000000022bd304 in evaluate_null_complemented_join_record (join=0x7f83300cb760, qep_tab=0x7f83300b9a70)
    at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_executor.cc:1792
#19 0x00000000022bc5d6 in sub_select (join=0x7f83300cb760, qep_tab=0x7f83300b9a70, end_of_records=false) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_executor.cc:1311
#20 0x00000000022bce08 in evaluate_join_record (join=0x7f83300cb760, qep_tab=0x7f83300b98f8) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_executor.cc:1652
#21 0x00000000022bc584 in sub_select (join=0x7f83300cb760, qep_tab=0x7f83300b98f8, end_of_records=false) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_executor.cc:1304
#22 0x00000000022bc01f in do_select (join=0x7f83300cb760) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_executor.cc:957
#23 0x00000000022ba2df in JOIN::exec (this=0x7f83300cb760) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_executor.cc:206
#24 0x000000000233e867 in handle_query (thd=0x7f8330011f20, lex=0x7f8330014098, result=0x7f8330010dd0, added_options=0, removed_options=0, optimize_after_bh=2, free_join_from_bh=1)
    at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_select.cc:195
#25 0x00000000022ff761 in execute_sqlcom_select (thd=0x7f8330011f20, all_tables=0x7f833000fb88) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_parse.cc:5184
#26 0x00000000022f954f in mysql_execute_command (thd=0x7f8330011f20, first_level=true) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_parse.cc:2831
#27 0x000000000230042e in mysql_parse (thd=0x7f8330011f20, parser_state=0x7f850d026f00) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_parse.cc:5621
#28 0x00000000022f6878 in dispatch_command (thd=0x7f8330011f20, com_data=0x7f850d027660, command=COM_QUERY) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_parse.cc:1495
#29 0x00000000022f5a1b in do_command (thd=0x7f8330011f20) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_parse.cc:1034
#30 0x00000000023f995b in handle_connection (arg=0x76f0d70) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/conn_handler/connection_handler_per_thread.cc:313
#31 0x0000000002915591 in pfs_spawn_thread (arg=0x7acfe30) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/storage/perfschema/pfs.cc:2197
#32 0x00007f8557ffaea5 in start_thread () from /lib64/libpthread.so.0




(gdb) f
#9  0x000000000225e4c7 in sp_head::execute_function (this=0x7f8330031810, thd=0x7f8330011f20, argp=0x7f83300170e0, argcount=1, return_value_fld=0x7f833001e600)
    at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sp_head.cc:1287
1287	  err_status= execute(thd, TRUE);


(gdb) p binlog_buf
$36 = {
  m_ptr = 0x7f850d0252f0 "SELECT `t2`.`get_value`(NULL)", 
  m_length = 29, 
  m_charset = 0x3d8a2a0 <my_charset_bin>, 
  m_alloced_length = 80, 
  m_is_alloced = false
}


adofsauron avatar Sep 19 '22 08:09 adofsauron

This is NULL because, compared to the InnoDB engine, the join_read_first time InnoDB reads the inner table and gets the data, but the TM engine uses join_init_read_record, TianmuHandler::rnd_init is entered, which should have all the data out according to functional equivalence, but does not****

adofsauron avatar Sep 19 '22 12:09 adofsauron

Mysql - InnoDB engine - Call custom function records



(gdb) bt
#0  ha_innobase::index_read (this=0x7fd7c803d280, buf=0x7fd7c803d690 "\372\001", key_ptr=0x0, key_len=0, find_flag=HA_READ_AFTER_KEY)
    at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/storage/innobase/handler/ha_innodb.cc:8714
#1  0x00000000026020b5 in ha_innobase::index_first (this=0x7fd7c803d280, buf=0x7fd7c803d690 "\372\001")
    at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/storage/innobase/handler/ha_innodb.cc:9222
#2  0x0000000001cdf451 in handler::ha_index_first (this=0x7fd7c803d280, buf=0x7fd7c803d690 "\372\001") at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/handler.cc:3216
#3  0x00000000022bef55 in join_read_first (tab=0x7fd7c8067ed0) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_executor.cc:2662
#4  0x00000000022bc4a1 in sub_select (join=0x7fd7c8032648, qep_tab=0x7fd7c8067ed0, end_of_records=false) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_executor.cc:1284
#5  0x00000000022bc01f in do_select (join=0x7fd7c8032648) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_executor.cc:957
#6  0x00000000022ba2df in JOIN::exec (this=0x7fd7c8032648) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_executor.cc:206
#7  0x000000000233e867 in handle_query (thd=0x7fd7c8039cb0, lex=0x7fd7c803be28, result=0x7fd7c8032150, added_options=0, removed_options=0, optimize_after_bh=0, free_join_from_bh=0)
    at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_select.cc:195
#8  0x00000000022ff761 in execute_sqlcom_select (thd=0x7fd7c8039cb0, all_tables=0x7fd7c8071ef8) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_parse.cc:5184
#9  0x00000000022f954f in mysql_execute_command (thd=0x7fd7c8039cb0, first_level=true) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_parse.cc:2831
#10 0x000000000230042e in mysql_parse (thd=0x7fd7c8039cb0, parser_state=0x7fd9ab1e4f00) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_parse.cc:5621
#11 0x00000000022f6878 in dispatch_command (thd=0x7fd7c8039cb0, com_data=0x7fd9ab1e5660, command=COM_QUERY) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_parse.cc:1495
#12 0x00000000022f5a1b in do_command (thd=0x7fd7c8039cb0) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_parse.cc:1034
#13 0x00000000023f995b in handle_connection (arg=0x649f180) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/conn_handler/connection_handler_per_thread.cc:313
#14 0x0000000002915591 in pfs_spawn_thread (arg=0x64b77c0) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/storage/perfschema/pfs.cc:2197
#15 0x00007fd9f61b8ea5 in start_thread () from /lib64/libpthread.so.0
#16 0x00007fd9f36dcb0d in clone () from /lib64/libc.so.6


(gdb) bt
#0  ha_innobase::index_read (this=0x7fd7c800e590, buf=0x7fd7c800e9a0 "\020\001", key_ptr=0x7fd7c8033218 "\001", key_len=4, find_flag=HA_READ_KEY_EXACT)
    at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/storage/innobase/handler/ha_innodb.cc:8714
#1  0x0000000001cd8296 in handler::index_read_map (this=0x7fd7c800e590, buf=0x7fd7c800e9a0 "\020\001", key=0x7fd7c8033218 "\001", keypart_map=1, find_flag=HA_READ_KEY_EXACT)
    at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/handler.h:2852
#2  0x0000000001cde8db in handler::ha_index_read_map (this=0x7fd7c800e590, buf=0x7fd7c800e9a0 "\020\001", key=0x7fd7c8033218 "\001", keypart_map=1, find_flag=HA_READ_KEY_EXACT)
    at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/handler.cc:3062
#3  0x00000000022bddff in join_read_key (tab=0x7fd7c8068048) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_executor.cc:2106
#4  0x00000000022bc4a1 in sub_select (join=0x7fd7c8032648, qep_tab=0x7fd7c8068048, end_of_records=false) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_executor.cc:1284
#5  0x00000000022bce08 in evaluate_join_record (join=0x7fd7c8032648, qep_tab=0x7fd7c8067ed0) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_executor.cc:1652
#6  0x00000000022bc584 in sub_select (join=0x7fd7c8032648, qep_tab=0x7fd7c8067ed0, end_of_records=false) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_executor.cc:1304
#7  0x00000000022bc01f in do_select (join=0x7fd7c8032648) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_executor.cc:957
#8  0x00000000022ba2df in JOIN::exec (this=0x7fd7c8032648) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_executor.cc:206
#9  0x000000000233e867 in handle_query (thd=0x7fd7c8039cb0, lex=0x7fd7c803be28, result=0x7fd7c8032150, added_options=0, removed_options=0, optimize_after_bh=0, free_join_from_bh=0)
    at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_select.cc:195
#10 0x00000000022ff761 in execute_sqlcom_select (thd=0x7fd7c8039cb0, all_tables=0x7fd7c8071ef8) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_parse.cc:5184
#11 0x00000000022f954f in mysql_execute_command (thd=0x7fd7c8039cb0, first_level=true) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_parse.cc:2831
#12 0x000000000230042e in mysql_parse (thd=0x7fd7c8039cb0, parser_state=0x7fd9ab1e4f00) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_parse.cc:5621
#13 0x00000000022f6878 in dispatch_command (thd=0x7fd7c8039cb0, com_data=0x7fd9ab1e5660, command=COM_QUERY) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_parse.cc:1495
#14 0x00000000022f5a1b in do_command (thd=0x7fd7c8039cb0) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_parse.cc:1034
#15 0x00000000023f995b in handle_connection (arg=0x649f180) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/conn_handler/connection_handler_per_thread.cc:313
#16 0x0000000002915591 in pfs_spawn_thread (arg=0x64b77c0) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/storage/perfschema/pfs.cc:2197
#17 0x00007fd9f61b8ea5 in start_thread () from /lib64/libpthread.so.0
#18 0x00007fd9f36dcb0d in clone () from /lib64/libc.so.6


(gdb) 
#0  Tianmu::core::Query::Preexecute (this=0x7fd9ab1e0680, qu=..., sender=0x7fd7c8070e90, display_now=true)
    at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/storage/tianmu/core/query.cpp:561
#1  0x00000000029d6a0e in Tianmu::core::Engine::Execute (this=0x41b2fd0, thd=0x7fd7c8039cb0, lex=0x7fd7c805e620, result_output=0x7fd7c805fed8, unit_for_union=0x0)
    at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/storage/tianmu/core/engine_execute.cpp:421
#2  0x00000000029d5bfe in Tianmu::core::Engine::HandleSelect (this=0x41b2fd0, thd=0x7fd7c8039cb0, lex=0x7fd7c805e620, result=@0x7fd9ab1e0b98: 0x7fd7c805fed8, setup_tables_done_option=0, 
    res=@0x7fd9ab1e0b94: 0, optimize_after_tianmu=@0x7fd9ab1e0b8c: 1, tianmu_free_join=@0x7fd9ab1e0b90: 1, with_insert=0)
    at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/storage/tianmu/core/engine_execute.cpp:232
#3  0x0000000002abb3b4 in Tianmu::dbhandler::TIANMU_HandleSelect (thd=0x7fd7c8039cb0, lex=0x7fd7c805e620, result=@0x7fd9ab1e0b98: 0x7fd7c805fed8, setup_tables_done_option=0, res=@0x7fd9ab1e0b94: 0, 
    optimize_after_tianmu=@0x7fd9ab1e0b8c: 1, tianmu_free_join=@0x7fd9ab1e0b90: 1, with_insert=0) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/storage/tianmu/handler/ha_rcengine.cpp:82
#4  0x00000000022ff727 in execute_sqlcom_select (thd=0x7fd7c8039cb0, all_tables=0x7fd7c8060110) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_parse.cc:5182
#5  0x00000000022f954f in mysql_execute_command (thd=0x7fd7c8039cb0, first_level=false) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_parse.cc:2831
#6  0x0000000002264ae8 in sp_instr_stmt::exec_core (this=0x7fd7c8060a28, thd=0x7fd7c8039cb0, nextp=0x7fd9ab1e2288) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sp_instr.cc:1027
#7  0x000000000226398b in sp_lex_instr::reset_lex_and_exec_core (this=0x7fd7c8060a28, thd=0x7fd7c8039cb0, nextp=0x7fd9ab1e2288, open_tables=false)
    at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sp_instr.cc:452
#8  0x0000000002264372 in sp_lex_instr::validate_lex_and_execute_core (this=0x7fd7c8060a28, thd=0x7fd7c8039cb0, nextp=0x7fd9ab1e2288, open_tables=false)
    at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sp_instr.cc:753
#9  0x0000000002264840 in sp_instr_stmt::execute (this=0x7fd7c8060a28, thd=0x7fd7c8039cb0, nextp=0x7fd9ab1e2288) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sp_instr.cc:938
#10 0x000000000225d505 in sp_head::execute (this=0x7fd7c8045fa0, thd=0x7fd7c8039cb0, merge_da_on_success=true) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sp_head.cc:796
#11 0x000000000225e4c7 in sp_head::execute_function (this=0x7fd7c8045fa0, thd=0x7fd7c8039cb0, argp=0x7fd7c8015ba8, argcount=1, return_value_fld=0x7fd7c80324c0)
    at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sp_head.cc:1287
#12 0x0000000001d76609 in Item_func_sp::execute_impl (this=0x7fd7c8015b00, thd=0x7fd7c8039cb0) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/item_func.cc:8706
#13 0x0000000001d7635c in Item_func_sp::execute (this=0x7fd7c8015b00) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/item_func.cc:8637
#14 0x0000000001d5d056 in Item_func_sp::val_int (this=0x7fd7c8015b00) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/item_func.h:2741
#15 0x0000000001d07bea in Item::send (this=0x7fd7c8015b00, protocol=0x7fd7c803ad10, buffer=0x7fd9ab1e3680) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/item.cc:7570
#16 0x00000000022ac08f in THD::send_result_set_row (this=0x7fd7c8039cb0, row_items=0x7fd7c80141d8) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_class.cc:4757
#17 0x00000000022a70fa in Query_result_send::send_data (this=0x7fd7c8032150, items=...) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_class.cc:2742
#18 0x00000000022bf790 in end_send (join=0x7fd7c8032648, qep_tab=0x7fd7c80681c0, end_of_records=false) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_executor.cc:2936
#19 0x00000000022bce08 in evaluate_join_record (join=0x7fd7c8032648, qep_tab=0x7fd7c8068048) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_executor.cc:1652
#20 0x00000000022bc584 in sub_select (join=0x7fd7c8032648, qep_tab=0x7fd7c8068048, end_of_records=false) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_executor.cc:1304
#21 0x00000000022bce08 in evaluate_join_record (join=0x7fd7c8032648, qep_tab=0x7fd7c8067ed0) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_executor.cc:1652
#22 0x00000000022bc584 in sub_select (join=0x7fd7c8032648, qep_tab=0x7fd7c8067ed0, end_of_records=false) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_executor.cc:1304
#23 0x00000000022bc01f in do_select (join=0x7fd7c8032648) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_executor.cc:957
#24 0x00000000022ba2df in JOIN::exec (this=0x7fd7c8032648) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_executor.cc:206
#25 0x000000000233e867 in handle_query (thd=0x7fd7c8039cb0, lex=0x7fd7c803be28, result=0x7fd7c8032150, added_options=0, removed_options=0, optimize_after_bh=0, free_join_from_bh=0)
    at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_select.cc:195
#26 0x00000000022ff761 in execute_sqlcom_select (thd=0x7fd7c8039cb0, all_tables=0x7fd7c8071ef8) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_parse.cc:5184
#27 0x00000000022f954f in mysql_execute_command (thd=0x7fd7c8039cb0, first_level=true) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_parse.cc:2831
#28 0x000000000230042e in mysql_parse (thd=0x7fd7c8039cb0, parser_state=0x7fd9ab1e4f00) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_parse.cc:5621
#29 0x00000000022f6878 in dispatch_command (thd=0x7fd7c8039cb0, com_data=0x7fd9ab1e5660, command=COM_QUERY) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_parse.cc:1495
#30 0x00000000022f5a1b in do_command (thd=0x7fd7c8039cb0) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_parse.cc:1034
#31 0x00000000023f995b in handle_connection (arg=0x649f180) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/conn_handler/connection_handler_per_thread.cc:313
#32 0x0000000002915591 in pfs_spawn_thread (arg=0x64b77c0) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/storage/perfschema/pfs.cc:2197
#33 0x00007fd9f61b8ea5 in start_thread () from /lib64/libpthread.so.0
#34 0x00007fd9f36dcb0d in clone () from /lib64/libc.so.6


 
T:-1 = TABLE_ALIAS(T:0,"employees")
T:-2 = TMP_TABLE(T:4294967295)
VC:-2.0 = CREATE_VC(T:-2,PHYS_COL(T:-1,A:5))
A:-1 = T:-2.ADD_COLUMN(VC:-2.0,LIST,"employee_salary","ALL")
VC:-2.1 = CREATE_VC(T:-2,PHYS_COL(T:-1,A:0))
VC:-2.2 = CREATE_VC(T:-2,EXPR("1"))
C:0 = CREATE_CONDS(T:-2,VC:-2.1,=,VC:-2.2,<null>)
T:-2.ADD_CONDS(C:0,WHERE)
T:-2.APPLY_CONDS()
RESULT(T:-2)
 

adofsauron avatar Sep 20 '22 01:09 adofsauron

Query Optimization

Source File

Description

/sql/abstract_query_plan.cc

Implements an abstract-query-plan interface for examining certain aspects of query plans without accessing mysqld internal classes (JOIN_TAB, SQL_SELECT, etc.) directly.

/sql/sql_optimizer.cc

Contains the optimizer-core functionality

/sql/sql_planner.cc

Contains classes to assist the optimizer in determining table order for retrieving rows for joins.

/sql/sql_select.h

The definitions for the structures used in the select functions to support the SELECT commands

/sql/sql_select.cc

Contains some of the optimization functions and the implementation of the select functions

/sql/sql_union.cc

Code for performing UNION operations.

Executing the Query

In the same way as the optimizer, the query execution uses a set of best practices for executing the query. For example, the query execution subsystem detects special clauses, such as ORDER BY and DISTINCT, and routes control of these operations to methods designed for fast sorting and tuple elimination.

Most of this activity occurs in the methods of the JOIN class. Listing 3-14 presents a condensed view of the join::exec() method. Notice that there is yet another function call to a function called by some name that includes select. Sure enough, there is another call that needs to be made to a function called do_select(). Take a look at the parameters for this function call. You are now starting to see things such as field lists. Does this mean you’re getting close to reading data? Yes, it does. In fact, the do_select() function is a high-level wrapper for exactly that.

adofsauron avatar Sep 20 '22 01:09 adofsauron

image

adofsauron avatar Sep 20 '22 01:09 adofsauron

image

adofsauron avatar Sep 20 '22 01:09 adofsauron

NULL was found when the argument to the custom function was passed


(gdb) bt
#0  Item_func_sp::execute_impl (this=0x7f77f80156a8, thd=0x7f77f8010540) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/item_func.cc:8706
#1  0x0000000001d7635c in Item_func_sp::execute (this=0x7f77f80156a8) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/item_func.cc:8637
#2  0x0000000001d5d056 in Item_func_sp::val_int (this=0x7f77f80156a8) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/item_func.h:2741
#3  0x0000000001d07bea in Item::send (this=0x7f77f80156a8, protocol=0x7f77f80115a0, buffer=0x7f79ee6ee620) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/item.cc:7570
#4  0x00000000022ac08f in THD::send_result_set_row (this=0x7f77f8010540, row_items=0x7f77f8014048) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_class.cc:4757
#5  0x00000000022a70fa in Query_result_send::send_data (this=0x7f77f804b720, items=...) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_class.cc:2742
#6  0x00000000022bf790 in end_send (join=0x7f77f8059c70, qep_tab=0x7f77f8003758, end_of_records=false) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_executor.cc:2938
#7  0x00000000022bce08 in evaluate_join_record (join=0x7f77f8059c70, qep_tab=0x7f77f80035e0) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_executor.cc:1654
#8  0x00000000022bd304 in evaluate_null_complemented_join_record (join=0x7f77f8059c70, qep_tab=0x7f77f80035e0) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_executor.cc:1794
#9  0x00000000022bc5d6 in sub_select (join=0x7f77f8059c70, qep_tab=0x7f77f80035e0, end_of_records=false) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_executor.cc:1312
#10 0x00000000022bce08 in evaluate_join_record (join=0x7f77f8059c70, qep_tab=0x7f77f8003468) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_executor.cc:1654
#11 0x00000000022bc584 in sub_select (join=0x7f77f8059c70, qep_tab=0x7f77f8003468, end_of_records=false) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_executor.cc:1304
#12 0x00000000022bc01f in do_select (join=0x7f77f8059c70) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_executor.cc:957
#13 0x00000000022ba2df in JOIN::exec (this=0x7f77f8059c70) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_executor.cc:206
#14 0x000000000233e867 in handle_query (thd=0x7f77f8010540, lex=0x7f77f80126b8, result=0x7f77f804b720, added_options=0, removed_options=0, optimize_after_bh=2, free_join_from_bh=1)
    at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_select.cc:195
#15 0x00000000022ff761 in execute_sqlcom_select (thd=0x7f77f8010540, all_tables=0x7f77f804a4d8) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_parse.cc:5184
#16 0x00000000022f954f in mysql_execute_command (thd=0x7f77f8010540, first_level=true) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_parse.cc:2831
#17 0x000000000230042e in mysql_parse (thd=0x7f77f8010540, parser_state=0x7f79ee6eff00) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_parse.cc:5621
#18 0x00000000022f6878 in dispatch_command (thd=0x7f77f8010540, com_data=0x7f79ee6f0660, command=COM_QUERY) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_parse.cc:1495
#19 0x00000000022f5a1b in do_command (thd=0x7f77f8010540) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_parse.cc:1034
#20 0x00000000023f995b in handle_connection (arg=0x67fe960) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/conn_handler/connection_handler_per_thread.cc:313
#21 0x0000000002915591 in pfs_spawn_thread (arg=0x67edbf0) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/storage/perfschema/pfs.cc:2197
#22 0x00007f7a396c3ea5 in start_thread () from /lib64/libpthread.so.0
#23 0x00007f7a36be7b0d in clone () from /lib64/libc.so.6


adofsauron avatar Sep 20 '22 01:09 adofsauron



(gdb) f
#9  0x000000000225e4c7 in sp_head::execute_function (this=0x7f8330031810, thd=0x7f8330011f20, argp=0x7f83300170e0, argcount=1, return_value_fld=0x7f833001e600)
    at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sp_head.cc:1287
1287	  err_status= execute(thd, TRUE);
(gdb) p binlog_buf
$36 = {
  m_ptr = 0x7f850d0252f0 "SELECT `t2`.`get_value`(NULL)", 
  m_length = 29, 
  m_charset = 0x3d8a2a0 <my_charset_bin>, 
  m_alloced_length = 80, 
  m_is_alloced = false
}

adofsauron avatar Sep 20 '22 01:09 adofsauron

After the index is removed, the direct result is normal. The localization problem lies in Tianmu's support for indexes


 
CREATE TABLE `employees_noindex` (
  `employee_id` int(11) NOT NULL DEFAULT 1,
  `employee_name` varchar(50) NOT NULL,
  `employee_sex` varchar(10) DEFAULT '男',
  `hire_date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `employee_mgr` int(11) DEFAULT NULL,
  `employee_salary` float DEFAULT '3000',
  `department_id` int(11) DEFAULT NULL
) ENGINE=TIANMU DEFAULT CHARSET=utf8mb4;



mysql>     select
    ->         a.employee_id,
    ->         b.employee_name,
    ->         get_value(b.employee_id)
    ->     from
    ->         employees_noindex a
    ->     inner join employees_noindex b on
    ->         a.employee_id = b.employee_id
    ->         and b.employee_name = 'David Tian';
+-------------+---------------+--------------------------+
| employee_id | employee_name | get_value(b.employee_id) |
+-------------+---------------+--------------------------+
|           1 | David Tian    |                     3000 |
+-------------+---------------+--------------------------+
1 row in set, 1 warning (0.00 sec)


adofsauron avatar Sep 20 '22 02:09 adofsauron

The Tianmu engine does not support the index interface


int TianmuHandler::index_init(uint index, [[maybe_unused]] bool sorted) {
  DBUG_ENTER(__PRETTY_FUNCTION__);
  active_index = index;
  DBUG_RETURN(0);
}

int TianmuHandler::index_end() {
  DBUG_ENTER(__PRETTY_FUNCTION__);
  active_index = MAX_KEY;
  DBUG_RETURN(0);
}


adofsauron avatar Sep 20 '22 02:09 adofsauron

Keep only the primary key index:


CREATE TABLE `employees_prindex` (
  `employee_id` int(11) NOT NULL DEFAULT '1',
  `employee_name` varchar(50) NOT NULL,
  `employee_sex` varchar(10) DEFAULT '男',
  `hire_date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `employee_mgr` int(11) DEFAULT NULL,
  `employee_salary` float DEFAULT '3000',
  `department_id` int(11) DEFAULT NULL,
  PRIMARY KEY (`employee_id`)
) ENGINE=TIANMU DEFAULT CHARSET=utf8mb4;


mysql>     select
    ->         a.employee_id,
    ->         get_value(b.employee_id)
    ->     from
    ->         employees_prindex a
    ->     left join employees_prindex b on
    ->         a.employee_id = b.employee_id
    ->         and b.employee_name = 'David Tian';
+-------------+--------------------------+
| employee_id | get_value(b.employee_id) |
+-------------+--------------------------+
|           1 |                     NULL |
+-------------+--------------------------+
1 row in set, 1 warning (0.01 sec)



``

adofsauron avatar Sep 20 '22 03:09 adofsauron

Mysql Column Storage engine -POC- Call custom functions - Parameter assignment


(gdb) bt
#0  Item_func::set_arguments (this=0x7f847c0156d8, list=..., context_free=true) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/item_func.cc:97
#1  0x0000000001d5e0db in Item_func::Item_func (this=0x7f847c0156d8, pos=..., opt_list=0x7f847c014bb8) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/item_func.cc:134
#2  0x0000000001d758f8 in Item_func_sp::Item_func_sp (this=0x7f847c0156d8, pos=..., db_name=..., fn_name=..., use_explicit_name=false, opt_list=0x7f847c014bb8)
    at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/item_func.cc:8374
#3  0x0000000001d47ed7 in Create_sp_func::create (this=0x3e0aff0 <Create_sp_func::s_singleton>, thd=0x7f847c010540, db=..., name=..., use_explicit_name=false, item_list=0x7f847c014bb8)
    at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/item_create.cc:4255
#4  0x0000000001d47a0a in Create_qfunc::create_func (this=0x3e0aff0 <Create_sp_func::s_singleton>, thd=0x7f847c010540, name=..., item_list=0x7f847c014bb8)
    at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/item_create.cc:4187
#5  0x0000000002413c9c in PTI_function_call_generic_ident_sys::itemize (this=0x7f847c014be8, pc=0x7f8665d27630, res=0x7f847c014d38)
    at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/parse_tree_items.h:350
#6  0x00000000024b77b2 in PTI_expr_with_alias::itemize (this=0x7f847c014ca0, pc=0x7f8665d27630, res=0x7f8665d26a08)
    at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/parse_tree_items.cc:186
#7  0x000000000240a2bf in PT_item_list::contextualize (this=0x7f847c0149f0, pc=0x7f8665d27630) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/parse_tree_helpers.h:77
#8  0x000000000240c761 in PT_select_item_list::contextualize (this=0x7f847c0149f0, pc=0x7f8665d27630) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/parse_tree_nodes.h:190
#9  0x0000000002410ed9 in PT_select_options_and_item_list::contextualize (this=0x7f847c014d70, pc=0x7f8665d27630)
    at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/parse_tree_nodes.h:2182
#10 0x00000000024110e1 in PT_select_part2::contextualize (this=0x7f847c015510, pc=0x7f8665d27630) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/parse_tree_nodes.h:2252
#11 0x0000000002411717 in PT_select_init2::contextualize (this=0x7f847c015578, pc=0x7f8665d27630) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/parse_tree_nodes.h:2377
#12 0x00000000024118a7 in PT_select::contextualize (this=0x7f847c015598, pc=0x7f8665d27630) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/parse_tree_nodes.h:2414
#13 0x0000000002416489 in MYSQLparse (YYTHD=0x7f847c010540) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_yacc.yy:1707
#14 0x0000000002302e46 in parse_sql (thd=0x7f847c010540, parser_state=0x7f8665d2af00, creation_ctx=0x0) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_parse.cc:7178
#15 0x00000000022fffba in mysql_parse (thd=0x7f847c010540, parser_state=0x7f8665d2af00) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_parse.cc:5501
#16 0x00000000022f6878 in dispatch_command (thd=0x7f847c010540, com_data=0x7f8665d2b660, command=COM_QUERY) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_parse.cc:1495
#17 0x00000000022f5a1b in do_command (thd=0x7f847c010540) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_parse.cc:1034
#18 0x00000000023f995b in handle_connection (arg=0x6903780) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/conn_handler/connection_handler_per_thread.cc:313
#19 0x0000000002915591 in pfs_spawn_thread (arg=0x6947e30) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/storage/perfschema/pfs.cc:2197
#20 0x00007f86b0cfeea5 in start_thread () from /lib64/libpthread.so.0
#21 0x00007f86ae222b0d in clone () from /lib64/libc.so.6


(gdb) p *(Item_field*)tmp_arg[0]
$102 = {
  <Item_ident> = {
    <Item> = {
      <Parse_tree_node> = {
        _vptr.Parse_tree_node = 0x3c65f40 <vtable for Parse_tree_node+16>
      }, 
      members of Item: 
      is_expensive_cache = -1 '\377', 
      rsize = 0, 
      str_value = {
        m_ptr = 0x0, 
        m_length = 0, 
        m_charset = 0x3d8a2a0 <my_charset_bin>, 
        m_alloced_length = 0, 
        m_is_alloced = false
      }, 
      item_name = {
        <Name_string> = {
          <Simple_cstring> = {
            m_str = 0x7f847c014a38 "employee_id", 
            m_length = 11
          }, <No data fields>}, 
        members of Item_name_string: 
        m_is_autogenerated = true
      }, 
      orig_name = {
        <Name_string> = {
          <Simple_cstring> = {
            m_str = 0x0, 
            m_length = 0
          }, <No data fields>}, 
        members of Item_name_string: 
        m_is_autogenerated = true
      }, 
      next = 0x7f847c014a48, 
      max_length = 11, 
      marker = 0, 
      decimals = 0 '\000', 
      maybe_null = 1 '\001', 
      null_value = 0 '\000', 
      unsigned_flag = 0 '\000', 
      with_sum_func = 0 '\000', 
      fixed = 0 '\000', 
      collation = {
---Type <return> to continue, or q <return> to quit---
        collation = 0x3d922c0 <my_charset_latin1>, 
        derivation = DERIVATION_NUMERIC, 
        repertoire = 1
      }, 
      cmp_context = 4294967295, 
      runtime_item = false, 
      derived_used = false, 
      with_subselect = 0 '\000', 
      with_stored_program = 0 '\000', 
      tables_locked_cache = false, 
      is_parser_item = true
    }, 
    members of Item_ident: 
    orig_db_name = 0x0, 
    orig_table_name = 0x7f847c014a30 "b", 
    orig_field_name = 0x7f847c014a38 "employee_id", 
    m_alias_of_expr = false, 
    context = 0x7f847c013f90, 
    db_name = 0x0, 
    table_name = 0x7f847c014a30 "b", 
    field_name = 0x7f847c014a38 "employee_id", 
    cached_field_index = 0, 
    cached_table = 0x7f847c04c5b8, 
    depended_from = 0x0
  }, 
  members of Item_field: 
  table_ref = 0x0, 
  field = 0x0, 
  result_field = 0x0, 
  item_equal = 0x0, 
  no_const_subst = false, 
  have_privileges = 0, 
  any_privileges = false
}


(gdb) p *item
$127 = {
  <Parse_tree_node> = {
    _vptr.Parse_tree_node = 0x3d1a578 <vtable for PTI_udf_expr+16>
  }, 
  members of Item: 
  is_expensive_cache = -1 '\377', 
  rsize = 0, 
  str_value = {
    m_ptr = 0x0, 
    m_length = 0, 
    m_charset = 0x3d8a2a0 <my_charset_bin>, 
    m_alloced_length = 0, 
    m_is_alloced = false
  }, 
  item_name = {
    <Name_string> = {
      <Simple_cstring> = {
        m_str = 0x0, 
        m_length = 0
      }, <No data fields>}, 
    members of Item_name_string: 
    m_is_autogenerated = true
  }, 
  orig_name = {
    <Name_string> = {
      <Simple_cstring> = {
        m_str = 0x0, 
        m_length = 0
      }, <No data fields>}, 
    members of Item_name_string: 
    m_is_autogenerated = true
  }, 
  next = 0x7f847c0156d8, 
  max_length = 0, 
  marker = 0, 
  decimals = 0 '\000', 
  maybe_null = 0 '\000', 
  null_value = 0 '\000', 
  unsigned_flag = 0 '\000', 
  with_sum_func = 0 '\000', 
  fixed = 0 '\000', 
  collation = {
    collation = 0x3d8a2a0 <my_charset_bin>, 
    derivation = DERIVATION_COERCIBLE, 
---Type <return> to continue, or q <return> to quit---
    repertoire = 3
  }, 
  cmp_context = 4294967295, 
  runtime_item = false, 
  derived_used = false, 
  with_subselect = 0 '\000', 
  with_stored_program = 0 '\000', 
  tables_locked_cache = false, 
  is_parser_item = true
}



(gdb)  p *(Item_field*)args[0]
$181 = {
  <Item_ident> = {
    <Item> = {
      <Parse_tree_node> = {
        _vptr.Parse_tree_node = 0x3d1a578 <vtable for PTI_udf_expr+16>
      }, 
      members of Item: 
      is_expensive_cache = -1 '\377', 
      rsize = 0, 
      str_value = {
        m_ptr = 0x0, 
        m_length = 0, 
        m_charset = 0x3d8a2a0 <my_charset_bin>, 
        m_alloced_length = 0, 
        m_is_alloced = false
      }, 
      item_name = {
        <Name_string> = {
          <Simple_cstring> = {
            m_str = 0x0, 
            m_length = 0
          }, <No data fields>}, 
        members of Item_name_string: 
        m_is_autogenerated = true
      }, 
      orig_name = {
        <Name_string> = {
          <Simple_cstring> = {
            m_str = 0x0, 
            m_length = 0
          }, <No data fields>}, 
        members of Item_name_string: 
        m_is_autogenerated = true
      }, 
      next = 0x7f847c0156d8, 
      max_length = 0, 
      marker = 0, 
      decimals = 0 '\000', 
      maybe_null = 0 '\000', 
      null_value = 0 '\000', 
      unsigned_flag = 0 '\000', 
      with_sum_func = 0 '\000', 
      fixed = 0 '\000', 
      collation = {
---Type <return> to continue, or q <return> to quit---
        collation = 0x3d8a2a0 <my_charset_bin>, 
        derivation = DERIVATION_COERCIBLE, 
        repertoire = 3
      }, 
      cmp_context = 4294967295, 
      runtime_item = false, 
      derived_used = false, 
      with_subselect = 0 '\000', 
      with_stored_program = 0 '\000', 
      tables_locked_cache = false, 
      is_parser_item = true
    }, 
    members of Item_ident: 
    orig_db_name = 0x7f847c014a48 "Ȉ\321\003", 
    orig_table_name = 0x0, 
    orig_field_name = 0x0, 
    m_alias_of_expr = 128, 
    context = 0x7f847c013e8d, 
    db_name = 0x0, 
    table_name = 0x31 <Address 0x31 out of bounds>, 
    field_name = 0x24d2bc60 <Address 0x24d2bc60 out of bounds>, 
    cached_field_index = 6609824, 
    cached_table = 0x0, 
    depended_from = 0x2532c760
  }, 
  members of Item_field: 
  table_ref = 0x30, 
  field = 0xa1, 
  result_field = 0x900000000, 
  item_equal = 0x0, 
  no_const_subst = false, 
  have_privileges = 0, 
  any_privileges = false
}


adofsauron avatar Sep 20 '22 06:09 adofsauron

But at execution time


(gdb) bt
#0  Item_func_sp::execute_impl (this=0x7f847c0156d8, thd=0x7f847c010540) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/item_func.cc:8706
#1  0x0000000001d7635c in Item_func_sp::execute (this=0x7f847c0156d8) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/item_func.cc:8637
#2  0x0000000001d5d056 in Item_func_sp::val_int (this=0x7f847c0156d8) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/item_func.h:2741
#3  0x0000000001d07bea in Item::send (this=0x7f847c0156d8, protocol=0x7f847c0115a0, buffer=0x7f8665d29620) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/item.cc:7570
#4  0x00000000022ac08f in THD::send_result_set_row (this=0x7f847c010540, row_items=0x7f847c014068) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_class.cc:4757
#5  0x00000000022a70fa in Query_result_send::send_data (this=0x7f847c01de60, items=...) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_class.cc:2742
#6  0x00000000022bf790 in end_send (join=0x7f847c05de10, qep_tab=0x7f847c04c668, end_of_records=false) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_executor.cc:2938
#7  0x00000000022bce08 in evaluate_join_record (join=0x7f847c05de10, qep_tab=0x7f847c04c4f0) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_executor.cc:1654
#8  0x00000000022bd304 in evaluate_null_complemented_join_record (join=0x7f847c05de10, qep_tab=0x7f847c04c4f0) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_executor.cc:1794
#9  0x00000000022bc5d6 in sub_select (join=0x7f847c05de10, qep_tab=0x7f847c04c4f0, end_of_records=false) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_executor.cc:1312
#10 0x00000000022bce08 in evaluate_join_record (join=0x7f847c05de10, qep_tab=0x7f847c04c378) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_executor.cc:1654
#11 0x00000000022bc584 in sub_select (join=0x7f847c05de10, qep_tab=0x7f847c04c378, end_of_records=false) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_executor.cc:1304
#12 0x00000000022bc01f in do_select (join=0x7f847c05de10) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_executor.cc:957
#13 0x00000000022ba2df in JOIN::exec (this=0x7f847c05de10) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_executor.cc:206
#14 0x000000000233e867 in handle_query (thd=0x7f847c010540, lex=0x7f847c0126b8, result=0x7f847c01de60, added_options=0, removed_options=0, optimize_after_bh=2, free_join_from_bh=1)
    at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_select.cc:195
#15 0x00000000022ff761 in execute_sqlcom_select (thd=0x7f847c010540, all_tables=0x7f847c01cc18) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_parse.cc:5184
#16 0x00000000022f954f in mysql_execute_command (thd=0x7f847c010540, first_level=true) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_parse.cc:2831
#17 0x000000000230042e in mysql_parse (thd=0x7f847c010540, parser_state=0x7f8665d2af00) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_parse.cc:5621
#18 0x00000000022f6878 in dispatch_command (thd=0x7f847c010540, com_data=0x7f8665d2b660, command=COM_QUERY) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_parse.cc:1495
#19 0x00000000022f5a1b in do_command (thd=0x7f847c010540) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_parse.cc:1034
#20 0x00000000023f995b in handle_connection (arg=0x6903780) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/conn_handler/connection_handler_per_thread.cc:313
#21 0x0000000002915591 in pfs_spawn_thread (arg=0x6947e30) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/storage/perfschema/pfs.cc:2197
#22 0x00007f86b0cfeea5 in start_thread () from /lib64/libpthread.so.0
#23 0x00007f86ae222b0d in clone () from /lib64/libc.so.6



(gdb) p *(Item_field*)args[0]
$180 = {
  <Item_ident> = {
    <Item> = {
      <Parse_tree_node> = {
        _vptr.Parse_tree_node = 0x3c704d8 <vtable for Item_field+16>
      }, 
      members of Item: 
      is_expensive_cache = -1 '\377', 
      rsize = 0, 
      str_value = {
        m_ptr = 0x0, 
        m_length = 0, 
        m_charset = 0x3d8a2a0 <my_charset_bin>, 
        m_alloced_length = 0, 
        m_is_alloced = false
      }, 
      item_name = {
        <Name_string> = {
          <Simple_cstring> = {
            m_str = 0x7f847c014a38 "employee_id", 
            m_length = 11
          }, <No data fields>}, 
        members of Item_name_string: 
        m_is_autogenerated = true
      }, 
      orig_name = {
        <Name_string> = {
          <Simple_cstring> = {
            m_str = 0x0, 
            m_length = 0
          }, <No data fields>}, 
        members of Item_name_string: 
        m_is_autogenerated = true
      }, 
      next = 0x7f847c014a48, 
      max_length = 11, 
      marker = 0, 
      decimals = 0 '\000', 
      maybe_null = 1 '\001', 
      null_value = 0 '\000', 
      unsigned_flag = 0 '\000', 
      with_sum_func = 0 '\000', 
      fixed = 1 '\001', 
      collation = {
---Type <return> to continue, or q <return> to quit---
        collation = 0x3d922c0 <my_charset_latin1>, 
        derivation = DERIVATION_NUMERIC, 
        repertoire = 1
      }, 
      cmp_context = 4294967295, 
      runtime_item = false, 
      derived_used = false, 
      with_subselect = 0 '\000', 
      with_stored_program = 0 '\000', 
      tables_locked_cache = false, 
      is_parser_item = true
    }, 
    members of Item_ident: 
    orig_db_name = 0x0, 
    orig_table_name = 0x7f847c014a30 "b", 
    orig_field_name = 0x7f847c014a38 "employee_id", 
    m_alias_of_expr = false, 
    context = 0x7f847c013f90, 
    db_name = 0x7f847c016550 "t2", 
    table_name = 0x7f847c024390 "b", 
    field_name = 0x7f847c0169e9 "employee_id", 
    cached_field_index = 0, 
    cached_table = 0x7f847c01d198, 
    depended_from = 0x0
  }, 
  members of Item_field: 
  table_ref = 0x7f847c01d198, 
  field = 0x7f847c025630, 
  result_field = 0x7f847c025630, 
  item_equal = 0x0, 
  no_const_subst = false, 
  have_privileges = 0, 
  any_privileges = false
}

adofsauron avatar Sep 20 '22 07:09 adofsauron

A place to assign values to custom function arguments



(gdb) bt
#0  Item_func::fix_func_arg (this=0x7f847c0156d8, thd=0x7f847c010540, arg=0x7f847c015780) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/item_func.cc:263
#1  0x0000000001d5e5a2 in Item_func::fix_fields (this=0x7f847c0156d8, thd=0x7f847c010540, ref=0x7f847c014d68) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/item_func.cc:249
#2  0x0000000001d76a00 in Item_func_sp::fix_fields (this=0x7f847c0156d8, thd=0x7f847c010540, ref=0x7f847c014d68) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/item_func.cc:8860
#3  0x0000000002293b8a in setup_fields (thd=0x7f847c010540, ref_pointer_array=..., fields=..., want_privilege=1, sum_func_list=0x7f847c014090, allow_sum_func=true, column_update=false)
    at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_base.cc:9138
#4  0x00000000023333ad in st_select_lex::prepare (this=0x7f847c013f30, thd=0x7f847c010540) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_resolver.cc:197
#5  0x00000000029d620a in Tianmu::core::optimize_select (thd=0x7f847c010540, select_options=2147748608, result=0x7f847c01de60, select_lex=0x7f847c013f30, optimize_after_tianmu=@0x7f8665d29dec: 0, 
    free_join=@0x7f8665d29df0: 1) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/storage/tianmu/core/engine_execute.cpp:338
#6  0x00000000029d5bc4 in Tianmu::core::Engine::HandleSelect (this=0x49f6160, thd=0x7f847c010540, lex=0x7f847c0126b8, result=@0x7f8665d29df8: 0x7f847c01de60, setup_tables_done_option=0, 
    res=@0x7f8665d29df4: 0, optimize_after_tianmu=@0x7f8665d29dec: 0, tianmu_free_join=@0x7f8665d29df0: 1, with_insert=0)
    at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/storage/tianmu/core/engine_execute.cpp:225
#7  0x0000000002abb3b4 in Tianmu::dbhandler::TIANMU_HandleSelect (thd=0x7f847c010540, lex=0x7f847c0126b8, result=@0x7f8665d29df8: 0x7f847c01de60, setup_tables_done_option=0, res=@0x7f8665d29df4: 0, 
    optimize_after_tianmu=@0x7f8665d29dec: 0, tianmu_free_join=@0x7f8665d29df0: 1, with_insert=0) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/storage/tianmu/handler/ha_rcengine.cpp:82
#8  0x00000000022ff727 in execute_sqlcom_select (thd=0x7f847c010540, all_tables=0x7f847c01cc18) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_parse.cc:5182
#9  0x00000000022f954f in mysql_execute_command (thd=0x7f847c010540, first_level=true) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_parse.cc:2831
#10 0x000000000230042e in mysql_parse (thd=0x7f847c010540, parser_state=0x7f8665d2af00) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_parse.cc:5621
#11 0x00000000022f6878 in dispatch_command (thd=0x7f847c010540, com_data=0x7f8665d2b660, command=COM_QUERY) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_parse.cc:1495
#12 0x00000000022f5a1b in do_command (thd=0x7f847c010540) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_parse.cc:1034
#13 0x00000000023f995b in handle_connection (arg=0x6903780) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/conn_handler/connection_handler_per_thread.cc:313
#14 0x0000000002915591 in pfs_spawn_thread (arg=0x6947e30) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/storage/perfschema/pfs.cc:2197
#15 0x00007f86b0cfeea5 in start_thread () from /lib64/libpthread.so.0
#16 0x00007f86ae222b0d in clone () from /lib64/libc.so.6



(gdb) p *(Item_field*)args[0]
$182 = {
  <Item_ident> = {
    <Item> = {
      <Parse_tree_node> = {
        _vptr.Parse_tree_node = 0x3c704d8 <vtable for Item_field+16>
      }, 
      members of Item: 
      is_expensive_cache = -1 '\377', 
      rsize = 0, 
      str_value = {
        m_ptr = 0x0, 
        m_length = 0, 
        m_charset = 0x3d8a2a0 <my_charset_bin>, 
        m_alloced_length = 0, 
        m_is_alloced = false
      }, 
      item_name = {
        <Name_string> = {
          <Simple_cstring> = {
            m_str = 0x7f847c014a38 "employee_id", 
            m_length = 11
          }, <No data fields>}, 
        members of Item_name_string: 
        m_is_autogenerated = true
      }, 
      orig_name = {
        <Name_string> = {
          <Simple_cstring> = {
            m_str = 0x0, 
            m_length = 0
          }, <No data fields>}, 
        members of Item_name_string: 
        m_is_autogenerated = true
      }, 
      next = 0x7f847c014a48, 
      max_length = 0, 
      marker = 0, 
      decimals = 0 '\000', 
      maybe_null = 0 '\000', 
      null_value = 0 '\000', 
      unsigned_flag = 0 '\000', 
      with_sum_func = 0 '\000', 
      fixed = 0 '\000', 
      collation = {
---Type <return> to continue, or q <return> to quit---
        collation = 0x3d8a2a0 <my_charset_bin>, 
        derivation = DERIVATION_IMPLICIT, 
        repertoire = 3
      }, 
      cmp_context = 4294967295, 
      runtime_item = false, 
      derived_used = false, 
      with_subselect = 0 '\000', 
      with_stored_program = 0 '\000', 
      tables_locked_cache = false, 
      is_parser_item = true
    }, 
    members of Item_ident: 
    orig_db_name = 0x0, 
    orig_table_name = 0x7f847c014a30 "b", 
    orig_field_name = 0x7f847c014a38 "employee_id", 
    m_alias_of_expr = false, 
    context = 0x7f847c013f90, 
    db_name = 0x0, 
    table_name = 0x7f847c014a30 "b", 
    field_name = 0x7f847c014a38 "employee_id", 
    cached_field_index = 4294967295, 
    cached_table = 0x0, 
    depended_from = 0x0
  }, 
  members of Item_field: 
  table_ref = 0x0, 
  field = 0x0, 
  result_field = 0x0, 
  item_equal = 0x0, 
  no_const_subst = false, 
  have_privileges = 0, 
  any_privileges = false
}


adofsauron avatar Sep 20 '22 07:09 adofsauron

When Item_func:: FIX_func_arg is executed a second time, look at the parameters


(gdb) bt
#0  Item_func::fix_func_arg (this=0x7f847c01d838, thd=0x7f847c010540, arg=0x7f847c01d8e0) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/item_func.cc:263
#1  0x0000000001d5e5a2 in Item_func::fix_fields (this=0x7f847c01d838, thd=0x7f847c010540, ref=0x7f847c015448) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/item_func.cc:249
#2  0x0000000001d27019 in Item_cond::fix_fields (this=0x7f847c015320, thd=0x7f847c010540, ref=0x7f847c01d208) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/item_cmpfunc.cc:5862
#3  0x00000000023356fd in st_select_lex::setup_conds (this=0x7f847c013f30, thd=0x7f847c010540) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_resolver.cc:1214
#4  0x0000000002333472 in st_select_lex::prepare (this=0x7f847c013f30, thd=0x7f847c010540) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_resolver.cc:212
#5  0x00000000029d620a in Tianmu::core::optimize_select (thd=0x7f847c010540, select_options=2147748608, result=0x7f847c01de60, select_lex=0x7f847c013f30, optimize_after_tianmu=@0x7f8665d29dec: 0, 
    free_join=@0x7f8665d29df0: 1) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/storage/tianmu/core/engine_execute.cpp:338
#6  0x00000000029d5bc4 in Tianmu::core::Engine::HandleSelect (this=0x49f6160, thd=0x7f847c010540, lex=0x7f847c0126b8, result=@0x7f8665d29df8: 0x7f847c01de60, setup_tables_done_option=0, 
    res=@0x7f8665d29df4: 0, optimize_after_tianmu=@0x7f8665d29dec: 0, tianmu_free_join=@0x7f8665d29df0: 1, with_insert=0)
    at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/storage/tianmu/core/engine_execute.cpp:225
#7  0x0000000002abb3b4 in Tianmu::dbhandler::TIANMU_HandleSelect (thd=0x7f847c010540, lex=0x7f847c0126b8, result=@0x7f8665d29df8: 0x7f847c01de60, setup_tables_done_option=0, res=@0x7f8665d29df4: 0, 
    optimize_after_tianmu=@0x7f8665d29dec: 0, tianmu_free_join=@0x7f8665d29df0: 1, with_insert=0) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/storage/tianmu/handler/ha_rcengine.cpp:82
#8  0x00000000022ff727 in execute_sqlcom_select (thd=0x7f847c010540, all_tables=0x7f847c01cc18) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_parse.cc:5182
#9  0x00000000022f954f in mysql_execute_command (thd=0x7f847c010540, first_level=true) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_parse.cc:2831
#10 0x000000000230042e in mysql_parse (thd=0x7f847c010540, parser_state=0x7f8665d2af00) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_parse.cc:5621
#11 0x00000000022f6878 in dispatch_command (thd=0x7f847c010540, com_data=0x7f8665d2b660, command=COM_QUERY) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_parse.cc:1495
#12 0x00000000022f5a1b in do_command (thd=0x7f847c010540) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_parse.cc:1034
#13 0x00000000023f995b in handle_connection (arg=0x6903780) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/conn_handler/connection_handler_per_thread.cc:313
#14 0x0000000002915591 in pfs_spawn_thread (arg=0x6947e30) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/storage/perfschema/pfs.cc:2197
#15 0x00007f86b0cfeea5 in start_thread () from /lib64/libpthread.so.0
#16 0x00007f86ae222b0d in clone () from /lib64/libc.so.6



(gdb) p *(Item_field*)args[0]
$191 = {
  <Item_ident> = {
    <Item> = {
      <Parse_tree_node> = {
        _vptr.Parse_tree_node = 0x3c704d8 <vtable for Item_field+16>
      }, 
      members of Item: 
      is_expensive_cache = -1 '\377', 
      rsize = 0, 
      str_value = {
        m_ptr = 0x0, 
        m_length = 0, 
        m_charset = 0x3d8a2a0 <my_charset_bin>, 
        m_alloced_length = 0, 
        m_is_alloced = false
      }, 
      item_name = {
        <Name_string> = {
          <Simple_cstring> = {
            m_str = 0x7f847c014ea8 "employee_id", 
            m_length = 11
          }, <No data fields>}, 
        members of Item_name_string: 
        m_is_autogenerated = true
      }, 
      orig_name = {
        <Name_string> = {
          <Simple_cstring> = {
            m_str = 0x0, 
            m_length = 0
          }, <No data fields>}, 
        members of Item_name_string: 
        m_is_autogenerated = true
      }, 
      next = 0x7f847c014eb8, 
      max_length = 0, 
      marker = 0, 
      decimals = 0 '\000', 
      maybe_null = 0 '\000', 
      null_value = 0 '\000', 
      unsigned_flag = 0 '\000', 
      with_sum_func = 0 '\000', 
      fixed = 0 '\000', 
      collation = {
---Type <return> to continue, or q <return> to quit---
        collation = 0x3d8a2a0 <my_charset_bin>, 
        derivation = DERIVATION_IMPLICIT, 
        repertoire = 3
      }, 
      cmp_context = 4294967295, 
      runtime_item = false, 
      derived_used = false, 
      with_subselect = 0 '\000', 
      with_stored_program = 0 '\000', 
      tables_locked_cache = false, 
      is_parser_item = true
    }, 
    members of Item_ident: 
    orig_db_name = 0x0, 
    orig_table_name = 0x7f847c014ea0 "a", 
    orig_field_name = 0x7f847c014ea8 "employee_id", 
    m_alias_of_expr = false, 
    context = 0x7f847c015ba0, 
    db_name = 0x0, 
    table_name = 0x7f847c014ea0 "a", 
    field_name = 0x7f847c014ea8 "employee_id", 
    cached_field_index = 4294967295, 
    cached_table = 0x0, 
    depended_from = 0x0
  }, 
  members of Item_field: 
  table_ref = 0x0, 
  field = 0x0, 
  result_field = 0x0, 
  item_equal = 0x0, 
  no_const_subst = false, 
  have_privileges = 0, 
  any_privileges = false
}


adofsauron avatar Sep 20 '22 07:09 adofsauron

When executed to Item_func:: FIX_func_arg after the function call, look at the parameters


(gdb) bt
#0  Item_func::fix_func_arg (this=0x7f847c037708, thd=0x7f847c010540, arg=0x7f847c0377b0) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/item_func.cc:263
#1  0x0000000001d5e5a2 in Item_func::fix_fields (this=0x7f847c037708, thd=0x7f847c010540, ref=0x7f847c035f90) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/item_func.cc:249
#2  0x00000000023355e5 in st_select_lex::setup_conds (this=0x7f847c035eb8, thd=0x7f847c010540) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_resolver.cc:1191
#3  0x0000000002333472 in st_select_lex::prepare (this=0x7f847c035eb8, thd=0x7f847c010540) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_resolver.cc:212
#4  0x00000000029d620a in Tianmu::core::optimize_select (thd=0x7f847c010540, select_options=2147486464, result=0x7f847c036d58, select_lex=0x7f847c035eb8, optimize_after_tianmu=@0x7f8665d26b2c: 0, 
    free_join=@0x7f8665d26b30: 1) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/storage/tianmu/core/engine_execute.cpp:338
#5  0x00000000029d5bc4 in Tianmu::core::Engine::HandleSelect (this=0x49f6160, thd=0x7f847c010540, lex=0x7f847c0354a0, result=@0x7f8665d26b38: 0x7f847c036d58, setup_tables_done_option=0, 
    res=@0x7f8665d26b34: 0, optimize_after_tianmu=@0x7f8665d26b2c: 0, tianmu_free_join=@0x7f8665d26b30: 1, with_insert=0)
    at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/storage/tianmu/core/engine_execute.cpp:225
#6  0x0000000002abb3b4 in Tianmu::dbhandler::TIANMU_HandleSelect (thd=0x7f847c010540, lex=0x7f847c0354a0, result=@0x7f8665d26b38: 0x7f847c036d58, setup_tables_done_option=0, res=@0x7f8665d26b34: 0, 
    optimize_after_tianmu=@0x7f8665d26b2c: 0, tianmu_free_join=@0x7f8665d26b30: 1, with_insert=0) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/storage/tianmu/handler/ha_rcengine.cpp:82
#7  0x00000000022ff727 in execute_sqlcom_select (thd=0x7f847c010540, all_tables=0x7f847c036f90) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_parse.cc:5182
#8  0x00000000022f954f in mysql_execute_command (thd=0x7f847c010540, first_level=false) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_parse.cc:2831
#9  0x0000000002264ae8 in sp_instr_stmt::exec_core (this=0x7f847c0378a8, thd=0x7f847c010540, nextp=0x7f8665d28228) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sp_instr.cc:1027
#10 0x000000000226398b in sp_lex_instr::reset_lex_and_exec_core (this=0x7f847c0378a8, thd=0x7f847c010540, nextp=0x7f8665d28228, open_tables=false)
    at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sp_instr.cc:452
#11 0x0000000002264372 in sp_lex_instr::validate_lex_and_execute_core (this=0x7f847c0378a8, thd=0x7f847c010540, nextp=0x7f8665d28228, open_tables=false)
    at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sp_instr.cc:753
#12 0x0000000002264840 in sp_instr_stmt::execute (this=0x7f847c0378a8, thd=0x7f847c010540, nextp=0x7f8665d28228) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sp_instr.cc:938
#13 0x000000000225d505 in sp_head::execute (this=0x7f847c02ede0, thd=0x7f847c010540, merge_da_on_success=true) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sp_head.cc:796
#14 0x000000000225e4c7 in sp_head::execute_function (this=0x7f847c02ede0, thd=0x7f847c010540, argp=0x7f847c015780, argcount=1, return_value_fld=0x7f847c0079f0)
    at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sp_head.cc:1287
#15 0x0000000001d76609 in Item_func_sp::execute_impl (this=0x7f847c0156d8, thd=0x7f847c010540) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/item_func.cc:8706
#16 0x0000000001d7635c in Item_func_sp::execute (this=0x7f847c0156d8) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/item_func.cc:8637
#17 0x0000000001d5d056 in Item_func_sp::val_int (this=0x7f847c0156d8) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/item_func.h:2741
#18 0x0000000001d07bea in Item::send (this=0x7f847c0156d8, protocol=0x7f847c0115a0, buffer=0x7f8665d29620) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/item.cc:7570
#19 0x00000000022ac08f in THD::send_result_set_row (this=0x7f847c010540, row_items=0x7f847c014068) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_class.cc:4757
#20 0x00000000022a70fa in Query_result_send::send_data (this=0x7f847c01de60, items=...) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_class.cc:2742
#21 0x00000000022bf790 in end_send (join=0x7f847c05de10, qep_tab=0x7f847c04c668, end_of_records=false) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_executor.cc:2938
#22 0x00000000022bce08 in evaluate_join_record (join=0x7f847c05de10, qep_tab=0x7f847c04c4f0) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_executor.cc:1654
#23 0x00000000022bd304 in evaluate_null_complemented_join_record (join=0x7f847c05de10, qep_tab=0x7f847c04c4f0) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_executor.cc:1794
#24 0x00000000022bc5d6 in sub_select (join=0x7f847c05de10, qep_tab=0x7f847c04c4f0, end_of_records=false) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_executor.cc:1312
#25 0x00000000022bce08 in evaluate_join_record (join=0x7f847c05de10, qep_tab=0x7f847c04c378) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_executor.cc:1654
#26 0x00000000022bc584 in sub_select (join=0x7f847c05de10, qep_tab=0x7f847c04c378, end_of_records=false) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_executor.cc:1304
#27 0x00000000022bc01f in do_select (join=0x7f847c05de10) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_executor.cc:957
#28 0x00000000022ba2df in JOIN::exec (this=0x7f847c05de10) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_executor.cc:206
#29 0x000000000233e867 in handle_query (thd=0x7f847c010540, lex=0x7f847c0126b8, result=0x7f847c01de60, added_options=0, removed_options=0, optimize_after_bh=2, free_join_from_bh=1)
    at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_select.cc:195
#30 0x00000000022ff761 in execute_sqlcom_select (thd=0x7f847c010540, all_tables=0x7f847c01cc18) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_parse.cc:5184
#31 0x00000000022f954f in mysql_execute_command (thd=0x7f847c010540, first_level=true) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_parse.cc:2831
#32 0x000000000230042e in mysql_parse (thd=0x7f847c010540, parser_state=0x7f8665d2af00) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_parse.cc:5621
#33 0x00000000022f6878 in dispatch_command (thd=0x7f847c010540, com_data=0x7f8665d2b660, command=COM_QUERY) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_parse.cc:1495
#34 0x00000000022f5a1b in do_command (thd=0x7f847c010540) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_parse.cc:1034
#35 0x00000000023f995b in handle_connection (arg=0x6903780) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/conn_handler/connection_handler_per_thread.cc:313
---Type <return> to continue, or q <return> to quit---
#36 0x0000000002915591 in pfs_spawn_thread (arg=0x6947e30) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/storage/perfschema/pfs.cc:2197
#37 0x00007f86b0cfeea5 in start_thread () from /lib64/libpthread.so.0
#38 0x00007f86ae222b0d in clone () from /lib64/libc.so.6



(gdb) p *(Item_field*)args[0]
$197 = {
  <Item_ident> = {
    <Item> = {
      <Parse_tree_node> = {
        _vptr.Parse_tree_node = 0x3c704d8 <vtable for Item_field+16>
      }, 
      members of Item: 
      is_expensive_cache = -1 '\377', 
      rsize = 0, 
      str_value = {
        m_ptr = 0x0, 
        m_length = 0, 
        m_charset = 0x3d8a2a0 <my_charset_bin>, 
        m_alloced_length = 0, 
        m_is_alloced = false
      }, 
      item_name = {
        <Name_string> = {
          <Simple_cstring> = {
            m_str = 0x7f847c0369e0 "employee_id", 
            m_length = 11
          }, <No data fields>}, 
        members of Item_name_string: 
        m_is_autogenerated = true
      }, 
      orig_name = {
        <Name_string> = {
          <Simple_cstring> = {
            m_str = 0x0, 
            m_length = 0
          }, <No data fields>}, 
        members of Item_name_string: 
        m_is_autogenerated = true
      }, 
      next = 0x7f847c0369f0, 
      max_length = 11, 
      marker = 0, 
      decimals = 0 '\000', 
      maybe_null = 0 '\000', 
      null_value = 0 '\000', 
      unsigned_flag = 0 '\000', 
      with_sum_func = 0 '\000', 
      fixed = 0 '\000', 
      collation = {
---Type <return> to continue, or q <return> to quit---
        collation = 0x3d922c0 <my_charset_latin1>, 
        derivation = DERIVATION_NUMERIC, 
        repertoire = 1
      }, 
      cmp_context = INT_RESULT, 
      runtime_item = false, 
      derived_used = false, 
      with_subselect = 0 '\000', 
      with_stored_program = 0 '\000', 
      tables_locked_cache = false, 
      is_parser_item = true
    }, 
    members of Item_ident: 
    orig_db_name = 0x0, 
    orig_table_name = 0x0, 
    orig_field_name = 0x7f847c0369e0 "employee_id", 
    m_alias_of_expr = false, 
    context = 0x7f847c035f18, 
    db_name = 0x0, 
    table_name = 0x0, 
    field_name = 0x7f847c0369e0 "employee_id", 
    cached_field_index = 0, 
    cached_table = 0x7f847c036f90, 
    depended_from = 0x0
  }, 
  members of Item_field: 
  table_ref = 0x0, 
  field = 0x0, 
  result_field = 0x0, 
  item_equal = 0x0, 
  no_const_subst = false, 
  have_privileges = 0, 
  any_privileges = false
}


adofsauron avatar Sep 20 '22 07:09 adofsauron

Execute the logic of the query when comparing tables without any indexes


(gdb) bt
#0  Tianmu::core::Engine::HandleSelect (this=0x49f6160, thd=0x7f847c010540, lex=0x7f847c033460, result=@0x7f8665d26ba8: 0x7f847c034d18, setup_tables_done_option=0, res=@0x7f8665d26ba4: 0, 
    optimize_after_tianmu=@0x7f8665d26b9c: 0, tianmu_free_join=@0x7f8665d26ba0: 0, with_insert=0)
    at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/storage/tianmu/core/engine_execute.cpp:225
#1  0x0000000002abb3b4 in Tianmu::dbhandler::TIANMU_HandleSelect (thd=0x7f847c010540, lex=0x7f847c033460, result=@0x7f8665d26ba8: 0x7f847c034d18, setup_tables_done_option=0, res=@0x7f8665d26ba4: 0, 
    optimize_after_tianmu=@0x7f8665d26b9c: 0, tianmu_free_join=@0x7f8665d26ba0: 0, with_insert=0) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/storage/tianmu/handler/ha_rcengine.cpp:82
#2  0x00000000022ff727 in execute_sqlcom_select (thd=0x7f847c010540, all_tables=0x7f847c034f50) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_parse.cc:5182
#3  0x00000000022f954f in mysql_execute_command (thd=0x7f847c010540, first_level=false) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_parse.cc:2831
#4  0x0000000002264ae8 in sp_instr_stmt::exec_core (this=0x7f847c035868, thd=0x7f847c010540, nextp=0x7f8665d28298) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sp_instr.cc:1027
#5  0x000000000226398b in sp_lex_instr::reset_lex_and_exec_core (this=0x7f847c035868, thd=0x7f847c010540, nextp=0x7f8665d28298, open_tables=false)
    at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sp_instr.cc:452
#6  0x0000000002264372 in sp_lex_instr::validate_lex_and_execute_core (this=0x7f847c035868, thd=0x7f847c010540, nextp=0x7f8665d28298, open_tables=false)
    at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sp_instr.cc:753
#7  0x0000000002264840 in sp_instr_stmt::execute (this=0x7f847c035868, thd=0x7f847c010540, nextp=0x7f8665d28298) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sp_instr.cc:938
#8  0x000000000225d505 in sp_head::execute (this=0x7f847c005790, thd=0x7f847c010540, merge_da_on_success=true) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sp_head.cc:796
#9  0x000000000225e4c7 in sp_head::execute_function (this=0x7f847c005790, thd=0x7f847c010540, argp=0x7f847c00ae50, argcount=1, return_value_fld=0x7f847c064040)
    at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sp_head.cc:1287
#10 0x0000000001d76609 in Item_func_sp::execute_impl (this=0x7f847c00ada8, thd=0x7f847c010540) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/item_func.cc:8706
#11 0x0000000001d7635c in Item_func_sp::execute (this=0x7f847c00ada8) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/item_func.cc:8637
#12 0x0000000001d5d056 in Item_func_sp::val_int (this=0x7f847c00ada8) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/item_func.h:2741
#13 0x0000000001d07bea in Item::send (this=0x7f847c00ada8, protocol=0x7f847c0115a0, buffer=0x7f8665d29690) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/item.cc:7570
#14 0x00000000022ac08f in THD::send_result_set_row (this=0x7f847c010540, row_items=0x7f847c009738) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_class.cc:4757
#15 0x00000000022a70fa in Query_result_send::send_data (this=0x7f847c01de60, items=...) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_class.cc:2742
#16 0x00000000022bf790 in end_send (join=0x7f847c03f8d0, qep_tab=0x7f847c040fe0, end_of_records=false) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_executor.cc:2938
#17 0x00000000024e5838 in JOIN_CACHE::generate_full_extensions (this=0x7f847c040fe0, rec_ptr=0x7f847cb0b571 "\001\001")
    at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_join_buffer.cc:2258
#18 0x00000000024e5571 in JOIN_CACHE_BNL::join_matching_records (this=0x7f847c040fe0, skip_last=false) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_join_buffer.cc:2141
#19 0x00000000024e4faa in JOIN_CACHE::join_records (this=0x7f847c040fe0, skip_last=false) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_join_buffer.cc:1938
#20 0x00000000024e1721 in JOIN_CACHE::end_send (this=0x7f847c040fe0) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_join_buffer.h:467
#21 0x00000000022bc239 in sub_select_op (join=0x7f847c03f8d0, qep_tab=0x7f847c040e68, end_of_records=true) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_executor.cc:1076
#22 0x00000000022bc2ea in sub_select (join=0x7f847c03f8d0, qep_tab=0x7f847c040cf0, end_of_records=true) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_executor.cc:1233
#23 0x00000000022bc045 in do_select (join=0x7f847c03f8d0) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_executor.cc:959
#24 0x00000000022ba2df in JOIN::exec (this=0x7f847c03f8d0) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_executor.cc:206
#25 0x000000000233e867 in handle_query (thd=0x7f847c010540, lex=0x7f847c0126b8, result=0x7f847c01de60, added_options=0, removed_options=0, optimize_after_bh=2, free_join_from_bh=1)
    at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_select.cc:195
#26 0x00000000022ff761 in execute_sqlcom_select (thd=0x7f847c010540, all_tables=0x7f847c01cc18) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_parse.cc:5184
#27 0x00000000022f954f in mysql_execute_command (thd=0x7f847c010540, first_level=true) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_parse.cc:2831
#28 0x000000000230042e in mysql_parse (thd=0x7f847c010540, parser_state=0x7f8665d2af00) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_parse.cc:5621
#29 0x00000000022f6878 in dispatch_command (thd=0x7f847c010540, com_data=0x7f8665d2b660, command=COM_QUERY) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_parse.cc:1495
#30 0x00000000022f5a1b in do_command (thd=0x7f847c010540) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_parse.cc:1034
#31 0x00000000023f995b in handle_connection (arg=0x6903780) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/conn_handler/connection_handler_per_thread.cc:313
#32 0x0000000002915591 in pfs_spawn_thread (arg=0x6947e30) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/storage/perfschema/pfs.cc:2197
#33 0x00007f86b0cfeea5 in start_thread () from /lib64/libpthread.so.0
#34 0x00007f86ae222b0d in clone () from /lib64/libc.so.6



(gdb) p (*(Item_field*) args[0]).field[0]
$248 = {
  <Proto_field> = {
    _vptr.Proto_field = 0x3c63ed0 <vtable for Field_long+16>
  }, 
  members of Field: 
  ptr = 0x7f847c023a31 "\001", 
  m_null_ptr = 0x0, 
  m_is_tmp_nullable = false, 
  m_is_tmp_null = false, 
  m_count_cuted_fields_saved = (unknown: 1634652180), 
  table = 0x7f847c023080, 
  orig_table = 0x7f847c023080, 
  table_name = 0x7f847c023170, 
  field_name = 0x7f847c047c59 "employee_id", 
  comment = {
    str = 0x3062fd1 "", 
    length = 0
  }, 
  key_start = {
    map = 0
  }, 
  part_of_key = {
    map = 0
  }, 
  part_of_sortkey = {
    map = 0
  }, 
  part_of_key_not_extended = {
    map = 0
  }, 
  unireg_check = Field::NONE, 
  field_length = 11, 
  flags = 1, 
  field_index = 0, 
  null_bit = 0 '\000', 
  is_created_from_null_item = false, 
  m_indexed = false, 
  m_warnings_pushed = 0, 
  gcol_info = 0x0, 
  stored_in_db = true
}



(gdb) p  *(*(Item_field*)args[0]).field
$25 = {
  <Proto_field> = {
    _vptr.Proto_field = 0x3c63ed0 <vtable for Field_long+16>
  }, 
  members of Field: 
  ptr = 0x7f847c092d71 "M", 
  m_null_ptr = 0x0, 
  m_is_tmp_nullable = false, 
  m_is_tmp_null = false, 
  m_count_cuted_fields_saved = (unknown: 1634652180), 
  table = 0x7f847c0923c0, 
  orig_table = 0x7f847c0923c0, 
  table_name = 0x7f847c0924b0, 
  field_name = 0x7f847c047c59 "employee_id", 
  comment = {
    str = 0x3062fd1 "", 
    length = 0
  }, 
  key_start = {
    map = 0
  }, 
  part_of_key = {
    map = 0
  }, 
  part_of_sortkey = {
    map = 0
  }, 
  part_of_key_not_extended = {
    map = 0
  }, 
  unireg_check = Field::NONE, 
  field_length = 11, 
  flags = 1, 
  field_index = 0, 
  null_bit = 0 '\000', 
  is_created_from_null_item = false, 
  m_indexed = false, 
  m_warnings_pushed = 0, 
  gcol_info = 0x0, 
  stored_in_db = true
}


adofsauron avatar Sep 20 '22 07:09 adofsauron

Execute the logic of the query when comparing tables with any indexes


(gdb) bt
#0  Tianmu::core::Engine::HandleSelect (this=0x49f6160, thd=0x7f847c010540, lex=0x7f847c0126b8, result=@0x7f8665d29df8: 0x7f847c040e30, setup_tables_done_option=0, res=@0x7f8665d29df4: 0, 
    optimize_after_tianmu=@0x7f8665d29dec: 0, tianmu_free_join=@0x7f8665d29df0: 0, with_insert=0)
    at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/storage/tianmu/core/engine_execute.cpp:225
#1  0x0000000002abb3b4 in Tianmu::dbhandler::TIANMU_HandleSelect (thd=0x7f847c010540, lex=0x7f847c0126b8, result=@0x7f8665d29df8: 0x7f847c040e30, setup_tables_done_option=0, res=@0x7f8665d29df4: 0, 
    optimize_after_tianmu=@0x7f8665d29dec: 0, tianmu_free_join=@0x7f8665d29df0: 0, with_insert=0) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/storage/tianmu/handler/ha_rcengine.cpp:82
#2  0x00000000022ff727 in execute_sqlcom_select (thd=0x7f847c010540, all_tables=0x7f847c01cc18) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_parse.cc:5182
#3  0x00000000022f954f in mysql_execute_command (thd=0x7f847c010540, first_level=true) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_parse.cc:2831
#4  0x000000000230042e in mysql_parse (thd=0x7f847c010540, parser_state=0x7f8665d2af00) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_parse.cc:5621
#5  0x00000000022f6878 in dispatch_command (thd=0x7f847c010540, com_data=0x7f8665d2b660, command=COM_QUERY) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_parse.cc:1495
#6  0x00000000022f5a1b in do_command (thd=0x7f847c010540) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_parse.cc:1034
#7  0x00000000023f995b in handle_connection (arg=0x6903780) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/conn_handler/connection_handler_per_thread.cc:313
#8  0x0000000002915591 in pfs_spawn_thread (arg=0x6947e30) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/storage/perfschema/pfs.cc:2197
#9  0x00007f86b0cfeea5 in start_thread () from /lib64/libpthread.so.0
#10 0x00007f86ae222b0d in clone () from /lib64/libc.so.6




(gdb) bt
#0  Tianmu::core::Engine::HandleSelect (this=0x49f6160, thd=0x7f847c010540, lex=0x7f847c02f420, result=@0x7f8665d26b38: 0x7f847c030cd8, setup_tables_done_option=0, res=@0x7f8665d26b34: 0, 
    optimize_after_tianmu=@0x7f8665d26b2c: 0, tianmu_free_join=@0x7f8665d26b30: 0, with_insert=0)
    at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/storage/tianmu/core/engine_execute.cpp:225
#1  0x0000000002abb3b4 in Tianmu::dbhandler::TIANMU_HandleSelect (thd=0x7f847c010540, lex=0x7f847c02f420, result=@0x7f8665d26b38: 0x7f847c030cd8, setup_tables_done_option=0, res=@0x7f8665d26b34: 0, 
    optimize_after_tianmu=@0x7f8665d26b2c: 0, tianmu_free_join=@0x7f8665d26b30: 0, with_insert=0) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/storage/tianmu/handler/ha_rcengine.cpp:82
#2  0x00000000022ff727 in execute_sqlcom_select (thd=0x7f847c010540, all_tables=0x7f847c030f10) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_parse.cc:5182
#3  0x00000000022f954f in mysql_execute_command (thd=0x7f847c010540, first_level=false) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_parse.cc:2831
#4  0x0000000002264ae8 in sp_instr_stmt::exec_core (this=0x7f847c031828, thd=0x7f847c010540, nextp=0x7f8665d28228) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sp_instr.cc:1027
#5  0x000000000226398b in sp_lex_instr::reset_lex_and_exec_core (this=0x7f847c031828, thd=0x7f847c010540, nextp=0x7f8665d28228, open_tables=false)
    at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sp_instr.cc:452
#6  0x0000000002264372 in sp_lex_instr::validate_lex_and_execute_core (this=0x7f847c031828, thd=0x7f847c010540, nextp=0x7f8665d28228, open_tables=false)
    at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sp_instr.cc:753
#7  0x0000000002264840 in sp_instr_stmt::execute (this=0x7f847c031828, thd=0x7f847c010540, nextp=0x7f8665d28228) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sp_instr.cc:938
#8  0x000000000225d505 in sp_head::execute (this=0x7f847c021d50, thd=0x7f847c010540, merge_da_on_success=true) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sp_head.cc:796
#9  0x000000000225e4c7 in sp_head::execute_function (this=0x7f847c021d50, thd=0x7f847c010540, argp=0x7f847c00ae50, argcount=1, return_value_fld=0x7f847c0410f0)
    at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sp_head.cc:1287
#10 0x0000000001d76609 in Item_func_sp::execute_impl (this=0x7f847c00ada8, thd=0x7f847c010540) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/item_func.cc:8706
#11 0x0000000001d7635c in Item_func_sp::execute (this=0x7f847c00ada8) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/item_func.cc:8637
#12 0x0000000001d5d056 in Item_func_sp::val_int (this=0x7f847c00ada8) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/item_func.h:2741
#13 0x0000000001d07bea in Item::send (this=0x7f847c00ada8, protocol=0x7f847c0115a0, buffer=0x7f8665d29620) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/item.cc:7570
#14 0x00000000022ac08f in THD::send_result_set_row (this=0x7f847c010540, row_items=0x7f847c009738) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_class.cc:4757
#15 0x00000000022a70fa in Query_result_send::send_data (this=0x7f847c040e30, items=...) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_class.cc:2742
#16 0x00000000022bf790 in end_send (join=0x7f847c039090, qep_tab=0x7f847c078318, end_of_records=false) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_executor.cc:2938
#17 0x00000000022bce08 in evaluate_join_record (join=0x7f847c039090, qep_tab=0x7f847c0781a0) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_executor.cc:1654
#18 0x00000000022bd304 in evaluate_null_complemented_join_record (join=0x7f847c039090, qep_tab=0x7f847c0781a0) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_executor.cc:1794
#19 0x00000000022bc5d6 in sub_select (join=0x7f847c039090, qep_tab=0x7f847c0781a0, end_of_records=false) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_executor.cc:1312
#20 0x00000000022bce08 in evaluate_join_record (join=0x7f847c039090, qep_tab=0x7f847c078028) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_executor.cc:1654
#21 0x00000000022bc584 in sub_select (join=0x7f847c039090, qep_tab=0x7f847c078028, end_of_records=false) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_executor.cc:1304
#22 0x00000000022bc01f in do_select (join=0x7f847c039090) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_executor.cc:957
#23 0x00000000022ba2df in JOIN::exec (this=0x7f847c039090) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_executor.cc:206
#24 0x000000000233e867 in handle_query (thd=0x7f847c010540, lex=0x7f847c0126b8, result=0x7f847c040e30, added_options=0, removed_options=0, optimize_after_bh=2, free_join_from_bh=1)
    at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_select.cc:195
#25 0x00000000022ff761 in execute_sqlcom_select (thd=0x7f847c010540, all_tables=0x7f847c01cc18) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_parse.cc:5184
#26 0x00000000022f954f in mysql_execute_command (thd=0x7f847c010540, first_level=true) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_parse.cc:2831
#27 0x000000000230042e in mysql_parse (thd=0x7f847c010540, parser_state=0x7f8665d2af00) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_parse.cc:5621
#28 0x00000000022f6878 in dispatch_command (thd=0x7f847c010540, com_data=0x7f8665d2b660, command=COM_QUERY) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_parse.cc:1495
#29 0x00000000022f5a1b in do_command (thd=0x7f847c010540) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_parse.cc:1034
#30 0x00000000023f995b in handle_connection (arg=0x6903780) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/conn_handler/connection_handler_per_thread.cc:313
#31 0x0000000002915591 in pfs_spawn_thread (arg=0x6947e30) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/storage/perfschema/pfs.cc:2197
#32 0x00007f86b0cfeea5 in start_thread () from /lib64/libpthread.so.0
#33 0x00007f86ae222b0d in clone () from /lib64/libc.so.6
 



```cpp

(gdb) bt
#0  Item_func::fix_func_arg (this=0x7f847c031688, thd=0x7f847c010540, arg=0x7f847c031730) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/item_func.cc:263
#1  0x0000000001d5e5a2 in Item_func::fix_fields (this=0x7f847c031688, thd=0x7f847c010540, ref=0x7f847c02ff10) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/item_func.cc:249
#2  0x00000000023355e5 in st_select_lex::setup_conds (this=0x7f847c02fe38, thd=0x7f847c010540) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_resolver.cc:1191
#3  0x0000000002333472 in st_select_lex::prepare (this=0x7f847c02fe38, thd=0x7f847c010540) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_resolver.cc:212
#4  0x00000000029d620a in Tianmu::core::optimize_select (thd=0x7f847c010540, select_options=2147486464, result=0x7f847c030cd8, select_lex=0x7f847c02fe38, optimize_after_tianmu=@0x7f8665d26b2c: 0, 
    free_join=@0x7f8665d26b30: 1) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/storage/tianmu/core/engine_execute.cpp:338
#5  0x00000000029d5bc4 in Tianmu::core::Engine::HandleSelect (this=0x49f6160, thd=0x7f847c010540, lex=0x7f847c02f420, result=@0x7f8665d26b38: 0x7f847c030cd8, setup_tables_done_option=0, 
    res=@0x7f8665d26b34: 0, optimize_after_tianmu=@0x7f8665d26b2c: 0, tianmu_free_join=@0x7f8665d26b30: 1, with_insert=0)
    at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/storage/tianmu/core/engine_execute.cpp:225
#6  0x0000000002abb3b4 in Tianmu::dbhandler::TIANMU_HandleSelect (thd=0x7f847c010540, lex=0x7f847c02f420, result=@0x7f8665d26b38: 0x7f847c030cd8, setup_tables_done_option=0, res=@0x7f8665d26b34: 0, 
    optimize_after_tianmu=@0x7f8665d26b2c: 0, tianmu_free_join=@0x7f8665d26b30: 1, with_insert=0) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/storage/tianmu/handler/ha_rcengine.cpp:82
#7  0x00000000022ff727 in execute_sqlcom_select (thd=0x7f847c010540, all_tables=0x7f847c030f10) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_parse.cc:5182
#8  0x00000000022f954f in mysql_execute_command (thd=0x7f847c010540, first_level=false) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_parse.cc:2831
#9  0x0000000002264ae8 in sp_instr_stmt::exec_core (this=0x7f847c031828, thd=0x7f847c010540, nextp=0x7f8665d28228) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sp_instr.cc:1027
#10 0x000000000226398b in sp_lex_instr::reset_lex_and_exec_core (this=0x7f847c031828, thd=0x7f847c010540, nextp=0x7f8665d28228, open_tables=false)
    at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sp_instr.cc:452
#11 0x0000000002264372 in sp_lex_instr::validate_lex_and_execute_core (this=0x7f847c031828, thd=0x7f847c010540, nextp=0x7f8665d28228, open_tables=false)
    at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sp_instr.cc:753
#12 0x0000000002264840 in sp_instr_stmt::execute (this=0x7f847c031828, thd=0x7f847c010540, nextp=0x7f8665d28228) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sp_instr.cc:938
#13 0x000000000225d505 in sp_head::execute (this=0x7f847c021d50, thd=0x7f847c010540, merge_da_on_success=true) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sp_head.cc:796
#14 0x000000000225e4c7 in sp_head::execute_function (this=0x7f847c021d50, thd=0x7f847c010540, argp=0x7f847c00ae50, argcount=1, return_value_fld=0x7f847c0410f0)
    at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sp_head.cc:1287
#15 0x0000000001d76609 in Item_func_sp::execute_impl (this=0x7f847c00ada8, thd=0x7f847c010540) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/item_func.cc:8706
#16 0x0000000001d7635c in Item_func_sp::execute (this=0x7f847c00ada8) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/item_func.cc:8637
#17 0x0000000001d5d056 in Item_func_sp::val_int (this=0x7f847c00ada8) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/item_func.h:2741
#18 0x0000000001d07bea in Item::send (this=0x7f847c00ada8, protocol=0x7f847c0115a0, buffer=0x7f8665d29620) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/item.cc:7570
#19 0x00000000022ac08f in THD::send_result_set_row (this=0x7f847c010540, row_items=0x7f847c009738) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_class.cc:4757
#20 0x00000000022a70fa in Query_result_send::send_data (this=0x7f847c040e30, items=...) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_class.cc:2742
#21 0x00000000022bf790 in end_send (join=0x7f847c039090, qep_tab=0x7f847c078318, end_of_records=false) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_executor.cc:2938
#22 0x00000000022bce08 in evaluate_join_record (join=0x7f847c039090, qep_tab=0x7f847c0781a0) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_executor.cc:1654
#23 0x00000000022bd304 in evaluate_null_complemented_join_record (join=0x7f847c039090, qep_tab=0x7f847c0781a0) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_executor.cc:1794
#24 0x00000000022bc5d6 in sub_select (join=0x7f847c039090, qep_tab=0x7f847c0781a0, end_of_records=false) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_executor.cc:1312
#25 0x00000000022bce08 in evaluate_join_record (join=0x7f847c039090, qep_tab=0x7f847c078028) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_executor.cc:1654
#26 0x00000000022bc584 in sub_select (join=0x7f847c039090, qep_tab=0x7f847c078028, end_of_records=false) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_executor.cc:1304
#27 0x00000000022bc01f in do_select (join=0x7f847c039090) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_executor.cc:957
#28 0x00000000022ba2df in JOIN::exec (this=0x7f847c039090) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_executor.cc:206
#29 0x000000000233e867 in handle_query (thd=0x7f847c010540, lex=0x7f847c0126b8, result=0x7f847c040e30, added_options=0, removed_options=0, optimize_after_bh=2, free_join_from_bh=1)
    at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_select.cc:195
#30 0x00000000022ff761 in execute_sqlcom_select (thd=0x7f847c010540, all_tables=0x7f847c01cc18) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_parse.cc:5184
#31 0x00000000022f954f in mysql_execute_command (thd=0x7f847c010540, first_level=true) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_parse.cc:2831
#32 0x000000000230042e in mysql_parse (thd=0x7f847c010540, parser_state=0x7f8665d2af00) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_parse.cc:5621
#33 0x00000000022f6878 in dispatch_command (thd=0x7f847c010540, com_data=0x7f8665d2b660, command=COM_QUERY) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_parse.cc:1495
#34 0x00000000022f5a1b in do_command (thd=0x7f847c010540) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/sql_parse.cc:1034
#35 0x00000000023f995b in handle_connection (arg=0x6903780) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/sql/conn_handler/connection_handler_per_thread.cc:313
---Type <return> to continue, or q <return> to quit---
#36 0x0000000002915591 in pfs_spawn_thread (arg=0x6947e30) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-128/storage/perfschema/pfs.cc:2197
#37 0x00007f86b0cfeea5 in start_thread () from /lib64/libpthread.so.0
#38 0x00007f86ae222b0d in clone () from /lib64/libc.so.6


adofsauron avatar Sep 20 '22 07:09 adofsauron

Mysql column storage engine, the previous index logic function is not complete. Crash was caused after removing the use of index logic.


(gdb) bt
#0  0x00007f27fe230387 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:55
#1  0x00007f27fe231a78 in __GI_abort () at abort.c:90
#2  0x0000000002f87ba5 in __gnu_cxx::__verbose_terminate_handler() ()
#3  0x0000000002ef63a6 in __cxxabiv1::__terminate(void (*)()) ()
#4  0x0000000002ef63f1 in std::terminate() ()
#5  0x0000000002ee9cc3 in __cxa_throw ()
#6  0x0000000002f7db1f in std::__throw_length_error(char const*) ()
#7  0x00000000029eb342 in std::vector<bool, std::allocator<bool> >::_M_check_len (this=0x7f2404cd94d0, __n=18446603336221196289, __s=0x315388d "vector<bool>::_M_fill_insert")
    at /opt/rh/devtoolset-7/root/usr/include/c++/7/bits/stl_bvector.h:1251
#8  0x00000000029eada5 in std::vector<bool, std::allocator<bool> >::_M_fill_insert (this=0x7f2404cd94d0, __position=..., __n=18446603336221196289, __x=false)
    at /opt/rh/devtoolset-7/root/usr/include/c++/7/bits/vector.tcc:741
#9  0x00000000029ea695 in std::vector<bool, std::allocator<bool> >::insert (this=0x7f2404cd94d0, __position=..., __n=18446603336221196289, __x=@0x7f27b5dfe51c: false)
    at /opt/rh/devtoolset-7/root/usr/include/c++/7/bits/stl_bvector.h:995
#10 0x00000000029ea25f in std::vector<bool, std::allocator<bool> >::resize (this=0x7f2404cd94d0, __new_size=18446603336221196289, __x=false)
    at /opt/rh/devtoolset-7/root/usr/include/c++/7/bits/stl_bvector.h:1036
#11 0x00000000029e52dc in Tianmu::core::Filter::Filter (this=0x7f2404cd9460, no_obj=-9223372036854775807, power=16, all_ones=false, shallow=false)
    at /data2/jenkins/workspace/stonedb5.7-zsl-centos7.9-30-238/storage/tianmu/core/filter.cpp:48
#12 0x0000000002d15417 in Tianmu::core::MIUpdatingIterator::MIUpdatingIterator (this=0x7f27b5dfe660, _mind=0x7f2404cd7bb0, dimensions=...)
    at /data2/jenkins/workspace/stonedb5.7-zsl-centos7.9-30-238/storage/tianmu/core/mi_updating_iterator.cpp:31
#13 0x0000000002d3c6ed in Tianmu::core::ParameterizedFilter::FilterDeletedByTable (this=0x7f2404cd7a40, rcTable=0x7f2404c34e40, no_dims=0)
    at /data2/jenkins/workspace/stonedb5.7-zsl-centos7.9-30-238/storage/tianmu/core/parameterized_filter.cpp:1470
#14 0x0000000002d39bb3 in Tianmu::core::ParameterizedFilter::UpdateMultiIndex (this=0x7f2404cd7a40, count_only=false, limit=-1)
    at /data2/jenkins/workspace/stonedb5.7-zsl-centos7.9-30-238/storage/tianmu/core/parameterized_filter.cpp:991
#15 0x0000000002a05157 in Tianmu::core::Query::Preexecute (this=0x7f27b5dff900, qu=..., sender=0x7f2404cd7790, display_now=true)
    at /data2/jenkins/workspace/stonedb5.7-zsl-centos7.9-30-238/storage/tianmu/core/query.cpp:777
#16 0x00000000029d7153 in Tianmu::core::Engine::Execute (this=0x5984890, thd=0x7f240403ff50, lex=0x7f24040420c8, result_output=0x7f2404c74d38, unit_for_union=0x0)
    at /data2/jenkins/workspace/stonedb5.7-zsl-centos7.9-30-238/storage/tianmu/core/engine_execute.cpp:421
#17 0x00000000029d634c in Tianmu::core::Engine::HandleSelect (this=0x5984890, thd=0x7f240403ff50, lex=0x7f24040420c8, result=@0x7f27b5dffdf8: 0x7f2404c74d38, setup_tables_done_option=0, 
    res=@0x7f27b5dffdf4: 0, optimize_after_tianmu=@0x7f27b5dffdec: 1, tianmu_free_join=@0x7f27b5dffdf0: 1, with_insert=0)
    at /data2/jenkins/workspace/stonedb5.7-zsl-centos7.9-30-238/storage/tianmu/core/engine_execute.cpp:232
#18 0x0000000002abb93d in Tianmu::dbhandler::TIANMU_HandleSelect (thd=0x7f240403ff50, lex=0x7f24040420c8, result=@0x7f27b5dffdf8: 0x7f2404c74d38, setup_tables_done_option=0, res=@0x7f27b5dffdf4: 0, 
    optimize_after_tianmu=@0x7f27b5dffdec: 1, tianmu_free_join=@0x7f27b5dffdf0: 1, with_insert=0)
    at /data2/jenkins/workspace/stonedb5.7-zsl-centos7.9-30-238/storage/tianmu/handler/ha_rcengine.cpp:82
#19 0x00000000022ffe85 in execute_sqlcom_select (thd=0x7f240403ff50, all_tables=0x7f24040512c8) at /data2/jenkins/workspace/stonedb5.7-zsl-centos7.9-30-238/sql/sql_parse.cc:5182
#20 0x00000000022f9cad in mysql_execute_command (thd=0x7f240403ff50, first_level=true) at /data2/jenkins/workspace/stonedb5.7-zsl-centos7.9-30-238/sql/sql_parse.cc:2831
#21 0x0000000002300b8c in mysql_parse (thd=0x7f240403ff50, parser_state=0x7f27b5e00f00) at /data2/jenkins/workspace/stonedb5.7-zsl-centos7.9-30-238/sql/sql_parse.cc:5621
#22 0x00000000022f6fd6 in dispatch_command (thd=0x7f240403ff50, com_data=0x7f27b5e01660, command=COM_QUERY) at /data2/jenkins/workspace/stonedb5.7-zsl-centos7.9-30-238/sql/sql_parse.cc:1495
#23 0x00000000022f6179 in do_command (thd=0x7f240403ff50) at /data2/jenkins/workspace/stonedb5.7-zsl-centos7.9-30-238/sql/sql_parse.cc:1034
#24 0x00000000023fa0bb in handle_connection (arg=0x739e780) at /data2/jenkins/workspace/stonedb5.7-zsl-centos7.9-30-238/sql/conn_handler/connection_handler_per_thread.cc:313
#25 0x0000000002915cf1 in pfs_spawn_thread (arg=0x7a2ca60) at /data2/jenkins/workspace/stonedb5.7-zsl-centos7.9-30-238/storage/perfschema/pfs.cc:2197
#26 0x00007f2800dafea5 in start_thread (arg=0x7f27b5e02700) at pthread_create.c:307
#27 0x00007f27fe2f8b0d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111



(gdb) f 11
#11 0x00000000029e52dc in Tianmu::core::Filter::Filter (this=0x7f2404cd9460, no_obj=-9223372036854775807, power=16, all_ones=false, shallow=false)
    at /data2/jenkins/workspace/stonedb5.7-zsl-centos7.9-30-238/storage/tianmu/core/filter.cpp:48
48	  block_changed.resize(no_blocks);
(gdb) p no_blocks
$1 = 18446603336221196289
(gdb) p no_obj
$2 = -9223372036854775807
(gdb) f 12
#12 0x0000000002d15417 in Tianmu::core::MIUpdatingIterator::MIUpdatingIterator (this=0x7f27b5dfe660, _mind=0x7f2404cd7bb0, dimensions=...)
    at /data2/jenkins/workspace/stonedb5.7-zsl-centos7.9-30-238/storage/tianmu/core/mi_updating_iterator.cpp:31
31	    multi_dim_filter.reset(new Filter(no_obj, pack_power));
(gdb) f 13
#13 0x0000000002d3c6ed in Tianmu::core::ParameterizedFilter::FilterDeletedByTable (this=0x7f2404cd7a40, rcTable=0x7f2404c34e40, no_dims=0)
    at /data2/jenkins/workspace/stonedb5.7-zsl-centos7.9-30-238/storage/tianmu/core/parameterized_filter.cpp:1470
1470	  MIUpdatingIterator mit(mind, dims);
(gdb) f 123
#0  0x0000000000000000 in ?? ()
(gdb) f 12
#12 0x0000000002d15417 in Tianmu::core::MIUpdatingIterator::MIUpdatingIterator (this=0x7f27b5dfe660, _mind=0x7f2404cd7bb0, dimensions=...)
    at /data2/jenkins/workspace/stonedb5.7-zsl-centos7.9-30-238/storage/tianmu/core/mi_updating_iterator.cpp:31
31	    multi_dim_filter.reset(new Filter(no_obj, pack_power));
(gdb) f 12
#12 0x0000000002d15417 in Tianmu::core::MIUpdatingIterator::MIUpdatingIterator (this=0x7f27b5dfe660, _mind=0x7f2404cd7bb0, dimensions=...)
    at /data2/jenkins/workspace/stonedb5.7-zsl-centos7.9-30-238/storage/tianmu/core/mi_updating_iterator.cpp:31
31	    multi_dim_filter.reset(new Filter(no_obj, pack_power));


adofsauron avatar Sep 20 '22 13:09 adofsauron

Syntax tree when arriving at the column engine:


 
 T:-1 = TABLE_ALIAS(T:0,"STSSALESVOUCHERTAB")
 T:-2 = TMP_TABLE(T:-1,T:-3,T:-4,T:-5,T:-6,T:-7,T:4294967288)
 T:-3 = TABLE_ALIAS(T:1,"STSSALESVOUCHERDETAILSTAB")
 T:-4 = TABLE_ALIAS(T:2,"CUSTOM")
 T:-5 = TABLE_ALIAS(T:2,"CUSTOM")
 VC:-2.0 = CREATE_VC(T:-2,PHYS_COL(T:-5,A:0))
 VC:-2.1 = CREATE_VC(T:-2,PHYS_COL(T:-4,A:13))
 C:0 = CREATE_CONDS(T:-2,VC:-2.0,=,VC:-2.1,<null>)
 T:-2.LEFT_JOIN_ON({T:-1,T:-3,T:-4},{T:-5},C:0)
 T:-6 = TABLE_ALIAS(T:3,"EDMTICKETTYPETAB")
 T:-7 = TABLE_ALIAS(T:4,"EDMCROWDKINDPRICETAB")
 T:-8 = TABLE_ALIAS(T:5,"STSSALESSETTLEMENTTAB")
 VC:-2.2 = CREATE_VC(T:-2,PHYS_COL(T:-1,A:17))
 A:-1 = T:-2.ADD_COLUMN(VC:-2.2,GROUP_BY,"usid","ALL")
 VC:-2.3 = CREATE_VC(T:-2,PHYS_COL(T:-4,A:14))
 A:-2 = T:-2.ADD_COLUMN(VC:-2.3,GROUP_BY,"corpname","ALL")
 VC:-2.4 = CREATE_VC(T:-2,PHYS_COL(T:-1,A:2))
 A:-3 = T:-2.ADD_COLUMN(VC:-2.4,GROUP_BY,"iscenicid","ALL")
 VC:-2.5 = CREATE_VC(T:-2,PHYS_COL(T:-3,A:4))
 A:-4 = T:-2.ADD_COLUMN(VC:-2.5,GROUP_BY,"itickettypeid","ALL")
 VC:-2.6 = CREATE_VC(T:-2,PHYS_COL(T:-7,A:3))
 A:-5 = T:-2.ADD_COLUMN(VC:-2.6,GROUP_BY,"icrowdkindid","ALL")
 VC:-2.7 = CREATE_VC(T:-2,PHYS_COL(T:-3,A:21))
 A:-6 = T:-2.ADD_COLUMN(VC:-2.7,GROUP_BY,"mactualsaleprice","ALL")
 VC:-2.8 = CREATE_VC(T:-2,PHYS_COL(T:-3,A:16))
 A:-7 = T:-2.ADD_COLUMN(VC:-2.8,SUM,"numb","ALL")
 VC:-2.9 = CREATE_VC(T:-2,PHYS_COL(T:-3,A:22))
 A:-8 = T:-2.ADD_COLUMN(VC:-2.9,SUM,"mont","ALL")
 VC:-2.10 = CREATE_VC(T:-2,PHYS_COL(T:-3,A:23))
 A:-9 = T:-2.ADD_COLUMN(VC:-2.10,SUM,"null","ALL")
 VC:-2.11 = CREATE_VC(T:-2,EXPR("coalesce"))
 A:-10 = T:-2.ADD_COLUMN(VC:-2.11,DELAYED,"mderatemoney","ALL")
 VC:-2.12 = CREATE_VC(T:-2,PHYS_COL(T:-3,A:18))
 A:-11 = T:-2.ADD_COLUMN(VC:-2.12,SUM,"null","ALL")
 VC:-2.13 = CREATE_VC(T:-2,EXPR("coalesce"))
 A:-12 = T:-2.ADD_COLUMN(VC:-2.13,DELAYED,"ideratenums","ALL")
 VC:-2.14 = CREATE_VC(T:-2,PHYS_COL(T:-3,A:27))
 A:-13 = T:-2.ADD_COLUMN(VC:-2.14,SUM,"null","ALL")
 VC:-2.15 = CREATE_VC(T:-2,EXPR("coalesce"))
 A:-14 = T:-2.ADD_COLUMN(VC:-2.15,DELAYED,"mhandcharge","ALL")
 VC:-2.16 = CREATE_VC(T:-2,PHYS_COL(T:-8,A:5))
 A:-15 = T:-2.ADD_COLUMN(VC:-2.16,GROUP_BY,"isettlementid","ALL")
 VC:-2.17 = CREATE_VC(T:-2,PHYS_COL(T:-1,A:10))
 A:-16 = T:-2.ADD_COLUMN(VC:-2.17,GROUP_BY,"bysalesvouchertype","ALL")
 VC:-2.18 = CREATE_VC(T:-2,PHYS_COL(T:-4,A:65))
 VC:-2.19 = CREATE_VC(T:-2,EXPR("2"))
 C:1 = CREATE_CONDS(T:-2,VC:-2.18,=,VC:-2.19,<null>)
 VC:-2.20 = CREATE_VC(T:-2,EXPR("1"))
 C:1.AND(VC:-2.4,=,VC:-2.20,<null>)
 VC:-2.21 = CREATE_VC(T:-2,PHYS_COL(T:-6,A:0))
 C:1.AND(VC:-2.21,=,VC:-2.5,<null>)
 VC:-2.22 = CREATE_VC(T:-2,PHYS_COL(T:-4,A:0))
 C:1.AND(VC:-2.2,=,VC:-2.22,<null>)
 VC:-2.23 = CREATE_VC(T:-2,PHYS_COL(T:-7,A:0))
 VC:-2.24 = CREATE_VC(T:-2,PHYS_COL(T:-3,A:3))
 C:1.AND(VC:-2.23,=,VC:-2.24,<null>)
 VC:-2.25 = CREATE_VC(T:-2,PHYS_COL(T:-3,A:2))
 VC:-2.26 = CREATE_VC(T:-2,PHYS_COL(T:-1,A:1))
 C:1.AND(VC:-2.25,=,VC:-2.26,<null>)
 VC:-2.27 = CREATE_VC(T:-2,PHYS_COL(T:-8,A:2))
 C:1.AND(VC:-2.27,=,VC:-2.26,<null>)
 VC:-2.28 = CREATE_VC(T:-2,PHYS_COL(T:-3,A:1))
 VC:-2.29 = CREATE_VC(T:-2,PHYS_COL(T:-1,A:0))
 C:1.AND(VC:-2.28,=,VC:-2.29,<null>)
 VC:-2.30 = CREATE_VC(T:-2,PHYS_COL(T:-8,A:1))
 C:1.AND(VC:-2.30,=,VC:-2.29,<null>)
 VC:-2.31 = CREATE_VC(T:-2,EXPR("substr"))
 VC:-2.32 = CREATE_VC(T:-2,EXPR("2022-08-18"))
 C:1.AND(VC:-2.31,>=,VC:-2.32,<null>)
 C:1.AND(VC:-2.31,<=,VC:-2.32,<null>)
 C:1.AND(VC:-2.18,<>,VC:-2.20,<null>)
 VC:-2.33 = CREATE_VC(T:-2,PHYS_COL(T:-4,A:2))
 VC:-2.34 = CREATE_VC(T:-2,EXPR("02"))
 C:1.AND(VC:-2.33,=,VC:-2.34,<null>)
 VC:-2.35 = CREATE_VC(T:-2,PHYS_COL(T:-4,A:3))
 VC:-2.36 = CREATE_VC(T:-2,EXPR("01"))
 C:1.AND(VC:-2.35,=,VC:-2.36,<null>)
 T:-2.ADD_CONDS(C:1,WHERE)
 T:-2.APPLY_CONDS()
 RESULT(T:-2)

adofsauron avatar Sep 21 '22 01:09 adofsauron

Crash Cause Locating

When multiple tables are associated, multiply the number of all table tuples so that the total number of tuples exceeds the range that can be accommodated, expressed in sectors


[2022-09-21 16:03:12.342030] [10533] [INFO] [multi_index.cpp:198] MSG: MultiIndex::AddDimension_cross size: 1000 no_tuples: 0
[2022-09-21 16:03:12.342201] [10533] [INFO] [multi_index.cpp:198] MSG: MultiIndex::AddDimension_cross size: 1000 no_tuples: 1000
[2022-09-21 16:03:12.342304] [10533] [INFO] [multi_index.cpp:198] MSG: MultiIndex::AddDimension_cross size: 1000 no_tuples: 1000000
[2022-09-21 16:03:12.342359] [10533] [INFO] [multi_index.cpp:198] MSG: MultiIndex::AddDimension_cross size: 1000 no_tuples: 1000000000
[2022-09-21 16:03:12.342555] [10533] [INFO] [multi_index.cpp:198] MSG: MultiIndex::AddDimension_cross size: 243 no_tuples: 1000000000000
[2022-09-21 16:03:12.342626] [10533] [INFO] [multi_index.cpp:198] MSG: MultiIndex::AddDimension_cross size: 697 no_tuples: 243000000000000
[2022-09-21 16:03:12.342697] [10533] [INFO] [multi_index.cpp:198] MSG: MultiIndex::AddDimension_cross size: 1000 no_tuples: 169371000000000000
[2022-09-21 16:03:12.403332] [10533] [WARN] [exception.cpp:41] MSG: Exception: Too many tuples.    (48).

STACK TRACE BEGIN
        /stonedb57/install/bin/mysqld(Tianmu::common::OutOfMemoryException::OutOfMemoryException(std::string const&)+0x23) [0x29e4a4b]
        /stonedb57/install/bin/mysqld(Tianmu::core::Filter::Filter(long, unsigned int, bool, bool)+0x188) [0x29e51ec]
        /stonedb57/install/bin/mysqld(Tianmu::core::MIUpdatingIterator::MIUpdatingIterator(Tianmu::core::MultiIndex*, Tianmu::core::DimensionVector&)+0x187) [0x2d15439]
        /stonedb57/install/bin/mysqld(Tianmu::core::ParameterizedFilter::FilterDeletedByTable(Tianmu::core::JustATable*, int)+0xe5) [0x2d3c743]
        /stonedb57/install/bin/mysqld(Tianmu::core::ParameterizedFilter::UpdateMultiIndex(bool, long)+0x28f) [0x2d39c09]
        /stonedb57/install/bin/mysqld(Tianmu::core::Query::Preexecute(Tianmu::core::CompiledQuery&, Tianmu::core::ResultSender*, bool)+0x1bc3) [0x2a05157]
        /stonedb57/install/bin/mysqld(Tianmu::core::Engine::Execute(THD*, LEX*, Query_result*, st_select_lex_unit*)+0x5e1) [0x29d7153]
        /stonedb57/install/bin/mysqld(Tianmu::core::Engine::HandleSelect(THD*, LEX*, Query_result*&, unsigned long, int&, int&, int&, int)+0x8d8) [0x29d634c]
        /stonedb57/install/bin/mysqld(Tianmu::dbhandler::TIANMU_HandleSelect(THD*, LEX*, Query_result*&, unsigned long, int&, int&, int&, int)+0x5b) [0x2abb93d]
        /stonedb57/install/bin/mysqld() [0x22ffe85]
        /stonedb57/install/bin/mysqld(mysql_execute_command(THD*, bool)+0x9de) [0x22f9cad]
        /stonedb57/install/bin/mysqld(mysql_parse(THD*, Parser_state*)+0x557) [0x2300b8c]
        /stonedb57/install/bin/mysqld(dispatch_command(THD*, COM_DATA const*, enum_server_command)+0xadc) [0x22f6fd6]
        /stonedb57/install/bin/mysqld(do_command(THD*)+0x23c) [0x22f6179]
        /stonedb57/install/bin/mysqld(handle_connection+0x1ee) [0x23fa0bb]
        /stonedb57/install/bin/mysqld(pfs_spawn_thread+0x173) [0x2915cf1]
        /lib64/libpthread.so.0(+0x7ea5) [0x7f2d5d1b8ea5]
        /lib64/libc.so.6(clone+0x6d) [0x7f2d5a701b0d]
STACK TRACE END


Retest after reducing the amount of data, you can query normally:


mysql>     SELECT
    ->         sale.usid AS usid,
    ->         cus.corpname AS corpname,
    ->         sale.iscenicid AS iscenicid,
    ->         salde.itickettypeid AS itickettypeid,
    ->         price.icrowdkindid AS icrowdkindid,
    ->         salde.mactualsaleprice AS mactualsaleprice,
    ->         saletype.isettlementid AS isettlementid,
    ->         sale.bysalesvouchertype AS bysalesvouchertype
    ->     FROM
    ->         STSSALESVOUCHERTAB sale,
    ->         STSSALESVOUCHERDETAILSTAB salde,
    ->         (
    ->             SELECT FIND_TOP_USID(C.USID) AS SUSID,
    ->             C2.CORPNAME AS SCORPNAME,
    ->             C2.BNAME,
    ->             C.USID,
    ->             C.CORPNAME,
    ->             C.IBUSINESSID,
    ->             C.TTLB
    ->         FROM
    ->             CUSTOM C
    ->         LEFT JOIN CUSTOM C2 ON
    ->             C2.USID = C.SUSID) cus,
    ->         EDMTICKETTYPETAB ti,
    ->         EDMCROWDKINDPRICETAB price,
    ->         STSSALESSETTLEMENTTAB saletype
    ->         limit 10;
+-------+----------+-----------+---------------+--------------+------------------+---------------+--------------------+
| usid  | corpname | iscenicid | itickettypeid | icrowdkindid | mactualsaleprice | isettlementid | bysalesvouchertype |
+-------+----------+-----------+---------------+--------------+------------------+---------------+--------------------+
| guest |          |         1 |            49 |           10 |             0.00 | 00            | 01                 |
| guest |          |         1 |            49 |           10 |             0.00 | 00            | 01                 |
| guest |          |         1 |            49 |           10 |             0.00 | 00            | 01                 |
| guest |          |         1 |            49 |           10 |             0.00 | 00            | 01                 |
| guest |          |         1 |            49 |           10 |             0.00 | 00            | 01                 |
| guest |          |         1 |            49 |           10 |             0.00 | 00            | 01                 |
| guest |          |         1 |            49 |           10 |             0.00 | 00            | 01                 |
| guest |          |         1 |            49 |           10 |             0.00 | 00            | 01                 |
| guest |          |         1 |            49 |           10 |             0.00 | 00            | 01                 |
| guest |          |         1 |            49 |           10 |             0.00 | 00            | 01                 |
+-------+----------+-----------+---------------+--------------+------------------+---------------+--------------------+
10 rows in set (0.02 sec)



[2022-09-21 16:27:32.322174] [10818] [INFO] [multi_index.cpp:198] MSG: MultiIndex::AddDimension_cross size: 10 no_tuples: 0
[2022-09-21 16:27:32.322287] [10818] [INFO] [multi_index.cpp:198] MSG: MultiIndex::AddDimension_cross size: 10 no_tuples: 10
[2022-09-21 16:27:32.322357] [10818] [INFO] [multi_index.cpp:198] MSG: MultiIndex::AddDimension_cross size: 10 no_tuples: 100
[2022-09-21 16:27:32.322416] [10818] [INFO] [multi_index.cpp:198] MSG: MultiIndex::AddDimension_cross size: 10 no_tuples: 1000
[2022-09-21 16:27:32.322577] [10818] [INFO] [multi_index.cpp:198] MSG: MultiIndex::AddDimension_cross size: 10 no_tuples: 10000
[2022-09-21 16:27:32.322647] [10818] [INFO] [multi_index.cpp:198] MSG: MultiIndex::AddDimension_cross size: 10 no_tuples: 100000
[2022-09-21 16:27:32.322710] [10818] [INFO] [multi_index.cpp:198] MSG: MultiIndex::AddDimension_cross size: 10 no_tuples: 1000000
[2022-09-21 16:27:32.325683] [10818] [INFO] [multi_index.cpp:198] MSG: MultiIndex::AddDimension_cross size: 10 no_tuples: 0


adofsauron avatar Sep 21 '22 08:09 adofsauron