From 034ababa508615fc4ad1a047703ef21f6926d677 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Fri, 3 May 2024 11:41:58 +1000 Subject: [PATCH 01/42] MDEV-34053 mariadbbackup privilege REPLICA MONITOR issue MariaDB-backup needs to check for SLAVE MONITOR as that is what is returned by SHOW GRANTS. Update test to ensure that warnings about missing privileges do not occur when the backup is successful. Reviewer: Andrew Hutchings Thanks Eugene for reporting the issue. --- extra/mariabackup/xtrabackup.cc | 2 +- .../suite/mariabackup/backup_grants.result | 9 ++++-- .../suite/mariabackup/backup_grants.test | 29 +++++++++++++------ 3 files changed, 28 insertions(+), 12 deletions(-) diff --git a/extra/mariabackup/xtrabackup.cc b/extra/mariabackup/xtrabackup.cc index 500ae683d80..c126d0b5b7c 100644 --- a/extra/mariabackup/xtrabackup.cc +++ b/extra/mariabackup/xtrabackup.cc @@ -6413,7 +6413,7 @@ static bool check_all_privileges() if (opt_galera_info || opt_slave_info || opt_safe_slave_backup) { check_result |= check_privilege(granted_privileges, - "REPLICA MONITOR", "*", "*", + "SLAVE MONITOR", "*", "*", PRIVILEGE_WARNING); } diff --git a/mysql-test/suite/mariabackup/backup_grants.result b/mysql-test/suite/mariabackup/backup_grants.result index 77cc3dd65d1..1dc3cc332dd 100644 --- a/mysql-test/suite/mariabackup/backup_grants.result +++ b/mysql-test/suite/mariabackup/backup_grants.result @@ -1,15 +1,20 @@ CREATE user backup@localhost IDENTIFIED BY 'xyz'; +NOT FOUND /missing required privilege/ in backup.log FOUND 1 /missing required privilege RELOAD/ in backup.log FOUND 1 /missing required privilege PROCESS/ in backup.log FOUND 1 /GRANT USAGE ON/ in backup.log GRANT RELOAD, PROCESS on *.* to backup@localhost; -FOUND 1 /missing required privilege REPLICA MONITOR/ in backup.log +NOT FOUND /missing required privilege/ in backup.log +FOUND 1 /missing required privilege SLAVE MONITOR/ in backup.log GRANT REPLICA MONITOR ON *.* TO backup@localhost; +NOT FOUND /missing required privilege/ in backup.log REVOKE REPLICA MONITOR ON *.* FROM backup@localhost; FOUND 1 /missing required privilege CONNECTION ADMIN/ in backup.log GRANT CONNECTION ADMIN ON *.* TO backup@localhost; +NOT FOUND /missing required privilege/ in backup.log FOUND 1 /missing required privilege REPLICATION SLAVE ADMIN/ in backup.log -FOUND 1 /missing required privilege REPLICA MONITOR/ in backup.log +FOUND 1 /missing required privilege SLAVE MONITOR/ in backup.log GRANT REPLICATION SLAVE ADMIN ON *.* TO backup@localhost; GRANT REPLICA MONITOR ON *.* TO backup@localhost; +NOT FOUND /missing required privilege/ in backup.log DROP USER backup@localhost; diff --git a/mysql-test/suite/mariabackup/backup_grants.test b/mysql-test/suite/mariabackup/backup_grants.test index 7b8c9b39b57..20a028ebc53 100644 --- a/mysql-test/suite/mariabackup/backup_grants.test +++ b/mysql-test/suite/mariabackup/backup_grants.test @@ -1,10 +1,14 @@ let $targetdir=$MYSQLTEST_VARDIR/tmp/backup; CREATE user backup@localhost IDENTIFIED BY 'xyz'; +let SEARCH_FILE=$MYSQLTEST_VARDIR/tmp/backup.log; # backup possible for unprivileges user, with --no-lock --disable_result_log -exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup -ubackup -pxyz --no-lock --target-dir=$targetdir; +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup -ubackup -pxyz --no-lock --target-dir=$targetdir > $MYSQLTEST_VARDIR/tmp/backup.log 2>&1; --enable_result_log + +--let SEARCH_PATTERN= missing required privilege +--source include/search_pattern_in_file.inc rmdir $targetdir; # backup fails without --no-lock, because of FTWRL @@ -13,7 +17,6 @@ error 1; exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup -ubackup -pxyz --target-dir=$targetdir > $MYSQLTEST_VARDIR/tmp/backup.log 2>&1; --enable_result_log -let SEARCH_FILE=$MYSQLTEST_VARDIR/tmp/backup.log; --let SEARCH_PATTERN= missing required privilege RELOAD --source include/search_pattern_in_file.inc --let SEARCH_PATTERN= missing required privilege PROCESS @@ -23,25 +26,29 @@ let SEARCH_FILE=$MYSQLTEST_VARDIR/tmp/backup.log; # backup succeeds with RELOAD privilege GRANT RELOAD, PROCESS on *.* to backup@localhost; --disable_result_log -exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --user=backup --password=xyz --target-dir=$targetdir; +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --user=backup --password=xyz --target-dir=$targetdir > $MYSQLTEST_VARDIR/tmp/backup.log 2>&1; --enable_result_log +--let SEARCH_PATTERN= missing required privilege +--source include/search_pattern_in_file.inc rmdir $targetdir; # MDEV-23607 Warning: missing required privilege REPLICATION CLIENT -# --slave-info and galera info require REPLICA MONITOR +# --slave-info and --galera-info require REPLICA MONITOR --disable_result_log error 1; exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --user backup --password xyz --slave-info --target-dir=$targetdir > $MYSQLTEST_VARDIR/tmp/backup.log 2>&1; --enable_result_log rmdir $targetdir; ---let SEARCH_PATTERN= missing required privilege REPLICA MONITOR +--let SEARCH_PATTERN= missing required privilege SLAVE MONITOR --source include/search_pattern_in_file.inc GRANT REPLICA MONITOR ON *.* TO backup@localhost; --disable_result_log -exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup -ubackup -pxyz --slave-info --target-dir=$targetdir; +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup -ubackup -pxyz --slave-info --target-dir=$targetdir > $MYSQLTEST_VARDIR/tmp/backup.log 2>&1; --enable_result_log +--let SEARCH_PATTERN= missing required privilege +--source include/search_pattern_in_file.inc rmdir $targetdir; REVOKE REPLICA MONITOR ON *.* FROM backup@localhost; @@ -59,8 +66,10 @@ rmdir $targetdir; GRANT CONNECTION ADMIN ON *.* TO backup@localhost; --disable_result_log -exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --user=backup --password=xyz --kill-long-query-type=all --kill-long-queries-timeout=1 --target-dir=$targetdir; +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup -ubackup --password=xyz --kill-long-query-type=all --kill-long-queries-timeout=1 --target-dir=$targetdir > $MYSQLTEST_VARDIR/tmp/backup.log 2>&1; --enable_result_log +--let SEARCH_PATTERN= missing required privilege +--source include/search_pattern_in_file.inc rmdir $targetdir; # --safe-slave-backup requires REPLICATION SLAVE ADMIN, and REPLICA MONITOR @@ -72,14 +81,16 @@ rmdir $targetdir; --let SEARCH_PATTERN= missing required privilege REPLICATION SLAVE ADMIN --source include/search_pattern_in_file.inc ---let SEARCH_PATTERN= missing required privilege REPLICA MONITOR +--let SEARCH_PATTERN= missing required privilege SLAVE MONITOR --source include/search_pattern_in_file.inc GRANT REPLICATION SLAVE ADMIN ON *.* TO backup@localhost; GRANT REPLICA MONITOR ON *.* TO backup@localhost; --disable_result_log -exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup -ubackup -pxyz --safe-slave-backup --target-dir=$targetdir; +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup -ubackup -pxyz --safe-slave-backup --target-dir=$targetdir > $MYSQLTEST_VARDIR/tmp/backup.log 2>&1; --enable_result_log +--let SEARCH_PATTERN= missing required privilege +--source include/search_pattern_in_file.inc rmdir $targetdir; DROP USER backup@localhost; From 867747204afd4a94885fdbdb2a1442ca35001f93 Mon Sep 17 00:00:00 2001 From: He Guohua <3803657@qq.com> Date: Tue, 7 May 2024 13:52:15 +0800 Subject: [PATCH 02/42] MDEV-31566 Fix buffer overrun of column_json function The accounting of the limit variable that represents the amount of space left it the buffer was incorrect. Also there was 1 or 2 bytes left to write that occured without the buffer length being checked. Review: Sanja Byelkin --- mysql-test/main/dyncol.result | 15 ++++++++------- mysql-test/main/dyncol.test | 15 ++++++--------- mysys/ma_dyncol.c | 17 +++++++++-------- 3 files changed, 23 insertions(+), 24 deletions(-) diff --git a/mysql-test/main/dyncol.result b/mysql-test/main/dyncol.result index eb1e0464570..d070ef8f626 100644 --- a/mysql-test/main/dyncol.result +++ b/mysql-test/main/dyncol.result @@ -1950,12 +1950,6 @@ ex # End of 10.4 tests # # -# Start of 10.5 tests -# -# -# Start of 10.5 tests -# -# # MDEV-33788 HEX(COLUMN_CREATE(.. AS CHAR ...)) fails with --view-protocol # SELECT hex(column_create(1,'a' AS CHAR CHARACTER SET utf8mb3 COLLATE utf8mb3_bin)) AS ex; @@ -1967,5 +1961,12 @@ SELECT hex(column_add(column_create( ex 00020001000302001353612162 # -# Start of 10.5 tests +# MDEV-31566 Fix buffer overrun of column_json function # +select column_json(0x0402000A0000000300030023076A736E7375626A6563742E0005006C0027000200290002002B0002002D0002002F0002000C31000C3B000C4B000C51000F62006631663266336634663509E5A79AE8BF9CE6B48B0FE8819AE9809AE98791E6A1A5E5BA970537343530301031313634332F393634352F31313630300C080000000000EFBFBDEFBFBD192E); +column_json(0x0402000A0000000300030023076A736E7375626A6563742E0005006C0027000200290002002B0002002D0002002F0002000C31000C3B000C4B000C51000F62006631663266336634663509E5A79AE8BF9CE6B48B0FE8819AE9809AE98791E6A1A5E5BA970537343530301031313634332F393634352F31313 +{"jsn":"\u0000\u0005\u0000l\u0000'\u0000\u0002\u0000)\u0000\u0002\u0000+\u0000\u0002\u0000-\u0000\u0002\u0000/\u0000\u0002\u0000\u000C1\u0000\u000C;\u0000\u000CK\u0000\u000CQ\u0000\u000Fb\u0000f1f2f3f4f5\u0009姚远洋\u000F聚通金桥店\u000574500\u001011643/9645/11600\u000C\u0008\u0000\u0000\u0000\u0000\u0000��\u0019","subject":""} +select column_json(0x0402000900000003000300740C6A736E766F6C756D652E000900EFBFBD004300020045000200470003004A0004004E00050053000500580005005D000500620005000C67000C6A000C6D000C7000052C00051B00052C000CEFBFBD0007EFBFBD006638663966313070696332626F785F63626F785F67626F785F6B626F785F7666355F696402343402343402333241687474703A2F2F6F73732E68646238382E636F6D2F302F70686F746F2F30373865653765376336343634616236386130343833373333323636613532612E67696608302E303532323732244F1E00030180C106); +column_json(0x0402000900000003000300740C6A736E766F6C756D652E000900EFBFBD004300020045000200470003004A0004004E00050053000500580005005D000500620005000C67000C6A000C6D000C7000052C00051B00052C000CEFBFBD0007EFBFBD006638663966313070696332626F785F63626F785F67626F7 +{"jsn":"\u0000\u0009\u0000�\u0000C\u0000\u0002\u0000E\u0000\u0002\u0000G\u0000\u0003\u0000J\u0000\u0004\u0000N\u0000\u0005\u0000S\u0000\u0005\u0000X\u0000\u0005\u0000]\u0000\u0005\u0000b\u0000\u0005\u0000\u000Cg\u0000\u000Cj\u0000\u000Cm\u0000\u000Cp\u0000\u0005,\u0000\u0005\u001B\u0000\u0005,\u0000\u000C�\u0000\u0007�\u0000f8f9f10pic2box_cbox_gbox_kbox_vf5_id\u000244\u000244\u000232Ahttp://oss.hdb88.com/0/photo/078ee7e7c6464ab68a0483733266a52a.gif\u00080.052272$O\u001E\u0000","volume":193.6} +# End of 10.5 tests diff --git a/mysql-test/main/dyncol.test b/mysql-test/main/dyncol.test index 16cf8a2306d..95121fef1e4 100644 --- a/mysql-test/main/dyncol.test +++ b/mysql-test/main/dyncol.test @@ -1001,14 +1001,6 @@ SELECT HEX(COLUMN_ADD(COLUMN_CREATE(1,10),2,NULL,1,NULL)) as ex; --echo # End of 10.4 tests --echo # ---echo # ---echo # Start of 10.5 tests ---echo # - ---echo # ---echo # Start of 10.5 tests ---echo # - --echo # --echo # MDEV-33788 HEX(COLUMN_CREATE(.. AS CHAR ...)) fails with --view-protocol --echo # @@ -1019,5 +1011,10 @@ SELECT hex(column_add(column_create( 2, 'b' AS CHAR CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci)) AS ex; --echo # ---echo # Start of 10.5 tests +--echo # MDEV-31566 Fix buffer overrun of column_json function --echo # + +select column_json(0x0402000A0000000300030023076A736E7375626A6563742E0005006C0027000200290002002B0002002D0002002F0002000C31000C3B000C4B000C51000F62006631663266336634663509E5A79AE8BF9CE6B48B0FE8819AE9809AE98791E6A1A5E5BA970537343530301031313634332F393634352F31313630300C080000000000EFBFBDEFBFBD192E); +select column_json(0x0402000900000003000300740C6A736E766F6C756D652E000900EFBFBD004300020045000200470003004A0004004E00050053000500580005005D000500620005000C67000C6A000C6D000C7000052C00051B00052C000CEFBFBD0007EFBFBD006638663966313070696332626F785F63626F785F67626F785F6B626F785F7666355F696402343402343402333241687474703A2F2F6F73732E68646238382E636F6D2F302F70686F746F2F30373865653765376336343634616236386130343833373333323636613532612E67696608302E303532323732244F1E00030180C106); + +--echo # End of 10.5 tests diff --git a/mysys/ma_dyncol.c b/mysys/ma_dyncol.c index 5ab7d28f915..013fcc913b4 100644 --- a/mysys/ma_dyncol.c +++ b/mysys/ma_dyncol.c @@ -3848,13 +3848,13 @@ my_bool dynstr_append_json_quoted(DYNAMIC_STRING *str, register char c= append[i]; if (unlikely(((uchar)c) <= 0x1F)) { - if (lim < 5) + if (lim < 6) { if (dynstr_realloc(str, additional)) return TRUE; lim+= additional; } - lim-= 5; + lim -= 6; str->str[str->length++]= '\\'; str->str[str->length++]= 'u'; str->str[str->length++]= '0'; @@ -3865,17 +3865,18 @@ my_bool dynstr_append_json_quoted(DYNAMIC_STRING *str, } else { + if (lim < 2) + { + if (dynstr_realloc(str, additional)) + return TRUE; + lim += additional; + } if (c == '"' || c == '\\') { - if (!lim) - { - if (dynstr_realloc(str, additional)) - return TRUE; - lim= additional; - } lim--; str->str[str->length++]= '\\'; } + lim--; str->str[str->length++]= c; } } From d7d8c2c287f8496091070007950a17e5bd2b5c84 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Fri, 10 May 2024 11:17:46 +1000 Subject: [PATCH 03/42] MDEV-31566: Fix buffer overrun of column_json function (postfix) Test case failed --view protocol. Revert to using table for data in the test. --- mysql-test/main/dyncol.result | 16 ++++++++++------ mysql-test/main/dyncol.test | 12 ++++++++++-- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/mysql-test/main/dyncol.result b/mysql-test/main/dyncol.result index d070ef8f626..4b216e77a66 100644 --- a/mysql-test/main/dyncol.result +++ b/mysql-test/main/dyncol.result @@ -1963,10 +1963,14 @@ ex # # MDEV-31566 Fix buffer overrun of column_json function # -select column_json(0x0402000A0000000300030023076A736E7375626A6563742E0005006C0027000200290002002B0002002D0002002F0002000C31000C3B000C4B000C51000F62006631663266336634663509E5A79AE8BF9CE6B48B0FE8819AE9809AE98791E6A1A5E5BA970537343530301031313634332F393634352F31313630300C080000000000EFBFBDEFBFBD192E); -column_json(0x0402000A0000000300030023076A736E7375626A6563742E0005006C0027000200290002002B0002002D0002002F0002000C31000C3B000C4B000C51000F62006631663266336634663509E5A79AE8BF9CE6B48B0FE8819AE9809AE98791E6A1A5E5BA970537343530301031313634332F393634352F31313 -{"jsn":"\u0000\u0005\u0000l\u0000'\u0000\u0002\u0000)\u0000\u0002\u0000+\u0000\u0002\u0000-\u0000\u0002\u0000/\u0000\u0002\u0000\u000C1\u0000\u000C;\u0000\u000CK\u0000\u000CQ\u0000\u000Fb\u0000f1f2f3f4f5\u0009姚远洋\u000F聚通金桥店\u000574500\u001011643/9645/11600\u000C\u0008\u0000\u0000\u0000\u0000\u0000��\u0019","subject":""} -select column_json(0x0402000900000003000300740C6A736E766F6C756D652E000900EFBFBD004300020045000200470003004A0004004E00050053000500580005005D000500620005000C67000C6A000C6D000C7000052C00051B00052C000CEFBFBD0007EFBFBD006638663966313070696332626F785F63626F785F67626F785F6B626F785F7666355F696402343402343402333241687474703A2F2F6F73732E68646238382E636F6D2F302F70686F746F2F30373865653765376336343634616236386130343833373333323636613532612E67696608302E303532323732244F1E00030180C106); -column_json(0x0402000900000003000300740C6A736E766F6C756D652E000900EFBFBD004300020045000200470003004A0004004E00050053000500580005005D000500620005000C67000C6A000C6D000C7000052C00051B00052C000CEFBFBD0007EFBFBD006638663966313070696332626F785F63626F785F67626F7 -{"jsn":"\u0000\u0009\u0000�\u0000C\u0000\u0002\u0000E\u0000\u0002\u0000G\u0000\u0003\u0000J\u0000\u0004\u0000N\u0000\u0005\u0000S\u0000\u0005\u0000X\u0000\u0005\u0000]\u0000\u0005\u0000b\u0000\u0005\u0000\u000Cg\u0000\u000Cj\u0000\u000Cm\u0000\u000Cp\u0000\u0005,\u0000\u0005\u001B\u0000\u0005,\u0000\u000C�\u0000\u0007�\u0000f8f9f10pic2box_cbox_gbox_kbox_vf5_id\u000244\u000244\u000232Ahttp://oss.hdb88.com/0/photo/078ee7e7c6464ab68a0483733266a52a.gif\u00080.052272$O\u001E\u0000","volume":193.6} +create table t1 ( +c1 varchar(32) primary key, +d1 blob +); +insert into t1 values ('var', 0x0402000A0000000300030023076A736E7375626A6563742E0005006C0027000200290002002B0002002D0002002F0002000C31000C3B000C4B000C51000F62006631663266336634663509E5A79AE8BF9CE6B48B0FE8819AE9809AE98791E6A1A5E5BA970537343530301031313634332F393634352F31313630300C080000000000EFBFBDEFBFBD192E), ('zzz', 0x0402000900000003000300740C6A736E766F6C756D652E000900EFBFBD004300020045000200470003004A0004004E00050053000500580005005D000500620005000C67000C6A000C6D000C7000052C00051B00052C000CEFBFBD0007EFBFBD006638663966313070696332626F785F63626F785F67626F785F6B626F785F7666355F696402343402343402333241687474703A2F2F6F73732E68646238382E636F6D2F302F70686F746F2F30373865653765376336343634616236386130343833373333323636613532612E67696608302E303532323732244F1E00030180C106); +select c1,column_json(d1) as not_crashing from t1 order by c1; +c1 not_crashing +var {"jsn":"\u0000\u0005\u0000l\u0000'\u0000\u0002\u0000)\u0000\u0002\u0000+\u0000\u0002\u0000-\u0000\u0002\u0000/\u0000\u0002\u0000\u000C1\u0000\u000C;\u0000\u000CK\u0000\u000CQ\u0000\u000Fb\u0000f1f2f3f4f5\u0009姚远洋\u000F聚通金桥店\u000574500\u001011643/9645/11600\u000C\u0008\u0000\u0000\u0000\u0000\u0000��\u0019","subject":""} +zzz {"jsn":"\u0000\u0009\u0000�\u0000C\u0000\u0002\u0000E\u0000\u0002\u0000G\u0000\u0003\u0000J\u0000\u0004\u0000N\u0000\u0005\u0000S\u0000\u0005\u0000X\u0000\u0005\u0000]\u0000\u0005\u0000b\u0000\u0005\u0000\u000Cg\u0000\u000Cj\u0000\u000Cm\u0000\u000Cp\u0000\u0005,\u0000\u0005\u001B\u0000\u0005,\u0000\u000C�\u0000\u0007�\u0000f8f9f10pic2box_cbox_gbox_kbox_vf5_id\u000244\u000244\u000232Ahttp://oss.hdb88.com/0/photo/078ee7e7c6464ab68a0483733266a52a.gif\u00080.052272$O\u001E\u0000","volume":193.6} +drop table t1; # End of 10.5 tests diff --git a/mysql-test/main/dyncol.test b/mysql-test/main/dyncol.test index 95121fef1e4..0c1978a8fa0 100644 --- a/mysql-test/main/dyncol.test +++ b/mysql-test/main/dyncol.test @@ -1014,7 +1014,15 @@ SELECT hex(column_add(column_create( --echo # MDEV-31566 Fix buffer overrun of column_json function --echo # -select column_json(0x0402000A0000000300030023076A736E7375626A6563742E0005006C0027000200290002002B0002002D0002002F0002000C31000C3B000C4B000C51000F62006631663266336634663509E5A79AE8BF9CE6B48B0FE8819AE9809AE98791E6A1A5E5BA970537343530301031313634332F393634352F31313630300C080000000000EFBFBDEFBFBD192E); -select column_json(0x0402000900000003000300740C6A736E766F6C756D652E000900EFBFBD004300020045000200470003004A0004004E00050053000500580005005D000500620005000C67000C6A000C6D000C7000052C00051B00052C000CEFBFBD0007EFBFBD006638663966313070696332626F785F63626F785F67626F785F6B626F785F7666355F696402343402343402333241687474703A2F2F6F73732E68646238382E636F6D2F302F70686F746F2F30373865653765376336343634616236386130343833373333323636613532612E67696608302E303532323732244F1E00030180C106); + +create table t1 ( + c1 varchar(32) primary key, + d1 blob +); +insert into t1 values ('var', 0x0402000A0000000300030023076A736E7375626A6563742E0005006C0027000200290002002B0002002D0002002F0002000C31000C3B000C4B000C51000F62006631663266336634663509E5A79AE8BF9CE6B48B0FE8819AE9809AE98791E6A1A5E5BA970537343530301031313634332F393634352F31313630300C080000000000EFBFBDEFBFBD192E), ('zzz', 0x0402000900000003000300740C6A736E766F6C756D652E000900EFBFBD004300020045000200470003004A0004004E00050053000500580005005D000500620005000C67000C6A000C6D000C7000052C00051B00052C000CEFBFBD0007EFBFBD006638663966313070696332626F785F63626F785F67626F785F6B626F785F7666355F696402343402343402333241687474703A2F2F6F73732E68646238382E636F6D2F302F70686F746F2F30373865653765376336343634616236386130343833373333323636613532612E67696608302E303532323732244F1E00030180C106); + +select c1,column_json(d1) as not_crashing from t1 order by c1; + +drop table t1; --echo # End of 10.5 tests From 6bf2b64a97ec5a8c46018f9ceaf4acbd28d1e922 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Fri, 10 May 2024 12:49:16 +0300 Subject: [PATCH 04/42] MDEV-34118 fsp_alloc_free_extent() fails to flag DB_OUT_OF_FILE_SPACE fsp_alloc_free_extent(): When applicable, set *err = DB_OUT_OF_FILE_SPACE. --- .../suite/innodb/r/temporary_table.result | 10 ++++++++++ .../suite/innodb/t/temporary_table.test | 19 +++++++++++++++++++ storage/innobase/fsp/fsp0fsp.cc | 1 + 3 files changed, 30 insertions(+) diff --git a/mysql-test/suite/innodb/r/temporary_table.result b/mysql-test/suite/innodb/r/temporary_table.result index ffcee726f0d..aaa5fbbd524 100644 --- a/mysql-test/suite/innodb/r/temporary_table.result +++ b/mysql-test/suite/innodb/r/temporary_table.result @@ -801,4 +801,14 @@ CHECK TABLE t EXTENDED; Table Op Msg_type Msg_text test.t check status OK DROP TEMPORARY TABLE t; +# +# MDEV-34118 fsp_alloc_free_extent() fails to flag DB_OUT_OF_FILE_SPACE +# +SET @save_increment = @@GLOBAL.innodb_autoextend_increment; +SET GLOBAL innodb_autoextend_increment=1; +CREATE TEMPORARY TABLE t (c LONGTEXT) ENGINE=INNODB; +INSERT INTO t VALUES (REPEAT ('1',16777216)); +ERROR HY000: The table 't' is full +DROP TEMPORARY TABLE t; +SET GLOBAL innodb_autoextend_increment=@save_increment; # End of 10.6 tests diff --git a/mysql-test/suite/innodb/t/temporary_table.test b/mysql-test/suite/innodb/t/temporary_table.test index d4e292bc6e8..36c78c5ee9c 100644 --- a/mysql-test/suite/innodb/t/temporary_table.test +++ b/mysql-test/suite/innodb/t/temporary_table.test @@ -635,4 +635,23 @@ CHECK TABLE t; CHECK TABLE t EXTENDED; DROP TEMPORARY TABLE t; +--echo # +--echo # MDEV-34118 fsp_alloc_free_extent() fails to flag DB_OUT_OF_FILE_SPACE +--echo # +SET @save_increment = @@GLOBAL.innodb_autoextend_increment; +SET GLOBAL innodb_autoextend_increment=1; +CREATE TEMPORARY TABLE t (c LONGTEXT) ENGINE=INNODB; +if ($MTR_COMBINATION_4K) +{ +--error ER_RECORD_FILE_FULL +INSERT INTO t VALUES (REPEAT ('1',16777216)); +} +if (!$MTR_COMBINATION_4K) +{ +INSERT INTO t VALUES (REPEAT ('1',16777216)); +--echo ERROR HY000: The table 't' is full +} +DROP TEMPORARY TABLE t; +SET GLOBAL innodb_autoextend_increment=@save_increment; + --echo # End of 10.6 tests diff --git a/storage/innobase/fsp/fsp0fsp.cc b/storage/innobase/fsp/fsp0fsp.cc index 314a3ae6952..457fbed2408 100644 --- a/storage/innobase/fsp/fsp0fsp.cc +++ b/storage/innobase/fsp/fsp0fsp.cc @@ -967,6 +967,7 @@ corrupted: first = flst_get_first(FSP_HEADER_OFFSET + FSP_FREE + header->page.frame); if (first.page == FIL_NULL) { + *err = DB_OUT_OF_FILE_SPACE; return nullptr; /* No free extents left */ } if (first.page >= space->free_limit) { From 9ea1f67214ee081388612740507ffe6dd84c1a55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Sun, 12 May 2024 08:04:06 +0300 Subject: [PATCH 05/42] MDEV-33817: Proper intrinsics for vextracti32x4 --- mysys/crc32/crc32c_x86.cc | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/mysys/crc32/crc32c_x86.cc b/mysys/crc32/crc32c_x86.cc index 02dbf2920eb..317b3545c0c 100644 --- a/mysys/crc32/crc32c_x86.cc +++ b/mysys/crc32/crc32c_x86.cc @@ -173,19 +173,11 @@ static inline __m512i combine512(__m512i a, __m512i tab, __m512i b) # define and128(a, b) _mm_and_si128(a, b) template USE_VPCLMULQDQ -/** Pick a 128-bit component of a 512-bit vector */ +/** Pick and zero-extend 128 bits of a 512-bit vector (vextracti32x4) */ static inline __m512i extract512_128(__m512i a) { static_assert(bits <= 3, "usage"); -# if defined __GNUC__ && __GNUC__ >= 11 - /* While technically incorrect, this would seem to translate into a - vextracti32x4 instruction, which actually outputs a ZMM register - (anything above the XMM range is cleared). */ - return _mm512_castsi128_si512(_mm512_extracti64x2_epi64(a, bits)); -# else - /* On clang, this is needed in order to get a correct result. */ - return _mm512_maskz_shuffle_i64x2(3, a, a, bits); -# endif + return _mm512_zextsi128_si512(_mm512_extracti64x2_epi64(a, bits)); } alignas(16) static const uint64_t shuffle128[4] = { From 1e5b0ff9778b16801d5afa08b6433070948f0910 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Sun, 12 May 2024 10:13:15 +0200 Subject: [PATCH 06/42] mtr: don't store galera sst logs in /tmp/ --- mysql-test/suite/galera/galera_2nodes.cnf | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mysql-test/suite/galera/galera_2nodes.cnf b/mysql-test/suite/galera/galera_2nodes.cnf index 3532c1f2134..f1697c08149 100644 --- a/mysql-test/suite/galera/galera_2nodes.cnf +++ b/mysql-test/suite/galera/galera_2nodes.cnf @@ -33,6 +33,9 @@ wsrep_node_address='127.0.0.1:@mysqld.2.#galera_port' wsrep_node_incoming_address=127.0.0.1:@mysqld.2.port wsrep_sst_receive_address='127.0.0.1:@mysqld.2.#sst_port' +[sst] +sst-log-archive-dir=@ENV.MYSQLTEST_VARDIR/log + [ENV] NODE_MYPORT_1= @mysqld.1.port NODE_MYSOCK_1= @mysqld.1.socket From a6ae1c2dfb272008666d1f15dc9cb0cc06a5b82a Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Mon, 13 May 2024 09:15:14 +1000 Subject: [PATCH 07/42] MDEV-32487 Check plugin is ready when resolving storage engine This handles the situation when one thread is still initiating a storage engine plugin, while another is creating a table using it. --- sql/handler.cc | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/sql/handler.cc b/sql/handler.cc index b12014b55ec..42e1c3e7212 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -291,13 +291,20 @@ redo: } +/* + Resolve the storage engine by name. + + Succeed if the storage engine is found and initialised. Otherwise + fail if the sql mode contains NO_ENGINE_SUBSTITUTION. +*/ bool Storage_engine_name::resolve_storage_engine_with_error(THD *thd, handlerton **ha, bool tmp_table) { - if (plugin_ref plugin= ha_resolve_by_name(thd, &m_storage_engine_name, - tmp_table)) + plugin_ref plugin; + if ((plugin= ha_resolve_by_name(thd, &m_storage_engine_name, tmp_table)) && + (plugin_ref_to_int(plugin)->state == PLUGIN_IS_READY)) { *ha= plugin_hton(plugin); return false; From 5e6c122427b254543745a0f16ad5bf4a111efcc0 Mon Sep 17 00:00:00 2001 From: Dmitry Shulga Date: Mon, 6 May 2024 20:10:06 +0700 Subject: [PATCH 08/42] MDEV-33769: Memory leak found in the test main.rownum run with --ps-protocol against a server built with the option -DWITH_PROTECT_STATEMENT_MEMROOT A memory leak happens on the second execution of a query that run in PS mode and uses the function ROWNUM(). A memory leak took place on allocation of an instance of the class Item_int for storing a limit value that is performed at the function set_limit_for_unit indirectly called from JOIN::optimize_inner. Typical trace to the place where the memory leak occurred is below: JOIN::optimize_inner optimize_rownum process_direct_rownum_comparison set_limit_for_unit new (thd->mem_root) Item_int(thd, lim, MAX_BIGINT_WIDTH); To fix this memory leak, calling of the function optimize_rownum() has to be performed only once on first execution and never called after that. To control it, the new data member first_rownum_optimization added into the structure st_select_lex. --- mysql-test/main/ps_mem_leaks.result | 29 +++++++++++++++++++++++++++++ mysql-test/main/ps_mem_leaks.test | 24 ++++++++++++++++++++++++ sql/sql_lex.cc | 1 + sql/sql_lex.h | 7 +++++++ sql/sql_select.cc | 6 +++++- 5 files changed, 66 insertions(+), 1 deletion(-) diff --git a/mysql-test/main/ps_mem_leaks.result b/mysql-test/main/ps_mem_leaks.result index 2ddf47a992c..e647c89b740 100644 --- a/mysql-test/main/ps_mem_leaks.result +++ b/mysql-test/main/ps_mem_leaks.result @@ -89,3 +89,32 @@ f DEALLOCATE PREPARE stmt; DROP TABLE t1; # End of 10.4 tests +# +# MDEV-33769: Memory leak found in the test main.rownum run with --ps-protocol against a server built with the option -DWITH_PROTECT_STATEMENT_MEMROOT +# +CREATE OR REPLACE TABLE t1(a INT); +PREPARE stmt FROM 'SELECT 1 FROM t1 WHERE ROWNUM() < 2'; +EXECUTE stmt; +1 +EXECUTE stmt; +1 +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +PREPARE stmt FROM 'SELECT * FROM t1 WHERE ROWNUM() < ?'; +# Expected output is two rows (1), (2) +EXECUTE stmt USING 3; +a +1 +2 +# Expected output is one row (1) +EXECUTE stmt USING 2; +a +1 +# Expected output is three rows (1), (2), (3) +EXECUTE stmt USING 4; +a +1 +2 +# Clean up +DEALLOCATE PREPARE stmt; +DROP TABLE t1; +# End of 10.6 tests diff --git a/mysql-test/main/ps_mem_leaks.test b/mysql-test/main/ps_mem_leaks.test index dacb4ecabba..16a46596c94 100644 --- a/mysql-test/main/ps_mem_leaks.test +++ b/mysql-test/main/ps_mem_leaks.test @@ -110,3 +110,27 @@ DEALLOCATE PREPARE stmt; DROP TABLE t1; --echo # End of 10.4 tests + +--echo # +--echo # MDEV-33769: Memory leak found in the test main.rownum run with --ps-protocol against a server built with the option -DWITH_PROTECT_STATEMENT_MEMROOT +--echo # +CREATE OR REPLACE TABLE t1(a INT); +PREPARE stmt FROM 'SELECT 1 FROM t1 WHERE ROWNUM() < 2'; +EXECUTE stmt; +EXECUTE stmt; + +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); + +PREPARE stmt FROM 'SELECT * FROM t1 WHERE ROWNUM() < ?'; +--echo # Expected output is two rows (1), (2) +EXECUTE stmt USING 3; +--echo # Expected output is one row (1) +EXECUTE stmt USING 2; +--echo # Expected output is three rows (1), (2), (3) +EXECUTE stmt USING 4; + +--echo # Clean up +DEALLOCATE PREPARE stmt; +DROP TABLE t1; + +--echo # End of 10.6 tests diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 8b9cc2473bf..bb389c98f3b 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -3051,6 +3051,7 @@ void st_select_lex::init_query() is_correlated= 0; first_natural_join_processing= 1; first_cond_optimization= 1; + first_rownum_optimization= true; no_wrap_view_item= 0; exclude_from_table_unique_test= 0; in_tvc= 0; diff --git a/sql/sql_lex.h b/sql/sql_lex.h index 5c9cd4ab3fa..37f1dee3d55 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -1262,6 +1262,13 @@ public: bool is_correlated:1; bool first_natural_join_processing:1; bool first_cond_optimization:1; + /** + The purpose of this flag is to run initialization phase for rownum + only once. This flag is set on at st_select_lex::init_query and reset to + the value false after the method optimize_rownum() has been called + from the method JOIN::optimize_inner. + */ + bool first_rownum_optimization:1; /* do not wrap view fields with Item_ref */ bool no_wrap_view_item:1; /* exclude this select from check of unique_table() */ diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 7aed2432e03..620a8328ac3 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -2312,8 +2312,12 @@ JOIN::optimize_inner() DBUG_RETURN(1); } if (select_lex->with_rownum && ! order && ! group_list && - !select_distinct && conds && select_lex == unit->global_parameters()) + !select_distinct && conds && select_lex == unit->global_parameters() && + select_lex->first_rownum_optimization) + { optimize_rownum(thd, unit, conds); + select_lex->first_rownum_optimization= false; + } having= optimize_cond(this, having, join_list, TRUE, &having_value, &having_equal); From fd76746234b480ce386e335533eefdab92795022 Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Tue, 7 May 2024 13:49:17 +1000 Subject: [PATCH 09/42] MDEV-28105 Return error in ha_spider::write_row() if info(HA_STATUS_AUTO) fails Spider calls info with HA_STATUS_AUTO to update auto increment info, which may attempt to connect the data node. If the connection fails, it may emit an error and return the same error. This error should not be of lower priority than any possible error from the later call to handler::update_auto_increment(). Without this change, certain errors from update_auto_increment() such as HA_ERR_AUTOINC_ERANGE may get ignored, causing my_insert() to call my_ok(), which fails the assertion because the error was emitted in the info() call (Diagnostics_area::is_set() returns true). --- storage/spider/ha_spider.cc | 19 ++++++------------- .../spider/bugfix/r/mdev_28105.result | 10 ++++++++++ .../mysql-test/spider/bugfix/t/mdev_28105.opt | 1 + .../spider/bugfix/t/mdev_28105.test | 8 ++++++++ 4 files changed, 25 insertions(+), 13 deletions(-) create mode 100644 storage/spider/mysql-test/spider/bugfix/r/mdev_28105.result create mode 100644 storage/spider/mysql-test/spider/bugfix/t/mdev_28105.opt create mode 100644 storage/spider/mysql-test/spider/bugfix/t/mdev_28105.test diff --git a/storage/spider/ha_spider.cc b/storage/spider/ha_spider.cc index 997f57ab6c8..31498328535 100644 --- a/storage/spider/ha_spider.cc +++ b/storage/spider/ha_spider.cc @@ -9396,18 +9396,6 @@ int ha_spider::update_auto_increment() DBUG_ENTER("ha_spider::update_auto_increment"); DBUG_PRINT("info",("spider this=%p", this)); force_auto_increment = TRUE; -/* - if ( - next_insert_id >= auto_inc_interval_for_cur_row.maximum() && - wide_handler->trx->thd->auto_inc_intervals_forced.get_current() - ) { - force_auto_increment = TRUE; - DBUG_PRINT("info",("spider force_auto_increment=TRUE")); - } else { - force_auto_increment = FALSE; - DBUG_PRINT("info",("spider force_auto_increment=FALSE")); - } -*/ DBUG_PRINT("info",("spider auto_increment_mode=%d", auto_increment_mode)); DBUG_PRINT("info",("spider next_number_field=%lld", @@ -9662,7 +9650,12 @@ int ha_spider::write_row( pthread_mutex_lock(&share->lgtm_tblhnd_share->auto_increment_mutex); if (!share->lgtm_tblhnd_share->auto_increment_init) { - info(HA_STATUS_AUTO); + if ((error_num= info(HA_STATUS_AUTO))) + { + pthread_mutex_unlock( + &share->lgtm_tblhnd_share->auto_increment_mutex); + DBUG_RETURN(error_num); + } share->lgtm_tblhnd_share->auto_increment_lclval = stats.auto_increment_value; share->lgtm_tblhnd_share->auto_increment_init = TRUE; diff --git a/storage/spider/mysql-test/spider/bugfix/r/mdev_28105.result b/storage/spider/mysql-test/spider/bugfix/r/mdev_28105.result new file mode 100644 index 00000000000..1932f6b2624 --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/r/mdev_28105.result @@ -0,0 +1,10 @@ +install soname 'ha_spider'; +Warnings: +Warning 1105 Cannot enable tc-log at run-time. XA features of SPIDER are disabled +SET @@insert_id=128; +CREATE TABLE t(c TINYINT AUTO_INCREMENT KEY) ENGINE=Spider; +INSERT IGNORE INTO t VALUES(0); +ERROR HY000: Unable to connect to foreign data source: localhost +drop table t; +Warnings: +Warning 1620 Plugin is busy and will be uninstalled on shutdown diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_28105.opt b/storage/spider/mysql-test/spider/bugfix/t/mdev_28105.opt new file mode 100644 index 00000000000..789275fa25e --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_28105.opt @@ -0,0 +1 @@ +--skip-log-bin diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_28105.test b/storage/spider/mysql-test/spider/bugfix/t/mdev_28105.test new file mode 100644 index 00000000000..219835075ba --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_28105.test @@ -0,0 +1,8 @@ +install soname 'ha_spider'; +SET @@insert_id=128; # 127 does not crash +CREATE TABLE t(c TINYINT AUTO_INCREMENT KEY) ENGINE=Spider; +--error ER_CONNECT_TO_FOREIGN_DATA_SOURCE +INSERT IGNORE INTO t VALUES(0); +drop table t; +--disable_query_log +--source ../../include/clean_up_spider.inc From 7e65512ecc04a50cec9f7db7220546180e3e08f9 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Tue, 14 May 2024 13:31:53 +0200 Subject: [PATCH 10/42] cleanup: compile with -fno-operator-names in maintainer mode --- cmake/maintainer.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/maintainer.cmake b/cmake/maintainer.cmake index b4936ff57cc..d5ad2867f5b 100644 --- a/cmake/maintainer.cmake +++ b/cmake/maintainer.cmake @@ -43,7 +43,7 @@ FOREACH(F ${MY_WARNING_FLAGS}) MY_CHECK_AND_SET_COMPILER_FLAG(${F} DEBUG RELWITHDEBINFO) ENDFOREACH() -SET(MY_ERROR_FLAGS -Werror) +SET(MY_ERROR_FLAGS -Werror -fno-operator-names) IF(CMAKE_COMPILER_IS_GNUCC AND CMAKE_C_COMPILER_VERSION VERSION_LESS "6.0.0") SET(MY_ERROR_FLAGS ${MY_ERROR_FLAGS} -Wno-error=maybe-uninitialized) From 32ee6670a5c7dd98136989686f23a181110fbf03 Mon Sep 17 00:00:00 2001 From: Daniel Bartholomew Date: Wed, 15 May 2024 10:52:16 -0400 Subject: [PATCH 11/42] bump the VERSION --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 31ae1672cba..05e6832c930 100644 --- a/VERSION +++ b/VERSION @@ -1,4 +1,4 @@ MYSQL_VERSION_MAJOR=10 MYSQL_VERSION_MINOR=5 -MYSQL_VERSION_PATCH=25 +MYSQL_VERSION_PATCH=26 SERVER_MATURITY=stable From 9a95f6b53b44a8be64817b92bb56423c6fad5a0d Mon Sep 17 00:00:00 2001 From: Daniel Bartholomew Date: Wed, 15 May 2024 10:53:41 -0400 Subject: [PATCH 12/42] bump the VERSION --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 67ac5f4c243..a4214274a42 100644 --- a/VERSION +++ b/VERSION @@ -1,4 +1,4 @@ MYSQL_VERSION_MAJOR=10 MYSQL_VERSION_MINOR=6 -MYSQL_VERSION_PATCH=18 +MYSQL_VERSION_PATCH=19 SERVER_MATURITY=stable From 4911ec1a5bc07ef20c9018386a3a2671c59c4dca Mon Sep 17 00:00:00 2001 From: Dave Gosselin Date: Wed, 15 May 2024 09:50:11 -0400 Subject: [PATCH 13/42] mtr on FreeBSD detects core count for --parallel=auto --- mysql-test/lib/My/Platform.pm | 11 ++++++++++- mysql-test/mysql-test-run.pl | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/mysql-test/lib/My/Platform.pm b/mysql-test/lib/My/Platform.pm index f33875e14aa..279fea02ffb 100644 --- a/mysql-test/lib/My/Platform.pm +++ b/mysql-test/lib/My/Platform.pm @@ -23,7 +23,7 @@ use File::Path; use Carp; use base qw(Exporter); -our @EXPORT= qw(IS_CYGWIN IS_MSYS IS_WINDOWS IS_WIN32PERL IS_AIX IS_MAC +our @EXPORT= qw(IS_CYGWIN IS_MSYS IS_WINDOWS IS_WIN32PERL IS_AIX IS_MAC IS_FREEBSD native_path posix_path mixed_path check_socket_path_length process_alive open_for_append); @@ -79,6 +79,15 @@ BEGIN { } } +BEGIN { + if ($^O eq "freebsd") { + eval 'sub IS_FREEBSD { 1 }'; + } + else { + eval 'sub IS_FREEBSD { 0 }'; + } +} + # # native_path # Convert from path format used by perl to the underlying diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 117252cb6f0..d1ad3bdea77 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -427,7 +427,7 @@ sub main { { $opt_parallel= $ENV{NUMBER_OF_PROCESSORS} || 1; } - elsif (IS_MAC) + elsif (IS_MAC || IS_FREEBSD) { $opt_parallel= `sysctl -n hw.ncpu`; } From dc38d8ea80e3a8d650478b4407f49b4adede710b Mon Sep 17 00:00:00 2001 From: Robin Newhouse Date: Tue, 25 Jul 2023 20:13:33 +0000 Subject: [PATCH 14/42] Minimize unsafe C functions with safe_strcpy() Similar to #2480. 567b681 introduced safe_strcpy() to minimize the use of C with potentially unsafe memory overflow with strcpy() whose use is discouraged. Replace instances of strcpy() with safe_strcpy() where possible, limited here to files in the `sql/` directory. All new code of the whole pull request, including one or several files that are either new files or modified ones, are contributed under the BSD-new license. I am contributing on behalf of my employer Amazon Web Services, Inc. --- sql/gcalc_slicescan.cc | 2 +- sql/hostname.cc | 18 ++++++++++++------ sql/log.h | 4 ++-- sql/my_json_writer.cc | 14 +++----------- sql/mysql_install_db.cc | 4 ++-- sql/rpl_parallel.cc | 24 ++++++++++++++++-------- sql/rpl_rli.cc | 3 ++- sql/semisync_master.cc | 7 ++++--- sql/sql_connect.cc | 4 ++-- sql/sql_partition.cc | 2 +- sql/sql_plugin.cc | 7 ++++--- sql/sql_repl.cc | 2 +- 12 files changed, 50 insertions(+), 41 deletions(-) diff --git a/sql/gcalc_slicescan.cc b/sql/gcalc_slicescan.cc index b079bd7a714..662783ea4ea 100644 --- a/sql/gcalc_slicescan.cc +++ b/sql/gcalc_slicescan.cc @@ -144,7 +144,7 @@ static void GCALC_DBUG_PRINT_SLICE(const char *header, size_t nbuf; char buf[1024]; nbuf= strlen(header); - strcpy(buf, header); + safe_strcpy(buf, sizeof(buf), header); for (; slice; slice= slice->get_next()) { size_t lnbuf= nbuf; diff --git a/sql/hostname.cc b/sql/hostname.cc index 48677b5ef76..984c1a219ff 100644 --- a/sql/hostname.cc +++ b/sql/hostname.cc @@ -513,42 +513,48 @@ int ip_to_hostname(struct sockaddr_storage *ip_storage, DBUG_EXECUTE_IF("getnameinfo_error_noname", { - strcpy(hostname_buffer, ""); + safe_strcpy(hostname_buffer, sizeof(hostname_buffer), + ""); err_code= EAI_NONAME; } ); DBUG_EXECUTE_IF("getnameinfo_error_again", { - strcpy(hostname_buffer, ""); + safe_strcpy(hostname_buffer, sizeof(hostname_buffer), + ""); err_code= EAI_AGAIN; } ); DBUG_EXECUTE_IF("getnameinfo_fake_ipv4", { - strcpy(hostname_buffer, "santa.claus.ipv4.example.com"); + safe_strcpy(hostname_buffer, sizeof(hostname_buffer), + "santa.claus.ipv4.example.com"); err_code= 0; } ); DBUG_EXECUTE_IF("getnameinfo_fake_ipv6", { - strcpy(hostname_buffer, "santa.claus.ipv6.example.com"); + safe_strcpy(hostname_buffer, sizeof(hostname_buffer), + "santa.claus.ipv6.example.com"); err_code= 0; } ); DBUG_EXECUTE_IF("getnameinfo_format_ipv4", { - strcpy(hostname_buffer, "12.12.12.12"); + safe_strcpy(hostname_buffer, sizeof(hostname_buffer), + "12.12.12.12"); err_code= 0; } ); DBUG_EXECUTE_IF("getnameinfo_format_ipv6", { - strcpy(hostname_buffer, "12:DEAD:BEEF:0"); + safe_strcpy(hostname_buffer, sizeof(hostname_buffer), + "12:DEAD:BEEF:0"); err_code= 0; } ); diff --git a/sql/log.h b/sql/log.h index dd31081c404..454f0ff63b7 100644 --- a/sql/log.h +++ b/sql/log.h @@ -936,7 +936,7 @@ public: mysql_mutex_assert_not_owner(&LOCK_binlog_end_pos); lock_binlog_end_pos(); binlog_end_pos= pos; - strcpy(binlog_end_pos_file, file_name); + safe_strcpy(binlog_end_pos_file, sizeof(binlog_end_pos_file), file_name); signal_bin_log_update(); unlock_binlog_end_pos(); } @@ -949,7 +949,7 @@ public: { mysql_mutex_assert_not_owner(&LOCK_log); mysql_mutex_assert_owner(&LOCK_binlog_end_pos); - strcpy(file_name_buf, binlog_end_pos_file); + safe_strcpy(file_name_buf, FN_REFLEN, binlog_end_pos_file); return binlog_end_pos; } void lock_binlog_end_pos() { mysql_mutex_lock(&LOCK_binlog_end_pos); } diff --git a/sql/my_json_writer.cc b/sql/my_json_writer.cc index 0397f87dd77..e41bad1ed25 100644 --- a/sql/my_json_writer.cc +++ b/sql/my_json_writer.cc @@ -190,7 +190,7 @@ void Json_writer::add_ull(ulonglong val) } -/* Add a memory size, printing in Kb, Kb, Gb if necessary */ +/* Add a memory size, printing in Kb, Mb if necessary */ void Json_writer::add_size(longlong val) { char buf[64]; @@ -198,18 +198,10 @@ void Json_writer::add_size(longlong val) if (val < 1024) len= my_snprintf(buf, sizeof(buf), "%lld", val); else if (val < 1024*1024*16) - { /* Values less than 16MB are specified in KB for precision */ - len= my_snprintf(buf, sizeof(buf), "%lld", val/1024); - strcpy(buf + len, "Kb"); - len+= 2; - } + len= my_snprintf(buf, sizeof(buf), "%lldKb", val/1024); else - { - len= my_snprintf(buf, sizeof(buf), "%lld", val/(1024*1024)); - strcpy(buf + len, "Mb"); - len+= 2; - } + len= my_snprintf(buf, sizeof(buf), "%lldMb", val/(1024*1024)); add_str(buf, len); } diff --git a/sql/mysql_install_db.cc b/sql/mysql_install_db.cc index 8879d7daf5d..d083372bec1 100644 --- a/sql/mysql_install_db.cc +++ b/sql/mysql_install_db.cc @@ -159,7 +159,7 @@ int main(int argc, char **argv) MY_INIT(argv[0]); GetModuleFileName(NULL, self_name, FN_REFLEN); - strcpy(mysqld_path,self_name); + safe_strcpy(mysqld_path, sizeof(mysqld_path), self_name); p= strrchr(mysqld_path, FN_LIBCHAR); if (p) { @@ -174,7 +174,7 @@ int main(int argc, char **argv) Figure out default data directory. It "data" directory, next to "bin" directory, where mysql_install_db.exe resides. */ - strcpy(default_datadir, self_name); + safe_strcpy(default_datadir, sizeof(default_datadir), self_name); p = strrchr(default_datadir, FN_LIBCHAR); if (p) { diff --git a/sql/rpl_parallel.cc b/sql/rpl_parallel.cc index 23ca235c3e9..1cfdf96ee3b 100644 --- a/sql/rpl_parallel.cc +++ b/sql/rpl_parallel.cc @@ -54,11 +54,13 @@ rpt_handle_event(rpl_parallel_thread::queued_event *qev, thd->system_thread_info.rpl_sql_info->rpl_filter = rli->mi->rpl_filter; ev->thd= thd; - strcpy(rgi->event_relay_log_name_buf, qev->event_relay_log_name); + safe_strcpy(rgi->event_relay_log_name_buf, sizeof(rgi->event_relay_log_name_buf), + qev->event_relay_log_name); rgi->event_relay_log_name= rgi->event_relay_log_name_buf; rgi->event_relay_log_pos= qev->event_relay_log_pos; rgi->future_event_relay_log_pos= qev->future_event_relay_log_pos; - strcpy(rgi->future_event_master_log_name, qev->future_event_master_log_name); + safe_strcpy(rgi->future_event_master_log_name, sizeof(rgi->future_event_master_log_name), + qev->future_event_master_log_name); if (event_can_update_last_master_timestamp(ev)) rgi->last_master_timestamp= ev->when + (time_t)ev->exec_time; err= apply_event_and_update_pos_for_parallel(ev, thd, rgi); @@ -115,7 +117,8 @@ handle_queued_pos_update(THD *thd, rpl_parallel_thread::queued_event *qev) cmp= compare_log_name(rli->group_master_log_name, qev->future_event_master_log_name); if (cmp < 0) { - strcpy(rli->group_master_log_name, qev->future_event_master_log_name); + safe_strcpy(rli->group_master_log_name, sizeof(rli->group_master_log_name), + qev->future_event_master_log_name); rli->group_master_log_pos= qev->future_event_master_log_pos; } else if (cmp == 0 @@ -1983,10 +1986,13 @@ rpl_parallel_thread::get_qev(Log_event *ev, ulonglong event_size, queued_event *qev= get_qev_common(ev, event_size); if (!qev) return NULL; - strcpy(qev->event_relay_log_name, rli->event_relay_log_name); + safe_strcpy(qev->event_relay_log_name, sizeof(qev->event_relay_log_name), + rli->event_relay_log_name); qev->event_relay_log_pos= rli->event_relay_log_pos; qev->future_event_relay_log_pos= rli->future_event_relay_log_pos; - strcpy(qev->future_event_master_log_name, rli->future_event_master_log_name); + safe_strcpy(qev->future_event_master_log_name, + sizeof(qev->future_event_master_log_name), + rli->future_event_master_log_name); return qev; } @@ -2000,11 +2006,13 @@ rpl_parallel_thread::retry_get_qev(Log_event *ev, queued_event *orig_qev, if (!qev) return NULL; qev->rgi= orig_qev->rgi; - strcpy(qev->event_relay_log_name, relay_log_name); + safe_strcpy(qev->event_relay_log_name, sizeof(qev->event_relay_log_name), + relay_log_name); qev->event_relay_log_pos= event_pos; qev->future_event_relay_log_pos= event_pos+event_size; - strcpy(qev->future_event_master_log_name, - orig_qev->future_event_master_log_name); + safe_strcpy(qev->future_event_master_log_name, + sizeof(qev->future_event_master_log_name), + orig_qev->future_event_master_log_name); return qev; } diff --git a/sql/rpl_rli.cc b/sql/rpl_rli.cc index efcbd29ef39..9d4e09a362c 100644 --- a/sql/rpl_rli.cc +++ b/sql/rpl_rli.cc @@ -1008,7 +1008,8 @@ void Relay_log_info::inc_group_relay_log_pos(ulonglong log_pos, { if (cmp < 0) { - strcpy(group_master_log_name, rgi->future_event_master_log_name); + safe_strcpy(group_master_log_name, sizeof(group_master_log_name), + rgi->future_event_master_log_name); group_master_log_pos= log_pos; } else if (group_master_log_pos < log_pos) diff --git a/sql/semisync_master.cc b/sql/semisync_master.cc index 670a6d8d9ed..410439c966a 100644 --- a/sql/semisync_master.cc +++ b/sql/semisync_master.cc @@ -352,8 +352,8 @@ Repl_semi_sync_master::Repl_semi_sync_master() m_state(0), m_wait_point(0) { - strcpy(m_reply_file_name, ""); - strcpy(m_wait_file_name, ""); + m_reply_file_name[0]= '\0'; + m_wait_file_name[0]= '\0'; } int Repl_semi_sync_master::init_object() @@ -777,7 +777,8 @@ int Repl_semi_sync_master::report_binlog_update(THD* thd, const char *log_file, return 1; thd->semisync_info= log_info; } - strcpy(log_info->log_file, log_file + dirname_length(log_file)); + safe_strcpy(log_info->log_file, sizeof(log_info->log_file), + log_file + dirname_length(log_file)); log_info->log_pos = log_pos; return write_tranx_in_binlog(log_info->log_file, log_pos); diff --git a/sql/sql_connect.cc b/sql/sql_connect.cc index badbca45aaf..61d6a529045 100644 --- a/sql/sql_connect.cc +++ b/sql/sql_connect.cc @@ -986,7 +986,7 @@ static int check_connection(THD *thd) /* See RFC 5737, 192.0.2.0/24 is reserved. */ const char* fake= "192.0.2.4"; inet_pton(AF_INET,fake, ip4); - strcpy(ip, fake); + safe_strcpy(ip, sizeof(ip), fake); peer_rc= 0; } ); @@ -1016,7 +1016,7 @@ static int check_connection(THD *thd) ip6->s6_addr[13] = 0x06; ip6->s6_addr[14] = 0x00; ip6->s6_addr[15] = 0x06; - strcpy(ip, fake); + safe_strcpy(ip, sizeof(ip), fake); peer_rc= 0; } ); diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index 5ce833bc608..6228991d46c 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -2181,7 +2181,7 @@ static int add_keyword_path(String *str, const char *keyword, const char *path) { char temp_path[FN_REFLEN]; - strcpy(temp_path, path); + safe_strcpy(temp_path, sizeof(temp_path), path); #ifdef __WIN__ /* Convert \ to / to be able to create table on unix */ char *pos, *end; diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index 979407bf3ea..69dbe0d7749 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -379,9 +379,10 @@ static void fix_dl_name(MEM_ROOT *root, LEX_CSTRING *dl) my_strcasecmp(&my_charset_latin1, dl->str + dl->length - so_ext_len, SO_EXT)) { - char *s= (char*)alloc_root(root, dl->length + so_ext_len + 1); + size_t s_size= dl->length + so_ext_len + 1; + char *s= (char*)alloc_root(root, s_size); memcpy(s, dl->str, dl->length); - strcpy(s + dl->length, SO_EXT); + safe_strcpy(s + dl->length, s_size - dl->length, SO_EXT); dl->str= s; dl->length+= so_ext_len; } @@ -3838,7 +3839,7 @@ static int construct_options(MEM_ROOT *mem_root, struct st_plugin_int *tmp, DBUG_ENTER("construct_options"); plugin_name_ptr= (char*) alloc_root(mem_root, plugin_name_len + 1); - strcpy(plugin_name_ptr, plugin_name); + safe_strcpy(plugin_name_ptr, plugin_name_len + 1, plugin_name); my_casedn_str(&my_charset_latin1, plugin_name_ptr); convert_underscore_to_dash(plugin_name_ptr, plugin_name_len); plugin_name_with_prefix_ptr= (char*) alloc_root(mem_root, diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index 972478fcb8f..54290cff242 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -3085,7 +3085,7 @@ err: info->error= ER_MASTER_FATAL_ERROR_READING_BINLOG; } else if (info->errmsg != NULL) - strcpy(info->error_text, info->errmsg); + safe_strcpy(info->error_text, sizeof(info->error_text), info->errmsg); my_message(info->error, info->error_text, MYF(0)); From 28073a979fa5a33dd9fe6768e14ddfb63929c6a2 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Mon, 20 May 2024 13:29:59 +0400 Subject: [PATCH 15/42] MDEV-34187 On startup: UBSAN: runtime error: applying zero offset to null pointer in skip_trailing_space and my_hash_sort_utf8mb3_general1400_nopad_as_ci The last element in func_array_oracle_overrides[] equal to {0,0} was erroneously passed to Native_functions_hash::replace(). Removing this element. --- sql/item_create.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sql/item_create.cc b/sql/item_create.cc index 2fc1ea28529..1e72a66f8e4 100644 --- a/sql/item_create.cc +++ b/sql/item_create.cc @@ -5687,8 +5687,7 @@ const Native_func_registry func_array_oracle_overrides[] = { { STRING_WITH_LEN("REGEXP_REPLACE") }, BUILDER(Create_func_regexp_replace_oracle)}, { { STRING_WITH_LEN("RPAD") }, BUILDER(Create_func_rpad_oracle)}, - { { STRING_WITH_LEN("RTRIM") }, BUILDER(Create_func_rtrim_oracle)}, - { {0, 0}, NULL} + { { STRING_WITH_LEN("RTRIM") }, BUILDER(Create_func_rtrim_oracle)} }; Native_func_registry_array From ac2e02e961f681903c0e288c881536c3ec24d78f Mon Sep 17 00:00:00 2001 From: Thirunarayanan Balathandayuthapani Date: Mon, 20 May 2024 18:18:41 +0530 Subject: [PATCH 16/42] MDEV-34175 mtr_t::log_close() warning should change the shutdown condition - InnoDB should print the warning message saying "Shutdown is in progress" only when shutdown state is greater than SRV_SHUTDOWN_INITIATED. --- storage/innobase/mtr/mtr0mtr.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storage/innobase/mtr/mtr0mtr.cc b/storage/innobase/mtr/mtr0mtr.cc index 4f730dd4eff..3b405b0f324 100644 --- a/storage/innobase/mtr/mtr0mtr.cc +++ b/storage/innobase/mtr/mtr0mtr.cc @@ -925,7 +925,7 @@ static mtr_t::page_flush_ahead log_close(lsn_t lsn) " last checkpoint LSN=" LSN_PF ", current LSN=" LSN_PF "%s.", lsn_t{log_sys.last_checkpoint_lsn}, lsn, - srv_shutdown_state != SRV_SHUTDOWN_INITIATED + srv_shutdown_state > SRV_SHUTDOWN_INITIATED ? ". Shutdown is in progress" : ""); } } From 8047c8bc7117171fd61e0a6ebaf3753f841a6205 Mon Sep 17 00:00:00 2001 From: mariadb-DebarunBanerjee Date: Wed, 15 May 2024 19:47:56 +0530 Subject: [PATCH 17/42] MDEV-28800 SIGABRT due to running out of memory for InnoDB locks This regression is introduced in 10.6 by following commit. commit 898dcf93a886a68450dce7713208fdad82f9178e (Cleanup the lock creation) It removed one important optimization for lock bitmap pre-allocation. We pre-allocate about 8 byte extra space along with every lock object to adjust for similar locks on newly created records on the same page by same transaction. When it is exhausted, a new lock object is created with similar 8 byte pre-allocation. With this optimization removed we are left with only 1 byte pre-allocation. When large number of records are inserted and locked in a single page, we end up creating too many new locks almost in n^2 order. Fix-1: Bring back LOCK_PAGE_BITMAP_MARGIN for pre-allocation. Fix-2: Use the extra space (40 bytes) for bitmap in trx->lock.rec_pool. --- mysql-test/suite/innodb/r/lock_memory.result | 20 ++++++++++++++ mysql-test/suite/innodb/t/lock_memory.test | 29 ++++++++++++++++++++ storage/innobase/lock/lock0lock.cc | 15 +++++++++- 3 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 mysql-test/suite/innodb/r/lock_memory.result create mode 100644 mysql-test/suite/innodb/t/lock_memory.test diff --git a/mysql-test/suite/innodb/r/lock_memory.result b/mysql-test/suite/innodb/r/lock_memory.result new file mode 100644 index 00000000000..9859fdfd1f4 --- /dev/null +++ b/mysql-test/suite/innodb/r/lock_memory.result @@ -0,0 +1,20 @@ +# +# MDEV-28800 SIGABRT due to running out of memory for InnoDB locks +# +CREATE TABLE t1 (col1 INT) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1),(2),(3),(4); +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +START TRANSACTION; +INSERT INTO t1 SELECT a.* FROM t1 a, t1 b, t1 c, t1 d; +SELECT CASE WHEN (POOL_SIZE - (FREE_BUFFERS + DATABASE_PAGES)) <= 10 THEN "PASSED" + ELSE (POOL_SIZE - (FREE_BUFFERS + DATABASE_PAGES)) END +FROM information_schema.innodb_buffer_pool_stats; +CASE WHEN (POOL_SIZE - (FREE_BUFFERS + DATABASE_PAGES)) <= 10 THEN "PASSED" + ELSE (POOL_SIZE - (FREE_BUFFERS + DATABASE_PAGES)) END +PASSED +COMMIT; +SELECT COUNT(*) FROM t1; +COUNT(*) +65552 +DROP TABLE t1; diff --git a/mysql-test/suite/innodb/t/lock_memory.test b/mysql-test/suite/innodb/t/lock_memory.test new file mode 100644 index 00000000000..6b936e18dfc --- /dev/null +++ b/mysql-test/suite/innodb/t/lock_memory.test @@ -0,0 +1,29 @@ +--source include/have_innodb.inc +--source include/have_innodb_16k.inc + +--echo # +--echo # MDEV-28800 SIGABRT due to running out of memory for InnoDB locks +--echo # + +CREATE TABLE t1 (col1 INT) ENGINE=InnoDB; + +INSERT INTO t1 VALUES (1),(2),(3),(4); +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; + +START TRANSACTION; + +# Insert 64K records +INSERT INTO t1 SELECT a.* FROM t1 a, t1 b, t1 c, t1 d; + +# The check needs to be adjusted if we start using more memory for locks. It +# needs 9 pages for 16k page size and we put the limit as 10. +SELECT CASE WHEN (POOL_SIZE - (FREE_BUFFERS + DATABASE_PAGES)) <= 10 THEN "PASSED" + ELSE (POOL_SIZE - (FREE_BUFFERS + DATABASE_PAGES)) END +FROM information_schema.innodb_buffer_pool_stats; + +COMMIT; + +SELECT COUNT(*) FROM t1; + +DROP TABLE t1; diff --git a/storage/innobase/lock/lock0lock.cc b/storage/innobase/lock/lock0lock.cc index a210700727c..52da6e5ccd9 100644 --- a/storage/innobase/lock/lock0lock.cc +++ b/storage/innobase/lock/lock0lock.cc @@ -1242,6 +1242,13 @@ lock_rec_create_low( type_mode = type_mode & ~(LOCK_GAP | LOCK_REC_NOT_GAP); } + /* Extra bitmap size in bytes over and above the current number of + records when a record lock is created. 8 x LOCK_PAGE_DEFAULT_BITMAP_SIZE + extra record locks of same type for newly inserted records can be added + without needing to create a new lock object. Useful when the number of + records in a page is growing. */ + static constexpr size_t LOCK_PAGE_DEFAULT_BITMAP_SIZE = 8; + if (UNIV_LIKELY(!(type_mode & (LOCK_PREDICATE | LOCK_PRDT_PAGE)))) { n_bytes = (page_dir_get_n_heap(page) + 7) / 8; } else { @@ -1270,13 +1277,19 @@ lock_rec_create_low( ut_ad(trx->mutex_is_owner()); ut_ad(trx->state != TRX_STATE_NOT_STARTED); + auto cached_bytes = sizeof *trx->lock.rec_pool - sizeof *lock; + if (trx->lock.rec_cached >= UT_ARR_SIZE(trx->lock.rec_pool) - || sizeof *lock + n_bytes > sizeof *trx->lock.rec_pool) { + || n_bytes > cached_bytes) { + n_bytes += LOCK_PAGE_DEFAULT_BITMAP_SIZE; lock = static_cast( mem_heap_alloc(trx->lock.lock_heap, sizeof *lock + n_bytes)); } else { lock = &trx->lock.rec_pool[trx->lock.rec_cached++].lock; + /* Use all the extra bytes for lock bitmap. */ + ut_ad(n_bytes <= cached_bytes); + n_bytes = cached_bytes; } lock->trx = trx; From 86adee38067effe039c8e4c5f6016baadaac7c6c Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Wed, 1 May 2024 14:22:46 +1000 Subject: [PATCH 18/42] MDEV-31475 remove unnecessary assignment to spider share init_error The init, init_error, and init_error_time fields of a SPIDER_SHARE should only be assigned when actually doing the initialisation of a SPIDER_SHARE, otherwise they could result in spurious failures from spider_get_share() in a subsequent statement. --- storage/spider/ha_spider.cc | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/storage/spider/ha_spider.cc b/storage/spider/ha_spider.cc index 31498328535..5c8b094001a 100644 --- a/storage/spider/ha_spider.cc +++ b/storage/spider/ha_spider.cc @@ -8328,8 +8328,6 @@ int ha_spider::info( spider_init_error_table->init_error_time = (time_t) time((time_t*) 0); } - share->init_error = TRUE; - share->init = TRUE; } if (wide_handler->sql_command == SQLCOM_SHOW_CREATE || wide_handler->sql_command == SQLCOM_SHOW_FIELDS) @@ -8382,10 +8380,6 @@ int ha_spider::info( share, TRUE)) ) { spider_init_error_table->init_error = error_num; -/* - if (!thd->is_error()) - my_error(error_num, MYF(0), ""); -*/ if ((spider_init_error_table->init_error_with_message = thd->is_error())) strmov(spider_init_error_table->init_error_msg, @@ -8393,8 +8387,6 @@ int ha_spider::info( spider_init_error_table->init_error_time = (time_t) time((time_t*) 0); } - share->init_error = TRUE; - share->init = TRUE; } if (wide_handler->sql_command == SQLCOM_SHOW_CREATE || wide_handler->sql_command == SQLCOM_SHOW_FIELDS) @@ -8688,8 +8680,6 @@ ha_rows ha_spider::records_in_range( spider_init_error_table->init_error_time = (time_t) time((time_t*) 0); } - share->init_error = TRUE; - share->init = TRUE; } if (check_error_mode(error_num)) my_errno = error_num; @@ -8993,8 +8983,6 @@ int ha_spider::check_crd() spider_init_error_table->init_error_time = (time_t) time((time_t*) 0); } - share->init_error = TRUE; - share->init = TRUE; } DBUG_RETURN(check_error_mode(error_num)); } From 698dae54effd0b2e1ce8d564f8b7d0ed04c431e2 Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Wed, 1 May 2024 14:25:39 +1000 Subject: [PATCH 19/42] MDEV-31475 Spider: only reset wide_handler when owning it A wide_handler is shared among ha_spider of partitions of the same spider table, where the last partition is designated the owner of the wide_handler, and is responsible for its deallocation. Therefore in case of failure, we only reset wide_handler in error handling if the current ha_spider is the owner of the wide_handler, otherwise it will result in segv in the destructor of ha_spider, or during ha_spider::close(). --- storage/spider/ha_spider.cc | 3 +- storage/spider/ha_spider.h | 1 + .../spider/bugfix/r/mdev_31475.result | 23 +++++++++++++ .../spider/bugfix/t/mdev_31475.test | 32 +++++++++++++++++++ storage/spider/spd_include.h | 4 +++ 5 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 storage/spider/mysql-test/spider/bugfix/r/mdev_31475.result create mode 100644 storage/spider/mysql-test/spider/bugfix/t/mdev_31475.test diff --git a/storage/spider/ha_spider.cc b/storage/spider/ha_spider.cc index 5c8b094001a..bdf2470f6cb 100644 --- a/storage/spider/ha_spider.cc +++ b/storage/spider/ha_spider.cc @@ -614,7 +614,8 @@ error_get_share: owner->wide_handler = NULL; owner->wide_handler_owner = FALSE; } - wide_handler = NULL; + if (!wide_handler_owner) + wide_handler = NULL; error_wide_handler_alloc: DBUG_RETURN(error_num); } diff --git a/storage/spider/ha_spider.h b/storage/spider/ha_spider.h index 89b39d585fa..969fbf850cd 100644 --- a/storage/spider/ha_spider.h +++ b/storage/spider/ha_spider.h @@ -94,6 +94,7 @@ public: #ifdef WITH_PARTITION_STORAGE_ENGINE SPIDER_PARTITION_HANDLER *partition_handler; #endif + /* Whether this ha_spider is the owner of its wide_handler. */ bool wide_handler_owner = FALSE; SPIDER_WIDE_HANDLER *wide_handler = NULL; diff --git a/storage/spider/mysql-test/spider/bugfix/r/mdev_31475.result b/storage/spider/mysql-test/spider/bugfix/r/mdev_31475.result new file mode 100644 index 00000000000..b4ad3692432 --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/r/mdev_31475.result @@ -0,0 +1,23 @@ +for master_1 +for child2 +for child3 +CREATE TABLE t3 (c1 MEDIUMINT NULL, c2 CHAR(5)) ENGINE=Spider PARTITION BY KEY(c1) PARTITIONS 2; +ALTER TABLE t3 DROP PRIMARY KEY; +ERROR 42000: Can't DROP INDEX `PRIMARY`; check that it exists +SELECT * FROM t3 WHERE c1 <=> '1000-00-01 00:00:00' ORDER BY c1,c2 LIMIT 2; +ERROR HY000: Unable to connect to foreign data source: localhost +CREATE TABLE t1 (a INT UNSIGNED NOT NULL PRIMARY KEY, b INT UNSIGNED NOT NULL, c INT UNSIGNED, UNIQUE (b, c) USING HASH) ENGINE=Spider; +SELECT t1.c1 FROM t3 RIGHT JOIN t1 ON t1.c1=current_date() UNION SELECT t1.c2 FROM t1 LEFT OUTER JOIN t3 ON t1.c2; +ERROR HY000: Unable to connect to foreign data source: localhost +drop table t1, t3; +set spider_same_server_link= 1; +CREATE SERVER srv FOREIGN DATA WRAPPER mysql +OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); +CREATE TABLE t1 (a INT, b VARCHAR(255), PRIMARY KEY(a)) ENGINE=Spider PARTITION BY RANGE (a) (PARTITION p1 VALUES LESS THAN (3), PARTITION p2 VALUES LESS THAN MAXVALUE COMMENT='srv "srv"'); +DROP SERVER srv; +SELECT * FROM t1; +ERROR HY000: The foreign server name you are trying to reference does not exist. Data source error: srv +drop table t1; +for master_1 +for child2 +for child3 diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_31475.test b/storage/spider/mysql-test/spider/bugfix/t/mdev_31475.test new file mode 100644 index 00000000000..6794e9df19e --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_31475.test @@ -0,0 +1,32 @@ +--disable_query_log +--disable_result_log +--source ../../t/test_init.inc +--enable_result_log +--enable_query_log + +# test 1 +CREATE TABLE t3 (c1 MEDIUMINT NULL, c2 CHAR(5)) ENGINE=Spider PARTITION BY KEY(c1) PARTITIONS 2; +--error ER_CANT_DROP_FIELD_OR_KEY +ALTER TABLE t3 DROP PRIMARY KEY; +--error ER_CONNECT_TO_FOREIGN_DATA_SOURCE +SELECT * FROM t3 WHERE c1 <=> '1000-00-01 00:00:00' ORDER BY c1,c2 LIMIT 2; +CREATE TABLE t1 (a INT UNSIGNED NOT NULL PRIMARY KEY, b INT UNSIGNED NOT NULL, c INT UNSIGNED, UNIQUE (b, c) USING HASH) ENGINE=Spider; +--error ER_CONNECT_TO_FOREIGN_DATA_SOURCE +SELECT t1.c1 FROM t3 RIGHT JOIN t1 ON t1.c1=current_date() UNION SELECT t1.c2 FROM t1 LEFT OUTER JOIN t3 ON t1.c2; +drop table t1, t3; + +# test 2 +set spider_same_server_link= 1; +evalp CREATE SERVER srv FOREIGN DATA WRAPPER mysql +OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); +CREATE TABLE t1 (a INT, b VARCHAR(255), PRIMARY KEY(a)) ENGINE=Spider PARTITION BY RANGE (a) (PARTITION p1 VALUES LESS THAN (3), PARTITION p2 VALUES LESS THAN MAXVALUE COMMENT='srv "srv"'); +DROP SERVER srv; +--error 1477 +SELECT * FROM t1; +drop table t1; + +--disable_query_log +--disable_result_log +--source ../../t/test_deinit.inc +--enable_result_log +--enable_query_log diff --git a/storage/spider/spd_include.h b/storage/spider/spd_include.h index ecf336f1c8e..d6525b7b730 100644 --- a/storage/spider/spd_include.h +++ b/storage/spider/spd_include.h @@ -879,6 +879,10 @@ enum spider_hnd_stage { SPD_HND_STAGE_CLEAR_TOP_TABLE_FIELDS }; +/* + A wide handler is shared among ha_spider of partitions of the same + table. It is owned by the last partition. +*/ typedef struct st_spider_wide_handler { spider_hnd_stage stage; From 2d5cba22a98e54c0c8975d8d7fe7e04981d73c8a Mon Sep 17 00:00:00 2001 From: mariadb-DebarunBanerjee Date: Thu, 16 May 2024 13:10:44 +0530 Subject: [PATCH 20/42] MDEV-34167 We fail to terminate transaction early with ER_LOCK_TABLE_FULL when lock memory is growing This regression is introduced in 10.6 by following commit. commit b6a2472489accf0ae9ac3655ffe9b2997ab267ba MDEV-27891: SIGSEGV in InnoDB buffer pool resize During DML, we check if buffer pool is running out of data pages in buf_pool_t::running_out. Here is 75% of the buffer pool is occupied by non-data pages we rollback the current transaction and exit with ER_LOCK_TABLE_FULL. The integer division (n_chunks_new / 4) becomes zero whenever the total number of chunks are < 4 making the check completely ineffective for such cases. Also the check is inaccurate for larger chunks. Fix-1: Correct the check in buf_pool_t::running_out. Fix-2: While waiting for free page, check for buf_LRU_check_size_of_non_data_objects. --- storage/innobase/buf/buf0lru.cc | 3 +++ storage/innobase/include/buf0buf.h | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/storage/innobase/buf/buf0lru.cc b/storage/innobase/buf/buf0lru.cc index 3fa0cf9002e..737df0a6913 100644 --- a/storage/innobase/buf/buf0lru.cc +++ b/storage/innobase/buf/buf0lru.cc @@ -451,7 +451,10 @@ got_block: mysql_mutex_unlock(&buf_pool.flush_list_mutex); if (my_cond_timedwait(&buf_pool.done_free, &buf_pool.mutex.m_mutex, &abstime)) + { buf_pool.LRU_warn(); + buf_LRU_check_size_of_non_data_objects(); + } } goto got_block; diff --git a/storage/innobase/include/buf0buf.h b/storage/innobase/include/buf0buf.h index 2a79b112bab..d403fe12430 100644 --- a/storage/innobase/include/buf0buf.h +++ b/storage/innobase/include/buf0buf.h @@ -1486,7 +1486,7 @@ public: { return !recv_recovery_is_on() && UT_LIST_GET_LEN(free) + UT_LIST_GET_LEN(LRU) < - n_chunks_new / 4 * chunks->size; + (n_chunks_new * chunks->size) / 4; } /** @return whether the buffer pool is running low */ From 0907df3d897149d4223800533e8e41ffdeb6ac8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Tue, 21 May 2024 09:52:35 +0300 Subject: [PATCH 21/42] MDEV-34204 Assertion `!*detailed_error' failed on shutdown after XA PREPARE trx_free_at_shutdown(): Similar to trx_t::commit_in_memory(), clear the detailed_error (FOREIGN KEY constraint error) before invoking trx_t::free(). We only do this on debug instrumented builds in order to avoid a debug assertion failure on shutdown. --- mysql-test/suite/innodb/r/xa_recovery.result | 17 ++++++++++++++--- mysql-test/suite/innodb/t/xa_recovery.test | 15 ++++++++++++--- storage/innobase/trx/trx0trx.cc | 1 + 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/mysql-test/suite/innodb/r/xa_recovery.result b/mysql-test/suite/innodb/r/xa_recovery.result index ed9f19b7eb3..833ccf2015f 100644 --- a/mysql-test/suite/innodb/r/xa_recovery.result +++ b/mysql-test/suite/innodb/r/xa_recovery.result @@ -1,4 +1,4 @@ -CREATE TABLE t1 (a INT) ENGINE=InnoDB; +CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB; INSERT INTO t1 VALUES (1); connect con1,localhost,root; XA START 'x'; @@ -6,7 +6,7 @@ UPDATE t1 set a=2; XA END 'x'; XA PREPARE 'x'; connect con2,localhost,root; -CREATE TABLE t2 (a INT) ENGINE=InnoDB; +CREATE TABLE t2 (a INT PRIMARY KEY) ENGINE=InnoDB; XA START 'y'; INSERT INTO t2 VALUES (1); XA END 'y'; @@ -29,7 +29,18 @@ XA ROLLBACK 'x'; SELECT * FROM t1; a 1 -DROP TABLE t1; +CREATE TABLE t3(a INT PRIMARY KEY REFERENCES t1(a)) ENGINE=InnoDB; +XA START 'a'; +INSERT INTO t3 SET a=1; +INSERT INTO t3 SET a=42; +ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t3`, CONSTRAINT `t3_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t1` (`a`)) +XA END 'a'; +XA PREPARE 'a'; SET GLOBAL innodb_fast_shutdown=0; # restart +XA COMMIT 'a'; +SELECT * FROM t3; +a +1 +DROP TABLE t3,t1; XA ROLLBACK 'y'; diff --git a/mysql-test/suite/innodb/t/xa_recovery.test b/mysql-test/suite/innodb/t/xa_recovery.test index da9626ebd29..6bdc986ae88 100644 --- a/mysql-test/suite/innodb/t/xa_recovery.test +++ b/mysql-test/suite/innodb/t/xa_recovery.test @@ -10,12 +10,12 @@ call mtr.add_suppression("Found [12] prepared XA transactions"); FLUSH TABLES; --enable_query_log -CREATE TABLE t1 (a INT) ENGINE=InnoDB; +CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB; INSERT INTO t1 VALUES (1); connect (con1,localhost,root); XA START 'x'; UPDATE t1 set a=2; XA END 'x'; XA PREPARE 'x'; connect (con2,localhost,root); -CREATE TABLE t2 (a INT) ENGINE=InnoDB; +CREATE TABLE t2 (a INT PRIMARY KEY) ENGINE=InnoDB; XA START 'y'; INSERT INTO t2 VALUES (1); XA END 'y'; XA PREPARE 'y'; connection default; @@ -53,9 +53,18 @@ SELECT * FROM t1; XA ROLLBACK 'x'; SELECT * FROM t1; -DROP TABLE t1; +CREATE TABLE t3(a INT PRIMARY KEY REFERENCES t1(a)) ENGINE=InnoDB; +XA START 'a'; +INSERT INTO t3 SET a=1; +--error ER_NO_REFERENCED_ROW_2 +INSERT INTO t3 SET a=42; +XA END 'a'; +XA PREPARE 'a'; SET GLOBAL innodb_fast_shutdown=0; --source include/restart_mysqld.inc +XA COMMIT 'a'; +SELECT * FROM t3; +DROP TABLE t3,t1; XA ROLLBACK 'y'; diff --git a/storage/innobase/trx/trx0trx.cc b/storage/innobase/trx/trx0trx.cc index 606416e677e..7f1f26547dc 100644 --- a/storage/innobase/trx/trx0trx.cc +++ b/storage/innobase/trx/trx0trx.cc @@ -554,6 +554,7 @@ trx_free_at_shutdown(trx_t *trx) trx->state = TRX_STATE_NOT_STARTED; ut_ad(!UT_LIST_GET_LEN(trx->lock.trx_locks)); trx->id = 0; + ut_d(*trx->detailed_error = '\0'); trx->free(); } From b2944adb76e93d22b9cfe088a2c568c46d8ecfd9 Mon Sep 17 00:00:00 2001 From: mariadb-DebarunBanerjee Date: Wed, 15 May 2024 17:30:52 +0530 Subject: [PATCH 22/42] MDEV-34166 Server could hang with BP < 80M under stress BUF_LRU_MIN_LEN (256) is too high value for low buffer pool(BP) size. For example, for BP size lower than 80M and 16 K page size, the limit is more than 5% of total BP and for lowest BP 5M, it is 80% of the BP. Non-data objects like explicit locks could occupy part of the BP pool reducing the pages available for LRU. If LRU reaches minimum limit and if no free pages are available, server would hang with page cleaner not able to free any more pages. Fix: To avoid such hang, we adjust the LRU limit lower than the limit for data objects as checked in buf_LRU_check_size_of_non_data_objects() i.e. one page less than 5% of BP. --- .../suite/innodb/r/lock_memory_debug.result | 13 +++++++++++++ .../suite/innodb/t/lock_memory_debug.opt | 1 + .../suite/innodb/t/lock_memory_debug.test | 19 +++++++++++++++++++ storage/innobase/buf/buf0flu.cc | 14 +++++++++++++- storage/innobase/lock/lock0lock.cc | 5 +++++ 5 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 mysql-test/suite/innodb/r/lock_memory_debug.result create mode 100644 mysql-test/suite/innodb/t/lock_memory_debug.opt create mode 100644 mysql-test/suite/innodb/t/lock_memory_debug.test diff --git a/mysql-test/suite/innodb/r/lock_memory_debug.result b/mysql-test/suite/innodb/r/lock_memory_debug.result new file mode 100644 index 00000000000..36d7433974e --- /dev/null +++ b/mysql-test/suite/innodb/r/lock_memory_debug.result @@ -0,0 +1,13 @@ +# +# MDEV-34166 Server could hang with BP < 80M under stress +# +call mtr.add_suppression("\\[Warning\\] InnoDB: Over 67 percent of the buffer pool"); +CREATE TABLE t1 (col1 INT) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1),(2),(3),(4),(5); +SET STATEMENT debug_dbug='+d,innodb_skip_lock_bitmap' FOR +INSERT INTO t1 SELECT a.* FROM t1 a, t1 b, t1 c, t1 d, t1 e, t1 f, t1 g LIMIT 45000; +ERROR HY000: The total number of locks exceeds the lock table size +SELECT COUNT(*) FROM t1; +COUNT(*) +5 +DROP TABLE t1; diff --git a/mysql-test/suite/innodb/t/lock_memory_debug.opt b/mysql-test/suite/innodb/t/lock_memory_debug.opt new file mode 100644 index 00000000000..67c8423cf2a --- /dev/null +++ b/mysql-test/suite/innodb/t/lock_memory_debug.opt @@ -0,0 +1 @@ +--innodb_buffer_pool_size=5M diff --git a/mysql-test/suite/innodb/t/lock_memory_debug.test b/mysql-test/suite/innodb/t/lock_memory_debug.test new file mode 100644 index 00000000000..51e0e8fd57e --- /dev/null +++ b/mysql-test/suite/innodb/t/lock_memory_debug.test @@ -0,0 +1,19 @@ +--source include/have_innodb.inc +--source include/have_debug.inc + +--echo # +--echo # MDEV-34166 Server could hang with BP < 80M under stress +--echo # + +call mtr.add_suppression("\\[Warning\\] InnoDB: Over 67 percent of the buffer pool"); + +CREATE TABLE t1 (col1 INT) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1),(2),(3),(4),(5); + +--error ER_LOCK_TABLE_FULL +SET STATEMENT debug_dbug='+d,innodb_skip_lock_bitmap' FOR +INSERT INTO t1 SELECT a.* FROM t1 a, t1 b, t1 c, t1 d, t1 e, t1 f, t1 g LIMIT 45000; + +SELECT COUNT(*) FROM t1; + +DROP TABLE t1; diff --git a/storage/innobase/buf/buf0flu.cc b/storage/innobase/buf/buf0flu.cc index a554309915d..b2d7d10b855 100644 --- a/storage/innobase/buf/buf0flu.cc +++ b/storage/innobase/buf/buf0flu.cc @@ -1300,9 +1300,21 @@ static void buf_flush_LRU_list_batch(ulint max, bool evict, static_assert(FIL_NULL > SRV_TMP_SPACE_ID, "consistency"); static_assert(FIL_NULL > SRV_SPACE_ID_UPPER_BOUND, "consistency"); + /* BUF_LRU_MIN_LEN (256) is too high value for low buffer pool(BP) size. For + example, for BP size lower than 80M and 16 K page size, the limit is more than + 5% of total BP and for lowest BP 5M, it is 80% of the BP. Non-data objects + like explicit locks could occupy part of the BP pool reducing the pages + available for LRU. If LRU reaches minimum limit and if no free pages are + available, server would hang with page cleaner not able to free any more + pages. To avoid such hang, we adjust the LRU limit lower than the limit for + data objects as checked in buf_LRU_check_size_of_non_data_objects() i.e. one + page less than 5% of BP. */ + size_t pool_limit= buf_pool.curr_size / 20 - 1; + auto buf_lru_min_len= std::min(pool_limit, BUF_LRU_MIN_LEN); + for (buf_page_t *bpage= UT_LIST_GET_LAST(buf_pool.LRU); bpage && - ((UT_LIST_GET_LEN(buf_pool.LRU) > BUF_LRU_MIN_LEN && + ((UT_LIST_GET_LEN(buf_pool.LRU) > buf_lru_min_len && UT_LIST_GET_LEN(buf_pool.free) < free_limit) || recv_recovery_is_on()); ++scanned) { diff --git a/storage/innobase/lock/lock0lock.cc b/storage/innobase/lock/lock0lock.cc index 0891ad5ceb7..d9a3c96aab0 100644 --- a/storage/innobase/lock/lock0lock.cc +++ b/storage/innobase/lock/lock0lock.cc @@ -1739,6 +1739,11 @@ lock_rec_find_similar_on_page( const trx_t* trx) /*!< in: transaction */ { ut_ad(lock_mutex_own()); + DBUG_EXECUTE_IF("innodb_skip_lock_bitmap", { + if (!trx->in_rollback) { + return nullptr; + } + }); for (/* No op */; lock != NULL; From 310fd6ff695541247db766baf3ade1e3b4db16e9 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Tue, 21 May 2024 08:53:40 +0400 Subject: [PATCH 23/42] Backporting bugs fixes fixed by MDEV-31340 from 11.5 The patch for MDEV-31340 fixed the following bugs: MDEV-33084 LASTVAL(t1) and LASTVAL(T1) do not work well with lower-case-table-names=0 MDEV-33085 Tables T1 and t1 do not work well with ENGINE=CSV and lower-case-table-names=0 MDEV-33086 SHOW OPEN TABLES IN DB1 -- is case insensitive with lower-case-table-names=0 MDEV-33088 Cannot create triggers in the database `MYSQL` MDEV-33103 LOCK TABLE t1 AS t2 -- alias is not case sensitive with lower-case-table-names=0 MDEV-33108 TABLE_STATISTICS and INDEX_STATISTICS are case insensitive with lower-case-table-names=0 MDEV-33109 DROP DATABASE MYSQL -- does not drop SP with lower-case-table-names=0 MDEV-33110 HANDLER commands are case insensitive with lower-case-table-names=0 MDEV-33119 User is case insensitive in INFORMATION_SCHEMA.VIEWS MDEV-33120 System log table names are case insensitive with lower-cast-table-names=0 Backporting the fixes from 11.5 to 10.5 --- mysql-test/main/lowercase_table5.result | 142 +++++++++++++++++++ mysql-test/main/lowercase_table5.test | 138 ++++++++++++++++++ mysql-test/main/view_grant.result | 31 ++++ mysql-test/main/view_grant.test | 27 ++++ mysql-test/suite/csv/lowercase_table0.result | 15 ++ mysql-test/suite/csv/lowercase_table0.test | 16 +++ sql/lex_ident.h | 85 +++++++++++ sql/sql_acl.cc | 18 +-- sql/sql_base.cc | 52 +++---- sql/sql_base.h | 3 +- sql/sql_class.cc | 5 +- sql/sql_class.h | 1 + sql/sql_connect.cc | 6 +- sql/sql_db.cc | 3 +- sql/sql_handler.cc | 7 +- sql/sql_parse.cc | 15 +- sql/sql_show.cc | 12 +- sql/sql_string.h | 5 + sql/sql_trigger.cc | 2 +- sql/table.cc | 35 +++-- sql/table.h | 17 ++- sql/temporary_tables.cc | 13 +- storage/csv/ha_tina.cc | 3 +- 23 files changed, 561 insertions(+), 90 deletions(-) create mode 100644 mysql-test/suite/csv/lowercase_table0.result create mode 100644 mysql-test/suite/csv/lowercase_table0.test create mode 100644 sql/lex_ident.h diff --git a/mysql-test/main/lowercase_table5.result b/mysql-test/main/lowercase_table5.result index 7e78f71b75f..cededde9525 100644 --- a/mysql-test/main/lowercase_table5.result +++ b/mysql-test/main/lowercase_table5.result @@ -47,3 +47,145 @@ DROP PROCEDURE SP; # # End of 10.4 tests # +# +# Start of 10.5 tests +# +# +# MDEV-33084 LASTVAL(t1) and LASTVAL(T1) do not work well with lower-case-table-names=0 +# +CREATE SEQUENCE t1; +CREATE SEQUENCE T1; +SELECT nextval(t1), lastval(t1); +nextval(t1) lastval(t1) +1 1 +SELECT nextval(T1), lastval(T1); +nextval(T1) lastval(T1) +1 1 +SELECT lastval(t1), lastval(T1) l2; +lastval(t1) l2 +1 1 +DROP SEQUENCE t1, T1; +# +# MDEV-33086 SHOW OPEN TABLES IN DB1 -- is case insensitive with lower-case-table-names=0 +# +CREATE DATABASE db1; +CREATE TABLE db1.t1 (a INT); +SELECT * FROM db1.t1; +a +SHOW OPEN TABLES IN DB1; +Database Table In_use Name_locked +SHOW OPEN TABLES IN db1; +Database Table In_use Name_locked +db1 t1 0 0 +DROP DATABASE db1; +# +# MDEV-33088 Cannot create triggers in the database `MYSQL` +# +CREATE DATABASE MYSQL; +CREATE TABLE MYSQL.t1 (a INT); +CREATE TABLE MYSQL.t2 (a INT); +CREATE TRIGGER MYSQL.tr1 AFTER INSERT ON t1 FOR EACH ROW INSERT INTO t2 VALUES (new.a); +INSERT INTO MYSQL.t1 VALUES (10); +SELECT * FROM MYSQL.t1; +a +10 +SELECT * FROM MYSQL.t2; +a +10 +DROP DATABASE MYSQL; +# +# MDEV-33103 LOCK TABLE t1 AS t2 -- alias is not case sensitive with lower-case-table-names=0 +# +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1); +LOCK TABLE t1 AS t2 READ; +SELECT * FROM t1 AS t2; +a +1 +UNLOCK TABLES; +LOCK TABLE t1 AS t2 READ; +SELECT * FROM t1 AS T2; +ERROR HY000: Table 'T2' was not locked with LOCK TABLES +UNLOCK TABLES; +DROP TABLE t1; +# +# MDEV-33108 TABLE_STATISTICS and INDEX_STATISTICS are case insensitive with lower-case-table-names=0 +# +SET GLOBAL userstat=1; +CREATE TABLE t1 (a INT, KEY(a)); +INSERT INTO t1 VALUES (1),(2),(3),(4); +SELECT * FROM t1 ORDER BY a; +a +1 +2 +3 +4 +CREATE TABLE T1 (a INT, KEY(a)); +INSERT INTO T1 VALUES (1),(2),(3),(4); +SELECT * FROM T1 ORDER BY a; +a +1 +2 +3 +4 +SELECT * FROM INFORMATION_SCHEMA.TABLE_STATISTICS ORDER BY BINARY TABLE_NAME; +TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES +test T1 4 4 4 +test t1 4 4 4 +SELECT * FROM INFORMATION_SCHEMA.INDEX_STATISTICS ORDER BY BINARY TABLE_NAME; +TABLE_SCHEMA TABLE_NAME INDEX_NAME ROWS_READ +test T1 a 4 +test t1 a 4 +DROP TABLE t1; +DROP TABLE T1; +SET GLOBAL userstat=DEFAULT; +# +# MDEV-33109 DROP DATABASE MYSQL -- does not drop SP with lower-case-table-names=0 +# +CREATE DATABASE MYSQL; +CREATE FUNCTION MYSQL.f1() RETURNS INT RETURN 1; +DROP DATABASE MYSQL; +SELECT db, name, body FROM mysql.proc WHERE db=BINARY 'MYSQL' AND name='f1'; +db name body +# +# MDEV-33110 HANDLER commands are case insensitive with lower-case-table-names=0 +# +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1),(2); +HANDLER t1 OPEN; +HANDLER t1 READ FIRST; +a +1 +CREATE OR REPLACE TABLE T1 (a INT); +DROP TABLE T1; +HANDLER t1 READ NEXT; +a +2 +HANDLER t1 CLOSE; +DROP TABLE t1; +# +# MDEV-33120 System log table names are case insensitive with lower-cast-table-names=0 +# +CREATE TABLE mysql.GENERAL_log (a INT); +INSERT INTO mysql.GENERAL_log VALUES (1),(2); +DROP TABLE mysql.GENERAL_log; +CREATE TABLE mysql.SLOW_log (a INT); +INSERT INTO mysql.SLOW_log VALUES (1),(2); +DROP TABLE mysql.SLOW_log; +CREATE TABLE mysql.TRANSACTION_registry (a INT); +INSERT INTO mysql.TRANSACTION_registry VALUES (1),(2); +DROP TABLE mysql.TRANSACTION_registry; +CREATE DATABASE MYSQL; +CREATE TABLE MYSQL.general_log (a INT); +INSERT INTO MYSQL.general_log VALUES (1),(2); +DROP TABLE MYSQL.general_log; +CREATE TABLE MYSQL.slow_log (a INT); +INSERT INTO MYSQL.slow_log VALUES (1),(2); +DROP TABLE MYSQL.slow_log; +CREATE TABLE MYSQL.transaction_registry (a INT); +INSERT INTO MYSQL.transaction_registry VALUES (1),(2); +DROP TABLE MYSQL.transaction_registry; +DROP DATABASE MYSQL; +# +# End of 10.5 tests +# diff --git a/mysql-test/main/lowercase_table5.test b/mysql-test/main/lowercase_table5.test index 0103dbf5fd2..fcbb3fefb33 100644 --- a/mysql-test/main/lowercase_table5.test +++ b/mysql-test/main/lowercase_table5.test @@ -49,3 +49,141 @@ DROP PROCEDURE SP; --echo # --echo # End of 10.4 tests --echo # + +--echo # +--echo # Start of 10.5 tests +--echo # + +--echo # +--echo # MDEV-33084 LASTVAL(t1) and LASTVAL(T1) do not work well with lower-case-table-names=0 +--echo # + +CREATE SEQUENCE t1; +CREATE SEQUENCE T1; +--disable_ps2_protocol +SELECT nextval(t1), lastval(t1); +SELECT nextval(T1), lastval(T1); +SELECT lastval(t1), lastval(T1) l2; +--enable_ps2_protocol +DROP SEQUENCE t1, T1; + +--echo # +--echo # MDEV-33086 SHOW OPEN TABLES IN DB1 -- is case insensitive with lower-case-table-names=0 +--echo # + +CREATE DATABASE db1; +CREATE TABLE db1.t1 (a INT); +SELECT * FROM db1.t1; +SHOW OPEN TABLES IN DB1; +SHOW OPEN TABLES IN db1; +DROP DATABASE db1; + +--echo # +--echo # MDEV-33088 Cannot create triggers in the database `MYSQL` +--echo # + +CREATE DATABASE MYSQL; +CREATE TABLE MYSQL.t1 (a INT); +CREATE TABLE MYSQL.t2 (a INT); +CREATE TRIGGER MYSQL.tr1 AFTER INSERT ON t1 FOR EACH ROW INSERT INTO t2 VALUES (new.a); +INSERT INTO MYSQL.t1 VALUES (10); +SELECT * FROM MYSQL.t1; +SELECT * FROM MYSQL.t2; +DROP DATABASE MYSQL; + + +--echo # +--echo # MDEV-33103 LOCK TABLE t1 AS t2 -- alias is not case sensitive with lower-case-table-names=0 +--echo # + +--disable_view_protocol +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1); +LOCK TABLE t1 AS t2 READ; +SELECT * FROM t1 AS t2; +UNLOCK TABLES; +LOCK TABLE t1 AS t2 READ; +--error ER_TABLE_NOT_LOCKED +SELECT * FROM t1 AS T2; +UNLOCK TABLES; +DROP TABLE t1; +--enable_view_protocol + + +--echo # +--echo # MDEV-33108 TABLE_STATISTICS and INDEX_STATISTICS are case insensitive with lower-case-table-names=0 +--echo # + +SET GLOBAL userstat=1; +CREATE TABLE t1 (a INT, KEY(a)); +INSERT INTO t1 VALUES (1),(2),(3),(4); +--disable_ps2_protocol +SELECT * FROM t1 ORDER BY a; +CREATE TABLE T1 (a INT, KEY(a)); +INSERT INTO T1 VALUES (1),(2),(3),(4); +SELECT * FROM T1 ORDER BY a; +--enable_ps2_protocol +SELECT * FROM INFORMATION_SCHEMA.TABLE_STATISTICS ORDER BY BINARY TABLE_NAME; +SELECT * FROM INFORMATION_SCHEMA.INDEX_STATISTICS ORDER BY BINARY TABLE_NAME; +DROP TABLE t1; +DROP TABLE T1; +SET GLOBAL userstat=DEFAULT; + + +--echo # +--echo # MDEV-33109 DROP DATABASE MYSQL -- does not drop SP with lower-case-table-names=0 +--echo # + +CREATE DATABASE MYSQL; +CREATE FUNCTION MYSQL.f1() RETURNS INT RETURN 1; +DROP DATABASE MYSQL; +SELECT db, name, body FROM mysql.proc WHERE db=BINARY 'MYSQL' AND name='f1'; + + +--echo # +--echo # MDEV-33110 HANDLER commands are case insensitive with lower-case-table-names=0 +--echo # + +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1),(2); +HANDLER t1 OPEN; +HANDLER t1 READ FIRST; +CREATE OR REPLACE TABLE T1 (a INT); +DROP TABLE T1; +HANDLER t1 READ NEXT; +HANDLER t1 CLOSE; +DROP TABLE t1; + +--echo # +--echo # MDEV-33120 System log table names are case insensitive with lower-cast-table-names=0 +--echo # + +CREATE TABLE mysql.GENERAL_log (a INT); +INSERT INTO mysql.GENERAL_log VALUES (1),(2); +DROP TABLE mysql.GENERAL_log; + +CREATE TABLE mysql.SLOW_log (a INT); +INSERT INTO mysql.SLOW_log VALUES (1),(2); +DROP TABLE mysql.SLOW_log; + +CREATE TABLE mysql.TRANSACTION_registry (a INT); +INSERT INTO mysql.TRANSACTION_registry VALUES (1),(2); +DROP TABLE mysql.TRANSACTION_registry; + +CREATE DATABASE MYSQL; +CREATE TABLE MYSQL.general_log (a INT); +INSERT INTO MYSQL.general_log VALUES (1),(2); +DROP TABLE MYSQL.general_log; + +CREATE TABLE MYSQL.slow_log (a INT); +INSERT INTO MYSQL.slow_log VALUES (1),(2); +DROP TABLE MYSQL.slow_log; + +CREATE TABLE MYSQL.transaction_registry (a INT); +INSERT INTO MYSQL.transaction_registry VALUES (1),(2); +DROP TABLE MYSQL.transaction_registry; +DROP DATABASE MYSQL; + +--echo # +--echo # End of 10.5 tests +--echo # diff --git a/mysql-test/main/view_grant.result b/mysql-test/main/view_grant.result index 04e3d013b48..818a15f86ce 100644 --- a/mysql-test/main/view_grant.result +++ b/mysql-test/main/view_grant.result @@ -1954,3 +1954,34 @@ connection default; drop user user_11766767; drop database mysqltest1; drop database mysqltest2; +# +# MDEV-33119 User is case insensitive in INFORMATION_SCHEMA.VIEWS +# +USE test; +CREATE USER foo; +CREATE USER FOO; +GRANT SELECT ON test.* TO foo; +GRANT SELECT ON test.* TO FOO; +CREATE DEFINER=foo SQL SECURITY INVOKER VIEW v1 AS SELECT 1 AS c1; +connect FOO, localhost, FOO, , test; +connection FOO; +SELECT CURRENT_USER; +CURRENT_USER +FOO@% +SELECT * FROM INFORMATION_SCHEMA.VIEWS; +TABLE_CATALOG def +TABLE_SCHEMA test +TABLE_NAME v1 +VIEW_DEFINITION +CHECK_OPTION NONE +IS_UPDATABLE NO +DEFINER foo@% +SECURITY_TYPE INVOKER +CHARACTER_SET_CLIENT latin1 +COLLATION_CONNECTION latin1_swedish_ci +ALGORITHM UNDEFINED +disconnect FOO; +connection default; +DROP VIEW v1; +DROP USER foo; +DROP USER FOO; diff --git a/mysql-test/main/view_grant.test b/mysql-test/main/view_grant.test index c9bb9569145..a5019e88d65 100644 --- a/mysql-test/main/view_grant.test +++ b/mysql-test/main/view_grant.test @@ -2207,3 +2207,30 @@ drop database mysqltest2; # Wait till we reached the initial number of concurrent sessions --source include/wait_until_count_sessions.inc + +--echo # +--echo # MDEV-33119 User is case insensitive in INFORMATION_SCHEMA.VIEWS +--echo # + +USE test; +CREATE USER foo; +CREATE USER FOO; +GRANT SELECT ON test.* TO foo; +GRANT SELECT ON test.* TO FOO; + +CREATE DEFINER=foo SQL SECURITY INVOKER VIEW v1 AS SELECT 1 AS c1; + +--connect (FOO, localhost, FOO, , test) +--connection FOO + +SELECT CURRENT_USER; +--vertical_results +--query_vertical SELECT * FROM INFORMATION_SCHEMA.VIEWS +--horizontal_results + +--disconnect FOO +--connection default + +DROP VIEW v1; +DROP USER foo; +DROP USER FOO; diff --git a/mysql-test/suite/csv/lowercase_table0.result b/mysql-test/suite/csv/lowercase_table0.result new file mode 100644 index 00000000000..fba6a509aea --- /dev/null +++ b/mysql-test/suite/csv/lowercase_table0.result @@ -0,0 +1,15 @@ +# +# MDEV-33085 Tables T1 and t1 do not work well with ENGINE=CSV and lower-case-table-names=0 +# +CREATE OR REPLACE TABLE t1 (a INT NOT NULL) ENGINE=CSV; +CREATE OR REPLACE TABLE T1 (a INT NOT NULL) ENGINE=CSV; +INSERT INTO t1 VALUES (10); +INSERT INTO T1 VALUES (20); +SELECT * FROM t1; +a +10 +SELECT * FROM T1; +a +20 +DROP TABLE t1; +DROP TABLE T1; diff --git a/mysql-test/suite/csv/lowercase_table0.test b/mysql-test/suite/csv/lowercase_table0.test new file mode 100644 index 00000000000..2bb0e486cb6 --- /dev/null +++ b/mysql-test/suite/csv/lowercase_table0.test @@ -0,0 +1,16 @@ +--source include/have_csv.inc +--source include/have_lowercase0.inc +--source include/have_case_sensitive_file_system.inc + +--echo # +--echo # MDEV-33085 Tables T1 and t1 do not work well with ENGINE=CSV and lower-case-table-names=0 +--echo # + +CREATE OR REPLACE TABLE t1 (a INT NOT NULL) ENGINE=CSV; +CREATE OR REPLACE TABLE T1 (a INT NOT NULL) ENGINE=CSV; +INSERT INTO t1 VALUES (10); +INSERT INTO T1 VALUES (20); +SELECT * FROM t1; +SELECT * FROM T1; +DROP TABLE t1; +DROP TABLE T1; diff --git a/sql/lex_ident.h b/sql/lex_ident.h new file mode 100644 index 00000000000..3af52ab99d0 --- /dev/null +++ b/sql/lex_ident.h @@ -0,0 +1,85 @@ +#ifndef LEX_IDENT_INCLUDED +#define LEX_IDENT_INCLUDED +/* + Copyright (c) 2023, MariaDB + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; version 2 of + the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA +*/ + + +extern MYSQL_PLUGIN_IMPORT CHARSET_INFO *table_alias_charset; + + +/* + Identifiers for the database objects stored on disk, + e.g. databases, tables, triggers. +*/ +class Lex_ident_fs: public LEX_CSTRING +{ +public: + static CHARSET_INFO *charset_info() + { + return table_alias_charset; + } +public: + Lex_ident_fs() + :LEX_CSTRING({0,0}) + { } + Lex_ident_fs(const char *str, size_t length) + :LEX_CSTRING({str, length}) + { } + explicit Lex_ident_fs(const LEX_CSTRING &str) + :LEX_CSTRING(str) + { } +#if MYSQL_VERSION_ID<=110501 +private: + static bool is_valid_ident(const LEX_CSTRING &str) + { + // NULL identifier, or 0-terminated identifier + return (str.str == NULL && str.length == 0) || str.str[str.length] == 0; + } +public: + bool streq(const LEX_CSTRING &rhs) const + { + DBUG_ASSERT(is_valid_ident(*this)); + DBUG_ASSERT(is_valid_ident(rhs)); + return length == rhs.length && + my_strcasecmp(charset_info(), str, rhs.str) == 0; + } +#else +/* + Starting from 11.5.1 streq() is inherited from the base. + The above implementations of streq() and is_valid_ident() should be removed. +*/ +#error Remove streq() above. +#endif +}; + + +class Lex_ident_db: public Lex_ident_fs +{ +public: + using Lex_ident_fs::Lex_ident_fs; +}; + + +class Lex_ident_table: public Lex_ident_fs +{ +public: + using Lex_ident_fs::Lex_ident_fs; +}; + + +#endif // LEX_IDENT_INCLUDED diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 8aee0624ed1..dd222998b3a 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -7226,8 +7226,8 @@ int mysql_table_grant(THD *thd, TABLE_LIST *table_list, continue; // Add next user } - db_name= table_list->get_db_name(); - table_name= table_list->get_table_name(); + db_name= table_list->get_db_name().str; + table_name= table_list->get_table_name().str; /* Find/create cached table grant */ grant_table= table_hash_search(Str->host.str, NullS, db_name, @@ -8294,8 +8294,8 @@ bool check_grant(THD *thd, privilege_t want_access, TABLE_LIST *tables, const ACL_internal_table_access *access= get_cached_table_access(&t_ref->grant.m_internal, - t_ref->get_db_name(), - t_ref->get_table_name()); + t_ref->get_db_name().str, + t_ref->get_table_name().str); if (access) { @@ -8359,14 +8359,14 @@ bool check_grant(THD *thd, privilege_t want_access, TABLE_LIST *tables, } grant_table= table_hash_search(sctx->host, sctx->ip, - t_ref->get_db_name(), + t_ref->get_db_name().str, sctx->priv_user, - t_ref->get_table_name(), + t_ref->get_table_name().str, FALSE); if (sctx->priv_role[0]) - grant_table_role= table_hash_search("", NULL, t_ref->get_db_name(), + grant_table_role= table_hash_search("", NULL, t_ref->get_db_name().str, sctx->priv_role, - t_ref->get_table_name(), + t_ref->get_table_name().str, TRUE); if (!grant_table && !grant_table_role) @@ -8414,7 +8414,7 @@ err: command, sctx->priv_user, sctx->host_or_ip, tl ? tl->db.str : "unknown", - tl ? tl->get_table_name() : "unknown"); + tl ? tl->get_table_name().str : "unknown"); } DBUG_RETURN(TRUE); } diff --git a/sql/sql_base.cc b/sql/sql_base.cc index f1fd0053a82..eb66d33b5b0 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -200,9 +200,9 @@ uint get_table_def_key(const TABLE_LIST *table_list, const char **key) is properly initialized, so table definition cache can be produced from key used by MDL subsystem. */ - DBUG_ASSERT(!strcmp(table_list->get_db_name(), + DBUG_ASSERT(!strcmp(table_list->get_db_name().str, table_list->mdl_request.key.db_name())); - DBUG_ASSERT(!strcmp(table_list->get_table_name(), + DBUG_ASSERT(!strcmp(table_list->get_table_name().str, table_list->mdl_request.key.name())); *key= (const char*)table_list->mdl_request.key.ptr() + 1; @@ -233,33 +233,40 @@ uint get_table_def_key(const TABLE_LIST *table_list, const char **key) # Pointer to list of names of open tables. */ -struct list_open_tables_arg +class list_open_tables_arg { +public: THD *thd; - const char *db; + const Lex_ident_db db; const char *wild; TABLE_LIST table_list; OPEN_TABLE_LIST **start_list, *open_list; + + list_open_tables_arg(THD *thd_arg, const LEX_CSTRING &db_arg, + const char *wild_arg) + :thd(thd_arg), db(db_arg), wild(wild_arg), + start_list(&open_list), open_list(0) + { + bzero((char*) &table_list, sizeof(table_list)); + } }; static my_bool list_open_tables_callback(TDC_element *element, list_open_tables_arg *arg) { - const char *db= (char*) element->m_key; - size_t db_length= strlen(db); - const char *table_name= db + db_length + 1; + const Lex_ident_db + db= Lex_ident_db(Lex_cstring_strlen((const char*) element->m_key)); + const char *table_name= db.str + db.length + 1; - if (arg->db && my_strcasecmp(system_charset_info, arg->db, db)) + if (arg->db.str && !arg->db.streq(db)) return FALSE; if (arg->wild && wild_compare(table_name, arg->wild, 0)) return FALSE; /* Check if user has SELECT privilege for any column in the table */ - arg->table_list.db.str= db; - arg->table_list.db.length= db_length; - arg->table_list.table_name.str= table_name; - arg->table_list.table_name.length= strlen(table_name); + arg->table_list.db= db; + arg->table_list.table_name= Lex_cstring_strlen(table_name); arg->table_list.grant.privilege= NO_ACL; if (check_table_access(arg->thd, SELECT_ACL, &arg->table_list, TRUE, 1, TRUE)) @@ -271,7 +278,7 @@ static my_bool list_open_tables_callback(TDC_element *element, strmov((*arg->start_list)->table= strmov(((*arg->start_list)->db= (char*) ((*arg->start_list) + 1)), - db) + 1, table_name); + db.str) + 1, table_name); (*arg->start_list)->in_use= 0; mysql_mutex_lock(&element->LOCK_table_share); @@ -288,17 +295,12 @@ static my_bool list_open_tables_callback(TDC_element *element, } -OPEN_TABLE_LIST *list_open_tables(THD *thd, const char *db, const char *wild) +OPEN_TABLE_LIST *list_open_tables(THD *thd, + const LEX_CSTRING &db, + const char *wild) { - list_open_tables_arg argument; DBUG_ENTER("list_open_tables"); - - argument.thd= thd; - argument.db= db; - argument.wild= wild; - bzero((char*) &argument.table_list, sizeof(argument.table_list)); - argument.start_list= &argument.open_list; - argument.open_list= 0; + list_open_tables_arg argument(thd, db, wild); if (tdc_iterate(thd, (my_hash_walk_action) list_open_tables_callback, &argument, true)) @@ -1682,7 +1684,7 @@ bool open_table(THD *thd, TABLE_LIST *table_list, Open_table_context *ot_ctx) TABLE *table; const char *key; uint key_length; - const char *alias= table_list->alias.str; + const LEX_CSTRING &alias= table_list->alias; uint flags= ot_ctx->get_flags(); MDL_ticket *mdl_ticket; TABLE_SHARE *share; @@ -1750,7 +1752,7 @@ bool open_table(THD *thd, TABLE_LIST *table_list, Open_table_context *ot_ctx) if (table->s->table_cache_key.length == key_length && !memcmp(table->s->table_cache_key.str, key, key_length)) { - if (!my_strcasecmp(system_charset_info, table->alias.c_ptr(), alias) && + if (Lex_ident_table(table->alias.to_lex_cstring()).streq(alias) && table->query_id != thd->query_id && /* skip tables already used */ (thd->locked_tables_mode == LTM_LOCK_TABLES || table->query_id == 0)) @@ -1821,7 +1823,7 @@ bool open_table(THD *thd, TABLE_LIST *table_list, Open_table_context *ot_ctx) if (thd->locked_tables_mode == LTM_PRELOCKED) my_error(ER_NO_SUCH_TABLE, MYF(0), table_list->db.str, table_list->alias.str); else - my_error(ER_TABLE_NOT_LOCKED, MYF(0), alias); + my_error(ER_TABLE_NOT_LOCKED, MYF(0), alias.str); DBUG_RETURN(TRUE); } diff --git a/sql/sql_base.h b/sql/sql_base.h index 267acede7dd..7cfe10ea2d1 100644 --- a/sql/sql_base.h +++ b/sql/sql_base.h @@ -309,7 +309,8 @@ bool flush_tables(THD *thd, flush_tables_type flag); void close_all_tables_for_name(THD *thd, TABLE_SHARE *share, ha_extra_function extra, TABLE *skip_table); -OPEN_TABLE_LIST *list_open_tables(THD *thd, const char *db, const char *wild); +OPEN_TABLE_LIST *list_open_tables(THD *thd, const LEX_CSTRING &db, + const char *wild); bool tdc_open_view(THD *thd, TABLE_LIST *table_list, uint flags); TABLE *find_table_for_mdl_upgrade(THD *thd, const char *db, diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 7913f1a40d2..34cd63d7839 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -855,7 +855,7 @@ THD::THD(my_thread_id id, bool is_wsrep_applier) my_hash_init(key_memory_user_var_entry, &user_vars, system_charset_info, USER_VARS_HASH_SIZE, 0, 0, (my_hash_get_key) get_var_key, (my_hash_free_key) free_user_var, HASH_THREAD_SPECIFIC); - my_hash_init(PSI_INSTRUMENT_ME, &sequences, system_charset_info, + my_hash_init(PSI_INSTRUMENT_ME, &sequences, Lex_ident_fs::charset_info(), SEQUENCES_HASH_SIZE, 0, 0, (my_hash_get_key) get_sequence_last_key, (my_hash_free_key) free_sequence_last, HASH_THREAD_SPECIFIC); @@ -1450,7 +1450,8 @@ void THD::change_user(void) my_hash_init(key_memory_user_var_entry, &user_vars, system_charset_info, USER_VARS_HASH_SIZE, 0, 0, (my_hash_get_key) get_var_key, (my_hash_free_key) free_user_var, HASH_THREAD_SPECIFIC); - my_hash_init(key_memory_user_var_entry, &sequences, system_charset_info, + my_hash_init(key_memory_user_var_entry, &sequences, + Lex_ident_fs::charset_info(), SEQUENCES_HASH_SIZE, 0, 0, (my_hash_get_key) get_sequence_last_key, (my_hash_free_key) free_sequence_last, HASH_THREAD_SPECIFIC); diff --git a/sql/sql_class.h b/sql/sql_class.h index 7e5d9ac96e3..7324ba73bf1 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -23,6 +23,7 @@ #include "dur_prop.h" #include #include "sql_const.h" +#include "lex_ident.h" #include #include "log.h" #include "rpl_tblmap.h" diff --git a/sql/sql_connect.cc b/sql/sql_connect.cc index 61d6a529045..b371e27eb3a 100644 --- a/sql/sql_connect.cc +++ b/sql/sql_connect.cc @@ -509,7 +509,8 @@ extern "C" void free_table_stats(TABLE_STATS* table_stats) void init_global_table_stats(void) { - my_hash_init(PSI_INSTRUMENT_ME, &global_table_stats, system_charset_info, + my_hash_init(PSI_INSTRUMENT_ME, &global_table_stats, + Lex_ident_fs::charset_info(), max_connections, 0, 0, (my_hash_get_key) get_key_table_stats, (my_hash_free_key) free_table_stats, 0); } @@ -528,7 +529,8 @@ extern "C" void free_index_stats(INDEX_STATS* index_stats) void init_global_index_stats(void) { - my_hash_init(PSI_INSTRUMENT_ME, &global_index_stats, system_charset_info, + my_hash_init(PSI_INSTRUMENT_ME, &global_index_stats, + Lex_ident_fs::charset_info(), max_connections, 0, 0, (my_hash_get_key) get_key_index_stats, (my_hash_free_key) free_index_stats, 0); } diff --git a/sql/sql_db.cc b/sql/sql_db.cc index 1dcc51f1332..63cd5c83d98 100644 --- a/sql/sql_db.cc +++ b/sql/sql_db.cc @@ -919,8 +919,7 @@ mysql_rm_db_internal(THD *thd, const LEX_CSTRING *db, bool if_exists, bool silen Disable drop of enabled log tables, must be done before name locking. This check is only needed if we are dropping the "mysql" database. */ - if ((rm_mysql_schema= - (my_strcasecmp(system_charset_info, MYSQL_SCHEMA_NAME.str, db->str) == 0))) + if ((rm_mysql_schema= MYSQL_SCHEMA_NAME.streq(*db))) { for (table= tables; table; table= table->next_local) if (check_if_log_table(table, TRUE, "DROP")) diff --git a/sql/sql_handler.cc b/sql/sql_handler.cc index 276cef6236b..4108f42eb14 100644 --- a/sql/sql_handler.cc +++ b/sql/sql_handler.cc @@ -1067,10 +1067,9 @@ static SQL_HANDLER *mysql_ha_find_match(THD *thd, TABLE_LIST *tables) if (tables->is_anonymous_derived_table()) continue; if ((! tables->db.str[0] || - ! my_strcasecmp(&my_charset_latin1, hash_tables->db.str, - tables->get_db_name())) && - ! my_strcasecmp(&my_charset_latin1, hash_tables->table_name.str, - tables->get_table_name())) + Lex_ident_db(tables->get_db_name()).streq(hash_tables->db)) && + Lex_ident_table(tables->get_table_name()). + streq(hash_tables->table_name)) { /* Link into hash_tables list */ hash_tables->next= head; diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 5db53b6f2b8..e458cd51dde 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1154,8 +1154,9 @@ static bool wsrep_tables_accessible_when_detached(const TABLE_LIST *tables) { for (const TABLE_LIST *table= tables; table; table= table->next_global) { - LEX_CSTRING db= table->db, tn= table->table_name; - if (get_table_category(&db, &tn) < TABLE_CATEGORY_INFORMATION) + if (get_table_category(Lex_ident_db(table->db), + Lex_ident_table(table->table_name)) + < TABLE_CATEGORY_INFORMATION) return false; } return tables != NULL; @@ -6522,15 +6523,15 @@ static TABLE *find_temporary_table_for_rename(THD *thd, { TABLE_LIST *next= table->next_local; - if (!strcmp(table->get_db_name(), cur_table->get_db_name()) && - !strcmp(table->get_table_name(), cur_table->get_table_name())) + if (!strcmp(table->get_db_name().str, cur_table->get_db_name().str) && + !strcmp(table->get_table_name().str, cur_table->get_table_name().str)) { /* Table was moved away, can't be same as 'table' */ found= 1; res= 0; // Table can't be a temporary table } - if (!strcmp(next->get_db_name(), cur_table->get_db_name()) && - !strcmp(next->get_table_name(), cur_table->get_table_name())) + if (!strcmp(next->get_db_name().str, cur_table->get_db_name().str) && + !strcmp(next->get_table_name().str, cur_table->get_table_name().str)) { /* Table has matching name with new name of this table. cur_table should @@ -7299,7 +7300,7 @@ check_table_access(THD *thd, privilege_t requirements, TABLE_LIST *tables, INSERT_ACL : SELECT_ACL); } - if (check_access(thd, want_access, table_ref->get_db_name(), + if (check_access(thd, want_access, table_ref->get_db_name().str, &table_ref->grant.privilege, &table_ref->grant.m_internal, 0, no_errors)) diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 3ed8e108f8d..eb84ef56419 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -1053,7 +1053,8 @@ public: ER_THD(thd, ER_TABLEACCESS_DENIED_ERROR), "SHOW VIEW", m_sctx->priv_user, m_sctx->host_or_ip, - m_top_view->get_db_name(), m_top_view->get_table_name()); + m_top_view->get_db_name().str, + m_top_view->get_table_name().str); } return m_view_access_denied_message_ptr; } @@ -1098,8 +1099,8 @@ public: push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, ER_VIEW_INVALID, ER_THD(thd, ER_VIEW_INVALID), - m_top_view->get_db_name(), - m_top_view->get_table_name()); + m_top_view->get_db_name().str, + m_top_view->get_table_name().str); is_handled= TRUE; break; @@ -6887,8 +6888,7 @@ static int get_schema_views_record(THD *thd, TABLE_LIST *tables, Security_context *sctx= thd->security_ctx; if (!tables->allowed_show) { - if (!my_strcasecmp(system_charset_info, tables->definer.user.str, - sctx->priv_user) && + if (!strcmp(tables->definer.user.str, sctx->priv_user) && !my_strcasecmp(system_charset_info, tables->definer.host.str, sctx->priv_host)) tables->allowed_show= TRUE; @@ -7981,7 +7981,7 @@ int fill_open_tables(THD *thd, TABLE_LIST *tables, COND *cond) TABLE *table= tables->table; CHARSET_INFO *cs= system_charset_info; OPEN_TABLE_LIST *open_list; - if (!(open_list= list_open_tables(thd, thd->lex->first_select_lex()->db.str, + if (!(open_list= list_open_tables(thd, thd->lex->first_select_lex()->db, wild)) && thd->is_fatal_error) DBUG_RETURN(1); diff --git a/sql/sql_string.h b/sql/sql_string.h index 3dbeb7b83cf..0475b2d1f6e 100644 --- a/sql/sql_string.h +++ b/sql/sql_string.h @@ -572,6 +572,11 @@ public: if (str.Alloced_length) Alloced_length= (uint32) (str.Alloced_length - offset); } + LEX_CSTRING to_lex_cstring() const + { + LEX_CSTRING tmp= {Ptr, str_length}; + return tmp; + } inline LEX_CSTRING *get_value(LEX_CSTRING *res) { res->str= Ptr; diff --git a/sql/sql_trigger.cc b/sql/sql_trigger.cc index d2e5ecbb4d8..8a0d761f51d 100644 --- a/sql/sql_trigger.cc +++ b/sql/sql_trigger.cc @@ -446,7 +446,7 @@ bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create) /* We don't allow creating triggers on tables in the 'mysql' schema */ - if (create && lex_string_eq(&tables->db, STRING_WITH_LEN("mysql"))) + if (create && Lex_ident_db(tables->db).streq(MYSQL_SCHEMA_NAME)) { my_error(ER_NO_TRIGGERS_ON_SYSTEM_SCHEMA, MYF(0)); DBUG_RETURN(TRUE); diff --git a/sql/table.cc b/sql/table.cc index cc8fb094e36..8f5b0ce3bcc 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -89,7 +89,7 @@ LEX_CSTRING INFORMATION_SCHEMA_NAME= {STRING_WITH_LEN("information_schema")}; LEX_CSTRING PERFORMANCE_SCHEMA_DB_NAME= {STRING_WITH_LEN("performance_schema")}; /* MYSQL_SCHEMA name */ -LEX_CSTRING MYSQL_SCHEMA_NAME= {STRING_WITH_LEN("mysql")}; +Lex_ident_db MYSQL_SCHEMA_NAME= {STRING_WITH_LEN("mysql")}; /* GENERAL_LOG name */ LEX_CSTRING GENERAL_LOG_NAME= {STRING_WITH_LEN("general_log")}; @@ -273,42 +273,38 @@ const char *fn_frm_ext(const char *name) } -TABLE_CATEGORY get_table_category(const LEX_CSTRING *db, - const LEX_CSTRING *name) +TABLE_CATEGORY get_table_category(const Lex_ident_db &db, + const Lex_ident_table &name) { - DBUG_ASSERT(db != NULL); - DBUG_ASSERT(name != NULL); - #ifdef WITH_WSREP - if (db->str && - my_strcasecmp(system_charset_info, db->str, WSREP_SCHEMA) == 0) + if (db.str && db.streq(MYSQL_SCHEMA_NAME)) { - if ((my_strcasecmp(system_charset_info, name->str, WSREP_STREAMING_TABLE) == 0 || - my_strcasecmp(system_charset_info, name->str, WSREP_CLUSTER_TABLE) == 0 || - my_strcasecmp(system_charset_info, name->str, WSREP_MEMBERS_TABLE) == 0)) + if (name.streq(Lex_ident_table{STRING_WITH_LEN(WSREP_STREAMING_TABLE)}) || + name.streq(Lex_ident_table{STRING_WITH_LEN(WSREP_CLUSTER_TABLE)}) || + name.streq(Lex_ident_table{STRING_WITH_LEN(WSREP_MEMBERS_TABLE)})) { return TABLE_CATEGORY_INFORMATION; } } #endif /* WITH_WSREP */ - if (is_infoschema_db(db)) + if (is_infoschema_db(&db)) return TABLE_CATEGORY_INFORMATION; - if (is_perfschema_db(db)) + if (is_perfschema_db(&db)) return TABLE_CATEGORY_PERFORMANCE; - if (lex_string_eq(&MYSQL_SCHEMA_NAME, db)) + if (db.streq(MYSQL_SCHEMA_NAME)) { - if (is_system_table_name(name->str, name->length)) + if (is_system_table_name(name.str, name.length)) return TABLE_CATEGORY_SYSTEM; - if (lex_string_eq(&GENERAL_LOG_NAME, name)) + if (name.streq(GENERAL_LOG_NAME)) return TABLE_CATEGORY_LOG; - if (lex_string_eq(&SLOW_LOG_NAME, name)) + if (name.streq(SLOW_LOG_NAME)) return TABLE_CATEGORY_LOG; - if (lex_string_eq(&TRANSACTION_REG_NAME, name)) + if (name.streq(TRANSACTION_REG_NAME)) return TABLE_CATEGORY_LOG; } @@ -361,7 +357,8 @@ TABLE_SHARE *alloc_table_share(const char *db, const char *table_name, strmov(path_buff, path); share->normalized_path.str= share->path.str; share->normalized_path.length= path_length; - share->table_category= get_table_category(& share->db, & share->table_name); + share->table_category= get_table_category(Lex_ident_db(share->db), + Lex_ident_table(share->table_name)); share->open_errno= ENOENT; /* The following will be updated in open_table_from_share */ share->can_do_row_logging= 1; diff --git a/sql/table.h b/sql/table.h index 97e595979b9..16a42b6e81e 100644 --- a/sql/table.h +++ b/sql/table.h @@ -22,6 +22,7 @@ #include "datadict.h" #include "sql_string.h" /* String */ #include "lex_string.h" +#include "lex_ident.h" #ifndef MYSQL_CLIENT @@ -522,8 +523,8 @@ enum enum_table_category typedef enum enum_table_category TABLE_CATEGORY; -TABLE_CATEGORY get_table_category(const LEX_CSTRING *db, - const LEX_CSTRING *name); +TABLE_CATEGORY get_table_category(const Lex_ident_db &db, + const Lex_ident_table &name); typedef struct st_table_field_type @@ -2880,7 +2881,10 @@ struct TABLE_LIST @brief Returns the name of the database that the referenced table belongs to. */ - const char *get_db_name() const { return view != NULL ? view_db.str : db.str; } + const LEX_CSTRING get_db_name() const + { + return view != NULL ? view_db : db; + } /** @brief Returns the name of the table that this TABLE_LIST represents. @@ -2888,7 +2892,10 @@ struct TABLE_LIST @details The unqualified table name or view name for a table or view, respectively. */ - const char *get_table_name() const { return view != NULL ? view_name.str : table_name.str; } + const LEX_CSTRING get_table_name() const + { + return view != NULL ? view_name : table_name; + } bool is_active_sjm(); bool is_jtbm() { return MY_TEST(jtbm_subselect != NULL); } st_select_lex_unit *get_unit(); @@ -3292,7 +3299,7 @@ extern LEX_CSTRING TRANSACTION_REG_NAME; /* information schema */ extern LEX_CSTRING INFORMATION_SCHEMA_NAME; -extern LEX_CSTRING MYSQL_SCHEMA_NAME; +extern Lex_ident_db MYSQL_SCHEMA_NAME; /* table names */ extern LEX_CSTRING MYSQL_PROC_NAME; diff --git a/sql/temporary_tables.cc b/sql/temporary_tables.cc index a28b5f96935..9687506762c 100644 --- a/sql/temporary_tables.cc +++ b/sql/temporary_tables.cc @@ -154,7 +154,8 @@ TABLE *THD::find_temporary_table(const TABLE_LIST *tl, Temporary_table_state state) { DBUG_ENTER("THD::find_temporary_table"); - TABLE *table= find_temporary_table(tl->get_db_name(), tl->get_table_name(), + TABLE *table= find_temporary_table(tl->get_db_name().str, + tl->get_table_name().str, state); DBUG_RETURN(table); } @@ -243,8 +244,8 @@ TMP_TABLE_SHARE *THD::find_tmp_table_share(const char *db, TMP_TABLE_SHARE *THD::find_tmp_table_share(const TABLE_LIST *tl) { DBUG_ENTER("THD::find_tmp_table_share"); - TMP_TABLE_SHARE *share= find_tmp_table_share(tl->get_db_name(), - tl->get_table_name()); + TMP_TABLE_SHARE *share= find_tmp_table_share(tl->get_db_name().str, + tl->get_table_name().str); DBUG_RETURN(share); } @@ -385,7 +386,7 @@ bool THD::open_temporary_table(TABLE_LIST *tl) */ if (!table && (share= find_tmp_table_share(tl))) { - table= open_temporary_table(share, tl->get_table_name()); + table= open_temporary_table(share, tl->get_table_name().str); /* Temporary tables are not safe for parallel replication. They were designed to be visible to one thread only, so have no table locking. @@ -1172,8 +1173,8 @@ bool THD::find_and_use_tmp_table(const TABLE_LIST *tl, TABLE **out_table) bool result; DBUG_ENTER("THD::find_and_use_tmp_table"); - key_length= create_tmp_table_def_key(key, tl->get_db_name(), - tl->get_table_name()); + key_length= create_tmp_table_def_key(key, tl->get_db_name().str, + tl->get_table_name().str); result= use_temporary_table(find_temporary_table(key, key_length, TMP_TABLE_NOT_IN_USE), out_table); diff --git a/storage/csv/ha_tina.cc b/storage/csv/ha_tina.cc index ec569feec9d..04e63530c0e 100644 --- a/storage/csv/ha_tina.cc +++ b/storage/csv/ha_tina.cc @@ -184,7 +184,8 @@ static int tina_init_func(void *p) tina_hton= (handlerton *)p; mysql_mutex_init(csv_key_mutex_tina, &tina_mutex, MY_MUTEX_INIT_FAST); (void) my_hash_init(csv_key_memory_tina_share, &tina_open_tables, - system_charset_info, 32, 0, 0, (my_hash_get_key) + Lex_ident_table::charset_info(), + 32, 0, 0, (my_hash_get_key) tina_get_key, 0, 0); tina_hton->db_type= DB_TYPE_CSV_DB; tina_hton->create= tina_create_handler; From 266495b93ef550210cd598f1d7eff6031b34a7a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Tue, 21 May 2024 16:45:07 +0300 Subject: [PATCH 24/42] MDEV-33817 fixup: Disable for macOS According to https://discussions.apple.com/thread/8256853 an attempt to use AVX512 registers on macOS will result in #UD (crash at runtime). Also, starting with clang-18 and GCC 14, we must add "evex512" to the target flags so that AVX and SSE instructions can use AVX512 specific encodings. This flag was introduced together with the avx10.1-512 target. Older compiler versions do not recognize "evex512". We do not want to write "avx10.1-512" because it could enable some AVX512 subfeatures that we do not have any CPUID check for. Reviewed by: Vladislav Vaintroub Tested on macOS by: Valerii Kravchuk --- mysys/crc32/crc32c_x86.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mysys/crc32/crc32c_x86.cc b/mysys/crc32/crc32c_x86.cc index 317b3545c0c..1ea0689a14b 100644 --- a/mysys/crc32/crc32c_x86.cc +++ b/mysys/crc32/crc32c_x86.cc @@ -24,7 +24,11 @@ # endif #else # include -# if __GNUC__ >= 11 || (defined __clang_major__ && __clang_major__ >= 8) +# ifdef __APPLE__ /* AVX512 states are not enabled in XCR0 */ +# elif __GNUC__ >= 14 || (defined __clang_major__ && __clang_major__ >= 18) +# define TARGET "pclmul,evex512,avx512f,avx512dq,avx512bw,avx512vl,vpclmulqdq" +# define USE_VPCLMULQDQ __attribute__((target(TARGET))) +# elif __GNUC__ >= 11 || (defined __clang_major__ && __clang_major__ >= 8) # define TARGET "pclmul,avx512f,avx512dq,avx512bw,avx512vl,vpclmulqdq" # define USE_VPCLMULQDQ __attribute__((target(TARGET))) # endif From c4020b541c25b8f8bed2dd2b58d8d7a3a3122495 Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Mon, 20 May 2024 09:44:47 +1000 Subject: [PATCH 25/42] MDEV-24610 MEMORY SE: check overflow in info calls with HA_STATUS_AUTO --- mysql-test/suite/parts/r/mdev_24610.result | 24 ++++++++++++++++++++++ mysql-test/suite/parts/t/mdev_24610.test | 22 ++++++++++++++++++++ storage/heap/hp_info.c | 6 +++++- 3 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 mysql-test/suite/parts/r/mdev_24610.result create mode 100644 mysql-test/suite/parts/t/mdev_24610.test diff --git a/mysql-test/suite/parts/r/mdev_24610.result b/mysql-test/suite/parts/r/mdev_24610.result new file mode 100644 index 00000000000..6b49b059993 --- /dev/null +++ b/mysql-test/suite/parts/r/mdev_24610.result @@ -0,0 +1,24 @@ +CREATE TABLE t (c BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY) ENGINE=MEMORY PARTITION BY KEY(); +INSERT INTO t VALUES (18446744073709551615); +select * from t; +c +18446744073709551615 +drop table t; +CREATE TABLE t (c BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY) ENGINE=MEMORY; +INSERT INTO t VALUES (18446744073709551615); +ALTER TABLE t PARTITION BY KEY(); +INSERT INTO t VALUES (1); +select * from t; +c +18446744073709551615 +1 +drop table t; +CREATE TABLE t (c BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY) ENGINE=MEMORY; +INSERT INTO t VALUES (18446744073709551615); +ALTER TABLE t PARTITION BY KEY(); +INSERT INTO t VALUES (NULL); +ERROR HY000: Failed to read auto-increment value from storage engine +select * from t; +c +18446744073709551615 +drop table t; diff --git a/mysql-test/suite/parts/t/mdev_24610.test b/mysql-test/suite/parts/t/mdev_24610.test new file mode 100644 index 00000000000..df3ce9fdf0b --- /dev/null +++ b/mysql-test/suite/parts/t/mdev_24610.test @@ -0,0 +1,22 @@ +--source include/have_innodb.inc +--source include/have_partition.inc + +CREATE TABLE t (c BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY) ENGINE=MEMORY PARTITION BY KEY(); +INSERT INTO t VALUES (18446744073709551615); +select * from t; +drop table t; + +CREATE TABLE t (c BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY) ENGINE=MEMORY; +INSERT INTO t VALUES (18446744073709551615); +ALTER TABLE t PARTITION BY KEY(); +INSERT INTO t VALUES (1); +select * from t; +drop table t; + +CREATE TABLE t (c BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY) ENGINE=MEMORY; +INSERT INTO t VALUES (18446744073709551615); +ALTER TABLE t PARTITION BY KEY(); +--error ER_AUTOINC_READ_FAILED +INSERT INTO t VALUES (NULL); +select * from t; +drop table t; diff --git a/storage/heap/hp_info.c b/storage/heap/hp_info.c index 41596d864a2..47b1ed6e846 100644 --- a/storage/heap/hp_info.c +++ b/storage/heap/hp_info.c @@ -40,6 +40,10 @@ int heap_info(reg1 HP_INFO *info,reg2 HEAPINFO *x, int flag ) x->errkey = info->errkey; x->create_time = info->s->create_time; if (flag & HA_STATUS_AUTO) - x->auto_increment= info->s->auto_increment + 1; + { + x->auto_increment= info->s->auto_increment+1; + if (!x->auto_increment) /* This shouldn't happen */ + x->auto_increment= ~(ulonglong) 0; + } DBUG_RETURN(0); } /* heap_info */ From 7c4c082349869b63ace23cd621585562684bbdf6 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Thu, 23 May 2024 14:18:34 +0400 Subject: [PATCH 26/42] MDEV-28387 UBSAN: runtime error: negation of -9223372036854775808 cannot be represented in type 'long long int'; cast to an unsigned type to negate this value to itself in my_strtoll10 on SELECT Fixing the condition to raise an overflow in the ulonglong representation of the number is greater or equal to 0x8000000000000000ULL. Before this change the condition did not catch -9223372036854775808 (the smallest possible signed negative longlong number). --- mysql-test/main/func_str.result | 8 ++++++++ mysql-test/main/func_str.test | 9 +++++++++ strings/my_strtoll10.c | 2 +- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/mysql-test/main/func_str.result b/mysql-test/main/func_str.result index c071b92318a..e5a21af03a3 100644 --- a/mysql-test/main/func_str.result +++ b/mysql-test/main/func_str.result @@ -5311,5 +5311,13 @@ NULL DROP TABLE t1; DROP VIEW v1; # +# MDEV-28387 UBSAN: runtime error: negation of -9223372036854775808 cannot be represented in type 'long long int'; cast to an unsigned type to negate this value to itself in my_strtoll10 on SELECT +# +SET @a='-9223372036854775808'; +CREATE TABLE t (c1 INT,c2 CHAR); +SELECT SUBSTR(0,@a) FROM t; +SUBSTR(0,@a) +DROP TABLE t; +# # End of 10.5 tests # diff --git a/mysql-test/main/func_str.test b/mysql-test/main/func_str.test index 69161349720..49b5546abb8 100644 --- a/mysql-test/main/func_str.test +++ b/mysql-test/main/func_str.test @@ -2348,6 +2348,15 @@ DROP TABLE t1; DROP VIEW v1; +--echo # +--echo # MDEV-28387 UBSAN: runtime error: negation of -9223372036854775808 cannot be represented in type 'long long int'; cast to an unsigned type to negate this value to itself in my_strtoll10 on SELECT +--echo # + +SET @a='-9223372036854775808'; # Quite specific value; considerably varying it will not work +CREATE TABLE t (c1 INT,c2 CHAR); +SELECT SUBSTR(0,@a) FROM t; +DROP TABLE t; + --echo # --echo # End of 10.5 tests --echo # diff --git a/strings/my_strtoll10.c b/strings/my_strtoll10.c index 183829d7074..8144be7a1da 100644 --- a/strings/my_strtoll10.c +++ b/strings/my_strtoll10.c @@ -241,7 +241,7 @@ end4: *endptr= (char*) s; if (negative) { - if (li > MAX_NEGATIVE_NUMBER) + if (li >= MAX_NEGATIVE_NUMBER) goto overflow; return -((longlong) li); } From 736449d30ffb2ec71bd700ac84eb38ba30bb662c Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Tue, 21 May 2024 16:03:13 +0200 Subject: [PATCH 27/42] MDEV-34205: ASAN stack buffer overflow in strxnmov() in frm_file_exists Correct the second parameter for strxnmov to prevent potential buffer overflows. The second parameter must be one less than the size of the input buffer to avoid writing past the end of the buffer. While the second parameter is usually correct, there are exceptions that need fixing. This commit addresses the issue within frm_file_exists() and other affected places. --- mysql-test/main/drop.result | 5 +++++ mysql-test/main/drop.test | 6 ++++++ sql/handler.cc | 2 +- sql/sql_parse.cc | 2 +- sql/sql_table.cc | 2 +- sql/sys_vars.cc | 2 +- storage/innobase/handler/ha_innodb.cc | 2 +- 7 files changed, 16 insertions(+), 5 deletions(-) diff --git a/mysql-test/main/drop.result b/mysql-test/main/drop.result index d50ffabc9fa..710986fa1ec 100644 --- a/mysql-test/main/drop.result +++ b/mysql-test/main/drop.result @@ -256,3 +256,8 @@ drop database mysqltest; Warnings: Note 1008 Can't drop database 'mysqltest'; database doesn't exist set @@session.sql_if_exists=0; +# +# MDEV-34205 ASAN stack-buffer-overflow in strxnmov | frm_file_exists +# +DROP TABLE `##################################################_long`.`#################################################_long`; +ERROR 42S02: Unknown table '##################################################_long.#########################################...' diff --git a/mysql-test/main/drop.test b/mysql-test/main/drop.test index 5185ce30db0..6b926d3f0c1 100644 --- a/mysql-test/main/drop.test +++ b/mysql-test/main/drop.test @@ -361,3 +361,9 @@ drop table mysqltest.does_not_exists; drop database mysqltest; drop database mysqltest; set @@session.sql_if_exists=0; + +--echo # +--echo # MDEV-34205 ASAN stack-buffer-overflow in strxnmov | frm_file_exists +--echo # +--error ER_BAD_TABLE_ERROR +DROP TABLE `##################################################_long`.`#################################################_long`; diff --git a/sql/handler.cc b/sql/handler.cc index 42e1c3e7212..3acc0246aab 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -4356,7 +4356,7 @@ void handler::print_error(int error, myf errflag) if (error < HA_ERR_FIRST && bas_ext()[0]) { char buff[FN_REFLEN]; - strxnmov(buff, sizeof(buff), + strxnmov(buff, sizeof(buff)-1, table_share->normalized_path.str, bas_ext()[0], NULL); my_error(textno, errflag, buff, error); } diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index e458cd51dde..b071c74b245 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -9564,7 +9564,7 @@ sql_kill_user(THD *thd, LEX_USER *user, killed_state state) break; case ER_KILL_DENIED_ERROR: char buf[DEFINER_LENGTH+1]; - strxnmov(buf, sizeof(buf), user->user.str, "@", user->host.str, NULL); + strxnmov(buf, sizeof(buf)-1, user->user.str, "@", user->host.str, NULL); my_printf_error(ER_KILL_DENIED_ERROR, ER_THD(thd, ER_CANNOT_USER), MYF(0), "KILL USER", buf); break; diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 7941f1de78c..1ef0a6e3bef 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -1906,7 +1906,7 @@ bool mysql_write_frm(ALTER_PARTITION_PARAM_TYPE *lpt, uint flags) */ build_table_filename(path, sizeof(path) - 1, lpt->alter_info->db.str, lpt->alter_info->table_name.str, "", 0); - strxnmov(frm_name, sizeof(frm_name), path, reg_ext, NullS); + strxnmov(frm_name, sizeof(frm_name)-1, path, reg_ext, NullS); /* When we are changing to use new frm file we need to ensure that we don't collide with another thread in process to open the frm file. diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc index 9a4180ae000..8ccd1bb235e 100644 --- a/sql/sys_vars.cc +++ b/sql/sys_vars.cc @@ -4655,7 +4655,7 @@ bool Sys_var_timestamp::on_check_access_session(THD *thd) const break; } char buf[1024]; - strxnmov(buf, sizeof(buf), "--secure-timestamp=", + strxnmov(buf, sizeof(buf)-1, "--secure-timestamp=", secure_timestamp_levels[opt_secure_timestamp], NULL); my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), buf); return true; diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index ff928a7d92a..7bed0ed73eb 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -13313,7 +13313,7 @@ ha_innobase::discard_or_import_tablespace( static bool frm_file_exists(const char *path) { char buff[FN_REFLEN]; - strxnmov(buff, FN_REFLEN, path, reg_ext, NullS); + strxnmov(buff, sizeof(buff)-1, path, reg_ext, NullS); return !access(buff, F_OK); } From 82ba486e5484a9dfb5608956453574542a89930d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Fri, 24 May 2024 10:06:11 +0300 Subject: [PATCH 28/42] MDEV-4742 fixup: g++-14 -Wmaybe-uninitialized to_natsort_key(): Zero-initialize also num_start. This silences a compiler warning. There is no impact on correctness, because before the first read of num_start, !n_digits would always hold and hence num_start would have been initialized. --- sql/item_strfunc.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index d06b3f57e42..2a9c14e7145 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -5761,7 +5761,7 @@ static NATSORT_ERR to_natsort_key(const String *in, String *out, { size_t n_digits= 0; size_t n_lead_zeros= 0; - size_t num_start; + size_t num_start= 0; size_t reserve_length= std::min( natsort_max_key_size(in->length()) + MAX_BIGINT_WIDTH + 2, max_key_size); From 0ffa340a49cbbc7c5d3db563dc583fd23fa90c01 Mon Sep 17 00:00:00 2001 From: Thirunarayanan Balathandayuthapani Date: Fri, 24 May 2024 10:51:32 +0530 Subject: [PATCH 29/42] MDEV-34221 Errors about checksum mismatch on crash recovery are confusing - InnoDB should avoid printing the error message before restoring the first page from doublewrite buffer. --- mysql-test/suite/innodb/r/undo_space_dblwr.result | 2 +- mysql-test/suite/innodb/t/undo_space_dblwr.test | 2 +- storage/innobase/srv/srv0start.cc | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/mysql-test/suite/innodb/r/undo_space_dblwr.result b/mysql-test/suite/innodb/r/undo_space_dblwr.result index 4466df9857b..2172ce53cb7 100644 --- a/mysql-test/suite/innodb/r/undo_space_dblwr.result +++ b/mysql-test/suite/innodb/r/undo_space_dblwr.result @@ -12,7 +12,7 @@ set global innodb_fil_make_page_dirty_debug = 1; SET GLOBAL innodb_buf_flush_list_now = 1; # Kill the server # restart: --debug_dbug=+d,ib_log_checkpoint_avoid_hard --innodb_flush_sync=0 -FOUND 1 /Checksum mismatch in the first page of file/ in mysqld.1.err +FOUND 1 /Restoring page \[page id: space=1, page number=0\] of datafile '.*undo001' from the doublewrite buffer./ in mysqld.1.err check table t1; Table Op Msg_type Msg_text test.t1 check status OK diff --git a/mysql-test/suite/innodb/t/undo_space_dblwr.test b/mysql-test/suite/innodb/t/undo_space_dblwr.test index 52b19a4b7fb..4cf4d3b8b6d 100644 --- a/mysql-test/suite/innodb/t/undo_space_dblwr.test +++ b/mysql-test/suite/innodb/t/undo_space_dblwr.test @@ -39,7 +39,7 @@ EOF --source include/start_mysqld.inc let SEARCH_FILE= $MYSQLTEST_VARDIR/log/mysqld.1.err; -let SEARCH_PATTERN= Checksum mismatch in the first page of file; +let SEARCH_PATTERN= Restoring page \[page id: space=1, page number=0\] of datafile '.*undo001' from the doublewrite buffer.; --source include/search_pattern_in_file.inc check table t1; diff --git a/storage/innobase/srv/srv0start.cc b/storage/innobase/srv/srv0start.cc index 9d64d4ce57f..640e83a33cf 100644 --- a/storage/innobase/srv/srv0start.cc +++ b/storage/innobase/srv/srv0start.cc @@ -554,7 +554,6 @@ err_exit: fsp_flags= mach_read_from_4(FSP_HEADER_OFFSET + FSP_SPACE_FLAGS + page); if (buf_page_is_corrupted(false, page, fsp_flags)) { - ib::error() << "Checksum mismatch in the first page of file " << name; if (recv_sys.dblwr.restore_first_page(space_id, name, fh)) goto err_exit; } From 44b23bb18476b9f2f3d88fabab41f206f3531f98 Mon Sep 17 00:00:00 2001 From: Thirunarayanan Balathandayuthapani Date: Fri, 24 May 2024 13:17:27 +0530 Subject: [PATCH 30/42] MDEV-34222 Alter operation on redundant table aborts the server - InnoDB page compression works only on COMPACT or DYNAMIC row format tables. So InnoDB should throw error when alter table tries to enable PAGE_COMPRESSED for redundant table. --- mysql-test/suite/innodb/r/table_flags.result | 11 +++++++++++ mysql-test/suite/innodb/t/table_flags.test | 12 ++++++++++++ storage/innobase/handler/handler0alter.cc | 9 +++++++++ 3 files changed, 32 insertions(+) diff --git a/mysql-test/suite/innodb/r/table_flags.result b/mysql-test/suite/innodb/r/table_flags.result index eada084d669..fcf2b68c7f6 100644 --- a/mysql-test/suite/innodb/r/table_flags.result +++ b/mysql-test/suite/innodb/r/table_flags.result @@ -210,3 +210,14 @@ ALTER TABLE t1 PAGE_COMPRESSED = 1; INSERT INTO t1 VALUES(2); # restart DROP TABLE t1; +# +# MDEV-34222 Alter operation on redundant table aborts the server +# +SET @df_row = @@global.INNODB_DEFAULT_ROW_FORMAT; +SET GLOBAL INNODB_DEFAULT_ROW_FORMAT=REDUNDANT; +CREATE TABLE t1 (c CHAR(1)) ENGINE=InnoDB; +SET GLOBAL INNODB_DEFAULT_ROW_FORMAT=compact; +ALTER TABLE t1 PAGE_COMPRESSED=1; +ERROR HY000: Table storage engine 'InnoDB' does not support the create option 'PAGE_COMPRESSED=1 ROW_FORMAT=REDUNDANT' +DROP TABLE t1; +SET @@global.INNODB_DEFAULT_ROW_FORMAT = @df_row; diff --git a/mysql-test/suite/innodb/t/table_flags.test b/mysql-test/suite/innodb/t/table_flags.test index 92ebdda442a..ab3c707af95 100644 --- a/mysql-test/suite/innodb/t/table_flags.test +++ b/mysql-test/suite/innodb/t/table_flags.test @@ -257,3 +257,15 @@ INSERT INTO t1 VALUES(2); let $shutdown_timeout = 0; --source include/restart_mysqld.inc DROP TABLE t1; + +--echo # +--echo # MDEV-34222 Alter operation on redundant table aborts the server +--echo # +SET @df_row = @@global.INNODB_DEFAULT_ROW_FORMAT; +SET GLOBAL INNODB_DEFAULT_ROW_FORMAT=REDUNDANT; +CREATE TABLE t1 (c CHAR(1)) ENGINE=InnoDB; +SET GLOBAL INNODB_DEFAULT_ROW_FORMAT=compact; +--error ER_ILLEGAL_HA_CREATE_OPTION +ALTER TABLE t1 PAGE_COMPRESSED=1; +DROP TABLE t1; +SET @@global.INNODB_DEFAULT_ROW_FORMAT = @df_row; diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc index 0c107111b34..ec34b7d1b67 100644 --- a/storage/innobase/handler/handler0alter.cc +++ b/storage/innobase/handler/handler0alter.cc @@ -8339,6 +8339,15 @@ field_changed: DBUG_RETURN(true); } + if ((ha_alter_info->handler_flags & ALTER_OPTIONS) + && ctx->page_compression_level + && !ctx->old_table->not_redundant()) { + my_error(ER_ILLEGAL_HA_CREATE_OPTION, MYF(0), + table_type(), + "PAGE_COMPRESSED=1 ROW_FORMAT=REDUNDANT"); + DBUG_RETURN(true); + } + if (!(ha_alter_info->handler_flags & INNOBASE_ALTER_DATA) && alter_templ_needs_rebuild(altered_table, ha_alter_info, ctx->new_table) From 79253261834e6e5286928e211b358d7508113dea Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Thu, 23 May 2024 16:42:15 +0400 Subject: [PATCH 31/42] MDEV-30931 UBSAN: negation of -X cannot be represented in type 'long long int'; cast to an unsigned type to negate this value to itself in get_interval_value on SELECT - Fixing the code in get_interval_value() to use Longlong_hybrid_null. This allows to handle correctly: - Signed and unsigned arguments (the old code assumed the argument to be signed) - Avoid undefined negation behavior the corner case with LONGLONG_MIN This fixes the UBSAN warning: negation of -9223372036854775808 cannot be represented in type 'long long int'; - Fixing the code in get_interval_value() to avoid overflow in the INTERVAL_QUARTER and INTERVAL_WEEK branches. This fixes the UBSAN warning: signed integer overflow: -9223372036854775808 * 7 cannot be represented in type 'long long int' - Fixing the INTERVAL_WEEK branch in date_add_interval() to handle huge numbers correctly. Before the change, huge positive numeber were treated as their negative complements. Note, some other branches still can be affected by this problem and should also be fixed eventually. --- mysql-test/main/func_date_add.result | 31 +++++++++++++++++++++++++ mysql-test/main/func_date_add.test | 17 ++++++++++++++ sql/item_timefunc.cc | 34 +++++++++++++++++++--------- sql/sql_time.cc | 16 +++++++++---- strings/my_strtoll10.c | 2 +- 5 files changed, 83 insertions(+), 17 deletions(-) diff --git a/mysql-test/main/func_date_add.result b/mysql-test/main/func_date_add.result index a6201a3c23f..1c2d9ab5eb1 100644 --- a/mysql-test/main/func_date_add.result +++ b/mysql-test/main/func_date_add.result @@ -200,3 +200,34 @@ select 30 + (20010101 + interval 2 day), x from v1; 20010133 20010133 drop view v1; End of 10.2 tests +# +# Start of 10.5 tests +# +# +# MDEV-30931 UBSAN: negation of -X cannot be represented in type 'long long int'; cast to an unsigned type to negate this value to itself in get_interval_value on SELECT +# +SELECT DATE_ADD('01-01-23',INTERVAL '9223372036854775808-02' WEEK); +DATE_ADD('01-01-23',INTERVAL '9223372036854775808-02' WEEK) +NULL +Warnings: +Warning 1292 Truncated incorrect INTEGER value: '9223372036854775808-02' +Warning 1441 Datetime function: datetime field overflow +SELECT DATE_ADD('01-01-23',INTERVAL -9223372036854775807 WEEK); +DATE_ADD('01-01-23',INTERVAL -9223372036854775807 WEEK) +NULL +Warnings: +Warning 1441 Datetime function: datetime field overflow +SELECT DATE_ADD('01-01-23',INTERVAL -9223372036854775808 WEEK); +DATE_ADD('01-01-23',INTERVAL -9223372036854775808 WEEK) +NULL +Warnings: +Warning 1441 Datetime function: datetime field overflow +SELECT DATE_ADD('01-01-23',INTERVAL -9223372036854775809 WEEK); +DATE_ADD('01-01-23',INTERVAL -9223372036854775809 WEEK) +NULL +Warnings: +Warning 1916 Got overflow when converting '-9223372036854775809' to INT. Value truncated +Warning 1441 Datetime function: datetime field overflow +# +# End of 10.5 tests +# diff --git a/mysql-test/main/func_date_add.test b/mysql-test/main/func_date_add.test index f9287b952d2..aa00fd144e2 100644 --- a/mysql-test/main/func_date_add.test +++ b/mysql-test/main/func_date_add.test @@ -169,3 +169,20 @@ select 30 + (20010101 + interval 2 day), x from v1; drop view v1; --echo End of 10.2 tests + +--echo # +--echo # Start of 10.5 tests +--echo # + +--echo # +--echo # MDEV-30931 UBSAN: negation of -X cannot be represented in type 'long long int'; cast to an unsigned type to negate this value to itself in get_interval_value on SELECT +--echo # + +SELECT DATE_ADD('01-01-23',INTERVAL '9223372036854775808-02' WEEK); +SELECT DATE_ADD('01-01-23',INTERVAL -9223372036854775807 WEEK); +SELECT DATE_ADD('01-01-23',INTERVAL -9223372036854775808 WEEK); +SELECT DATE_ADD('01-01-23',INTERVAL -9223372036854775809 WEEK); + +--echo # +--echo # End of 10.5 tests +--echo # diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index 2f689acc54c..cd0e88544e0 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -1306,6 +1306,15 @@ my_decimal *Item_func_time_to_sec::decimal_op(my_decimal* buf) } +static inline +uint32 adjust_interval_field_uint32(ulonglong value, int32 multiplier) +{ + return value > ((ulonglong) (uint32) (UINT_MAX32)) / multiplier ? + (uint32) UINT_MAX32 : + (uint32) (value * multiplier); +} + + /** Convert a string to a interval value. @@ -1316,7 +1325,7 @@ bool get_interval_value(THD *thd, Item *args, interval_type int_type, INTERVAL *interval) { ulonglong array[5]; - longlong UNINIT_VAR(value); + ulonglong UNINIT_VAR(value); const char *UNINIT_VAR(str); size_t UNINIT_VAR(length); CHARSET_INFO *UNINIT_VAR(cs); @@ -1343,14 +1352,17 @@ bool get_interval_value(THD *thd, Item *args, } else if ((int) int_type <= INTERVAL_MICROSECOND) { - value= args->val_int(); - if (args->null_value) - return 1; - if (value < 0) - { - interval->neg=1; - value= -value; - } + /* + Let's use Longlong_hybrid_null to handle correctly: + - signed and unsigned values + - the corner case with LONGLONG_MIN + (avoid undefined behavior with its negation) + */ + const Longlong_hybrid_null nr= args->to_longlong_hybrid_null(); + if (nr.is_null()) + return true; + value= nr.abs(); + interval->neg= nr.neg() ? 1 : 0; } else { @@ -1377,13 +1389,13 @@ bool get_interval_value(THD *thd, Item *args, interval->year= (ulong) value; break; case INTERVAL_QUARTER: - interval->month= (ulong)(value*3); + interval->month= adjust_interval_field_uint32(value, 3); break; case INTERVAL_MONTH: interval->month= (ulong) value; break; case INTERVAL_WEEK: - interval->day= (ulong)(value*7); + interval->day= adjust_interval_field_uint32(value, 7); break; case INTERVAL_DAY: interval->day= (ulong) value; diff --git a/sql/sql_time.cc b/sql/sql_time.cc index 12e4460ed25..90bf701fadc 100644 --- a/sql/sql_time.cc +++ b/sql/sql_time.cc @@ -930,7 +930,7 @@ void make_truncated_value_warning(THD *thd, bool date_add_interval(THD *thd, MYSQL_TIME *ltime, interval_type int_type, const INTERVAL &interval, bool push_warn) { - long period, sign; + long sign; sign= (interval.neg == (bool)ltime->neg ? 1 : -1); @@ -1001,13 +1001,17 @@ bool date_add_interval(THD *thd, MYSQL_TIME *ltime, interval_type int_type, break; } case INTERVAL_WEEK: - period= (calc_daynr(ltime->year,ltime->month,ltime->day) + - sign * (long) interval.day); + { + longlong period= calc_daynr(ltime->year, ltime->month, ltime->day) + + (longlong) sign * (longlong) interval.day; + if (period < 0 || period > 0x7FFFFFFF) + goto invalid_date; /* Daynumber from year 0 to 9999-12-31 */ if (get_date_from_daynr((long) period,<ime->year,<ime->month, <ime->day)) goto invalid_date; break; + } case INTERVAL_YEAR: ltime->year+= sign * (long) interval.year; if ((ulong) ltime->year >= 10000L) @@ -1019,8 +1023,9 @@ bool date_add_interval(THD *thd, MYSQL_TIME *ltime, interval_type int_type, case INTERVAL_YEAR_MONTH: case INTERVAL_QUARTER: case INTERVAL_MONTH: - period= (ltime->year*12 + sign * (long) interval.year*12 + - ltime->month-1 + sign * (long) interval.month); + { + long period= (ltime->year*12 + sign * (long) interval.year*12 + + ltime->month-1 + sign * (long) interval.month); if ((ulong) period >= 120000L) goto invalid_date; ltime->year= (uint) (period / 12); @@ -1033,6 +1038,7 @@ bool date_add_interval(THD *thd, MYSQL_TIME *ltime, interval_type int_type, ltime->day++; // Leap-year } break; + } default: goto null_date; } diff --git a/strings/my_strtoll10.c b/strings/my_strtoll10.c index 8144be7a1da..74baef080eb 100644 --- a/strings/my_strtoll10.c +++ b/strings/my_strtoll10.c @@ -241,7 +241,7 @@ end4: *endptr= (char*) s; if (negative) { - if (li >= MAX_NEGATIVE_NUMBER) + if (li >= MAX_NEGATIVE_NUMBER) // Avoid undefined behavior goto overflow; return -((longlong) li); } From 4a158ec167028060000f4087db69703aab3c42a5 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Mon, 27 May 2024 12:46:51 +0400 Subject: [PATCH 32/42] MDEV-34226 On startup: UBSAN: applying zero offset to null pointer in my_copy_fix_mb from strings/ctype-mb.c and other locations nullptr+0 is an UB (undefined behavior). - Fixing my_string_metadata_get_mb() to handle {nullptr,0} without UB. - Fixing THD::copy_with_error() to disallow {nullptr,0} by DBUG_ASSERT(). - Fixing parse_client_handshake_packet() to call THD::copy_with_error() with an empty string {"",0} instead of NULL string {nullptr,0}. --- mysql-test/main/connect-no-db.result | 9 +++++++++ mysql-test/main/connect-no-db.test | 10 ++++++++++ sql/sql_acl.cc | 4 +++- sql/sql_class.cc | 2 ++ strings/ctype.c | 2 +- 5 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 mysql-test/main/connect-no-db.result create mode 100644 mysql-test/main/connect-no-db.test diff --git a/mysql-test/main/connect-no-db.result b/mysql-test/main/connect-no-db.result new file mode 100644 index 00000000000..75597c0753c --- /dev/null +++ b/mysql-test/main/connect-no-db.result @@ -0,0 +1,9 @@ +# +# MDEV-34226 On startup: UBSAN: applying zero offset to null pointer in my_copy_fix_mb from strings/ctype-mb.c and other locations +# +connect con1,localhost,root,,"*NO-ONE*"; +SELECT database(); +database() +NULL +disconnect con1; +connection default; diff --git a/mysql-test/main/connect-no-db.test b/mysql-test/main/connect-no-db.test new file mode 100644 index 00000000000..bc36499e703 --- /dev/null +++ b/mysql-test/main/connect-no-db.test @@ -0,0 +1,10 @@ +--echo # +--echo # MDEV-34226 On startup: UBSAN: applying zero offset to null pointer in my_copy_fix_mb from strings/ctype-mb.c and other locations +--echo # + +# Connect without a database + +connect (con1,localhost,root,,"*NO-ONE*"); +SELECT database(); +disconnect con1; +connection default; diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index dd222998b3a..ee0351cb38f 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -13799,9 +13799,11 @@ static ulong parse_client_handshake_packet(MPVIO_EXT *mpvio, Since 4.1 all database names are stored in utf8 The cast is ok as copy_with_error will create a new area for db */ + DBUG_ASSERT(db || !db_len); + // Don't pass db==nullptr to avoid UB nullptr+0 inside copy_with_error() if (unlikely(thd->copy_with_error(system_charset_info, (LEX_STRING*) &mpvio->db, - thd->charset(), db, db_len))) + thd->charset(), db ? db : "", db_len))) return packet_error; user_len= copy_and_convert(user_buff, sizeof(user_buff) - 1, diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 34cd63d7839..124ed6e051d 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -2522,6 +2522,8 @@ bool THD::copy_with_error(CHARSET_INFO *dstcs, LEX_STRING *dst, CHARSET_INFO *srccs, const char *src, size_t src_length) { + // Don't allow NULL to avoid UB in the called functions: nullptr+0 + DBUG_ASSERT(src); String_copier_with_error status; return copy_fix(dstcs, dst, srccs, src, src_length, &status) || status.check_errors(srccs, src, src_length); diff --git a/strings/ctype.c b/strings/ctype.c index f1c1ec9d7fc..ccc59a20fe8 100644 --- a/strings/ctype.c +++ b/strings/ctype.c @@ -867,7 +867,7 @@ static void my_string_metadata_get_mb(MY_STRING_METADATA *metadata, CHARSET_INFO *cs, const char *str, ulong length) { - const char *strend= str + length; + const char *strend= str ? str + length : NULL; // Avoid UB nullptr+0 for (my_string_metadata_init(metadata) ; str < strend; metadata->char_length++) From 36ab6cc80cc8d8bf332852ecdf5fac3adf8e8888 Mon Sep 17 00:00:00 2001 From: Sergei Petrunia Date: Sun, 12 May 2024 19:10:47 +0300 Subject: [PATCH 33/42] MDEV-34125: ANALYZE FORMAT=JSON: r_engine_stats.pages_read_time_ms has wrong scale - Change the comments in class ha_handler_stats to say the members are in ticks, not milliseconds. - In sql_explain.cc, adjust the scale to print milliseconds. --- mysql-test/main/analyze_engine_stats2.opt | 1 + mysql-test/main/analyze_engine_stats2.result | 57 +++++++++++++++ mysql-test/main/analyze_engine_stats2.test | 73 ++++++++++++++++++++ sql/ha_handler_stats.h | 9 ++- sql/sql_explain.cc | 5 +- 5 files changed, 142 insertions(+), 3 deletions(-) create mode 100644 mysql-test/main/analyze_engine_stats2.opt create mode 100644 mysql-test/main/analyze_engine_stats2.result create mode 100644 mysql-test/main/analyze_engine_stats2.test diff --git a/mysql-test/main/analyze_engine_stats2.opt b/mysql-test/main/analyze_engine_stats2.opt new file mode 100644 index 00000000000..a5bb9a93636 --- /dev/null +++ b/mysql-test/main/analyze_engine_stats2.opt @@ -0,0 +1 @@ +--innodb_buffer_pool_dump_at_shutdown=off --innodb_buffer_pool_load_at_startup=off --innodb-stats-persistent=1 --innodb-stats-auto-recalc=off diff --git a/mysql-test/main/analyze_engine_stats2.result b/mysql-test/main/analyze_engine_stats2.result new file mode 100644 index 00000000000..3ba9895dd39 --- /dev/null +++ b/mysql-test/main/analyze_engine_stats2.result @@ -0,0 +1,57 @@ +# +# MDEV-34125: ANALYZE FORMAT=JSON: r_engine_stats.pages_read_time_ms has wrong scale +# +create table t1 ( +a varchar(255), +b varchar(255), +c varchar(255), +d varchar(255), +primary key(a,b,c,d) +) engine=innodb; +insert into t1 select +repeat(uuid(), 7), +repeat(uuid(), 7), +repeat(uuid(), 7), +repeat(uuid(), 7) +from seq_1_to_16384; +# restart +set log_slow_verbosity='engine'; +set long_query_time=0.0; +set @js='$analyze_output'; +select @js; +@js +{ + "query_block": { + "select_id": 1, + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "table": { + "table_name": "t1", + "access_type": "index", + "key": "PRIMARY", + "key_length": "1028", + "used_key_parts": ["a", "b", "c", "d"], + "r_loops": 1, + "rows": 1, + "r_rows": 16384, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "r_engine_stats": { + "pages_accessed": "REPLACED", + "pages_read_count": "REPLACED", + "pages_read_time_ms": "REPLACED" + }, + "filtered": 100, + "r_filtered": 100, + "using_index": true + } + } +} +set @pages_read_time_ms= +(select json_value(@js,'$.query_block.table.r_engine_stats.pages_read_time_ms')); + + + OK: pages_read_time is same in slow log and ANALYZE + +set long_query_time=default; +drop table t1; diff --git a/mysql-test/main/analyze_engine_stats2.test b/mysql-test/main/analyze_engine_stats2.test new file mode 100644 index 00000000000..1a811f6d9e0 --- /dev/null +++ b/mysql-test/main/analyze_engine_stats2.test @@ -0,0 +1,73 @@ +# +# r_engine_stats tests that require slow query log. +# +--source include/analyze-format.inc +--source include/have_sequence.inc +--source include/have_innodb.inc + +--echo # +--echo # MDEV-34125: ANALYZE FORMAT=JSON: r_engine_stats.pages_read_time_ms has wrong scale +--echo # + +# Each row is 1K. +create table t1 ( + a varchar(255), + b varchar(255), + c varchar(255), + d varchar(255), + primary key(a,b,c,d) +) engine=innodb; + +# The data size is 160K * 1K = 160M +# 16M / (page_size=16K) = 1K pages. +insert into t1 select + repeat(uuid(), 7), + repeat(uuid(), 7), + repeat(uuid(), 7), + repeat(uuid(), 7) +from seq_1_to_16384; + +source include/restart_mysqld.inc; +set log_slow_verbosity='engine'; +set long_query_time=0.0; + +let $analyze_output= `analyze format=json +select * from t1 force index (PRIMARY) order by a desc, b desc, c desc, d desc`; +evalp set @js='$analyze_output'; + +# Print it out for user-friendlines +--replace_regex /("(r_[a-z_]*_time_ms|pages[^"]*)": )[^, \n]*/\1"REPLACED"/ +select @js; + +set @pages_read_time_ms= + (select json_value(@js,'$.query_block.table.r_engine_stats.pages_read_time_ms')); + +let ANALYZE_PAGES=`select @pages_read_time_ms`; +let SLOW_LOG_FILE= `select @@slow_query_log_file`; + +perl; + my $slow_log_file= $ENV{'SLOW_LOG_FILE'} or die "SLOW_LOG_FILE not set"; + my $analyze_pages=$ENV{'ANALYZE_PAGES'}; + open(FILE, $slow_log_file) or die "Failed to open $slow_log_file"; + # We didn't run any queries touching a storage engine after the query of + # interest, so we will be fine here if we just get the last occurrence of + # Pages_read_time: NNNN in the file + while() { + $slow_log_pages=$1 if (/Pages_read_time: ([0-9.]+)/); + } + close(FILE); + + if ( $slow_log_pages > $analyze_pages * 0.95 && + $slow_log_pages < $analyze_pages * 1.05) { + print "\n\n OK: pages_read_time is same in slow log and ANALYZE\n\n"; + } else { + print "\n\n FAIL: $slow_log_pages not equal to $analyze_pages\n"; + } + +EOF + + +set long_query_time=default; +drop table t1; + + diff --git a/sql/ha_handler_stats.h b/sql/ha_handler_stats.h index 726ba6041dc..60ae5deedbe 100644 --- a/sql/ha_handler_stats.h +++ b/sql/ha_handler_stats.h @@ -26,9 +26,14 @@ public: ulonglong pages_accessed; /* Pages accessed from page cache */ ulonglong pages_updated; /* Pages changed in page cache */ ulonglong pages_read_count; /* Pages read from disk */ - ulonglong pages_read_time; /* Time reading pages, in microsec. */ + + /* Time spent reading pages, in timer_tracker_frequency() units */ + ulonglong pages_read_time; + ulonglong undo_records_read; - ulonglong engine_time; /* Time spent in engine in microsec */ + + /* Time spent in engine, in timer_tracker_frequency() units */ + ulonglong engine_time; uint active; /* <> 0 if status has to be updated */ #define first_stat pages_accessed #define last_stat engine_time diff --git a/sql/sql_explain.cc b/sql/sql_explain.cc index 774eacb58a5..c84a3a00a8f 100644 --- a/sql/sql_explain.cc +++ b/sql/sql_explain.cc @@ -207,6 +207,9 @@ int Explain_query::send_explain(THD *thd, bool extended) int Explain_query::print_explain(select_result_sink *output, uint8 explain_flags, bool is_analyze) { + /* A sanity check for ANALYZE: */ + DBUG_ASSERT(timer_tracker_frequency() != 0.0); + if (upd_del_plan) { upd_del_plan->print_explain(this, output, explain_flags, is_analyze); @@ -1723,7 +1726,7 @@ static void trace_engine_stats(handler *file, Json_writer *writer) writer->add_member("pages_read_count").add_ull(hs->pages_read_count); if (hs->pages_read_time) writer->add_member("pages_read_time_ms"). - add_double(hs->pages_read_time / 1000.0); + add_double(hs->pages_read_time * 1000. / timer_tracker_frequency()); if (hs->undo_records_read) writer->add_member("old_rows_read").add_ull(hs->undo_records_read); writer->end_object(); From 83a04be84aa5ed95f24371d2eb125216e4a89eab Mon Sep 17 00:00:00 2001 From: Souradeep Saha Date: Thu, 23 May 2024 21:35:18 +0000 Subject: [PATCH 34/42] Fix Various Typos Fix various typos, in comments and DEBUG statements, and code changes are non-functional. All new code of the whole pull request, including one or several files that are either new files or modified ones, are contributed under the BSD-new license. I am contributing on behalf of my employer Amazon Web Services, Inc. --- client/mysqladmin.cc | 2 +- client/mysqldump.c | 6 +++--- client/mysqlimport.c | 8 ++++---- sql-common/client.c | 14 +++++++------- sql-common/my_time.c | 20 ++++++++++---------- 5 files changed, 25 insertions(+), 25 deletions(-) diff --git a/client/mysqladmin.cc b/client/mysqladmin.cc index 098e7ef7c83..2dba3d272fb 100644 --- a/client/mysqladmin.cc +++ b/client/mysqladmin.cc @@ -417,7 +417,7 @@ int main(int argc,char *argv[]) is given a t!=0, we get an endless loop, or n iterations if --count=n was given an n!=0. If --sleep wasn't given, we get one iteration. - To wit, --wait loops the connection-attempts, while --sleep loops + To wait, --wait loops the connection-attempts, while --sleep loops the command execution (endlessly if no --count is given). */ diff --git a/client/mysqldump.c b/client/mysqldump.c index d3d6851b65a..521e048497d 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -5842,7 +5842,7 @@ static int dump_selected_tables(char *db, char **table_names, int tables) free_root(&glob_root, MYF(0)); } maybe_die(EX_ILLEGAL_TABLE, "Couldn't find table: \"%s\"", *table_names); - /* We shall countinue here, if --force was given */ + /* We shall continue here, if --force was given */ } } end= pos; @@ -5863,7 +5863,7 @@ static int dump_selected_tables(char *db, char **table_names, int tables) free_root(&glob_root, MYF(0)); } DB_error(mysql, "when doing LOCK TABLES"); - /* We shall countinue here, if --force was given */ + /* We shall continue here, if --force was given */ } } dynstr_free(&lock_tables_query); @@ -5875,7 +5875,7 @@ static int dump_selected_tables(char *db, char **table_names, int tables) free_root(&glob_root, MYF(0)); DB_error(mysql, "when doing refresh"); } - /* We shall countinue here, if --force was given */ + /* We shall continue here, if --force was given */ else verbose_msg("-- dump_selected_tables : logs flushed successfully!\n"); } diff --git a/client/mysqlimport.c b/client/mysqlimport.c index b7c507e359d..3a9f9005cb6 100644 --- a/client/mysqlimport.c +++ b/client/mysqlimport.c @@ -414,7 +414,7 @@ static void lock_table(MYSQL *mysql, int tablecount, char **raw_tablename) dynstr_append(&query, " WRITE,"); } if (mysql_real_query(mysql, query.str, (ulong)query.length-1)) - db_error(mysql); /* We shall countinue here, if --force was given */ + db_error(mysql); /* We shall continue here, if --force was given */ } @@ -612,7 +612,7 @@ pthread_handler_t worker_thread(void *arg) if (mysql_query(mysql, "/*!40101 set @@character_set_database=binary */;")) { - db_error(mysql); /* We shall countinue here, if --force was given */ + db_error(mysql); /* We shall continue here, if --force was given */ goto error; } @@ -736,12 +736,12 @@ int main(int argc, char **argv) if (!(mysql= db_connect(current_host,current_db,current_user,opt_password))) { free_defaults(argv_to_free); - return(1); /* purecov: deadcode */ + return(1); /* purecov: dead code */ } if (mysql_query(mysql, "/*!40101 set @@character_set_database=binary */;")) { - db_error(mysql); /* We shall countinue here, if --force was given */ + db_error(mysql); /* We shall continue here, if --force was given */ return(1); } diff --git a/sql-common/client.c b/sql-common/client.c index 687f28cea28..13882caa340 100644 --- a/sql-common/client.c +++ b/sql-common/client.c @@ -21,7 +21,7 @@ The differences for the two cases are: - Things that only works for the client: - - Trying to automaticly determinate user name if not supplied to + - Trying to automatically determinate user name if not supplied to mysql_real_connect() - Support for reading local file with LOAD DATA LOCAL - SHARED memory handling @@ -30,7 +30,7 @@ - Things that only works for the server - Alarm handling on connect - In all other cases, the code should be idential for the client and + In all other cases, the code should be identical for the client and server. */ @@ -1457,7 +1457,7 @@ mysql_init(MYSQL *mysql) mysql_reconnect()). This is a change: < 5.0.3 mysql->reconnect was set to 1 by default. How this change impacts existing apps: - - existing apps which relyed on the default will see a behaviour change; + - existing apps which relied on the default will see a behaviour change; they will have to set reconnect=1 after mysql_real_connect(). - existing apps which explicitly asked for reconnection (the only way they could do it was by setting mysql.reconnect to 1 after mysql_real_connect()) @@ -1936,7 +1936,7 @@ typedef struct { /* - Write 1-8 bytes of string length header infromation to dest depending on + Write 1-8 bytes of string length header information to dest depending on value of src_len, then copy src_len bytes from src to dest. @param dest Destination buffer of size src_len+8 @@ -2217,7 +2217,7 @@ static int send_client_reply_packet(MCPVIO_EXT *mpvio, } #endif /* HAVE_OPENSSL */ - DBUG_PRINT("info",("Server version = '%s' capabilites: %lu status: %u client_flag: %lu", + DBUG_PRINT("info",("Server version = '%s' capabilities: %lu status: %u client_flag: %lu", mysql->server_version, mysql->server_capabilities, mysql->server_status, mysql->client_flag)); @@ -2354,7 +2354,7 @@ static int client_mpvio_read_packet(struct st_plugin_vio *mpv, uchar **buf) to send data to the server. It transparently wraps the data into a change user or authentication - handshake packet, if neccessary. + handshake packet, if necessary. */ static int client_mpvio_write_packet(struct st_plugin_vio *mpv, const uchar *pkt, int pkt_len) @@ -3830,7 +3830,7 @@ mysql_options(MYSQL *mysql,enum mysql_option option, const void *arg) mysql->options.compress= 1; /* Remember for connect */ mysql->options.client_flag|= CLIENT_COMPRESS; break; - case MYSQL_OPT_NAMED_PIPE: /* This option is depricated */ + case MYSQL_OPT_NAMED_PIPE: /* This option is deprecated */ mysql->options.protocol=MYSQL_PROTOCOL_PIPE; /* Force named pipe */ break; case MYSQL_OPT_LOCAL_INFILE: /* Allow LOAD DATA LOCAL ?*/ diff --git a/sql-common/my_time.c b/sql-common/my_time.c index 96674723b34..eff39cd5eae 100644 --- a/sql-common/my_time.c +++ b/sql-common/my_time.c @@ -475,7 +475,7 @@ str_to_DDhhmmssff_internal(my_bool neg, const char *str, size_t length, DESCRIPTION - At least the following formats are recogniced (based on number of digits) + At least the following formats are recognized (based on number of digits) YYMMDD, YYYYMMDD, YYMMDDHHMMSS, YYYYMMDDHHMMSS YY-MM-DD, YYYY-MM-DD, YY-MM-DD HH.MM.SS YYYYMMDDTHHMMSS where T is a the character T (ISO8601) @@ -1223,7 +1223,7 @@ long calc_daynr(uint year,uint month,uint day) /* Convert time in MYSQL_TIME representation in system time zone to its - my_time_t form (number of seconds in UTC since begginning of Unix Epoch). + my_time_t form (number of seconds in UTC since beginning of Unix Epoch). SYNOPSIS my_system_gmt_sec() @@ -1291,7 +1291,7 @@ my_system_gmt_sec(const MYSQL_TIME *t_src, long *my_timezone, uint *error_code) two days earlier, and then add these days to the final value. The same trick is done for the values close to 0 in time_t - representation for platfroms with unsigned time_t (QNX). + representation for platforms with unsigned time_t (QNX). To be more verbose, here is a sample (extracted from the code below): (calc_daynr(2038, 1, 19) - (long) days_at_timestart)*86400L + 4*3600L @@ -1303,9 +1303,9 @@ my_system_gmt_sec(const MYSQL_TIME *t_src, long *my_timezone, uint *error_code) will give -3600. On some platforms, (E.g. on QNX) time_t is unsigned and localtime(-3600) - wil give us a date around 2106 year. Which is no good. + will give us a date around 2106 year. Which is no good. - Theoreticaly, there could be problems with the latter conversion: + Theoretically, there could be problems with the latter conversion: there are at least two timezones, which had time switches near 1 Jan of 1970 (because of political reasons). These are America/Hermosillo and America/Mazatlan time zones. They changed their offset on @@ -1335,7 +1335,7 @@ my_system_gmt_sec(const MYSQL_TIME *t_src, long *my_timezone, uint *error_code) else { /* - We can get 0 in time_t representaion only on 1969, 31 of Dec or on + We can get 0 in time_t representation only on 1969, 31 of Dec or on 1970, 1 of Jan. For both dates we use shift, which is added to t->day in order to step out a bit from the border. This is required for platforms, where time_t is unsigned. @@ -1430,9 +1430,9 @@ my_system_gmt_sec(const MYSQL_TIME *t_src, long *my_timezone, uint *error_code) First check will pass for platforms with signed time_t. instruction above (tmp+= shift*86400L) could exceed MAX_INT32 (== TIMESTAMP_MAX_VALUE) and overflow will happen. - So, tmp < TIMESTAMP_MIN_VALUE will be triggered. On platfroms + So, tmp < TIMESTAMP_MIN_VALUE will be triggered. On platforms with unsigned time_t tmp+= shift*86400L might result in a number, - larger then TIMESTAMP_MAX_VALUE, so another check will work. + larger than TIMESTAMP_MAX_VALUE, so another check will work. */ if (!IS_TIME_T_VALID_FOR_TIMESTAMP(tmp)) { @@ -1545,8 +1545,8 @@ static inline char* fmt_number2(uint8 val, char *out) - 0.225 sec (current) - 0.219 sec (array) - It demonstrated an additional 3% performance imrovement one these queries. - However, as the array size is too huge, we afraid that it will flush data + It demonstrated an additional 3% performance improvement one these queries. + However, as the array size is too huge, we are afraid that it will flush data from the CPU memory cache, which under real load may affect negatively. Let's keep using the fmt_number4() version with division and remainder From a960e95febd10b8558e9e626869babd0573bbf69 Mon Sep 17 00:00:00 2001 From: Brian White Date: Tue, 21 May 2024 08:15:28 -0400 Subject: [PATCH 35/42] don't require resolveip if it won't be used --- scripts/mysql_install_db.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/scripts/mysql_install_db.sh b/scripts/mysql_install_db.sh index f38c1d7f98b..e2b2109373a 100644 --- a/scripts/mysql_install_db.sh +++ b/scripts/mysql_install_db.sh @@ -38,6 +38,7 @@ force=0 in_rpm=0 ip_only=0 cross_bootstrap=0 +do_resolve=0 auth_root_authentication_method=socket auth_root_socket_user="" skip_test_db=0 @@ -330,6 +331,11 @@ parse_arguments PICK-ARGS-FROM-ARGV "$@" rel_mysqld="$dirname0/@INSTALL_SBINDIR@/mariadbd" +if test "$cross_bootstrap" -eq 0 -a "$in_rpm" -eq 0 -a "$force" -eq 0 + do_resolve=1 +then +fi + # Configure paths to support files if test -n "$srcdir" then @@ -422,7 +428,7 @@ fi hostname=`@HOSTNAME@` # Check if hostname is valid -if test "$cross_bootstrap" -eq 0 -a "$in_rpm" -eq 0 -a "$force" -eq 0 +if test "$do_resolve" -eq 1 then resolved=`"$resolveip" $hostname 2>&1` if test $? -ne 0 @@ -448,7 +454,7 @@ then fi fi -if test "$ip_only" -eq 1 +if test "$do_resolve" -eq 1 -a "$ip_only" -eq 1 then hostname=`echo "$resolved" | awk '/ /{print $6}'` fi From 1929a698a362cd9811161a06518608b9aefcee45 Mon Sep 17 00:00:00 2001 From: Andrew Hutchings Date: Wed, 29 May 2024 10:27:58 +0100 Subject: [PATCH 36/42] Update README for branch choice This commit updates the README to indicate that the "Get the code, build it, test it" link will help decide the correct branch to work in. Also fixes a grammar issue and cleans-up the Markdown a little bit. --- README.md | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 5fe95f46a6b..a8fbc119f0f 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,8 @@ -Code status: ------------- +# Code status: * [![Appveyor CI status](https://ci.appveyor.com/api/projects/status/4u6pexmtpuf8jq66?svg=true)](https://ci.appveyor.com/project/rasmushoj/server) ci.appveyor.com -## MariaDB: The innovative open source database +## MariaDB: The innovative open source database MariaDB was designed as a drop-in replacement of MySQL(R) with more features, new storage engines, fewer bugs, and better performance. @@ -33,20 +32,19 @@ https://mariadb.com/kb/en/mariadb-versus-mysql-compatibility/ https://mariadb.com/kb/en/new-and-old-releases/ -Getting the code, building it and testing it ---------------------------------------------------------------- +# Getting the code, building it and testing it -Refer to the following guide: https://mariadb.org/get-involved/getting-started-for-developers/get-code-build-test/ which outlines how to correctly build the source code and run the MariaDB testing framework. +Refer to the following guide: https://mariadb.org/get-involved/getting-started-for-developers/get-code-build-test/ +which outlines how to build the source code correctly and run the MariaDB testing framework, +as well as which branch to target for your contributions. -Help ------ +# Help More help is available from the Maria Discuss mailing list https://lists.mariadb.org/postorius/lists/discuss.lists.mariadb.org/ and MariaDB's Zulip -instance, https://mariadb.zulipchat.com/ +instance, https://mariadb.zulipchat.com/ -Licensing ---------- +# Licensing *************************************************************************** @@ -60,8 +58,7 @@ license information can be found in the THIRDPARTY file. *************************************************************************** -Bug Reports ------------- +# Bug Reports Bug and/or error reports regarding MariaDB should be submitted at: https://jira.mariadb.org From b0b463a894bab4e6cd7786924b1a0afa62d0cd42 Mon Sep 17 00:00:00 2001 From: Dave Gosselin Date: Wed, 29 May 2024 12:36:58 -0400 Subject: [PATCH 37/42] MDEV-33616 Fix memleak in pfs_noop Invoke cleanup routine at the end of pfs_noop. --- storage/perfschema/unittest/pfs_noop-t.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/storage/perfschema/unittest/pfs_noop-t.cc b/storage/perfschema/unittest/pfs_noop-t.cc index 57e8cfd8a0a..6d5e4eb152f 100644 --- a/storage/perfschema/unittest/pfs_noop-t.cc +++ b/storage/perfschema/unittest/pfs_noop-t.cc @@ -240,6 +240,7 @@ int main(int, char **) MY_INIT("pfs_noop-t"); test_noop(); + my_end(MY_CHECK_ERROR); return (exit_status()); } From c71275b69ee4f36a7e46160ae4f3709e662cc72c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Thu, 30 May 2024 14:22:00 +0300 Subject: [PATCH 38/42] Fix ./mtr --repeat=2 main.func_str --- mysql-test/main/func_str.test | 1 + 1 file changed, 1 insertion(+) diff --git a/mysql-test/main/func_str.test b/mysql-test/main/func_str.test index 49b5546abb8..c42c27538d8 100644 --- a/mysql-test/main/func_str.test +++ b/mysql-test/main/func_str.test @@ -1545,6 +1545,7 @@ CREATE TABLE t1 ( a TEXT ); SELECT insert( substring_index( 'a', 'a', 'b' ), 1, 0, 'x' ); --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR --eval LOAD DATA INFILE '$MYSQLTEST_VARDIR/tmp/bug58165.txt' INTO TABLE t1; +--remove_file $MYSQLTEST_VARDIR/tmp/bug58165.txt SELECT * FROM t1; DROP TABLE t1; From 0c440abd5e0f2a31e1e82c0a927e7d2a0d3b9c5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Thu, 30 May 2024 14:23:45 +0300 Subject: [PATCH 39/42] MDEV-31340 fixup: Add end-of-test marker --- mysql-test/main/view_grant.result | 1 + mysql-test/main/view_grant.test | 2 ++ 2 files changed, 3 insertions(+) diff --git a/mysql-test/main/view_grant.result b/mysql-test/main/view_grant.result index 818a15f86ce..f1bebf98ecd 100644 --- a/mysql-test/main/view_grant.result +++ b/mysql-test/main/view_grant.result @@ -1985,3 +1985,4 @@ connection default; DROP VIEW v1; DROP USER foo; DROP USER FOO; +# End of 10.5 tests diff --git a/mysql-test/main/view_grant.test b/mysql-test/main/view_grant.test index a5019e88d65..686a9428bf6 100644 --- a/mysql-test/main/view_grant.test +++ b/mysql-test/main/view_grant.test @@ -2234,3 +2234,5 @@ SELECT CURRENT_USER; DROP VIEW v1; DROP USER foo; DROP USER FOO; + +--echo # End of 10.5 tests From 6c302207807fcd255f152d663014868dbde5dcea Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Tue, 30 Apr 2024 14:51:37 +1000 Subject: [PATCH 40/42] MDEV-26858 Spider: Remove dead code related to HandlerSocket Remove the dead-code, in Spider, which is related to the Spider's HandlerSocket support. The code has been disabled for a long time and it is unlikely that the code will be enabled. - rm all files under storage/spider/hs_client/ except hs_compat.h - rm storage/spider/spd_db_handlersocket.* - unifdef -UHS_HAS_SQLCOM -UHAVE_HANDLERSOCKET \ -m storage/spider/spd_* storage/spider/ha_spider.* storage/spider/hs_client/* - remove relevant files from storage/spider/CMakeLists.txt --- storage/spider/CMakeLists.txt | 5 +- storage/spider/ha_spider.cc | 1207 ---- storage/spider/ha_spider.h | 81 - storage/spider/hs_client/allocator.hpp | 43 - storage/spider/hs_client/auto_addrinfo.hpp | 49 - storage/spider/hs_client/auto_file.hpp | 67 - .../spider/hs_client/auto_ptrcontainer.hpp | 70 - storage/spider/hs_client/config.cpp | 286 - storage/spider/hs_client/config.hpp | 76 - storage/spider/hs_client/escape.cpp | 129 - storage/spider/hs_client/escape.hpp | 64 - storage/spider/hs_client/fatal.cpp | 44 - storage/spider/hs_client/fatal.hpp | 26 - storage/spider/hs_client/hstcpcli.cpp | 662 -- storage/spider/hs_client/hstcpcli.hpp | 93 - storage/spider/hs_client/mutex.hpp | 48 - storage/spider/hs_client/socket.cpp | 306 - storage/spider/hs_client/socket.hpp | 57 - storage/spider/hs_client/string_buffer.hpp | 146 - storage/spider/hs_client/string_ref.hpp | 106 - storage/spider/hs_client/string_util.cpp | 202 - storage/spider/hs_client/string_util.hpp | 51 - storage/spider/hs_client/thread.hpp | 84 - storage/spider/hs_client/util.hpp | 25 - storage/spider/spd_conn.cc | 772 -- storage/spider/spd_db_conn.cc | 1143 +-- storage/spider/spd_db_conn.h | 5 - storage/spider/spd_db_handlersocket.cc | 6311 ----------------- storage/spider/spd_db_handlersocket.h | 1091 --- storage/spider/spd_db_include.h | 175 - storage/spider/spd_db_mysql.cc | 261 - storage/spider/spd_db_mysql.h | 76 - storage/spider/spd_db_oracle.cc | 272 - storage/spider/spd_db_oracle.h | 76 - storage/spider/spd_direct_sql.cc | 251 +- storage/spider/spd_include.h | 125 - storage/spider/spd_param.cc | 185 - storage/spider/spd_param.h | 33 - storage/spider/spd_table.cc | 754 -- storage/spider/spd_table.h | 8 - storage/spider/spd_trx.cc | 281 +- 41 files changed, 20 insertions(+), 15726 deletions(-) delete mode 100644 storage/spider/hs_client/allocator.hpp delete mode 100644 storage/spider/hs_client/auto_addrinfo.hpp delete mode 100644 storage/spider/hs_client/auto_file.hpp delete mode 100644 storage/spider/hs_client/auto_ptrcontainer.hpp delete mode 100644 storage/spider/hs_client/config.cpp delete mode 100644 storage/spider/hs_client/config.hpp delete mode 100644 storage/spider/hs_client/escape.cpp delete mode 100644 storage/spider/hs_client/escape.hpp delete mode 100644 storage/spider/hs_client/fatal.cpp delete mode 100644 storage/spider/hs_client/fatal.hpp delete mode 100644 storage/spider/hs_client/hstcpcli.cpp delete mode 100644 storage/spider/hs_client/hstcpcli.hpp delete mode 100644 storage/spider/hs_client/mutex.hpp delete mode 100644 storage/spider/hs_client/socket.cpp delete mode 100644 storage/spider/hs_client/socket.hpp delete mode 100644 storage/spider/hs_client/string_buffer.hpp delete mode 100644 storage/spider/hs_client/string_ref.hpp delete mode 100644 storage/spider/hs_client/string_util.cpp delete mode 100644 storage/spider/hs_client/string_util.hpp delete mode 100644 storage/spider/hs_client/thread.hpp delete mode 100644 storage/spider/hs_client/util.hpp delete mode 100644 storage/spider/spd_db_handlersocket.cc delete mode 100644 storage/spider/spd_db_handlersocket.h diff --git a/storage/spider/CMakeLists.txt b/storage/spider/CMakeLists.txt index 397478bfc40..11304d05b18 100644 --- a/storage/spider/CMakeLists.txt +++ b/storage/spider/CMakeLists.txt @@ -17,10 +17,7 @@ SET(SPIDER_SOURCES spd_param.cc spd_sys_table.cc spd_trx.cc spd_db_conn.cc spd_conn.cc spd_table.cc spd_direct_sql.cc spd_udf.cc spd_ping_table.cc spd_copy_tables.cc spd_i_s.cc spd_malloc.cc ha_spider.cc spd_udf.def - spd_db_mysql.cc spd_db_handlersocket.cc spd_db_oracle.cc - spd_group_by_handler.cc spd_db_include.cc - hs_client/config.cpp hs_client/escape.cpp hs_client/fatal.cpp - hs_client/hstcpcli.cpp hs_client/socket.cpp hs_client/string_util.cpp + spd_db_mysql.cc spd_db_oracle.cc spd_group_by_handler.cc spd_db_include.cc ) IF(DEFINED ENV{ORACLE_HOME}) diff --git a/storage/spider/ha_spider.cc b/storage/spider/ha_spider.cc index bdf2470f6cb..485b98eec84 100644 --- a/storage/spider/ha_spider.cc +++ b/storage/spider/ha_spider.cc @@ -71,10 +71,6 @@ ha_spider::ha_spider( conn_keys = NULL; spider_thread_id = 0; trx_conn_adjustment = 0; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - trx_hs_r_conn_adjustment = 0; - trx_hs_w_conn_adjustment = 0; -#endif search_link_query_id = 0; #ifdef WITH_PARTITION_STORAGE_ENGINE partition_handler = NULL; @@ -104,14 +100,6 @@ ha_spider::ha_spider( use_pre_action = FALSE; #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS do_direct_update = FALSE; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - hs_pushed_ret_fields_num = MAX_FIELDS; - hs_pushed_ret_fields = NULL; - hs_pushed_ret_fields_size = 0; - hs_increment = FALSE; - hs_decrement = FALSE; - hs_pushed_strref_num = 0; -#endif #endif #ifdef HA_CAN_BULK_ACCESS is_bulk_access_clone = FALSE; @@ -134,16 +122,10 @@ ha_spider::ha_spider( result_list.insert_sqls = NULL; result_list.update_sqls = NULL; result_list.tmp_sqls = NULL; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - result_list.hs_result_buf = NULL; -#endif result_list.tmp_tables_created = FALSE; result_list.bgs_working = FALSE; result_list.direct_order_limit = FALSE; result_list.direct_limit_offset = FALSE; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - result_list.hs_has_result = FALSE; -#endif result_list.set_split_read = FALSE; result_list.insert_dup_update_pushdown = FALSE; result_list.tmp_pos_row_first = NULL; @@ -174,10 +156,6 @@ ha_spider::ha_spider( conn_keys = NULL; spider_thread_id = 0; trx_conn_adjustment = 0; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - trx_hs_r_conn_adjustment = 0; - trx_hs_w_conn_adjustment = 0; -#endif search_link_query_id = 0; #ifdef WITH_PARTITION_STORAGE_ENGINE partition_handler = NULL; @@ -207,14 +185,6 @@ ha_spider::ha_spider( use_pre_action = FALSE; #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS do_direct_update = FALSE; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - hs_pushed_ret_fields_num = MAX_FIELDS; - hs_pushed_ret_fields = NULL; - hs_pushed_ret_fields_size = 0; - hs_increment = FALSE; - hs_decrement = FALSE; - hs_pushed_strref_num = 0; -#endif #endif #ifdef HA_CAN_BULK_ACCESS is_bulk_access_clone = FALSE; @@ -237,16 +207,10 @@ ha_spider::ha_spider( result_list.insert_sqls = NULL; result_list.update_sqls = NULL; result_list.tmp_sqls = NULL; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - result_list.hs_result_buf = NULL; -#endif result_list.tmp_tables_created = FALSE; result_list.bgs_working = FALSE; result_list.direct_order_limit = FALSE; result_list.direct_limit_offset = FALSE; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - result_list.hs_has_result = FALSE; -#endif result_list.set_split_read = FALSE; result_list.insert_dup_update_pushdown = FALSE; result_list.tmp_pos_row_first = NULL; @@ -746,25 +710,8 @@ int ha_spider::close() delete [] result_list.tmp_sqls; result_list.tmp_sqls = NULL; } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (result_list.hs_result_buf) - { - delete result_list.hs_result_buf; - result_list.hs_result_buf = NULL; - } -#endif spider_free_share(share); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS - if (hs_pushed_ret_fields) - { - spider_free(spider_current_trx, hs_pushed_ret_fields, MYF(0)); - hs_pushed_ret_fields = NULL; - hs_pushed_ret_fields_size = 0; - } -#endif -#endif is_clone = FALSE; pt_clone_source_handler = NULL; share = NULL; @@ -783,84 +730,6 @@ int ha_spider::check_access_kind_for_connection( conn_kinds = 0; switch (wide_handler->sql_command) { -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - case SQLCOM_HS_READ: - for (roop_count = 0; roop_count < (int) share->link_count; roop_count++) - { - if (!write_request) - { - DBUG_PRINT("info",("spider spider_use_hs_read=%d", - spider_param_use_hs_read(thd, share->use_hs_reads[roop_count]))); - DBUG_PRINT("info",("spider use_hs_reads[%d]=%ld", roop_count, - share->use_hs_reads[roop_count])); - if (spider_param_use_hs_read(thd, share->use_hs_reads[roop_count])) - { - DBUG_PRINT("info",("spider set %d to HS_READ", roop_count)); - conn_kinds |= SPIDER_CONN_KIND_HS_READ; - conn_kind[roop_count] = SPIDER_CONN_KIND_HS_READ; - } else { - conn_kinds |= SPIDER_CONN_KIND_MYSQL; - conn_kind[roop_count] = SPIDER_CONN_KIND_MYSQL; - } - } else if (share->hs_write_to_reads[roop_count]) - { - DBUG_PRINT("info",("spider spider_use_hs_write=%d", - spider_param_use_hs_write(thd, share->use_hs_writes[roop_count]))); - DBUG_PRINT("info",("spider use_hs_write[%d]=%ld", roop_count, - share->use_hs_writes[roop_count])); - if (spider_param_use_hs_write(thd, share->use_hs_writes[roop_count])) - { - DBUG_PRINT("info",("spider set %d to HS_WRITE", roop_count)); - conn_kinds |= SPIDER_CONN_KIND_HS_READ; - conn_kind[roop_count] = SPIDER_CONN_KIND_HS_READ; - } else { - conn_kinds |= SPIDER_CONN_KIND_MYSQL; - conn_kind[roop_count] = SPIDER_CONN_KIND_MYSQL; - } - } else { - DBUG_PRINT("info",("spider spider_use_hs_write=%d", - spider_param_use_hs_write(thd, share->use_hs_writes[roop_count]))); - DBUG_PRINT("info",("spider use_hs_write[%d]=%ld", roop_count, - share->use_hs_writes[roop_count])); - if (spider_param_use_hs_write(thd, share->use_hs_writes[roop_count])) - { - DBUG_PRINT("info",("spider set %d to HS_WRITE", roop_count)); - conn_kinds |= SPIDER_CONN_KIND_HS_WRITE; - conn_kind[roop_count] = SPIDER_CONN_KIND_HS_WRITE; - } else { - conn_kinds |= SPIDER_CONN_KIND_MYSQL; - conn_kind[roop_count] = SPIDER_CONN_KIND_MYSQL; - } - } - } - break; - case SQLCOM_HS_UPDATE: - case SQLCOM_HS_DELETE: - conn_kinds |= SPIDER_CONN_KIND_MYSQL; - for (roop_count = 0; roop_count < (int) share->link_count; roop_count++) - { - conn_kind[roop_count] = SPIDER_CONN_KIND_MYSQL; - } - break; - case SQLCOM_HS_INSERT: - for (roop_count = 0; roop_count < (int) share->link_count; roop_count++) - { - DBUG_PRINT("info",("spider spider_use_hs_write=%d", - spider_param_use_hs_write(thd, share->use_hs_writes[roop_count]))); - DBUG_PRINT("info",("spider use_hs_write[%d]=%ld", roop_count, - share->use_hs_writes[roop_count])); - if (spider_param_use_hs_write(thd, share->use_hs_writes[roop_count])) - { - DBUG_PRINT("info",("spider set %d to HS_WRITE", roop_count)); - conn_kinds |= SPIDER_CONN_KIND_HS_WRITE; - conn_kind[roop_count] = SPIDER_CONN_KIND_HS_WRITE; - } else { - conn_kinds |= SPIDER_CONN_KIND_MYSQL; - conn_kind[roop_count] = SPIDER_CONN_KIND_MYSQL; - } - } - break; -#endif case SQLCOM_UPDATE: case SQLCOM_UPDATE_MULTI: case SQLCOM_DELETE: @@ -873,12 +742,6 @@ int ha_spider::check_access_kind_for_connection( } break; } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if ((error_num = reset_hs_strs_pos(SPIDER_SQL_TYPE_UPDATE_HS))) - { - DBUG_RETURN(error_num); - } -#endif if ((error_num = spider_check_trx_and_get_conn(thd, this, TRUE))) { DBUG_RETURN(error_num); @@ -913,17 +776,9 @@ void ha_spider::check_access_kind( DBUG_PRINT("info",("spider sql_command=%u", wide_handler->sql_command)); DBUG_PRINT("info",("spider thd->query_id=%lld", thd->query_id)); #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS -#ifdef HS_HAS_SQLCOM - if (wide_handler->sql_command == SQLCOM_HS_UPDATE) - wide_handler->update_request = TRUE; - else -#endif wide_handler->update_request = FALSE; #else if ( -#ifdef HS_HAS_SQLCOM - wide_handler->sql_command == SQLCOM_HS_UPDATE || -#endif wide_handler->sql_command == SQLCOM_UPDATE || wide_handler->sql_command == SQLCOM_UPDATE_MULTI || /* for triggers */ @@ -1006,9 +861,6 @@ THR_LOCK_DATA **ha_spider::store_lock( { case SQLCOM_SELECT: case SQLCOM_HA_READ: -#ifdef HS_HAS_SQLCOM - case SQLCOM_HS_READ: -#endif if (lock_type == TL_READ_WITH_SHARED_LOCKS) wide_handler->lock_mode = 1; else if (lock_type <= TL_READ_NO_INSERT) @@ -1021,9 +873,6 @@ THR_LOCK_DATA **ha_spider::store_lock( break; case SQLCOM_UPDATE: case SQLCOM_UPDATE_MULTI: -#ifdef HS_HAS_SQLCOM - case SQLCOM_HS_UPDATE: -#endif case SQLCOM_CREATE_TABLE: case SQLCOM_INSERT: case SQLCOM_INSERT_SELECT: @@ -1032,10 +881,6 @@ THR_LOCK_DATA **ha_spider::store_lock( case SQLCOM_REPLACE: case SQLCOM_REPLACE_SELECT: case SQLCOM_DELETE_MULTI: -#ifdef HS_HAS_SQLCOM - case SQLCOM_HS_INSERT: - case SQLCOM_HS_DELETE: -#endif if (lock_type >= TL_READ && lock_type <= TL_READ_NO_INSERT) { wide_handler->lock_mode = -2; @@ -1478,13 +1323,6 @@ int ha_spider::reset() ft_count = 0; ft_init_without_index_init = FALSE; sql_kinds = 0; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS - hs_pushed_ret_fields_num = MAX_FIELDS; - hs_increment = FALSE; - hs_decrement = FALSE; -#endif -#endif #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS do_direct_update = FALSE; #endif @@ -1492,10 +1330,6 @@ int ha_spider::reset() result_list.have_sql_kind_backup = FALSE; result_list.direct_order_limit = FALSE; result_list.direct_limit_offset = FALSE; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if ((error_num2 = reset_hs_strs(SPIDER_SQL_TYPE_UPDATE_HS))) - error_num = error_num2; -#endif result_list.set_split_read = FALSE; result_list.insert_dup_update_pushdown = FALSE; use_spatial_index = FALSE; @@ -1687,12 +1521,6 @@ int ha_spider::index_init( if ((error_num = reset_sql_sql( SPIDER_SQL_TYPE_SELECT_SQL | SPIDER_SQL_TYPE_HANDLER))) DBUG_RETURN(error_num); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if ((error_num = reset_hs_sql(SPIDER_SQL_TYPE_SELECT_HS))) - DBUG_RETURN(error_num); - if ((error_num = reset_hs_keys(SPIDER_SQL_TYPE_SELECT_HS))) - DBUG_RETURN(error_num); -#endif result_list.check_direct_order_limit = FALSE; prev_index_rnd_init = SPD_INDEX; DBUG_RETURN(0); @@ -1801,10 +1629,6 @@ int ha_spider::index_read_map_internal( if ((error_num = reset_sql_sql( SPIDER_SQL_TYPE_SELECT_SQL | SPIDER_SQL_TYPE_HANDLER))) DBUG_RETURN(error_num); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if ((error_num = reset_hs_keys(SPIDER_SQL_TYPE_SELECT_HS))) - DBUG_RETURN(error_num); -#endif #ifndef WITHOUT_SPIDER_BG_SEARCH if ((error_num = spider_set_conn_bg_param(this))) DBUG_RETURN(error_num); @@ -1892,18 +1716,6 @@ int ha_spider::index_read_map_internal( DBUG_RETURN(error_num); } } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (sql_kinds & SPIDER_SQL_KIND_HS) - { - if ((error_num = append_limit_hs_part( - result_list.internal_offset, - result_list.limit_num, - SPIDER_SQL_TYPE_SELECT_HS))) - { - DBUG_RETURN(error_num); - } - } -#endif int roop_start, roop_end, lock_mode, link_ok; lock_mode = spider_conn_lock_mode(this); @@ -1964,10 +1776,6 @@ int ha_spider::index_read_map_internal( } else { #endif ulong sql_type; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (conn_kind[roop_count] == SPIDER_CONN_KIND_MYSQL) - { -#endif conn = conns[roop_count]; if (sql_kind[roop_count] == SPIDER_SQL_KIND_SQL) { @@ -1975,15 +1783,6 @@ int ha_spider::index_read_map_internal( } else { sql_type = SPIDER_SQL_TYPE_HANDLER; } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else { - if (conn_kind[roop_count] == SPIDER_CONN_KIND_HS_READ) - conn = hs_r_conns[roop_count]; - else - conn = hs_w_conns[roop_count]; - sql_type = SPIDER_SQL_TYPE_SELECT_HS; - } -#endif spider_db_handler *dbton_hdl = dbton_handler[conn->dbton_id]; pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); if ((error_num = dbton_hdl->set_sql_for_exec(sql_type, roop_count))) @@ -2217,19 +2016,7 @@ int ha_spider::index_read_map( conn_link_idx, roop_count, share->link_count, SPIDER_LINK_STATUS_RECOVERY) ) { -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (conn_kind[roop_count] == SPIDER_CONN_KIND_MYSQL) - { -#endif conn = conns[roop_count]; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else { - if (conn_kind[roop_count] == SPIDER_CONN_KIND_HS_READ) - conn = hs_r_conns[roop_count]; - else - conn = hs_w_conns[roop_count]; - } -#endif if ((tmp_error_num = spider_db_bulk_store_result(this, conn, roop_count, (roop_count != link_ok)))) { @@ -2303,14 +2090,7 @@ int ha_spider::index_read_last_map_internal( spider_db_free_one_result_for_start_next(this); */ if ( -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - ( - result_list.hs_has_result || -#endif result_list.current -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - ) -#endif && (error_num = spider_db_free_result(this, FALSE)) ) @@ -2323,10 +2103,6 @@ int ha_spider::index_read_last_map_internal( if ((error_num = reset_sql_sql( SPIDER_SQL_TYPE_SELECT_SQL | SPIDER_SQL_TYPE_HANDLER))) DBUG_RETURN(error_num); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if ((error_num = reset_hs_keys(SPIDER_SQL_TYPE_SELECT_HS))) - DBUG_RETURN(error_num); -#endif #ifndef WITHOUT_SPIDER_BG_SEARCH if ((error_num = spider_set_conn_bg_param(this))) DBUG_RETURN(error_num); @@ -2462,10 +2238,6 @@ int ha_spider::index_read_last_map_internal( } else { #endif ulong sql_type; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (conn_kind[roop_count] == SPIDER_CONN_KIND_MYSQL) - { -#endif conn = conns[roop_count]; if (sql_kind[roop_count] == SPIDER_SQL_KIND_SQL) { @@ -2473,15 +2245,6 @@ int ha_spider::index_read_last_map_internal( } else { sql_type = SPIDER_SQL_TYPE_HANDLER; } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else { - if (conn_kind[roop_count] == SPIDER_CONN_KIND_HS_READ) - conn = hs_r_conns[roop_count]; - else - conn = hs_w_conns[roop_count]; - sql_type = SPIDER_SQL_TYPE_SELECT_HS; - } -#endif spider_db_handler *dbton_hdl = dbton_handler[conn->dbton_id]; pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); if ((error_num = dbton_hdl->set_sql_for_exec(sql_type, roop_count))) @@ -2782,9 +2545,6 @@ int ha_spider::index_first_internal( pt_clone_source_handler->pt_clone_last_searcher = this; } if ( -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - result_list.hs_has_result || -#endif sql_is_empty(SPIDER_SQL_TYPE_HANDLER) || sql_is_empty(SPIDER_SQL_TYPE_SELECT_SQL) ) { @@ -2934,10 +2694,6 @@ int ha_spider::index_first_internal( } else { #endif ulong sql_type; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (conn_kind[roop_count] == SPIDER_CONN_KIND_MYSQL) - { -#endif conn = conns[roop_count]; if (sql_kind[roop_count] == SPIDER_SQL_KIND_SQL) { @@ -2945,15 +2701,6 @@ int ha_spider::index_first_internal( } else { sql_type = SPIDER_SQL_TYPE_HANDLER; } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else { - if (conn_kind[roop_count] == SPIDER_CONN_KIND_HS_READ) - conn = hs_r_conns[roop_count]; - else - conn = hs_w_conns[roop_count]; - sql_type = SPIDER_SQL_TYPE_SELECT_HS; - } -#endif spider_db_handler *dbton_hdl = dbton_handler[conn->dbton_id]; pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); if ((error_num = @@ -3172,9 +2919,6 @@ int ha_spider::index_last_internal( pt_clone_source_handler->pt_clone_last_searcher = this; } if ( -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - result_list.hs_has_result || -#endif sql_is_empty(SPIDER_SQL_TYPE_HANDLER) || sql_is_empty(SPIDER_SQL_TYPE_SELECT_SQL) ) { @@ -3324,10 +3068,6 @@ int ha_spider::index_last_internal( } else { #endif ulong sql_type; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (conn_kind[roop_count] == SPIDER_CONN_KIND_MYSQL) - { -#endif conn = conns[roop_count]; if (sql_kind[roop_count] == SPIDER_SQL_KIND_SQL) { @@ -3335,15 +3075,6 @@ int ha_spider::index_last_internal( } else { sql_type = SPIDER_SQL_TYPE_HANDLER; } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else { - if (conn_kind[roop_count] == SPIDER_CONN_KIND_HS_READ) - conn = hs_r_conns[roop_count]; - else - conn = hs_w_conns[roop_count]; - sql_type = SPIDER_SQL_TYPE_SELECT_HS; - } -#endif spider_db_handler *dbton_hdl = dbton_handler[conn->dbton_id]; pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); if ((error_num = @@ -3634,10 +3365,6 @@ int ha_spider::read_range_first_internal( if ((error_num = reset_sql_sql( SPIDER_SQL_TYPE_SELECT_SQL | SPIDER_SQL_TYPE_HANDLER))) DBUG_RETURN(error_num); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if ((error_num = reset_hs_keys(SPIDER_SQL_TYPE_SELECT_HS))) - DBUG_RETURN(error_num); -#endif #ifndef WITHOUT_SPIDER_BG_SEARCH if ((error_num = spider_set_conn_bg_param(this))) DBUG_RETURN(error_num); @@ -3774,10 +3501,6 @@ int ha_spider::read_range_first_internal( } else { #endif ulong sql_type; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (conn_kind[roop_count] == SPIDER_CONN_KIND_MYSQL) - { -#endif conn = conns[roop_count]; if (sql_kind[roop_count] == SPIDER_SQL_KIND_SQL) { @@ -3785,15 +3508,6 @@ int ha_spider::read_range_first_internal( } else { sql_type = SPIDER_SQL_TYPE_HANDLER; } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else { - if (conn_kind[roop_count] == SPIDER_CONN_KIND_HS_READ) - conn = hs_r_conns[roop_count]; - else - conn = hs_w_conns[roop_count]; - sql_type = SPIDER_SQL_TYPE_SELECT_HS; - } -#endif spider_db_handler *dbton_hdl = dbton_handler[conn->dbton_id]; pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); if ((error_num = dbton_hdl->set_sql_for_exec(sql_type, roop_count))) @@ -4020,26 +3734,11 @@ void ha_spider::reset_no_where_cond() { uint roop_count; DBUG_ENTER("ha_spider::reset_no_where_cond"); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (sql_kinds & (SPIDER_SQL_KIND_SQL | SPIDER_SQL_KIND_HANDLER)) - { -#endif for (roop_count = 0; roop_count < share->use_sql_dbton_count; roop_count++) { dbton_handler[share->use_sql_dbton_ids[roop_count]]->no_where_cond = FALSE; } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } - if (sql_kinds & SPIDER_SQL_KIND_HS) - { - for (roop_count = 0; roop_count < share->use_hs_dbton_count; roop_count++) - { - dbton_handler[share->use_hs_dbton_ids[roop_count]]->no_where_cond = - FALSE; - } - } -#endif DBUG_VOID_RETURN; } @@ -4047,10 +3746,6 @@ bool ha_spider::check_no_where_cond() { uint roop_count; DBUG_ENTER("ha_spider::check_no_where_cond"); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (sql_kinds & (SPIDER_SQL_KIND_SQL | SPIDER_SQL_KIND_HANDLER)) - { -#endif for (roop_count = 0; roop_count < share->use_sql_dbton_count; roop_count++) { if (dbton_handler[share->use_sql_dbton_ids[roop_count]]->no_where_cond) @@ -4058,19 +3753,6 @@ bool ha_spider::check_no_where_cond() DBUG_RETURN(TRUE); } } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } - if (sql_kinds & SPIDER_SQL_KIND_HS) - { - for (roop_count = 0; roop_count < share->use_hs_dbton_count; roop_count++) - { - if (dbton_handler[share->use_hs_dbton_ids[roop_count]]->no_where_cond) - { - DBUG_RETURN(TRUE); - } - } - } -#endif DBUG_RETURN(FALSE); } @@ -4272,10 +3954,6 @@ int ha_spider::read_multi_range_first_internal( if ((error_num = reset_sql_sql( SPIDER_SQL_TYPE_SELECT_SQL | SPIDER_SQL_TYPE_HANDLER))) DBUG_RETURN(error_num); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if ((error_num = reset_hs_keys(SPIDER_SQL_TYPE_SELECT_HS))) - DBUG_RETURN(error_num); -#endif result_list.desc_flg = FALSE; #ifdef HA_MRR_USE_DEFAULT_IMPL result_list.sorted = mrr_is_output_sorted; @@ -4437,10 +4115,6 @@ int ha_spider::read_multi_range_first_internal( } else { #endif ulong sql_type; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (conn_kind[roop_count] == SPIDER_CONN_KIND_MYSQL) - { -#endif conn = conns[roop_count]; if (sql_kind[roop_count] == SPIDER_SQL_KIND_SQL) { @@ -4448,15 +4122,6 @@ int ha_spider::read_multi_range_first_internal( } else { sql_type = SPIDER_SQL_TYPE_HANDLER; } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else { - if (conn_kind[roop_count] == SPIDER_CONN_KIND_HS_READ) - conn = hs_r_conns[roop_count]; - else - conn = hs_w_conns[roop_count]; - sql_type = SPIDER_SQL_TYPE_SELECT_HS; - } -#endif spider_db_handler *dbton_hdl = dbton_handler[conn->dbton_id]; pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); if ((error_num = @@ -4786,9 +4451,6 @@ int ha_spider::read_multi_range_first_internal( result_list.tmp_reuse_sql = FALSE; if (bka_mode && have_multi_range && -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - !(sql_kinds & SPIDER_SQL_KIND_HS) && -#endif #ifdef HA_MRR_USE_DEFAULT_IMPL SPIDER_TEST(mrr_cur_range.range_flag & EQ_RANGE) #else @@ -5233,10 +4895,6 @@ int ha_spider::read_multi_range_first_internal( } else { #endif ulong sql_type; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (conn_kind[roop_count] == SPIDER_CONN_KIND_MYSQL) - { -#endif conn = conns[roop_count]; if (sql_kind[roop_count] == SPIDER_SQL_KIND_SQL) { @@ -5244,15 +4902,6 @@ int ha_spider::read_multi_range_first_internal( } else { sql_type = SPIDER_SQL_TYPE_HANDLER; } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else { - if (conn_kind[roop_count] == SPIDER_CONN_KIND_HS_READ) - conn = hs_r_conns[roop_count]; - else - conn = hs_w_conns[roop_count]; - sql_type = SPIDER_SQL_TYPE_SELECT_HS; - } -#endif spider_db_handler *dbton_hdl = dbton_handler[conn->dbton_id]; pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); if ((error_num = @@ -5560,10 +5209,6 @@ int ha_spider::read_multi_range_first_internal( if ((error_num = reset_sql_sql( SPIDER_SQL_TYPE_SELECT_SQL | SPIDER_SQL_TYPE_HANDLER))) DBUG_RETURN(error_num); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if ((error_num = reset_hs_keys(SPIDER_SQL_TYPE_SELECT_HS))) - DBUG_RETURN(error_num); -#endif #ifdef HA_MRR_USE_DEFAULT_IMPL #else multi_range_ranges = multi_range_curr; @@ -5885,10 +5530,6 @@ int ha_spider::read_multi_range_next( } else { #endif ulong sql_type; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (conn_kind[roop_count] == SPIDER_CONN_KIND_MYSQL) - { -#endif conn = conns[roop_count]; if (sql_kind[roop_count] == SPIDER_SQL_KIND_SQL) { @@ -5896,15 +5537,6 @@ int ha_spider::read_multi_range_next( } else { sql_type = SPIDER_SQL_TYPE_HANDLER; } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else { - if (conn_kind[roop_count] == SPIDER_CONN_KIND_HS_READ) - conn = hs_r_conns[roop_count]; - else - conn = hs_w_conns[roop_count]; - sql_type = SPIDER_SQL_TYPE_SELECT_HS; - } -#endif spider_db_handler *dbton_hdl = dbton_handler[conn->dbton_id]; pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); if ((error_num = @@ -6213,10 +5845,6 @@ int ha_spider::read_multi_range_next( if ((error_num = reset_sql_sql( SPIDER_SQL_TYPE_SELECT_SQL | SPIDER_SQL_TYPE_HANDLER))) DBUG_RETURN(error_num); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if ((error_num = reset_hs_keys(SPIDER_SQL_TYPE_SELECT_HS))) - DBUG_RETURN(error_num); -#endif #ifdef HA_MRR_USE_DEFAULT_IMPL #else multi_range_ranges = multi_range_curr; @@ -6253,9 +5881,6 @@ int ha_spider::read_multi_range_next( result_list.tmp_reuse_sql = FALSE; if (bka_mode && have_multi_range && -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - !(sql_kinds & SPIDER_SQL_KIND_HS) && -#endif #ifdef HA_MRR_USE_DEFAULT_IMPL SPIDER_TEST(mrr_cur_range.range_flag & EQ_RANGE) #else @@ -6684,10 +6309,6 @@ int ha_spider::read_multi_range_next( } else { #endif ulong sql_type; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (conn_kind[roop_count] == SPIDER_CONN_KIND_MYSQL) - { -#endif conn = conns[roop_count]; if (sql_kind[roop_count] == SPIDER_SQL_KIND_SQL) { @@ -6695,15 +6316,6 @@ int ha_spider::read_multi_range_next( } else { sql_type = SPIDER_SQL_TYPE_HANDLER; } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else { - if (conn_kind[roop_count] == SPIDER_CONN_KIND_HS_READ) - conn = hs_r_conns[roop_count]; - else - conn = hs_w_conns[roop_count]; - sql_type = SPIDER_SQL_TYPE_SELECT_HS; - } -#endif spider_db_handler *dbton_hdl = dbton_handler[conn->dbton_id]; pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); if ((error_num = @@ -7005,12 +6617,6 @@ int ha_spider::read_multi_range_next( if ((error_num = reset_sql_sql( SPIDER_SQL_TYPE_SELECT_SQL | SPIDER_SQL_TYPE_HANDLER))) DBUG_RETURN(error_num); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if ( - (error_num = reset_hs_keys(SPIDER_SQL_TYPE_SELECT_HS)) - ) - DBUG_RETURN(error_num); -#endif #ifdef HA_MRR_USE_DEFAULT_IMPL #else multi_range_ranges = multi_range_curr; @@ -7125,13 +6731,6 @@ int ha_spider::rnd_init( if ((error_num = reset_sql_sql( SPIDER_SQL_TYPE_SELECT_SQL | SPIDER_SQL_TYPE_HANDLER))) DBUG_RETURN(error_num); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if ( - (error_num = reset_hs_sql(SPIDER_SQL_TYPE_SELECT_HS)) || - (error_num = reset_hs_keys(SPIDER_SQL_TYPE_SELECT_HS)) - ) - DBUG_RETURN(error_num); -#endif result_list.check_direct_order_limit = FALSE; } } @@ -7203,10 +6802,6 @@ int ha_spider::rnd_next_internal( if (rnd_scan_and_first) { -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (sql_kinds & SPIDER_SQL_KIND_HS) - DBUG_RETURN(HA_ERR_WRONG_COMMAND); -#endif #ifndef WITHOUT_SPIDER_BG_SEARCH if ((error_num = spider_set_conn_bg_param(this))) DBUG_RETURN(error_num); @@ -9210,9 +8805,6 @@ ulonglong ha_spider::table_flags() const HA_CAN_TABLE_CONDITION_PUSHDOWN | #endif #ifdef HA_CAN_BULK_ACCESS -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - (support_bulk_access_hs() ? HA_CAN_BULK_ACCESS : 0) | -#endif #endif SPIDER_CAN_BG_SEARCH | SPIDER_CAN_BG_INSERT | @@ -9716,32 +9308,9 @@ void ha_spider::direct_update_init( THD *thd, bool hs_request ) { -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - uint roop_count; -#endif DBUG_ENTER("ha_spider::direct_update_init"); DBUG_PRINT("info",("spider this=%p", this)); do_direct_update = TRUE; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (hs_request) - { - maybe_do_hs_direct_update = TRUE; - memset(do_hs_direct_update, 0, share->link_bitmap_size); - for (roop_count = 0; roop_count < share->link_count; roop_count++) - { - if (spider_param_use_hs_write(thd, share->use_hs_writes[roop_count])) - { - DBUG_PRINT("info",("spider do_hs_direct_update[%d]=TRUE", - roop_count)); - spider_set_bit(do_hs_direct_update, roop_count); - } else { - maybe_do_hs_direct_update = FALSE; - } - } - } else { - maybe_do_hs_direct_update = FALSE; - } -#endif DBUG_VOID_RETURN; } #endif @@ -9929,9 +9498,6 @@ int ha_spider::direct_update_rows_init( ) #endif { -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - int error_num; -#endif st_select_lex *select_lex; longlong select_limit; longlong offset_limit; @@ -9973,11 +9539,7 @@ int ha_spider::direct_update_rows_init( } direct_update_init( thd, -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - sql_command == SQLCOM_HS_UPDATE -#else FALSE -#endif ); if (!condition) cond_check = FALSE; @@ -10025,41 +9587,14 @@ int ha_spider::direct_update_rows_init( DBUG_PRINT("info",("spider offset_limit=%lld", offset_limit)); DBUG_PRINT("info",("spider mode=%u", mode)); DBUG_PRINT("info",("spider sql_command=%u", sql_command)); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - DBUG_PRINT("info",("spider maybe_do_hs_direct_update=%s", - maybe_do_hs_direct_update ? "TRUE" : "FALSE")); - DBUG_PRINT("info",("spider hs_pushed_ret_fields_num=%zu", - hs_pushed_ret_fields_num)); -#endif DBUG_PRINT("info",("spider do_direct_update=%s", do_direct_update ? "TRUE" : "FALSE")); if ( ( !offset_limit -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - || (mode == 2 && maybe_do_hs_direct_update) -#endif ) && -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - sql_command == SQLCOM_HS_UPDATE && - hs_pushed_ret_fields_num < MAX_FIELDS && -#endif do_direct_update ) { -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - DBUG_PRINT("info",("spider pk_update=%s", pk_update ? "TRUE" : "FALSE")); - DBUG_PRINT("info",("spider start_key=%p", &ranges->start_key)); - if (pk_update && spider_check_hs_pk_update(this, &ranges->start_key)) - { - DBUG_PRINT("info",("spider FALSE by pk_update")); - do_direct_update = FALSE; - DBUG_RETURN(HA_ERR_WRONG_COMMAND); - } - if ((error_num = spider_check_trx_and_get_conn(thd, this, TRUE))) - { - DBUG_RETURN(error_num); - } -#endif wide_handler->trx->direct_update_count++; DBUG_PRINT("info",("spider OK")); DBUG_RETURN(0); @@ -10544,9 +10079,6 @@ int ha_spider::direct_delete_rows_init( uint range_count, bool sorted ) { -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - int error_num; -#endif st_select_lex *select_lex; longlong select_limit; longlong offset_limit; @@ -10581,11 +10113,7 @@ int ha_spider::direct_delete_rows_init( } direct_update_init( thd, -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - sql_command == SQLCOM_HS_DELETE -#else FALSE -#endif ); if (!condition) cond_check = FALSE; @@ -10630,21 +10158,9 @@ int ha_spider::direct_delete_rows_init( if ( ( !offset_limit -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - || (mode == 2 && maybe_do_hs_direct_update) -#endif ) && -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - sql_command == SQLCOM_HS_DELETE && -#endif do_direct_update ) { -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if ((error_num = spider_check_trx_and_get_conn(thd, this, TRUE))) - { - DBUG_RETURN(error_num); - } -#endif wide_handler->trx->direct_delete_count++; DBUG_PRINT("info",("spider OK")); DBUG_RETURN(0); @@ -11964,9 +11480,6 @@ int ha_spider::info_push( #ifdef HA_CAN_BULK_ACCESS if ( #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - info_type != INFO_KIND_HS_RET_FIELDS && -#endif #endif info_type != INFO_KIND_BULK_ACCESS_BEGIN && info_type != INFO_KIND_BULK_ACCESS_CURRENT && @@ -11993,144 +11506,6 @@ int ha_spider::info_push( switch (info_type) { #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - case INFO_KIND_HS_RET_FIELDS: - { - DBUG_PRINT("info",("spider INFO_KIND_HS_RET_FIELDS")); - size_t roop_count; - Field *field; - SPIDER_HS_UINT32_INFO *tmp_info = (SPIDER_HS_UINT32_INFO *) info; - wide_handler->hs_pushed_ret_fields_num = tmp_info->info_size; - if (wide_handler->hs_pushed_ret_fields_size < - wide_handler->hs_pushed_ret_fields_num) - { - if (wide_handler->hs_pushed_ret_fields) - spider_free(spider_current_trx, wide_handler->hs_pushed_ret_fields, - MYF(0)); - if (!(wide_handler->hs_pushed_ret_fields = (uint32 *) - spider_bulk_malloc(spider_current_trx, SPD_MID_HA_SPIDER_INFO_PUSH_1, MYF(MY_WME), - &wide_handler->hs_pushed_ret_fields, - sizeof(uint32) * wide_handler->hs_pushed_ret_fields_num, - NullS)) - ) { - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - } - wide_handler->hs_pushed_ret_fields_size = - wide_handler->hs_pushed_ret_fields_num; - } - memcpy(wide_handler->hs_pushed_ret_fields, tmp_info->info, - sizeof(uint32) * wide_handler->hs_pushed_ret_fields_num); - bitmap_clear_all(table->read_set); - bitmap_clear_all(table->write_set); - wide_handler->hs_pushed_lcl_fields_num = 0; - for (roop_count = 0; roop_count < wide_handler->hs_pushed_ret_fields_num; - roop_count++) - { - field = get_top_table_field( - wide_handler->hs_pushed_ret_fields[roop_count]); - if ((field = field_exchange(field))) - { - if (!bitmap_is_set(table->read_set, field->field_index)) - { - ++wide_handler->hs_pushed_lcl_fields_num; - bitmap_set_bit(table->read_set, field->field_index); - bitmap_set_bit(table->write_set, field->field_index); - } - } - } - } - break; - case INFO_KIND_HS_APPEND_STRING_REF: - { - DBUG_PRINT("info",("spider INFO_KIND_HS_APPEND_STRING_REF")); -#ifndef DBUG_OFF - SPIDER_HS_STRING_REF *tmp_ref = (SPIDER_HS_STRING_REF*) info; - char print_buf[MAX_FIELD_WIDTH]; - if (tmp_ref->size() < MAX_FIELD_WIDTH) - { - memcpy(print_buf, tmp_ref->begin(), tmp_ref->size()); - print_buf[tmp_ref->size()] = '\0'; - DBUG_PRINT("info",("spider info=%s", print_buf)); - } -#endif - Field *field; - if (wide_handler->hs_pushed_ret_fields) - { - field = get_top_table_field( - wide_handler->hs_pushed_ret_fields[ - wide_handler->hs_pushed_strref_num]); - } else { - field = get_top_table_field( - pt_clone_source_handler->wide_handler->hs_pushed_ret_fields[ - wide_handler->hs_pushed_strref_num]); - } - if (!field_exchange(field)) - { - wide_handler->hs_pushed_strref_num++; - break; - } - wide_handler->hs_pushed_strref_num++; - if (partition_handler && partition_handler->handlers) - { - size_t roop_count; - ha_spider **handlers = partition_handler->handlers; - for (roop_count = 0; roop_count < partition_handler->no_parts; - ++roop_count) - { - if ((error_num = handlers[roop_count]->push_back_hs_upds( - *((SPIDER_HS_STRING_REF*) info)))) - { - DBUG_RETURN(error_num); - } - } - } else { - if ((error_num = push_back_hs_upds(*((SPIDER_HS_STRING_REF*) info)))) - { - DBUG_RETURN(error_num); - } - } - break; - } - case INFO_KIND_HS_CLEAR_STRING_REF: - DBUG_PRINT("info",("spider INFO_KIND_HS_CLEAR_STRING_REF")); - wide_handler->hs_pushed_strref_num = 0; - if (partition_handler && partition_handler->handlers) - { - size_t roop_count; - ha_spider **handlers = partition_handler->handlers; - for (roop_count = 0; roop_count < partition_handler->no_parts; - ++roop_count) - { - if ((error_num = handlers[roop_count]->reset_hs_upds( - SPIDER_SQL_TYPE_UPDATE_HS))) - { - DBUG_RETURN(error_num); - } - } - } else { - if ((error_num = reset_hs_upds(SPIDER_SQL_TYPE_UPDATE_HS))) - { - DBUG_RETURN(error_num); - } - } - break; - case INFO_KIND_HS_INCREMENT_BEGIN: - DBUG_PRINT("info",("spider INFO_KIND_HS_INCREMENT_BEGIN")); - wide_handler->hs_increment = TRUE; - break; - case INFO_KIND_HS_INCREMENT_END: - DBUG_PRINT("info",("spider INFO_KIND_HS_INCREMENT_END")); - wide_handler->hs_increment = FALSE; - break; - case INFO_KIND_HS_DECREMENT_BEGIN: - DBUG_PRINT("info",("spider INFO_KIND_HS_DECREMENT_BEGIN")); - wide_handler->hs_decrement = TRUE; - break; - case INFO_KIND_HS_DECREMENT_END: - DBUG_PRINT("info",("spider INFO_KIND_HS_DECREMENT_END")); - wide_handler->hs_decrement = FALSE; - break; -#endif #ifdef INFO_KIND_UPDATE_FIELDS case INFO_KIND_UPDATE_FIELDS: DBUG_PRINT("info",("spider INFO_KIND_UPDATE_FIELDS")); @@ -12933,22 +12308,7 @@ bool ha_spider::handler_opened( DBUG_PRINT("info",("spider link_idx=%d", link_idx)); DBUG_PRINT("info",("spider tgt_conn_kind=%u", tgt_conn_kind)); if ( -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - ( - tgt_conn_kind == SPIDER_CONN_KIND_MYSQL && -#endif spider_bit_is_set(m_handler_opened, link_idx) -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - ) || - ( - tgt_conn_kind == SPIDER_CONN_KIND_HS_READ && - spider_bit_is_set(r_handler_opened, link_idx) - ) || - ( - tgt_conn_kind == SPIDER_CONN_KIND_HS_WRITE && - spider_bit_is_set(w_handler_opened, link_idx) - ) -#endif ) { DBUG_PRINT("info",("spider TRUE")); DBUG_RETURN(TRUE); @@ -12962,16 +12322,7 @@ void ha_spider::set_handler_opened( ) { DBUG_ENTER("ha_spider::set_handler_opened"); DBUG_PRINT("info",("spider this=%p", this)); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (conn_kind[link_idx] == SPIDER_CONN_KIND_MYSQL) -#endif spider_set_bit(m_handler_opened, link_idx); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - else if (conn_kind[link_idx] == SPIDER_CONN_KIND_HS_READ) - spider_set_bit(r_handler_opened, link_idx); - else - spider_set_bit(w_handler_opened, link_idx); -#endif DBUG_VOID_RETURN; } @@ -12981,16 +12332,7 @@ void ha_spider::clear_handler_opened( ) { DBUG_ENTER("ha_spider::clear_handler_opened"); DBUG_PRINT("info",("spider this=%p", this)); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (tgt_conn_kind == SPIDER_CONN_KIND_MYSQL) -#endif spider_clear_bit(m_handler_opened, link_idx); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - else if (tgt_conn_kind == SPIDER_CONN_KIND_HS_READ) - spider_clear_bit(r_handler_opened, link_idx); - else - spider_clear_bit(w_handler_opened, link_idx); -#endif DBUG_VOID_RETURN; } @@ -13038,96 +12380,6 @@ int ha_spider::close_opened_handler( conns[link_idx] = NULL; } } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (spider_bit_is_set(r_handler_opened, link_idx)) - { - if ((error_num2 = spider_db_close_handler(this, - hs_r_conns[link_idx], link_idx, SPIDER_CONN_KIND_HS_READ)) - ) { - if ( - share->monitoring_kind[link_idx] && - need_mons[link_idx] - ) { - error_num2 = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - link_idx, - (uint32) share->monitoring_sid[link_idx], - share->table_name, - share->table_name_length, - conn_link_idx[link_idx], - NULL, - 0, - share->monitoring_kind[link_idx], - share->monitoring_limit[link_idx], - share->monitoring_flag[link_idx], - TRUE - ); - } - error_num = error_num2; - } - spider_clear_bit(r_handler_opened, link_idx); - if (release_conn && !hs_w_conns[link_idx]->join_trx) - { - if ( - !hs_r_conns[link_idx]->opened_handlers && - wide_handler->trx->trx_hs_r_conn_adjustment == - trx_hs_r_conn_adjustment && - spider_param_hs_r_conn_recycle_mode(wide_handler->trx->thd) != 2 - ) { - wide_handler->trx->trx_hs_r_conn_adjustment++; - } - spider_free_conn_from_trx(wide_handler->trx, hs_r_conns[link_idx], - FALSE, FALSE, NULL); - hs_r_conns[link_idx] = NULL; - } - } - if (spider_bit_is_set(w_handler_opened, link_idx)) - { - if ((error_num2 = spider_db_close_handler(this, - hs_w_conns[link_idx], link_idx, SPIDER_CONN_KIND_HS_WRITE)) - ) { - if ( - share->monitoring_kind[link_idx] && - need_mons[link_idx] - ) { - error_num2 = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - link_idx, - (uint32) share->monitoring_sid[link_idx], - share->table_name, - share->table_name_length, - conn_link_idx[link_idx], - NULL, - 0, - share->monitoring_kind[link_idx], - share->monitoring_limit[link_idx], - share->monitoring_flag[link_idx], - TRUE - ); - } - error_num = error_num2; - } - spider_clear_bit(w_handler_opened, link_idx); - if (release_conn && !hs_w_conns[link_idx]->join_trx) - { - if ( - !hs_w_conns[link_idx]->opened_handlers && - wide_handler->trx->trx_hs_w_conn_adjustment == - trx_hs_w_conn_adjustment && - spider_param_hs_w_conn_recycle_mode(wide_handler->trx->thd) != 2 - ) { - wide_handler->trx->trx_hs_w_conn_adjustment++; - } - spider_free_conn_from_trx(wide_handler->trx, hs_w_conns[link_idx], - FALSE, FALSE, NULL); - hs_w_conns[link_idx] = NULL; - } - } -#endif DBUG_RETURN(error_num); } @@ -13165,31 +12417,8 @@ int ha_spider::index_handler_init() spider_conn_use_handler(this, lock_mode, roop_count) && spider_conn_need_open_handler(this, active_index, roop_count) ) { -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - uint tmp_conn_kind1; -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS - if ( - do_direct_update && - spider_bit_is_set(do_hs_direct_update, roop_count) - ) { - tmp_conn_kind1 = SPIDER_CONN_KIND_HS_WRITE; - } else { -#endif - tmp_conn_kind1 = conn_kind[roop_count]; -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS - } -#endif -#endif if ((error_num = spider_db_open_handler(this, -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - (tmp_conn_kind1 == SPIDER_CONN_KIND_MYSQL ? -#endif conns[roop_count] -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - : tmp_conn_kind1 == SPIDER_CONN_KIND_HS_READ ? - hs_r_conns[roop_count] : hs_w_conns[roop_count] - ) -#endif , roop_count)) ) { if ( @@ -13215,18 +12444,7 @@ int ha_spider::index_handler_init() } DBUG_RETURN(error_num); } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS - uint tmp_conn_kind2 = conn_kind[roop_count]; - conn_kind[roop_count] = tmp_conn_kind1; -#endif -#endif set_handler_opened(roop_count); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS - conn_kind[roop_count] = tmp_conn_kind2; -#endif -#endif } } if (sql_kinds & SPIDER_SQL_KIND_HANDLER) @@ -13288,15 +12506,7 @@ int ha_spider::rnd_handler_init() spider_conn_need_open_handler(this, MAX_KEY, roop_count) ) { if ((error_num = spider_db_open_handler(this, -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - (conn_kind[roop_count] == SPIDER_CONN_KIND_MYSQL ? -#endif conns[roop_count] -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - : conn_kind[roop_count] == SPIDER_CONN_KIND_HS_READ ? - hs_r_conns[roop_count] : hs_w_conns[roop_count] - ) -#endif , roop_count)) ) { if ( @@ -13402,9 +12612,6 @@ void ha_spider::set_error_mode() case SQLCOM_SHOW_CREATE_TRIGGER: case SQLCOM_SHOW_PROFILE: case SQLCOM_SHOW_PROFILES: -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - case SQLCOM_HS_READ: -#endif error_mode = spider_param_error_read_mode(thd, share->error_read_mode); DBUG_PRINT("info",("spider read error_mode=%d", error_mode)); break; @@ -13620,10 +12827,6 @@ int ha_spider::sync_from_clone_source( DBUG_PRINT("info",("spider synced from clone source all")); wide_handler->trx = spider->wide_handler->trx; sql_command = spider->sql_command; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - conn_kinds = spider->conn_kinds; - memcpy(conn_kind, spider->conn_kind, sizeof(uint) * share->link_count); -#endif wide_handler->external_lock_type = spider->wide_handler->external_lock_type; selupd_lock_mode = spider->selupd_lock_mode; @@ -13633,18 +12836,8 @@ int ha_spider::sync_from_clone_source( low_priority = spider->low_priority; memcpy(conns, spider->conns, sizeof(SPIDER_CONN *) * share->link_count); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - memcpy(hs_r_conns, spider->hs_r_conns, - sizeof(SPIDER_CONN *) * share->link_count); - memcpy(hs_w_conns, spider->hs_w_conns, - sizeof(SPIDER_CONN *) * share->link_count); -#endif spider_thread_id = spider->spider_thread_id; trx_conn_adjustment = spider->trx_conn_adjustment; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - trx_hs_r_conn_adjustment = spider->trx_hs_r_conn_adjustment; - trx_hs_w_conn_adjustment = spider->trx_hs_w_conn_adjustment; -#endif search_link_idx = spider->search_link_idx; external_lock_cnt = spider->external_lock_cnt; uint roop_count, dbton_id; @@ -13661,10 +12854,6 @@ int ha_spider::sync_from_clone_source( { DBUG_PRINT("info",("spider synced from clone source")); sql_command = spider->sql_command; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - conn_kinds = spider->conn_kinds; - memcpy(conn_kind, spider->conn_kind, sizeof(uint) * share->link_count); -#endif wide_handler->external_lock_type = spider->wide_handler->external_lock_type; selupd_lock_mode = spider->selupd_lock_mode; @@ -13683,18 +12872,6 @@ int ha_spider::sync_from_clone_source( } #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (spider->hs_pushed_ret_fields_num < MAX_FIELDS) - { - SPIDER_HS_UINT32_INFO tmp_info; - tmp_info.info_size = spider->hs_pushed_ret_fields_num; - tmp_info.info = spider->hs_pushed_ret_fields; - if ((error_num = info_push(INFO_KIND_HS_RET_FIELDS, &tmp_info))) - { - DBUG_RETURN(error_num); - } - } -#endif #endif DBUG_PRINT("info",("spider bulk_access_link->spider->dbton_handler=%p", dbton_handler)); @@ -13756,21 +12933,6 @@ void ha_spider::set_first_link_idx() dbton_hdl->strict_group_by = TRUE; } } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - dbton_id = share->hs_dbton_ids[all_link_idx]; - if (dbton_id < SPIDER_DBTON_SIZE) - { - dbton_hdl = dbton_handler[dbton_id]; - if (dbton_hdl->first_link_idx == -1) - { - dbton_hdl->first_link_idx = roop_count; - } - if (share->strict_group_bys[all_link_idx]) - { - dbton_hdl->strict_group_by = TRUE; - } - } -#endif } DBUG_VOID_RETURN; } @@ -13801,17 +12963,6 @@ void ha_spider::reset_first_link_idx() dbton_hdl->first_link_idx = search_link_idx; } } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - dbton_id = share->hs_dbton_ids[all_link_idx]; - if (dbton_id < SPIDER_DBTON_SIZE) - { - dbton_hdl = dbton_handler[dbton_id]; - if (dbton_hdl->first_link_idx == -1) - { - dbton_hdl->first_link_idx = search_link_idx; - } - } -#endif } DBUG_VOID_RETURN; } @@ -13841,109 +12992,6 @@ int ha_spider::reset_sql_sql( DBUG_RETURN(0); } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -int ha_spider::reset_hs_sql( - ulong sql_type -) { - int error_num; - uint roop_count, dbton_id; - DBUG_ENTER("ha_spider::reset_hs_sql"); - for (roop_count = 0; roop_count < share->use_hs_dbton_count; roop_count++) - { - dbton_id = share->use_hs_dbton_ids[roop_count]; - if ((error_num = dbton_handler[dbton_id]->reset_sql(sql_type))) - { - DBUG_RETURN(error_num); - } - } - DBUG_RETURN(0); -} - -int ha_spider::reset_hs_keys( - ulong sql_type -) { - int error_num; - uint roop_count, dbton_id; - DBUG_ENTER("ha_spider::reset_hs_keys"); - for (roop_count = 0; roop_count < share->use_hs_dbton_count; roop_count++) - { - dbton_id = share->use_hs_dbton_ids[roop_count]; - if ((error_num = dbton_handler[dbton_id]->reset_keys(sql_type))) - { - DBUG_RETURN(error_num); - } - } - DBUG_RETURN(0); -} - -int ha_spider::reset_hs_upds( - ulong sql_type -) { - int error_num; - uint roop_count, dbton_id; - DBUG_ENTER("ha_spider::reset_hs_upds"); - for (roop_count = 0; roop_count < share->use_dbton_count; roop_count++) - { - dbton_id = share->use_dbton_ids[roop_count]; - if ((error_num = dbton_handler[dbton_id]->reset_upds(sql_type))) - { - DBUG_RETURN(error_num); - } - } - DBUG_RETURN(0); -} - -int ha_spider::reset_hs_strs( - ulong sql_type -) { - int error_num; - uint roop_count, dbton_id; - DBUG_ENTER("ha_spider::reset_hs_strs"); - for (roop_count = 0; roop_count < share->use_hs_dbton_count; roop_count++) - { - dbton_id = share->use_hs_dbton_ids[roop_count]; - if ((error_num = dbton_handler[dbton_id]->reset_strs(sql_type))) - { - DBUG_RETURN(error_num); - } - } - DBUG_RETURN(0); -} - -int ha_spider::reset_hs_strs_pos( - ulong sql_type -) { - int error_num; - uint roop_count, dbton_id; - DBUG_ENTER("ha_spider::reset_hs_strs_pos"); - for (roop_count = 0; roop_count < share->use_hs_dbton_count; roop_count++) - { - dbton_id = share->use_hs_dbton_ids[roop_count]; - if ((error_num = dbton_handler[dbton_id]->reset_strs_pos(sql_type))) - { - DBUG_RETURN(error_num); - } - } - DBUG_RETURN(0); -} - -int ha_spider::push_back_hs_upds( - SPIDER_HS_STRING_REF &info -) { - int error_num; - uint roop_count, dbton_id; - DBUG_ENTER("ha_spider::push_back_hs_upds"); - for (roop_count = 0; roop_count < share->use_dbton_count; roop_count++) - { - dbton_id = share->use_dbton_ids[roop_count]; - if ((error_num = dbton_handler[dbton_id]->push_back_upds(info))) - { - DBUG_RETURN(error_num); - } - } - DBUG_RETURN(0); -} -#endif int ha_spider::append_tmp_table_and_sql_for_bka( const key_range *start_key @@ -14067,29 +13115,6 @@ int ha_spider::append_update_sql_part() DBUG_RETURN(0); } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS -int ha_spider::append_increment_update_set_sql_part() -{ - int error_num; - uint roop_count, dbton_id; - spider_db_handler *dbton_hdl; - DBUG_ENTER("ha_spider::append_increment_update_set_sql_part"); - for (roop_count = 0; roop_count < share->use_sql_dbton_count; roop_count++) - { - dbton_id = share->use_sql_dbton_ids[roop_count]; - dbton_hdl = dbton_handler[dbton_id]; - if ( - dbton_hdl->first_link_idx >= 0 && - (error_num = dbton_hdl->append_increment_update_set_part()) - ) { - DBUG_RETURN(error_num); - } - } - DBUG_RETURN(0); -} -#endif -#endif int ha_spider::append_update_set_sql_part() { @@ -14132,27 +13157,6 @@ int ha_spider::append_direct_update_set_sql_part() DBUG_RETURN(0); } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -int ha_spider::append_direct_update_set_hs_part() -{ - int error_num; - uint roop_count, dbton_id; - spider_db_handler *dbton_hdl; - DBUG_ENTER("ha_spider::append_direct_update_set_hs_part"); - for (roop_count = 0; roop_count < share->use_hs_dbton_count; roop_count++) - { - dbton_id = share->use_hs_dbton_ids[roop_count]; - dbton_hdl = dbton_handler[dbton_id]; - if ( - dbton_hdl->first_link_idx >= 0 && - (error_num = dbton_hdl->append_direct_update_set_part()) - ) { - DBUG_RETURN(error_num); - } - } - DBUG_RETURN(0); -} -#endif #endif #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS @@ -14583,31 +13587,6 @@ int ha_spider::append_key_where_sql_part( DBUG_RETURN(0); } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -int ha_spider::append_key_where_hs_part( - const key_range *start_key, - const key_range *end_key, - ulong sql_type -) { - int error_num; - uint roop_count, dbton_id; - spider_db_handler *dbton_hdl; - DBUG_ENTER("ha_spider::append_key_where_hs_part"); - for (roop_count = 0; roop_count < share->use_hs_dbton_count; roop_count++) - { - dbton_id = share->use_hs_dbton_ids[roop_count]; - dbton_hdl = dbton_handler[dbton_id]; - if ( - dbton_hdl->first_link_idx >= 0 && - (error_num = dbton_hdl->append_key_where_part(start_key, end_key, - sql_type)) - ) { - DBUG_RETURN(error_num); - } - } - DBUG_RETURN(0); -} -#endif int ha_spider::append_match_where_sql_part( ulong sql_type @@ -14883,30 +13862,6 @@ int ha_spider::append_limit_sql_part( DBUG_RETURN(0); } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -int ha_spider::append_limit_hs_part( - longlong offset, - longlong limit, - ulong sql_type -) { - int error_num; - uint roop_count, dbton_id; - spider_db_handler *dbton_hdl; - DBUG_ENTER("ha_spider::append_limit_hs_part"); - for (roop_count = 0; roop_count < share->use_hs_dbton_count; roop_count++) - { - dbton_id = share->use_hs_dbton_ids[roop_count]; - dbton_hdl = dbton_handler[dbton_id]; - if ( - dbton_hdl->first_link_idx >= 0 && - (error_num = dbton_hdl->append_limit_part(offset, limit, sql_type)) - ) { - DBUG_RETURN(error_num); - } - } - DBUG_RETURN(0); -} -#endif int ha_spider::reappend_limit_sql_part( longlong offset, @@ -14973,28 +13928,6 @@ int ha_spider::append_insert_values_sql_part( DBUG_RETURN(0); } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -int ha_spider::append_insert_values_hs_part( - ulong sql_type -) { - int error_num; - uint roop_count, dbton_id; - spider_db_handler *dbton_hdl; - DBUG_ENTER("ha_spider::append_insert_values_hs_part"); - for (roop_count = 0; roop_count < share->use_hs_dbton_count; roop_count++) - { - dbton_id = share->use_hs_dbton_ids[roop_count]; - dbton_hdl = dbton_handler[dbton_id]; - if ( - dbton_hdl->first_link_idx >= 0 && - (error_num = dbton_hdl->append_insert_values_part(sql_type)) - ) { - DBUG_RETURN(error_num); - } - } - DBUG_RETURN(0); -} -#endif int ha_spider::append_into_sql_part( ulong sql_type @@ -15039,10 +13972,6 @@ bool ha_spider::is_bulk_insert_exec_period( uint roop_count, dbton_id; spider_db_handler *dbton_hdl; DBUG_ENTER("ha_spider::is_bulk_insert_exec_period"); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (sql_kinds & SPIDER_SQL_KIND_SQL) - { -#endif for (roop_count = 0; roop_count < share->use_sql_dbton_count; roop_count++) { dbton_id = share->use_sql_dbton_ids[roop_count]; @@ -15054,23 +13983,6 @@ bool ha_spider::is_bulk_insert_exec_period( DBUG_RETURN(TRUE); } } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } - if (sql_kinds & SPIDER_SQL_KIND_HS) - { - for (roop_count = 0; roop_count < share->use_hs_dbton_count; roop_count++) - { - dbton_id = share->use_hs_dbton_ids[roop_count]; - dbton_hdl = dbton_handler[dbton_id]; - if ( - dbton_hdl->first_link_idx >= 0 && - dbton_hdl->is_bulk_insert_exec_period(bulk_end) - ) { - DBUG_RETURN(TRUE); - } - } - } -#endif DBUG_RETURN(FALSE); } @@ -15776,21 +14688,6 @@ bool ha_spider::support_use_handler_sql( DBUG_RETURN(TRUE); } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -bool ha_spider::support_bulk_access_hs() const -{ - uint roop_count; - DBUG_ENTER("ha_spider::support_bulk_access_hs"); - if (!share) - DBUG_RETURN(FALSE); - for (roop_count = 0; roop_count < share->all_link_count; roop_count++) - { - if (share->hs_dbton_ids[roop_count] == SPIDER_DBTON_SIZE) - DBUG_RETURN(FALSE); - } - DBUG_RETURN(TRUE); -} -#endif int ha_spider::init_union_table_name_pos_sql() { @@ -15909,10 +14806,6 @@ int ha_spider::lock_tables() DBUG_PRINT("info",("spider lock_table_type=%u", wide_handler->lock_table_type)); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if ((conn_kinds & SPIDER_CONN_KIND_MYSQL)) - { -#endif if (!conns[search_link_idx]) { my_message(ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM, @@ -16031,9 +14924,6 @@ int ha_spider::lock_tables() } } } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } -#endif DBUG_RETURN(0); } @@ -16054,10 +14944,6 @@ int ha_spider::dml_init() { DBUG_RETURN(error_num); } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if ((conn_kinds & SPIDER_CONN_KIND_MYSQL)) - { -#endif if (!conns[search_link_idx]) { my_message(ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM, @@ -16148,91 +15034,6 @@ int ha_spider::dml_init() conns[roop_count]->semi_trx_isolation = -1; } } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else { - reset_first_link_idx(); - } - if ((conn_kinds & SPIDER_CONN_KIND_HS_READ)) - { - SPIDER_CONN *hs_conn; - for ( - roop_count = spider_conn_link_idx_next(share->link_statuses, - conn_link_idx, -1, share->link_count, - SPIDER_LINK_STATUS_RECOVERY); - roop_count < (int) share->link_count; - roop_count = spider_conn_link_idx_next(share->link_statuses, - conn_link_idx, roop_count, share->link_count, - SPIDER_LINK_STATUS_RECOVERY) - ) { - hs_conn = hs_r_conns[roop_count]; - if ( - hs_conn && - hs_conn->hsc_query_id != thd->query_id && - hs_conn->hs_pre_age == hs_conn->hs_age - ) { - double interval = spider_param_hs_ping_interval(thd); - time_t tmp_time = (time_t) time((time_t*) 0); - DBUG_PRINT("info", - ("spider difftime=%f", difftime(tmp_time, hs_conn->ping_time))); - DBUG_PRINT("info", ("spider interval=%f", interval)); - if ( - hs_conn->server_lost || - difftime(tmp_time, hs_conn->ping_time) >= interval - ) { - DBUG_PRINT("info", ("spider hsr[%d] need reconnect", roop_count)); - hs_conn->hs_pre_age++; - hs_conn->ping_time = tmp_time; - } - hs_conn->hsc_query_id = thd->query_id; - } - } - } - if ( -#if defined(HS_HAS_SQLCOM) && defined(HANDLER_HAS_DIRECT_UPDATE_ROWS) - ( -#endif - conn_kinds & SPIDER_CONN_KIND_HS_WRITE -#if defined(HS_HAS_SQLCOM) && defined(HANDLER_HAS_DIRECT_UPDATE_ROWS) - ) || - /* for direct_update */ - wide_handler->sql_command == SQLCOM_HS_UPDATE || - wide_handler->sql_command == SQLCOM_HS_DELETE -#endif - ) { - SPIDER_CONN *hs_conn; - for ( - roop_count = spider_conn_link_idx_next(share->link_statuses, - conn_link_idx, -1, share->link_count, - SPIDER_LINK_STATUS_RECOVERY); - roop_count < (int) share->link_count; - roop_count = spider_conn_link_idx_next(share->link_statuses, - conn_link_idx, roop_count, share->link_count, - SPIDER_LINK_STATUS_RECOVERY) - ) { - hs_conn = hs_w_conns[roop_count]; - if ( - hs_conn && - hs_conn->hsc_query_id != thd->query_id && - hs_conn->hs_pre_age == hs_conn->hs_age - ) { - double interval = spider_param_hs_ping_interval(thd); - time_t tmp_time = (time_t) time((time_t*) 0); - DBUG_PRINT("info", - ("spider difftime=%f", difftime(tmp_time, hs_conn->ping_time))); - DBUG_PRINT("info", ("spider interval=%f", interval)); - if ( - hs_conn->server_lost || - difftime(tmp_time, hs_conn->ping_time) >= interval - ) { - DBUG_PRINT("info", ("spider hsw[%d] need reconnect", roop_count)); - hs_conn->hs_pre_age++; - hs_conn->ping_time = tmp_time; - } - hs_conn->hsc_query_id = thd->query_id; - } - } - } -#endif #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS if (wide_handler->insert_with_update) { @@ -16285,14 +15086,6 @@ int ha_spider::bulk_access_begin( ) { DBUG_RETURN(error_num); } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - memset( - bulk_access_link_current->spider->result_list.hs_r_bulk_open_index, 0, - share->link_bitmap_size); - memset( - bulk_access_link_current->spider->result_list.hs_w_bulk_open_index, 0, - share->link_bitmap_size); -#endif bulk_access_link_current->spider->bulk_access_executing = FALSE; bulk_access_link_current->spider->bulk_access_pre_called = FALSE; bulk_access_link_current->used = TRUE; diff --git a/storage/spider/ha_spider.h b/storage/spider/ha_spider.h index 969fbf850cd..5ccf3d5c4f5 100644 --- a/storage/spider/ha_spider.h +++ b/storage/spider/ha_spider.h @@ -55,10 +55,6 @@ public: SPIDER_SHARE *share; ulonglong spider_thread_id; ulonglong trx_conn_adjustment; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - ulonglong trx_hs_r_conn_adjustment; - ulonglong trx_hs_w_conn_adjustment; -#endif uint mem_calc_id; const char *mem_calc_func_name; const char *mem_calc_file_name; @@ -71,14 +67,6 @@ public: char *conn_keys_first_ptr; char **conn_keys; SPIDER_CONN **conns; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - char **hs_r_conn_keys; - SPIDER_CONN **hs_r_conns; - ulonglong *hs_r_conn_ages; - char **hs_w_conn_keys; - SPIDER_CONN **hs_w_conns; - ulonglong *hs_w_conn_ages; -#endif /* for active-standby mode */ uint *conn_link_idx; uchar *conn_can_fo; @@ -179,27 +167,8 @@ public: uchar *m_handler_opened; uint *m_handler_id; char **m_handler_cid; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - uchar *r_handler_opened; - uint *r_handler_id; - uint *r_handler_index; - uchar *w_handler_opened; - uint *w_handler_id; - uint *w_handler_index; -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS - uchar *do_hs_direct_update; - uint32 **hs_r_ret_fields; - uint32 **hs_w_ret_fields; - size_t *hs_r_ret_fields_num; - size_t *hs_w_ret_fields_num; - uchar *tmp_column_bitmap; -#endif -#endif #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS bool do_direct_update; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - bool maybe_do_hs_direct_update; -#endif uint direct_update_kinds; #endif spider_index_rnd_init prev_index_rnd_init; @@ -938,26 +907,6 @@ public: int reset_sql_sql( ulong sql_type ); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - int reset_hs_sql( - ulong sql_type - ); - int reset_hs_keys( - ulong sql_type - ); - int reset_hs_upds( - ulong sql_type - ); - int reset_hs_strs( - ulong sql_type - ); - int reset_hs_strs_pos( - ulong sql_type - ); - int push_back_hs_upds( - SPIDER_HS_STRING_REF &info - ); -#endif int append_tmp_table_and_sql_for_bka( const key_range *start_key ); @@ -968,17 +917,9 @@ public: int reuse_union_table_and_sql_for_bka(); int append_insert_sql_part(); int append_update_sql_part(); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS - int append_increment_update_set_sql_part(); -#endif -#endif int append_update_set_sql_part(); #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS int append_direct_update_set_sql_part(); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - int append_direct_update_set_hs_part(); -#endif #endif #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS int append_dup_update_pushdown_sql_part( @@ -1045,13 +986,6 @@ public: const key_range *end_key, ulong sql_type ); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - int append_key_where_hs_part( - const key_range *start_key, - const key_range *end_key, - ulong sql_type - ); -#endif int append_match_where_sql_part( ulong sql_type ); @@ -1106,13 +1040,6 @@ public: longlong limit, ulong sql_type ); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - int append_limit_hs_part( - longlong offset, - longlong limit, - ulong sql_type - ); -#endif int reappend_limit_sql_part( longlong offset, longlong limit, @@ -1124,11 +1051,6 @@ public: int append_insert_values_sql_part( ulong sql_type ); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - int append_insert_values_hs_part( - ulong sql_type - ); -#endif int append_into_sql_part( ulong sql_type ); @@ -1197,9 +1119,6 @@ public: bool support_use_handler_sql( int use_handler ); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - bool support_bulk_access_hs() const; -#endif int init_union_table_name_pos_sql(); int set_union_table_name_pos_sql(); int append_lock_tables_list(); diff --git a/storage/spider/hs_client/allocator.hpp b/storage/spider/hs_client/allocator.hpp deleted file mode 100644 index c302e07804e..00000000000 --- a/storage/spider/hs_client/allocator.hpp +++ /dev/null @@ -1,43 +0,0 @@ - -// vim:sw=2:ai - -/* - * Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved. - * Copyright (C) 2011-2017 Kentoku SHIBA - * See COPYRIGHT.txt for details. - */ - -#ifndef DENA_ALLOCATOR_HPP -#define DENA_ALLOCATOR_HPP - -#if 0 -extern "C" { -#include -}; -#define DENA_MALLOC(x) tlsf_malloc(x) -#define DENA_REALLOC(x, y) tlsf_realloc(x, y) -#define DENA_FREE(x) tlsf_free(x) -#define DENA_NEWCHAR(x) static_cast(tlsf_malloc(x)) -#define DENA_DELETE(x) tlsf_free(x) -#endif - -#if 1 -#define DENA_MALLOC(x) malloc(x) -#define DENA_REALLOC(x, y) realloc(x, y) -#define DENA_FREE(x) free(x) -#define DENA_NEWCHAR(x) (new char[x]) -#define DENA_DELETE(x) (delete [] x) -#endif - -#if 1 -#define DENA_ALLOCA_ALLOCATE(typ, len) \ - (typ *) (alloca((len) * sizeof(typ))) -#define DENA_ALLOCA_FREE(x) -#else -#define DENA_ALLOCA_ALLOCATE(typ, len) \ - (typ *) (malloc((len) * sizeof(typ))) -#define DENA_ALLOCA_FREE(x) free(x) -#endif - -#endif - diff --git a/storage/spider/hs_client/auto_addrinfo.hpp b/storage/spider/hs_client/auto_addrinfo.hpp deleted file mode 100644 index 5262ad11d4a..00000000000 --- a/storage/spider/hs_client/auto_addrinfo.hpp +++ /dev/null @@ -1,49 +0,0 @@ - -// vim:sw=2:ai - -/* - * Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved. - * See COPYRIGHT.txt for details. - */ - -#ifndef DENA_AUTO_ADDRINFO_HPP -#define DENA_AUTO_ADDRINFO_HPP - -#ifndef __WIN__ -#include -#endif - -#include "util.hpp" - -namespace dena { - -struct auto_addrinfo : private noncopyable { - auto_addrinfo() : addr(0) { } - ~auto_addrinfo() { - reset(); - } - void reset(addrinfo *a = 0) { - if (addr != 0) { - freeaddrinfo(addr); - } - addr = a; - } - const addrinfo *get() const { return addr; } - int resolve(const char *node, const char *service, int flags = 0, - int family = AF_UNSPEC, int socktype = SOCK_STREAM, int protocol = 0) { - reset(); - addrinfo hints; - hints.ai_flags = flags; - hints.ai_family = family; - hints.ai_socktype = socktype; - hints.ai_protocol = protocol; - return getaddrinfo(node, service, &hints, &addr); - } - private: - addrinfo *addr; -}; - -}; - -#endif - diff --git a/storage/spider/hs_client/auto_file.hpp b/storage/spider/hs_client/auto_file.hpp deleted file mode 100644 index ddd1f8c9196..00000000000 --- a/storage/spider/hs_client/auto_file.hpp +++ /dev/null @@ -1,67 +0,0 @@ - -// vim:sw=2:ai - -/* - * Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved. - * See COPYRIGHT.txt for details. - */ - -#ifndef DENA_AUTO_FILE_HPP -#define DENA_AUTO_FILE_HPP - -/* -#ifndef __WIN__ -#include -#endif -*/ - -#include "util.hpp" - -namespace dena { - -struct auto_file : private noncopyable { - auto_file() : fd(-1) { } - ~auto_file() { - reset(); - } - int get() const { return fd; } - int close() { - if (fd < 0) { - return 0; - } - const int r = ::close(fd); - fd = -1; - return r; - } - void reset(int x = -1) { - if (fd >= 0) { - this->close(); - } - fd = x; - } - private: - int fd; -}; - -/* -struct auto_dir : private noncopyable { - auto_dir() : dp(0) { } - ~auto_dir() { - reset(); - } - DIR *get() const { return dp; } - void reset(DIR *d = 0) { - if (dp != 0) { - closedir(dp); - } - dp = d; - } - private: - DIR *dp; -}; -*/ - -}; - -#endif - diff --git a/storage/spider/hs_client/auto_ptrcontainer.hpp b/storage/spider/hs_client/auto_ptrcontainer.hpp deleted file mode 100644 index 3629f19c8ea..00000000000 --- a/storage/spider/hs_client/auto_ptrcontainer.hpp +++ /dev/null @@ -1,70 +0,0 @@ - -// vim:sw=2:ai - -/* - * Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved. - * Copyright (C) 2011 Kentoku SHIBA - * See COPYRIGHT.txt for details. - */ - -#ifndef DENA_AUTO_PTRCONTAINER_HPP -#define DENA_AUTO_PTRCONTAINER_HPP - -namespace dena { - -/* -template -struct auto_ptrcontainer { - typedef Tcnt container_type; - typedef typename container_type::value_type value_type; - typedef typename container_type::pointer pointer; - typedef typename container_type::reference reference; - typedef typename container_type::const_reference const_reference; - typedef typename container_type::size_type size_type; - typedef typename container_type::difference_type difference_type; - typedef typename container_type::iterator iterator; - typedef typename container_type::const_iterator const_iterator; - typedef typename container_type::reverse_iterator reverse_iterator; - typedef typename container_type::const_reverse_iterator - const_reverse_iterator; - iterator begin() { return cnt.begin(); } - const_iterator begin() const { return cnt.begin(); } - iterator end() { return cnt.end(); } - const_iterator end() const { return cnt.end(); } - reverse_iterator rbegin() { return cnt.rbegin(); } - reverse_iterator rend() { return cnt.rend(); } - const_reverse_iterator rbegin() const { return cnt.rbegin(); } - const_reverse_iterator rend() const { return cnt.rend(); } - size_type size() const { return cnt.size(); } - size_type max_size() const { return cnt.max_size(); } - bool empty() const { return cnt.empty(); } - reference front() { return cnt.front(); } - const_reference front() const { cnt.front(); } - reference back() { return cnt.back(); } - const_reference back() const { cnt.back(); } - void swap(auto_ptrcontainer& x) { cnt.swap(x.cnt); } - ~auto_ptrcontainer() { - for (iterator i = begin(); i != end(); ++i) { - delete *i; - } - } - template void push_back_ptr(Tap& ap) { - cnt.push_back(ap.get()); - ap.release(); - } - void erase_ptr(iterator i) { - delete *i; - cnt.erase(i); - } - reference operator [](size_type n) { return cnt[n]; } - const_reference operator [](size_type n) const { return cnt[n]; } - void clear() { cnt.clear(); } - private: - Tcnt cnt; -}; -*/ - -}; - -#endif - diff --git a/storage/spider/hs_client/config.cpp b/storage/spider/hs_client/config.cpp deleted file mode 100644 index ac5acbccd16..00000000000 --- a/storage/spider/hs_client/config.cpp +++ /dev/null @@ -1,286 +0,0 @@ - -// vim:sw=2:ai - -/* - * Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved. - * Copyright (C) 2011-2017 Kentoku SHIBA - * See COPYRIGHT.txt for details. - */ - -#include -#include "mysql_version.h" -#include "sql_priv.h" -#include "probes_mysql.h" - -#include "config.hpp" - -namespace dena { - -unsigned int verbose_level = 0; - -uchar * -conf_get_key( - conf_param *param, - size_t *length, - my_bool not_used __attribute__ ((unused)) -) { - *length = param->key.length(); - return (uchar*) param->key.ptr(); -} - -config::config() -{ - if (my_hash_init(PSI_INSTRUMENT_ME, &conf_hash, &my_charset_bin, 32, 0, 0, - (my_hash_get_key) conf_get_key, 0, 0)) - init = FALSE; - else - init = TRUE; - return; -} - -config::~config() -{ - if (init) - { - conf_param *param; - while ((param = (conf_param *) my_hash_element(&conf_hash, 0))) - { - my_hash_delete(&conf_hash, (uchar*) param); - delete param; - } - my_hash_free(&conf_hash); - } -} - -conf_param * -config::find(const String& key) const -{ - if (init) - return (conf_param *) my_hash_search(&conf_hash, (const uchar*) key.ptr(), - key.length()); - else - return NULL; -} - -conf_param * -config::find(const char *key) const -{ - if (init) - return (conf_param *) my_hash_search(&conf_hash, (const uchar*) key, - strlen(key)); - else - return NULL; -} - -String -config::get_str(const String& key, const String& def) const -{ - DENA_VERBOSE(30, list_all_params()); - conf_param *param = find(key); - if (!param) { - DENA_VERBOSE(10, fprintf(stderr, "CONFIG: %s=%s(default)\n", key.ptr(), - def.ptr())); - return def; - } - DENA_VERBOSE(10, fprintf(stderr, "CONFIG: %s=%s\n", key.ptr(), - param->val.ptr())); - return param->val; -} - -String -config::get_str(const char *key, const char *def) const -{ - DENA_VERBOSE(30, list_all_params()); - conf_param *param = find(key); - if (!param) { - DENA_VERBOSE(10, fprintf(stderr, "CONFIG: %s=%s(default)\n", key, def)); - return String(def, strlen(def), &my_charset_bin); - } - DENA_VERBOSE(10, fprintf(stderr, "CONFIG: %s=%s\n", - key, param->val.ptr())); - return param->val; -} - -long long -config::get_int(const String& key, long long def) const -{ - int err; - DENA_VERBOSE(30, list_all_params()); - conf_param *param = find(key); - if (!param) { - DENA_VERBOSE(10, fprintf(stderr, "CONFIG: %s=%lld(default)\n", key.ptr(), - def)); - return def; - } - const long long r = my_strtoll10(param->val.ptr(), (char**) NULL, &err); - if (err) { - DENA_VERBOSE(10, fprintf(stderr, "CONFIG: %s=%lld(err)\n", key.ptr(), - def)); - return def; - } - DENA_VERBOSE(10, fprintf(stderr, "CONFIG: %s=%lld\n", key.ptr(), r)); - return r; -} - -long long -config::get_int(const char *key, long long def) const -{ - int err; - DENA_VERBOSE(30, list_all_params()); - conf_param *param = find(key); - if (!param) { - DENA_VERBOSE(10, fprintf(stderr, "CONFIG: %s=%lld(default)\n", key, def)); - return def; - } - const long long r = my_strtoll10(param->val.ptr(), (char**) NULL, &err); - if (err) { - DENA_VERBOSE(10, fprintf(stderr, "CONFIG: %s=%lld(err)\n", key, def)); - return def; - } - DENA_VERBOSE(10, fprintf(stderr, "CONFIG: %s=%lld\n", key, r)); - return r; -} - -bool -config::replace(const char *key, const char *val) -{ - uint32 val_len = strlen(val); - conf_param *param = find(key); - if (!param) { - /* create */ - if (!(param = new conf_param())) - return TRUE; - uint32 key_len = strlen(key); - if ( - param->key.reserve(key_len + 1) || - param->val.reserve(val_len + 1) - ) { - delete param; - return TRUE; - } - param->key.q_append(key, key_len); - param->val.q_append(val, val_len); - param->key.c_ptr_safe(); - param->val.c_ptr_safe(); - if (my_hash_insert(&conf_hash, (uchar*) param)) - { - delete param; - return TRUE; - } - DENA_VERBOSE(10, fprintf(stderr, "CONFIG: %s=%s(create)\n", - param->key.ptr(), param->val.ptr())); - return FALSE; - } - /* replace */ - param->val.length(0); - if (param->val.reserve(val_len + 1)) - return TRUE; - param->val.q_append(val, val_len); - param->val.c_ptr_safe(); - DENA_VERBOSE(10, fprintf(stderr, "CONFIG: %s=%s(replace)\n", - param->key.ptr(), param->val.ptr())); - return FALSE; -} - -bool -config::replace(const char *key, long long val) -{ - char val_str[22]; - sprintf(val_str, "%lld", val); - return replace(key, val_str); -} - -bool -config::compare(const char *key, const char *val) -{ - conf_param *param = find(key); - if (!param) - return FALSE; - return !strcmp(param->val.ptr(), val); -} - -void -config::list_all_params() const -{ - conf_param *param; - DENA_VERBOSE(10, fprintf(stderr, "list_all_params start\n")); - for(ulong i = 0; i < conf_hash.records; i++) - { - if ((param = (conf_param *) my_hash_element((HASH *) &conf_hash, i))) - { - DENA_VERBOSE(10, fprintf(stderr, "CONFIG: %s=%s\n", - param->key.ptr(), param->val.ptr())); - } - } - DENA_VERBOSE(10, fprintf(stderr, "list_all_params end\n")); -} - -config& -config::operator =(const config& x) -{ - DENA_VERBOSE(10, fprintf(stderr, "config operator = start")); - if (this != &x && init && x.init) { - conf_param *param, *new_param; - for(ulong i = 0; i < x.conf_hash.records; i++) - { - if ((param = (conf_param *) my_hash_element((HASH *) &x.conf_hash, i))) - if ((new_param = new conf_param())) - { - if ( - !new_param->key.copy(param->key) && - !new_param->val.copy(param->val) - ) { - new_param->key.c_ptr_safe(); - new_param->val.c_ptr_safe(); - DENA_VERBOSE(10, fprintf(stderr, "CONFIG: %s=%s\n", - new_param->key.ptr(), new_param->val.ptr())); - if (my_hash_insert(&conf_hash, (uchar*) new_param)) - delete new_param; - } else - delete new_param; - } - } - } - DENA_VERBOSE(10, fprintf(stderr, "config operator = end %p", this)); - return *this; -} - -void -parse_args(int argc, char **argv, config& conf) -{ - conf_param *param; - for (int i = 1; i < argc; ++i) { - const char *const arg = argv[i]; - const char *const eq = strchr(arg, '='); - if (eq == 0) { - continue; - } - if (!(param = new conf_param())) - continue; - uint32 key_len = (uint32)(eq - arg); - uint32 val_len = strlen(eq + 1); - if ( - param->key.reserve(key_len + 1) || - param->val.reserve(val_len + 1) - ) { - delete param; - continue; - } - param->key.q_append(arg, key_len); - param->val.q_append(eq + 1, val_len); - param->key.c_ptr_safe(); - param->val.c_ptr_safe(); - if (my_hash_insert(&conf.conf_hash, (uchar*) param)) - { - delete param; - continue; - } - } - param = conf.find("verbose"); - if (param) { - verbose_level = atoi(param->val.c_ptr()); - } -} - -}; - diff --git a/storage/spider/hs_client/config.hpp b/storage/spider/hs_client/config.hpp deleted file mode 100644 index a3a986cc1fd..00000000000 --- a/storage/spider/hs_client/config.hpp +++ /dev/null @@ -1,76 +0,0 @@ - -// vim:sw=2:ai - -/* - * Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved. - * Copyright (C) 2011 Kentoku SHIBA - * See COPYRIGHT.txt for details. - */ - -#ifndef DENA_CONFIG_HPP -#define DENA_CONFIG_HPP - -#include "mysql_version.h" -#include "sql_priv.h" -#include "probes_mysql.h" -#include "sql_class.h" - -#define DENA_VERBOSE(lv, x) if (dena::verbose_level >= (lv)) { (x); } - -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS -#define INFO_KIND_HS_RET_FIELDS 1 -#define INFO_KIND_HS_APPEND_STRING_REF 3 -#define INFO_KIND_HS_CLEAR_STRING_REF 4 -#define INFO_KIND_HS_INCREMENT_BEGIN 5 -#define INFO_KIND_HS_INCREMENT_END 6 -#define INFO_KIND_HS_DECREMENT_BEGIN 7 -#define INFO_KIND_HS_DECREMENT_END 8 -#endif - -namespace dena { - -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS -struct uint32_info { - size_t info_size; - uint32 *info; -}; -#endif - -struct conf_param { - String key; - String val; -}; - -uchar *conf_get_key( - conf_param *share, - size_t *length, - my_bool not_used __attribute__ ((unused)) -); - -struct config { - bool init; - HASH conf_hash; - config(); - ~config(); - conf_param *find(const String& key) const; - conf_param *find(const char *key) const; - String get_str(const String& key, const String& def = - String("", &my_charset_bin)) const; - String get_str(const char *key, const char *def = "") const; - long long get_int(const String& key, long long def = 0) const; - long long get_int(const char *key, long long def = 0) const; - bool replace(const char *key, const char *val); - bool replace(const char *key, long long val); - bool compare(const char *key, const char *val); - void list_all_params() const; - config& operator =(const config& x); -}; - -void parse_args(int argc, char **argv, config& conf); - -extern unsigned int verbose_level; - -}; - -#endif - diff --git a/storage/spider/hs_client/escape.cpp b/storage/spider/hs_client/escape.cpp deleted file mode 100644 index f3e60afc387..00000000000 --- a/storage/spider/hs_client/escape.cpp +++ /dev/null @@ -1,129 +0,0 @@ - -// vim:sw=2:ai - -/* - * Copyright (C) 2010 DeNA Co.,Ltd.. All rights reserved. - * Copyright (C) 2011-2017 Kentoku SHIBA - * See COPYRIGHT.txt for details. - */ - -#include -#include "mysql_version.h" -#include "hs_compat.h" -#include "escape.hpp" -#include "string_buffer.hpp" -#include "fatal.hpp" -#include "string_util.hpp" - -#define DBG_OP(x) -#define DBG_BUF(x) - -namespace dena { - -enum special_char_t { - special_char_escape_prefix = 0x01, /* SOH */ - special_char_noescape_min = 0x10, /* DLE */ - special_char_escape_shift = 0x40, /* '@' */ -}; - -void -escape_string(char *& wp, const char *start, const char *finish) -{ - while (start != finish) { - const unsigned char c = *start; - if (c >= special_char_noescape_min) { - wp[0] = c; /* no need to escape */ - } else { - wp[0] = special_char_escape_prefix; - ++wp; - wp[0] = c + special_char_escape_shift; - } - ++start; - ++wp; - } -} - -void -escape_string(string_buffer& ar, const char *start, const char *finish) -{ - const size_t buflen = (finish - start) * 2; - char *const wp_begin = ar.make_space(buflen); - char *wp = wp_begin; - escape_string(wp, start, finish); - ar.space_wrote(wp - wp_begin); -} - -bool -unescape_string(char *& wp, const char *start, const char *finish) -{ - /* works even if wp == start */ - while (start != finish) { - const unsigned char c = *start; - if (c != special_char_escape_prefix) { - wp[0] = c; - } else if (start + 1 != finish) { - ++start; - const unsigned char cn = *start; - if (cn < special_char_escape_shift) { - return false; - } - wp[0] = cn - special_char_escape_shift; - } else { - return false; - } - ++start; - ++wp; - } - return true; -} - -bool -unescape_string(string_buffer& ar, const char *start, const char *finish) -{ - const size_t buflen = finish - start; - char *const wp_begin = ar.make_space(buflen); - char *wp = wp_begin; - const bool r = unescape_string(wp, start, finish); - ar.space_wrote(wp - wp_begin); - return r; -} - -uint32 -read_ui32(char *& start, char *finish) -{ - char *const n_begin = start; - read_token(start, finish); - char *const n_end = start; - uint32 v = 0; - for (char *p = n_begin; p != n_end; ++p) { - const char ch = p[0]; - if (ch >= '0' && ch <= '9') { - v *= 10; - v += (ch - '0'); - } - } - return v; -} - -void -write_ui32(string_buffer& buf, uint32 v) -{ - char *wp = buf.make_space(12); - int len = snprintf(wp, 12, "%u", v); - if (len > 0) { - buf.space_wrote(len); - } -} - -void -write_ui64(string_buffer& buf, uint64 v) -{ - char *wp = buf.make_space(22); - int len = snprintf(wp, 22, "%llu", static_cast(v)); - if (len > 0) { - buf.space_wrote(len); - } -} - -}; - diff --git a/storage/spider/hs_client/escape.hpp b/storage/spider/hs_client/escape.hpp deleted file mode 100644 index 4c23e16701c..00000000000 --- a/storage/spider/hs_client/escape.hpp +++ /dev/null @@ -1,64 +0,0 @@ - -// vim:sw=2:ai - -/* - * Copyright (C) 2010 DeNA Co.,Ltd.. All rights reserved. - * See COPYRIGHT.txt for details. - */ - -#include "string_buffer.hpp" -#include "string_ref.hpp" -#include "string_util.hpp" - -#ifndef DENA_ESCAPE_HPP -#define DENA_ESCAPE_HPP - -namespace dena { - -void escape_string(char *& wp, const char *start, const char *finish); -void escape_string(string_buffer& ar, const char *start, const char *finish); -bool unescape_string(char *& wp, const char *start, const char *finish); - /* unescaped_string() works even if wp == start */ -bool unescape_string(string_buffer& ar, const char *start, const char *finish); - -uint32 read_ui32(char *& start, char *finish); -void write_ui32(string_buffer& buf, uint32 v); -void write_ui64(string_buffer& buf, uint64 v); - -inline bool -is_null_expression(const char *start, const char *finish) -{ - return (finish == start + 1 && start[0] == 0); -} - -inline void -read_token(char *& start, char *finish) -{ - char *const p = memchr_char(start, '\t', finish - start); - if (p == 0) { - start = finish; - } else { - start = p; - } -} - -inline void -skip_token_delim_fold(char *& start, char *finish) -{ - while (start != finish && start[0] == '\t') { - ++start; - } -} - -inline void -skip_one(char *& start, char *finish) -{ - if (start != finish) { - ++start; - } -} - -}; - -#endif - diff --git a/storage/spider/hs_client/fatal.cpp b/storage/spider/hs_client/fatal.cpp deleted file mode 100644 index 1ed20189a93..00000000000 --- a/storage/spider/hs_client/fatal.cpp +++ /dev/null @@ -1,44 +0,0 @@ - -// vim:sw=2:ai - -/* - * Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved. - * Copyright (C) 2011-2017 Kentoku SHIBA - * See COPYRIGHT.txt for details. - */ - -#include -#include "mysql_version.h" -#include "sql_priv.h" -#include "probes_mysql.h" - -#include "fatal.hpp" - -namespace dena { - -/* -const int opt_syslog = LOG_ERR | LOG_PID | LOG_CONS; -*/ - -void -fatal_abort(const String& message) -{ - fprintf(stderr, "FATAL_COREDUMP: %s\n", message.ptr()); -/* - syslog(opt_syslog, "FATAL_COREDUMP: %s", message.ptr()); -*/ - abort(); -} - -void -fatal_abort(const char *message) -{ - fprintf(stderr, "FATAL_COREDUMP: %s\n", message); -/* - syslog(opt_syslog, "FATAL_COREDUMP: %s", message); -*/ - abort(); -} - -}; - diff --git a/storage/spider/hs_client/fatal.hpp b/storage/spider/hs_client/fatal.hpp deleted file mode 100644 index 859b695baf3..00000000000 --- a/storage/spider/hs_client/fatal.hpp +++ /dev/null @@ -1,26 +0,0 @@ - -// vim:sw=2:ai - -/* - * Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved. - * Copyright (C) 2011-2017 Kentoku SHIBA - * See COPYRIGHT.txt for details. - */ - -#ifndef DENA_FATAL_HPP -#define DENA_FATAL_HPP - -#include "mysql_version.h" -#include "sql_priv.h" -#include "probes_mysql.h" -#include "sql_class.h" - -namespace dena { - -void fatal_abort(const String& message); -void fatal_abort(const char *message); - -}; - -#endif - diff --git a/storage/spider/hs_client/hstcpcli.cpp b/storage/spider/hs_client/hstcpcli.cpp deleted file mode 100644 index 791ee9a9e4c..00000000000 --- a/storage/spider/hs_client/hstcpcli.cpp +++ /dev/null @@ -1,662 +0,0 @@ - -// vim:sw=2:ai - -/* - * Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved. - * Copyright (C) 2011-2017 Kentoku SHIBA - * See COPYRIGHT.txt for details. - */ - -#include -#include "mysql_version.h" -#include "hs_compat.h" -#include "sql_priv.h" -#include "probes_mysql.h" -#include "sql_class.h" - -#include "hstcpcli.hpp" -#include "auto_file.hpp" -#include "string_util.hpp" -#include "auto_addrinfo.hpp" -#include "escape.hpp" -#include "util.hpp" - -/* TODO */ -#if !defined(__linux__) && !defined(__FreeBSD__) && !defined(MSG_NOSIGNAL) -#define MSG_NOSIGNAL 0 -#endif - -#define DBG(x) - -namespace dena { - -hstresult::hstresult() -{ - SPD_INIT_DYNAMIC_ARRAY2(&flds, sizeof(string_ref), NULL, 16, 16, - MYF(MY_WME)); -} - -hstresult::~hstresult() -{ - delete_dynamic(&flds); -} - -struct hstcpcli : public hstcpcli_i, private noncopyable { - hstcpcli(const socket_args& args); - virtual ~hstcpcli(); - virtual void close(); - virtual int reconnect(); - virtual bool stable_point(); - virtual void request_buf_open_index(size_t pst_id, const char *dbn, - const char *tbl, const char *idx, const char *retflds, const char *filflds); - virtual void request_buf_auth(const char *secret, const char *typ); - virtual void request_buf_exec_generic(size_t pst_id, const string_ref& op, - const string_ref *kvs, size_t kvslen, uint32 limit, uint32 skip, - const string_ref& mod_op, const string_ref *mvs, size_t mvslen, - const hstcpcli_filter *fils, size_t filslen, int invalues_keypart, - const string_ref *invalues, size_t invalueslen); - virtual size_t request_buf_append(const char *start, const char *finish); - virtual void request_reset(); - virtual int request_send(); - virtual int response_recv(size_t& num_flds_r); - virtual int get_result(hstresult& result); - virtual const string_ref *get_next_row(); - virtual const string_ref *get_next_row_from_result(hstresult& result); - virtual size_t get_row_size(); - virtual size_t get_row_size_from_result(hstresult& result); - virtual void response_buf_remove(); - virtual int get_error_code(); - virtual String& get_error(); - virtual void clear_error(); - virtual int set_timeout(int send_timeout, int recv_timeout); - virtual size_t get_num_req_bufd() { return num_req_bufd; } - virtual size_t get_num_req_sent() { return num_req_sent; } - virtual size_t get_num_req_rcvd() { return num_req_rcvd; } - virtual size_t get_response_end_offset() { return response_end_offset; } - virtual const char *get_readbuf_begin() { return readbuf.begin(); } - virtual const char *get_readbuf_end() { return readbuf.end(); } - virtual const char *get_writebuf_begin() { return writebuf.begin(); } - virtual size_t get_writebuf_size() { return writebuf.size(); } - virtual void write_error_to_log(const char *func_name, const char *file_name, - ulong line_no); - private: - int read_more(); - int set_error(int code, const String& str); - int set_error(int code, const char *str); - private: - auto_file fd; - socket_args sargs; - string_buffer readbuf; - string_buffer writebuf; - size_t response_end_offset; /* incl newline */ - size_t cur_row_offset; - size_t cur_row_size; - size_t num_flds; - size_t num_req_bufd; /* buffered but not yet sent */ - size_t num_req_sent; /* sent but not yet received */ - size_t num_req_rcvd; /* received but not yet removed */ - int error_code; - String error_str; - DYNAMIC_ARRAY flds; - int errno_buf; -}; - -hstcpcli::hstcpcli(const socket_args& args) - : sargs(args), response_end_offset(0), cur_row_offset(0), cur_row_size(0), - num_flds(0), num_req_bufd(0), num_req_sent(0), num_req_rcvd(0), - error_code(0), errno_buf(0) -{ - String err; - SPD_INIT_DYNAMIC_ARRAY2(&flds, sizeof(string_ref), NULL, 16, 16, MYF(MY_WME)); - if (socket_connect(fd, sargs, err) != 0) { - set_error(-1, err); - } -} - -hstcpcli::~hstcpcli() -{ - delete_dynamic(&flds); -} - -void -hstcpcli::close() -{ - fd.close(); - readbuf.clear(); - writebuf.clear(); - response_end_offset = 0; - cur_row_offset = 0; - num_flds = 0; - num_req_bufd = 0; - num_req_sent = 0; - num_req_rcvd = 0; -} - -int -hstcpcli::reconnect() -{ - clear_error(); - close(); - String err; - if (socket_connect(fd, sargs, err) != 0) { - set_error(-1, err); - } - return error_code; -} - -int -hstcpcli::set_timeout(int send_timeout, int recv_timeout) -{ - String err; - sargs.send_timeout = send_timeout; - sargs.recv_timeout = recv_timeout; - if (socket_set_timeout(fd, sargs, err) != 0) { - set_error(-1, err); - } - return error_code; -} - -bool -hstcpcli::stable_point() -{ - /* returns true if cli can send a new request */ - return fd.get() >= 0 && num_req_bufd == 0 && num_req_sent == 0 && - num_req_rcvd == 0 && response_end_offset == 0; -} - -int -hstcpcli::get_error_code() -{ - return error_code; -} - -String& -hstcpcli::get_error() -{ - return error_str; -} - -int -hstcpcli::read_more() -{ - const size_t block_size = 4096; // FIXME - char *const wp = readbuf.make_space(block_size); - int rlen; - errno = 0; - while ((rlen = read(fd.get(), wp, block_size)) <= 0) { - errno_buf = errno; - if (rlen < 0) { - if (errno == EINTR || errno == EAGAIN) - { - errno = 0; - continue; - } - error_str = String("read: failed", &my_charset_bin); - } else { - error_str = String("read: eof", &my_charset_bin); - } - return rlen; - } - readbuf.space_wrote(rlen); - return rlen; -} - -void -hstcpcli::clear_error() -{ - DBG(fprintf(stderr, "CLEAR_ERROR: %d\n", error_code)); - error_code = 0; - error_str.length(0); -} - -int -hstcpcli::set_error(int code, const String& str) -{ - DBG(fprintf(stderr, "SET_ERROR: %d\n", code)); - error_code = code; - error_str = str; - return error_code; -} - -int -hstcpcli::set_error(int code, const char *str) -{ - uint32 str_len = strlen(str); - DBG(fprintf(stderr, "SET_ERROR: %d\n", code)); - error_code = code; - error_str.length(0); - if (error_str.reserve(str_len + 1)) - return 0; - error_str.q_append(str, str_len); - error_str.c_ptr_safe(); - return error_code; -} - -void -hstcpcli::request_buf_open_index(size_t pst_id, const char *dbn, - const char *tbl, const char *idx, const char *retflds, const char *filflds) -{ -/* - if (num_req_sent > 0 || num_req_rcvd > 0) { -*/ - if (num_req_rcvd > 0) { - close(); - set_error(-1, "request_buf_open_index: protocol out of sync"); - return; - } - const string_ref dbn_ref(dbn, strlen(dbn)); - const string_ref tbl_ref(tbl, strlen(tbl)); - const string_ref idx_ref(idx, strlen(idx)); - const string_ref rfs_ref(retflds, strlen(retflds)); - writebuf.append_literal("P\t"); - append_uint32(writebuf, pst_id); // FIXME size_t ? - writebuf.append_literal("\t"); - writebuf.append(dbn_ref.begin(), dbn_ref.end()); - writebuf.append_literal("\t"); - writebuf.append(tbl_ref.begin(), tbl_ref.end()); - writebuf.append_literal("\t"); - writebuf.append(idx_ref.begin(), idx_ref.end()); - writebuf.append_literal("\t"); - writebuf.append(rfs_ref.begin(), rfs_ref.end()); - if (filflds != 0) { - const string_ref fls_ref(filflds, strlen(filflds)); - writebuf.append_literal("\t"); - writebuf.append(fls_ref.begin(), fls_ref.end()); - } - writebuf.append_literal("\n"); - ++num_req_bufd; -} - -void -hstcpcli::request_buf_auth(const char *secret, const char *typ) -{ -/* - if (num_req_sent > 0 || num_req_rcvd > 0) { -*/ - if (num_req_rcvd > 0) { - close(); - set_error(-1, "request_buf_auth: protocol out of sync"); - return; - } - if (typ == 0) { - typ = "1"; - } - const string_ref typ_ref(typ, strlen(typ)); - const string_ref secret_ref(secret, strlen(secret)); - writebuf.append_literal("A\t"); - writebuf.append(typ_ref.begin(), typ_ref.end()); - writebuf.append_literal("\t"); - writebuf.append(secret_ref.begin(), secret_ref.end()); - writebuf.append_literal("\n"); - ++num_req_bufd; -} - -namespace { - -void -append_delim_value(string_buffer& buf, const char *start, const char *finish) -{ - if (start == 0) { - /* null */ - const char t[] = "\t\0"; - buf.append(t, t + 2); - } else { - /* non-null */ - buf.append_literal("\t"); - escape_string(buf, start, finish); - } -} - -}; - -void -hstcpcli::request_buf_exec_generic(size_t pst_id, const string_ref& op, - const string_ref *kvs, size_t kvslen, uint32 limit, uint32 skip, - const string_ref& mod_op, const string_ref *mvs, size_t mvslen, - const hstcpcli_filter *fils, size_t filslen, int invalues_keypart, - const string_ref *invalues, size_t invalueslen) -{ -/* - if (num_req_sent > 0 || num_req_rcvd > 0) { -*/ - if (num_req_rcvd > 0) { - close(); - set_error(-1, "request_buf_exec_generic: protocol out of sync"); - return; - } - append_uint32(writebuf, pst_id); // FIXME size_t ? - writebuf.append_literal("\t"); - writebuf.append(op.begin(), op.end()); - writebuf.append_literal("\t"); - append_uint32(writebuf, kvslen); // FIXME size_t ? - for (size_t i = 0; i < kvslen; ++i) { - const string_ref& kv = kvs[i]; - append_delim_value(writebuf, kv.begin(), kv.end()); - } - if (limit != 0 || skip != 0 || invalues_keypart >= 0 || - mod_op.size() != 0 || filslen != 0) { - /* has more option */ - writebuf.append_literal("\t"); - append_uint32(writebuf, limit); // FIXME size_t ? - if (skip != 0 || invalues_keypart >= 0 || - mod_op.size() != 0 || filslen != 0) { - writebuf.append_literal("\t"); - append_uint32(writebuf, skip); // FIXME size_t ? - } - if (invalues_keypart >= 0) { - writebuf.append_literal("\t@\t"); - append_uint32(writebuf, invalues_keypart); - writebuf.append_literal("\t"); - append_uint32(writebuf, invalueslen); - for (size_t i = 0; i < invalueslen; ++i) { - const string_ref& s = invalues[i]; - append_delim_value(writebuf, s.begin(), s.end()); - } - } - for (size_t i = 0; i < filslen; ++i) { - const hstcpcli_filter& f = fils[i]; - writebuf.append_literal("\t"); - writebuf.append(f.filter_type.begin(), f.filter_type.end()); - writebuf.append_literal("\t"); - writebuf.append(f.op.begin(), f.op.end()); - writebuf.append_literal("\t"); - append_uint32(writebuf, f.ff_offset); - append_delim_value(writebuf, f.val.begin(), f.val.end()); - } - if (mod_op.size() != 0) { - writebuf.append_literal("\t"); - writebuf.append(mod_op.begin(), mod_op.end()); - for (size_t i = 0; i < mvslen; ++i) { - const string_ref& mv = mvs[i]; - append_delim_value(writebuf, mv.begin(), mv.end()); - } - } - } - writebuf.append_literal("\n"); - ++num_req_bufd; -} - -size_t -hstcpcli::request_buf_append(const char *start, const char *finish) -{ -/* - if (num_req_sent > 0 || num_req_rcvd > 0) { -*/ - if (num_req_rcvd > 0) { - close(); - set_error(-1, "request_buf_append: protocol out of sync"); - return 0; - } - const char *nl = start; - size_t num_req = 0; - while ((nl = memchr_char(nl, '\n', finish - nl))) { - if (nl == finish) - break; - num_req++; - nl++; - } - num_req++; - writebuf.append(start, finish); - if (*(finish - 1) != '\n') - writebuf.append_literal("\n"); - num_req_bufd += num_req; - return num_req; -} - -void -hstcpcli::request_reset() -{ - if (num_req_bufd) { - writebuf.erase_front(writebuf.size()); - num_req_bufd = 0; - } -} - -int -hstcpcli::request_send() -{ - if (error_code < 0) { - return error_code; - } - clear_error(); - if (fd.get() < 0) { - close(); - return set_error(-1, "write: closed"); - } -/* - if (num_req_bufd == 0 || num_req_sent > 0 || num_req_rcvd > 0) { -*/ - if (num_req_bufd == 0 || num_req_rcvd > 0) { - close(); - return set_error(-1, "request_send: protocol out of sync"); - } - const size_t wrlen = writebuf.size(); - const ssize_t r = send(fd.get(), writebuf.begin(), wrlen, MSG_NOSIGNAL); - if (r <= 0) { - close(); - return set_error(-1, r < 0 ? "write: failed" : "write: eof"); - } - writebuf.erase_front(r); - if (static_cast(r) != wrlen) { - close(); - return set_error(-1, "write: incomplete"); - } - num_req_sent += num_req_bufd; - num_req_bufd = 0; - DBG(fprintf(stderr, "REQSEND 0\n")); - return 0; -} - -int -hstcpcli::response_recv(size_t& num_flds_r) -{ - if (error_code < 0) { - return error_code; - } - clear_error(); - if (num_req_bufd > 0 || num_req_sent == 0 || num_req_rcvd > 0 || - response_end_offset != 0) { - close(); - return set_error(-1, "response_recv: protocol out of sync"); - } - cur_row_offset = 0; - num_flds_r = num_flds = 0; - if (fd.get() < 0) { - return set_error(-1, "read: closed"); - } - size_t offset = 0; - while (true) { - const char *const lbegin = readbuf.begin() + offset; - const char *const lend = readbuf.end(); - if (lbegin < lend) - { - const char *const nl = memchr_char(lbegin, '\n', lend - lbegin); - if (nl != 0) { - offset += (nl + 1) - lbegin; - break; - } - offset += lend - lbegin; - } - if (read_more() <= 0) { - close(); - error_code = -1; - return error_code; - } - } - response_end_offset = offset; - --num_req_sent; - ++num_req_rcvd; - char *start = readbuf.begin(); - char *const finish = start + response_end_offset - 1; - const size_t resp_code = read_ui32(start, finish); - skip_one(start, finish); - num_flds_r = num_flds = read_ui32(start, finish); - if (resp_code != 0) { - skip_one(start, finish); - char *const err_begin = start; - read_token(start, finish); - char *const err_end = start; - String e = String(err_begin, (uint32)(err_end - err_begin), &my_charset_bin); - if (!e.length()) { - e = String("unknown_error", &my_charset_bin); - } - return set_error(resp_code, e); - } - cur_row_size = 0; - cur_row_offset = start - readbuf.begin(); - DBG(fprintf(stderr, "[%s] ro=%zu eol=%zu\n", - String(readbuf.begin(), readbuf.begin() + response_end_offset) - .c_str(), - cur_row_offset, response_end_offset)); - DBG(fprintf(stderr, "RES 0\n")); - if (flds.max_element < num_flds) - { - if (allocate_dynamic(&flds, num_flds)) - return set_error(-1, "out of memory"); - } - flds.elements = num_flds; - return 0; -} - -int -hstcpcli::get_result(hstresult& result) -{ -/* - readbuf.swap(result.readbuf); -*/ - char *const wp = result.readbuf.make_space(response_end_offset); - memcpy(wp, readbuf.begin(), response_end_offset); - result.readbuf.space_wrote(response_end_offset); - result.response_end_offset = response_end_offset; - result.num_flds = num_flds; - result.cur_row_size = cur_row_size; - result.cur_row_offset = cur_row_offset; - if (result.flds.max_element < num_flds) - { - if (allocate_dynamic(&result.flds, num_flds)) - return set_error(-1, "out of memory"); - } - result.flds.elements = num_flds; - return 0; -} - -const string_ref * -hstcpcli::get_next_row() -{ - if (num_flds == 0 || flds.elements < num_flds) { - DBG(fprintf(stderr, "GNR NF 0\n")); - return 0; - } - char *start = readbuf.begin() + cur_row_offset; - char *const finish = readbuf.begin() + response_end_offset - 1; - if (start >= finish) { /* start[0] == nl */ - DBG(fprintf(stderr, "GNR FIN 0 %p %p\n", start, finish)); - return 0; - } - for (size_t i = 0; i < num_flds; ++i) { - skip_one(start, finish); - char *const fld_begin = start; - read_token(start, finish); - char *const fld_end = start; - char *wp = fld_begin; - if (is_null_expression(fld_begin, fld_end)) { - /* null */ - ((string_ref *) flds.buffer)[i] = string_ref(); - } else { - unescape_string(wp, fld_begin, fld_end); /* in-place */ - ((string_ref *) flds.buffer)[i] = string_ref(fld_begin, wp); - } - } - cur_row_size = start - (readbuf.begin() + cur_row_offset); - cur_row_offset = start - readbuf.begin(); - return (string_ref *) flds.buffer; -} - -const string_ref * -hstcpcli::get_next_row_from_result(hstresult& result) -{ - if (result.num_flds == 0 || result.flds.elements < result.num_flds) { - DBG(fprintf(stderr, "GNR NF 0\n")); - return 0; - } - char *start = result.readbuf.begin() + result.cur_row_offset; - char *const finish = result.readbuf.begin() + result.response_end_offset - 1; - if (start >= finish) { /* start[0] == nl */ - DBG(fprintf(stderr, "GNR FIN 0 %p %p\n", start, finish)); - return 0; - } - for (size_t i = 0; i < result.num_flds; ++i) { - skip_one(start, finish); - char *const fld_begin = start; - read_token(start, finish); - char *const fld_end = start; - char *wp = fld_begin; - if (is_null_expression(fld_begin, fld_end)) { - /* null */ - ((string_ref *) result.flds.buffer)[i] = string_ref(); - } else { - unescape_string(wp, fld_begin, fld_end); /* in-place */ - ((string_ref *) result.flds.buffer)[i] = string_ref(fld_begin, wp); - } - } - result.cur_row_size = - start - (result.readbuf.begin() + result.cur_row_offset); - result.cur_row_offset = start - result.readbuf.begin(); - return (string_ref *) result.flds.buffer; -} - -size_t -hstcpcli::get_row_size() -{ - return cur_row_size; -} - -size_t -hstcpcli::get_row_size_from_result(hstresult& result) -{ - return result.cur_row_size; -} - -void -hstcpcli::response_buf_remove() -{ - if (response_end_offset == 0) { - close(); - set_error(-1, "response_buf_remove: protocol out of sync"); - return; - } - readbuf.erase_front(response_end_offset); - response_end_offset = 0; - --num_req_rcvd; - cur_row_offset = 0; - num_flds = 0; -} - -void -hstcpcli::write_error_to_log( - const char *func_name, - const char *file_name, - ulong line_no -) { - if (errno_buf) { - time_t cur_time = (time_t) time((time_t*) 0); - struct tm lt; - struct tm *l_time = localtime_r(&cur_time, <); - fprintf(stderr, - "%04d%02d%02d %02d:%02d:%02d [ERROR] hstcpcli: [%d][%s]" - " [%s][%s][%lu] errno=%d\n", - l_time->tm_year + 1900, l_time->tm_mon + 1, l_time->tm_mday, - l_time->tm_hour, l_time->tm_min, l_time->tm_sec, - error_code, error_str.c_ptr_safe(), - func_name, file_name, line_no, errno_buf); - } -} - -hstcpcli_ptr -hstcpcli_i::create(const socket_args& args) -{ - return hstcpcli_ptr(new hstcpcli(args)); -} - -}; - diff --git a/storage/spider/hs_client/hstcpcli.hpp b/storage/spider/hs_client/hstcpcli.hpp deleted file mode 100644 index 06044f169a3..00000000000 --- a/storage/spider/hs_client/hstcpcli.hpp +++ /dev/null @@ -1,93 +0,0 @@ - -// vim:sw=2:ai - -/* - * Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved. - * Copyright (C) 2011 Kentoku SHIBA - * See COPYRIGHT.txt for details. - */ - -#ifndef DENA_HSTCPCLI_HPP -#define DENA_HSTCPCLI_HPP - -#define HANDLERSOCKET_MYSQL_UTIL 1 - -#include "mysql_version.h" -#include "sql_priv.h" -#include "probes_mysql.h" - -#include "config.hpp" -#include "socket.hpp" -#include "string_ref.hpp" -#include "string_buffer.hpp" - -namespace dena { - -struct hstcpcli_filter { - string_ref filter_type; - string_ref op; - size_t ff_offset; - string_ref val; - hstcpcli_filter() : ff_offset(0) { } -}; - -struct hstcpcli_i; -typedef hstcpcli_i *hstcpcli_ptr; - -struct hstresult { - hstresult(); - virtual ~hstresult(); - string_buffer readbuf; - size_t response_end_offset; - size_t num_flds; - size_t cur_row_offset; - size_t cur_row_size; - DYNAMIC_ARRAY flds; -}; - -struct hstcpcli_i { - virtual ~hstcpcli_i() = default; - virtual void close() = 0; - virtual int reconnect() = 0; - virtual bool stable_point() = 0; - virtual void request_buf_auth(const char *secret, const char *typ) = 0; - virtual void request_buf_open_index(size_t pst_id, const char *dbn, - const char *tbl, const char *idx, const char *retflds, - const char *filflds = 0) = 0; - virtual void request_buf_exec_generic(size_t pst_id, const string_ref& op, - const string_ref *kvs, size_t kvslen, uint32 limit, uint32 skip, - const string_ref& mod_op, const string_ref *mvs, size_t mvslen, - const hstcpcli_filter *fils = 0, size_t filslen = 0, - int invalues_keypart = -1, const string_ref *invalues = 0, - size_t invalueslen = 0) = 0; // FIXME: too long - virtual size_t request_buf_append(const char *start, const char *finish) = 0; - virtual void request_reset() = 0; - virtual int request_send() = 0; - virtual int response_recv(size_t& num_flds_r) = 0; - virtual int get_result(hstresult& result) = 0; - virtual const string_ref *get_next_row() = 0; - virtual const string_ref *get_next_row_from_result(hstresult& result) = 0; - virtual size_t get_row_size() = 0; - virtual size_t get_row_size_from_result(hstresult& result) = 0; - virtual void response_buf_remove() = 0; - virtual int get_error_code() = 0; - virtual String& get_error() = 0; - virtual void clear_error() = 0; - virtual int set_timeout(int send_timeout, int recv_timeout) = 0; - virtual size_t get_num_req_bufd() = 0; - virtual size_t get_num_req_sent() = 0; - virtual size_t get_num_req_rcvd() = 0; - virtual size_t get_response_end_offset() = 0; - virtual const char *get_readbuf_begin() = 0; - virtual const char *get_readbuf_end() = 0; - virtual const char *get_writebuf_begin() = 0; - virtual size_t get_writebuf_size() = 0; - virtual void write_error_to_log(const char *func_name, const char *file_name, - ulong line_no) = 0; - static hstcpcli_ptr create(const socket_args& args); -}; - -}; - -#endif - diff --git a/storage/spider/hs_client/mutex.hpp b/storage/spider/hs_client/mutex.hpp deleted file mode 100644 index 8e331fb6ab2..00000000000 --- a/storage/spider/hs_client/mutex.hpp +++ /dev/null @@ -1,48 +0,0 @@ - -// vim:sw=2:ai - -/* - * Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved. - * See COPYRIGHT.txt for details. - */ - -#ifndef DENA_MUTEX_HPP -#define DENA_MUTEX_HPP - -#include "fatal.hpp" -#include "util.hpp" - -namespace dena { - -struct condition; - -struct mutex : private noncopyable { - friend struct condition; - mutex() { - if (pthread_mutex_init(&mtx, 0) != 0) { - fatal_abort("pthread_mutex_init"); - } - } - ~mutex() { - if (pthread_mutex_destroy(&mtx) != 0) { - fatal_abort("pthread_mutex_destroy"); - } - } - void lock() const { - if (pthread_mutex_lock(&mtx) != 0) { - fatal_abort("pthread_mutex_lock"); - } - } - void unlock() const { - if (pthread_mutex_unlock(&mtx) != 0) { - fatal_abort("pthread_mutex_unlock"); - } - } - private: - mutable pthread_mutex_t mtx; -}; - -}; - -#endif - diff --git a/storage/spider/hs_client/socket.cpp b/storage/spider/hs_client/socket.cpp deleted file mode 100644 index 469acb2725f..00000000000 --- a/storage/spider/hs_client/socket.cpp +++ /dev/null @@ -1,306 +0,0 @@ - -// vim:sw=2:ai - -/* - * Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved. - * Copyright (C) 2011-2017 Kentoku SHIBA - * See COPYRIGHT.txt for details. - */ - -#include -#include -#ifndef __WIN__ -#include -#include -#endif - -#include "mysql_version.h" -#include "hs_compat.h" -#include -#include "sql_priv.h" -#include "probes_mysql.h" - -#include "socket.hpp" -#include "string_util.hpp" -#include "fatal.hpp" - -/* -struct sockaddr_un { - short sun_family; - char sun_path[108]; -}; -*/ - -namespace dena { - -void -ignore_sigpipe() -{ -#if defined(SIGPIPE) && !defined(__WIN__) - if (signal(SIGPIPE, SIG_IGN) == SIG_ERR) { - fatal_abort("SIGPIPE SIG_IGN"); - } -#endif -} - -void -socket_args::set(const config& conf) -{ - timeout = (int) conf.get_int("timeout", 600); - listen_backlog = (int) conf.get_int("listen_backlog", 256); - String node = conf.get_str("host", ""); - String port = conf.get_str("port", ""); - if (node.length() || port.length()) { - if (family == AF_UNIX || !strcmp(node.c_ptr(), "/")) { - set_unix_domain(port.c_ptr()); - } else { - const char *nd = !node.length() ? 0 : node.c_ptr(); - if (resolve(nd, port.c_ptr()) != 0) { - String message("getaddrinfo failed: ", &my_charset_bin); - message.reserve(node.length() + sizeof(":") - 1 + port.length()); - message.append(node); - message.q_append(":", sizeof(":") - 1); - message.append(port); - fatal_abort(message); - } - } - } - sndbuf = (int) conf.get_int("sndbuf", 0); - rcvbuf = (int) conf.get_int("rcvbuf", 0); -} - -void -socket_args::set_unix_domain(const char *path) -{ -#ifndef __WIN__ - family = AF_UNIX; - addr = sockaddr_storage(); - addrlen = sizeof(sockaddr_un); - sockaddr_un *const ap = reinterpret_cast(&addr); - ap->sun_family = AF_UNIX; - strncpy(ap->sun_path, path, sizeof(ap->sun_path) - 1); -#endif -} - -int -socket_args::resolve(const char *node, const char *service) -{ - const int flags = (node == 0) ? AI_PASSIVE : 0; - auto_addrinfo ai; - addr = sockaddr_storage(); - addrlen = 0; - const int r = ai.resolve(node, service, flags, family, socktype, protocol); - if (r != 0) { - return r; - } - memcpy(&addr, ai.get()->ai_addr, ai.get()->ai_addrlen); - addrlen = ai.get()->ai_addrlen; - return 0; -} - -int -socket_set_timeout(auto_file& fd, const socket_args& args, String& err_r) -{ - if (!args.nonblocking) { -#if defined(SO_SNDTIMEO) && defined(SO_RCVTIMEO) - if (args.recv_timeout != 0) { -#ifndef __WIN__ - struct timeval tv; - tv.tv_sec = args.recv_timeout; - tv.tv_usec = 0; -#else - int tv = args.recv_timeout * 1000; -#endif - if (setsockopt(fd.get(), SOL_SOCKET, SO_RCVTIMEO, -#ifndef __WIN__ - (const void *) &tv, -#else - (const char *) &tv, -#endif - sizeof(tv)) != 0) { - return errno_string("setsockopt SO_RCVTIMEO", errno, err_r); - } - } - if (args.send_timeout != 0) { -#ifndef __WIN__ - struct timeval tv; - tv.tv_sec = args.send_timeout; - tv.tv_usec = 0; -#else - int tv = args.send_timeout * 1000; -#endif - if (setsockopt(fd.get(), SOL_SOCKET, SO_SNDTIMEO, -#ifndef __WIN__ - (const void *) &tv, -#else - (const char *) &tv, -#endif - sizeof(tv)) != 0) { - return errno_string("setsockopt SO_SNDTIMEO", errno, err_r); - } - } -#endif - } - return 0; -} - -int -socket_set_options(auto_file& fd, const socket_args& args, String& err_r) -{ - if (args.timeout != 0 && !args.nonblocking) { -#if defined(SO_SNDTIMEO) && defined(SO_RCVTIMEO) -#ifndef __WIN__ - struct timeval tv; - tv.tv_sec = args.timeout; - tv.tv_usec = 0; -#else - int tv = args.timeout * 1000; -#endif - if (setsockopt(fd.get(), SOL_SOCKET, SO_RCVTIMEO, -#ifndef __WIN__ - (const void *) &tv, -#else - (const char *) &tv, -#endif - sizeof(tv)) != 0) { - return errno_string("setsockopt SO_RCVTIMEO", errno, err_r); - } -#ifndef __WIN__ - tv.tv_sec = args.timeout; - tv.tv_usec = 0; -#else - tv = args.timeout * 1000; -#endif - if (setsockopt(fd.get(), SOL_SOCKET, SO_SNDTIMEO, -#ifndef __WIN__ - (const void *) &tv, -#else - (const char *) &tv, -#endif - sizeof(tv)) != 0) { - return errno_string("setsockopt SO_RCVTIMEO", errno, err_r); - } -#endif - } -#ifndef __WIN__ - if (args.nonblocking && fcntl(fd.get(), F_SETFL, O_NONBLOCK) != 0) { - return errno_string("fcntl O_NONBLOCK", errno, err_r); - } -#endif - if (args.sndbuf != 0) { - const int v = args.sndbuf; - if (setsockopt(fd.get(), SOL_SOCKET, SO_SNDBUF, -#ifndef __WIN__ - (const void *) &v, -#else - (const char *) &v, -#endif - sizeof(v)) != 0) { - return errno_string("setsockopt SO_SNDBUF", errno, err_r); - } - } - if (args.rcvbuf != 0) { - const int v = args.rcvbuf; - if (setsockopt(fd.get(), SOL_SOCKET, SO_RCVBUF, -#ifndef __WIN__ - (const void *) &v, -#else - (const char *) &v, -#endif - sizeof(v)) != 0) { - return errno_string("setsockopt SO_RCVBUF", errno, err_r); - } - } - return 0; -} - -int -socket_open(auto_file& fd, const socket_args& args, String& err_r) -{ - fd.reset((int) socket(args.family, args.socktype, args.protocol)); - if (fd.get() < 0) { - return errno_string("socket", errno, err_r); - } - return socket_set_options(fd, args, err_r); -} - -int -socket_connect(auto_file& fd, const socket_args& args, String& err_r) -{ - int r = 0; - if ((r = socket_open(fd, args, err_r)) != 0) { - return r; - } - if (connect(fd.get(), reinterpret_cast(&args.addr), - args.addrlen) != 0) { - if (!args.nonblocking -#ifndef __WIN__ - || errno != EINPROGRESS -#endif - ) { - return errno_string("connect", errno, err_r); - } - } - return 0; -} - -int -socket_bind(auto_file& fd, const socket_args& args, String& err_r) -{ - fd.reset((int) socket(args.family, args.socktype, args.protocol)); - if (fd.get() < 0) { - return errno_string("socket", errno, err_r); - } - if (args.reuseaddr) { -#ifndef __WIN__ - if (args.family == AF_UNIX) { - const sockaddr_un *const ap = - reinterpret_cast(&args.addr); - if (unlink(ap->sun_path) != 0 && errno != ENOENT) { - return errno_string("unlink uds", errno, err_r); - } - } else { -#endif - int v = 1; - if (setsockopt(fd.get(), SOL_SOCKET, SO_REUSEADDR, -#ifndef __WIN__ - (const void *) &v, -#else - (const char *) &v, -#endif - sizeof(v)) != 0) { - return errno_string("setsockopt SO_REUSEADDR", errno, err_r); - } -#ifndef __WIN__ - } -#endif - } - if (bind(fd.get(), reinterpret_cast(&args.addr), - args.addrlen) != 0) { - return errno_string("bind", errno, err_r); - } - if (listen(fd.get(), args.listen_backlog) != 0) { - return errno_string("listen", errno, err_r); - } -#ifndef __WIN__ - if (args.nonblocking && fcntl(fd.get(), F_SETFL, O_NONBLOCK) != 0) { - return errno_string("fcntl O_NONBLOCK", errno, err_r); - } -#endif - return 0; -} - -int -socket_accept(int listen_fd, auto_file& fd, const socket_args& args, - sockaddr_storage& addr_r, socklen_t& addrlen_r, String& err_r) -{ - fd.reset((int) accept(listen_fd, reinterpret_cast(&addr_r), - &addrlen_r)); - if (fd.get() < 0) { - return errno_string("accept", errno, err_r); - } - return socket_set_options(fd, args, err_r); -} - -}; - diff --git a/storage/spider/hs_client/socket.hpp b/storage/spider/hs_client/socket.hpp deleted file mode 100644 index e4f7530aec9..00000000000 --- a/storage/spider/hs_client/socket.hpp +++ /dev/null @@ -1,57 +0,0 @@ - -// vim:sw=2:ai - -/* - * Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved. - * Copyright (C) 2011 Kentoku SHIBA - * See COPYRIGHT.txt for details. - */ - -#ifndef DENA_SOCKET_HPP -#define DENA_SOCKET_HPP - -#include "mysql_version.h" -#include "sql_priv.h" -#include "probes_mysql.h" - -#include "auto_addrinfo.hpp" -#include "auto_file.hpp" -#include "config.hpp" - -namespace dena { - -struct socket_args { - sockaddr_storage addr; - socklen_t addrlen; - int family; - int socktype; - int protocol; - int timeout; - int send_timeout; - int recv_timeout; - int listen_backlog; - bool reuseaddr; - bool nonblocking; - bool use_epoll; - int sndbuf; - int rcvbuf; - socket_args() : addr(), addrlen(0), family(AF_INET), socktype(SOCK_STREAM), - protocol(0), timeout(600), send_timeout(600), recv_timeout(600), - listen_backlog(256), reuseaddr(true), nonblocking(false), use_epoll(false), - sndbuf(0), rcvbuf(0) { } - void set(const config& conf); - void set_unix_domain(const char *path); - int resolve(const char *node, const char *service); -}; - -void ignore_sigpipe(); -int socket_set_timeout(auto_file& fd, const socket_args& args, String& err_r); -int socket_bind(auto_file& fd, const socket_args& args, String& err_r); -int socket_connect(auto_file& fd, const socket_args& args, String& err_r); -int socket_accept(int listen_fd, auto_file& fd, const socket_args& args, - sockaddr_storage& addr_r, socklen_t& addrlen_r, String& err_r); - -}; - -#endif - diff --git a/storage/spider/hs_client/string_buffer.hpp b/storage/spider/hs_client/string_buffer.hpp deleted file mode 100644 index c9a6074819b..00000000000 --- a/storage/spider/hs_client/string_buffer.hpp +++ /dev/null @@ -1,146 +0,0 @@ - -// vim:sw=2:ai - -/* - * Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved. - * Copyright (C) 2011 Kentoku SHIBA - * See COPYRIGHT.txt for details. - */ - -#ifndef DENA_STRING_BUFFER_HPP -#define DENA_STRING_BUFFER_HPP - -/* -#include -#include -*/ - -#include "util.hpp" -#include "allocator.hpp" -#include "fatal.hpp" - -namespace dena { - -struct string_buffer : private noncopyable { - string_buffer() : buffer(0), begin_offset(0), end_offset(0), alloc_size(0) { } - ~string_buffer() { - real_free(); - } - void real_free() { - if (alloc_size) { - DENA_FREE(buffer); - buffer = 0; - begin_offset = 0; - end_offset = 0; - alloc_size = 0; - } - } - size_t real_size() { - return alloc_size; - } - const char *begin() const { - return buffer + begin_offset; - } - const char *end() const { - return buffer + end_offset; - } - char *begin() { - return buffer + begin_offset; - } - char *end() { - return buffer + end_offset; - } - size_t size() const { - return end_offset - begin_offset; - } - void clear() { - begin_offset = end_offset = 0; - } - void resize(size_t len) { - if (size() < len) { - reserve(len); - memset(buffer + end_offset, 0, len - size()); - } - end_offset = begin_offset + len; - } - void reserve(size_t len) { - if (alloc_size >= begin_offset + len) { - return; - } - size_t asz = alloc_size; - while (asz < begin_offset + len) { - if (asz == 0) { - asz = 16; - } - const size_t asz_n = asz << 1; - if (asz_n < asz) { - fatal_abort("string_buffer::resize() overflow"); - } - asz = asz_n; - } - void *const p = DENA_REALLOC(buffer, asz); - if (p == 0) { - fatal_abort("string_buffer::resize() realloc"); - } - buffer = static_cast(p); - alloc_size = asz; - } - void erase_front(size_t len) { - if (len >= size()) { - clear(); - } else { - begin_offset += len; - } - } - char *make_space(size_t len) { - reserve(size() + len); - return buffer + end_offset; - } - void space_wrote(size_t len) { - len = len < alloc_size - end_offset ? len : alloc_size - end_offset; - end_offset += len; - } - template - void append_literal(const char (& str)[N]) { - append(str, str + N - 1); - } - void append(const char *start, const char *finish) { - const size_t len = finish - start; - reserve(size() + len); - memcpy(buffer + end_offset, start, len); - end_offset += len; - } - void append_2(const char *s1, const char *f1, const char *s2, - const char *f2) { - const size_t l1 = f1 - s1; - const size_t l2 = f2 - s2; - reserve(end_offset + l1 + l2); - memcpy(buffer + end_offset, s1, l1); - memcpy(buffer + end_offset + l1, s2, l2); - end_offset += l1 + l2; - } - void swap(string_buffer& sb) { - char *tmp_buffer = buffer; - size_t tmp_begin_offset = begin_offset; - size_t tmp_end_offset = end_offset; - size_t tmp_alloc_size = alloc_size; - buffer = sb.buffer; - begin_offset = sb.begin_offset; - end_offset = sb.end_offset; - alloc_size = sb.alloc_size; - sb.buffer = tmp_buffer; - sb.begin_offset = tmp_begin_offset; - sb.end_offset = tmp_end_offset; - sb.alloc_size = tmp_alloc_size; - } - private: - char *buffer; - size_t begin_offset; - size_t end_offset; - size_t alloc_size; -}; - -}; - -#endif - diff --git a/storage/spider/hs_client/string_ref.hpp b/storage/spider/hs_client/string_ref.hpp deleted file mode 100644 index 028c4146c73..00000000000 --- a/storage/spider/hs_client/string_ref.hpp +++ /dev/null @@ -1,106 +0,0 @@ - -// vim:sw=2:ai - -/* - * Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved. - * Copyright (C) 2011 Kentoku SHIBA - * See COPYRIGHT.txt for details. - */ - -#ifndef DENA_STRING_REF_HPP -#define DENA_STRING_REF_HPP - -namespace dena { - -struct string_wref { - typedef char value_type; - char *begin() const { return start; } - char *end() const { return start + length; } - size_t size() const { return length; } - private: - char *start; - size_t length; - public: - string_wref(char *s = 0, size_t len = 0) : start(s), length(len) { } -}; - -struct string_ref { - typedef const char value_type; - const char *begin() const { return start; } - const char *end() const { return start + length; } - size_t size() const { return length; } - void set(const char *s, size_t len) { start = s; length = len; } - void set(const char *s, const char *f) { start = s; length = f - s; } - private: - const char *start; - size_t length; - public: - string_ref(const char *s = 0, size_t len = 0) : start(s), length(len) { } - string_ref(const char *s, const char *f) : start(s), length(f - s) { } - string_ref(const string_wref& w) : start(w.begin()), length(w.size()) { } -}; - -template inline bool -operator ==(const string_ref& x, const char (& y)[N]) { - return (x.size() == N - 1) && (::memcmp(x.begin(), y, N - 1) == 0); -} - -inline bool -operator ==(const string_ref& x, const string_ref& y) { - return (x.size() == y.size()) && - (::memcmp(x.begin(), y.begin(), x.size()) == 0); -} - -inline bool -operator !=(const string_ref& x, const string_ref& y) { - return (x.size() != y.size()) || - (::memcmp(x.begin(), y.begin(), x.size()) != 0); -} - -struct string_ref_list_wrap { - string_ref_list_wrap() { - if (SPD_INIT_DYNAMIC_ARRAY2(&string_ref_list, sizeof(string_ref), - NULL, 16, 16, MYF(MY_WME))) - string_ref_list_init = FALSE; - else - string_ref_list_init = TRUE; - } - virtual ~string_ref_list_wrap() { - if (string_ref_list_init) delete_dynamic(&string_ref_list); } - void clear() { - if (string_ref_list_init) string_ref_list.elements = 0; } - void push_back(string_ref &e) { - if (string_ref_list_init) insert_dynamic(&string_ref_list, (uchar*) &e); - return; } - size_t size() { - return string_ref_list_init ? string_ref_list.elements : 0; } - bool resize(size_t new_size) { - if (string_ref_list_init) { - if (string_ref_list.max_element < new_size && allocate_dynamic( - &string_ref_list, new_size)) return TRUE; - string_ref_list.elements = new_size; - return FALSE; - } - return TRUE; - } - bool empty() { - return string_ref_list_init ? string_ref_list.elements ? - FALSE : TRUE : TRUE; } - string_ref &operator [](size_t n) { - return ((string_ref *) (string_ref_list.buffer + - string_ref_list.size_of_element * n))[0]; } - bool string_ref_list_init; - DYNAMIC_ARRAY string_ref_list; -}; - -inline String * -q_append_str(String *str, const char *p) { - uint32 p_len = strlen(p); - if (str->reserve(p_len)) return NULL; - str->q_append(p, p_len); return str; -} - -}; - -#endif - diff --git a/storage/spider/hs_client/string_util.cpp b/storage/spider/hs_client/string_util.cpp deleted file mode 100644 index 647cf877805..00000000000 --- a/storage/spider/hs_client/string_util.cpp +++ /dev/null @@ -1,202 +0,0 @@ - -// vim:sw=2:ai - -/* - * Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved. - * Copyright (C) 2011-2017 Kentoku SHIBA - * See COPYRIGHT.txt for details. - */ - -#include -#include "mysql_version.h" -#include "hs_compat.h" -#include "sql_priv.h" -#include "probes_mysql.h" - -#include "string_util.hpp" - -namespace dena { - -string_wref -get_token(char *& wp, char *wp_end, char delim) -{ - char *const wp_begin = wp; - char *const p = memchr_char(wp_begin, delim, wp_end - wp_begin); - if (p == 0) { - wp = wp_end; - return string_wref(wp_begin, wp_end - wp_begin); - } - wp = p + 1; - return string_wref(wp_begin, p - wp_begin); -} - -uint32 -atoi_uint32_nocheck(const char *start, const char *finish) -{ - uint32 v = 0; - for (; start != finish; ++start) { - const char c = *start; - if (c < '0' || c > '9') { - break; - } - v *= 10; - v += (uint32) (c - '0'); - } - return v; -} - -long long -atoll_nocheck(const char *start, const char *finish) -{ - long long v = 0; - bool negative = false; - if (start != finish) { - if (start[0] == '-') { - ++start; - negative = true; - } else if (start[0] == '+') { - ++start; - } - } - for (; start != finish; ++start) { - const char c = *start; - if (c < '0' || c > '9') { - break; - } - v *= 10; - if (negative) { - v -= (long long) (c - '0'); - } else { - v += (long long) (c - '0'); - } - } - return v; -} - -void -append_uint32(string_buffer& buf, uint32 v) -{ - char *const wp = buf.make_space(64); - const int len = snprintf(wp, 64, "%lu", static_cast(v)); - if (len > 0) { - buf.space_wrote(len); - } -} - -/* -String * -to_stdstring(uint32 v) -{ - char buf[64]; - int str_len; - String *str; - str_len = snprintf(buf, sizeof(buf), "%lu", static_cast(v)); - if ((str = new String(str_len + 1))) - str->q_append(buf, str_len); - return str; -} -*/ - -int -errno_string(const char *s, int en, String& err_r) -{ - char buf[64]; - int str_len; - str_len = snprintf(buf, sizeof(buf), "%s: %d", s, en); - if (!err_r.reserve(str_len + 1)) - err_r.q_append(buf, str_len); - return en; -} - -size_t -split(char delim, const string_ref& buf, string_ref *parts, - size_t parts_len) -{ - size_t i = 0; - const char *start = buf.begin(); - const char *const finish = buf.end(); - for (i = 0; i < parts_len; ++i) { - const char *const p = memchr_char(start, delim, finish - start); - if (p == 0) { - parts[i] = string_ref(start, finish - start); - ++i; - break; - } - parts[i] = string_ref(start, p - start); - start = p + 1; - } - const size_t r = i; - for (; i < parts_len; ++i) { - parts[i] = string_ref(); - } - return r; -} - -size_t -split(char delim, const string_wref& buf, string_wref *parts, - size_t parts_len) -{ - size_t i = 0; - char *start = buf.begin(); - char *const finish = buf.end(); - for (i = 0; i < parts_len; ++i) { - char *const p = memchr_char(start, delim, finish - start); - if (p == 0) { - parts[i] = string_wref(start, finish - start); - ++i; - break; - } - parts[i] = string_wref(start, p - start); - start = p + 1; - } - const size_t r = i; - for (; i < parts_len; ++i) { - parts[i] = string_wref(); - } - return r; -} - -size_t -split(char delim, const string_ref& buf, DYNAMIC_ARRAY& parts_r) -{ - size_t i = 0; - const char *start = buf.begin(); - const char *finish = buf.end(); - while (true) { - const char *p = memchr_char(start, delim, finish - start); - if (p == 0) { - string_ref param(start, finish - start); - insert_dynamic(&parts_r, (uchar *) ¶m); - break; - } - string_ref param(start, p - start); - insert_dynamic(&parts_r, (uchar *) ¶m); - start = p + 1; - } - const size_t r = i; - return r; -} - -size_t -split(char delim, const string_wref& buf, DYNAMIC_ARRAY& parts_r) -{ - size_t i = 0; - char *start = buf.begin(); - char *finish = buf.end(); - while (true) { - char *p = memchr_char(start, delim, finish - start); - if (p == 0) { - string_wref param(start, finish - start); - insert_dynamic(&parts_r, (uchar *) ¶m); - break; - } - string_wref param(start, p - start); - insert_dynamic(&parts_r, (uchar *) ¶m); - start = p + 1; - } - const size_t r = i; - return r; -} - -}; - diff --git a/storage/spider/hs_client/string_util.hpp b/storage/spider/hs_client/string_util.hpp deleted file mode 100644 index b886addecfb..00000000000 --- a/storage/spider/hs_client/string_util.hpp +++ /dev/null @@ -1,51 +0,0 @@ - -// vim:sw=2:ai - -/* - * Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved. - * Copyright (C) 2011 Kentoku SHIBA - * See COPYRIGHT.txt for details. - */ - -#ifndef DENA_STRING_UTIL_HPP -#define DENA_STRING_UTIL_HPP - -#include "string_buffer.hpp" -#include "string_ref.hpp" - -namespace dena { - -inline const char * -memchr_char(const char *s, int c, size_t n) -{ - return static_cast(memchr(s, c, n)); -} - -inline char * -memchr_char(char *s, int c, size_t n) -{ - return static_cast(memchr(s, c, n)); -} - -string_wref get_token(char *& wp, char *wp_end, char delim); -uint32 atoi_uint32_nocheck(const char *start, const char *finish); -/* -String *to_stdstring(uint32 v); -*/ -void append_uint32(string_buffer& buf, uint32 v); -long long atoll_nocheck(const char *start, const char *finish); - -int errno_string(const char *s, int en, String& err_r); - -size_t split(char delim, const string_ref& buf, string_ref *parts, - size_t parts_len); -size_t split(char delim, const string_wref& buf, string_wref *parts, - size_t parts_len); -size_t split(char delim, const string_ref& buf, - DYNAMIC_ARRAY& parts_r); -size_t split(char delim, const string_wref& buf, - DYNAMIC_ARRAY& parts_r); -}; - -#endif - diff --git a/storage/spider/hs_client/thread.hpp b/storage/spider/hs_client/thread.hpp deleted file mode 100644 index 79fba706a42..00000000000 --- a/storage/spider/hs_client/thread.hpp +++ /dev/null @@ -1,84 +0,0 @@ - -// vim:sw=2:ai - -/* - * Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved. - * Copyright (C) 2011 Kentoku SHIBA - * See COPYRIGHT.txt for details. - */ - -#ifndef DENA_THREAD_HPP -#define DENA_THREAD_HPP - -#include "fatal.hpp" - -namespace dena { - -/* -template -struct thread : private noncopyable { - template thread(const Ta& arg, size_t stack_sz = 256 * 1024) - : obj(arg), thr(0), need_join(false), stack_size(stack_sz) { } - template thread(const Ta0& a0, - volatile Ta1& a1, size_t stack_sz = 256 * 1024) - : obj(a0, a1), thr(0), need_join(false), stack_size(stack_sz) { } - ~thread() { - join(); - } - void start() { - if (!start_nothrow()) { - fatal_abort("thread::start"); - } - } - bool start_nothrow() { - if (need_join) { - return need_join; - } - void *const arg = this; - pthread_attr_t attr; - if (pthread_attr_init(&attr) != 0) { - fatal_abort("pthread_attr_init"); - } - if (pthread_attr_setstacksize(&attr, stack_size) != 0) { - fatal_abort("pthread_attr_setstacksize"); - } - const int r = pthread_create(&thr, &attr, thread_main, arg); - if (pthread_attr_destroy(&attr) != 0) { - fatal_abort("pthread_attr_destroy"); - } - if (r != 0) { - return need_join; - } - need_join = true; - return need_join; - } - void join() { - if (!need_join) { - return; - } - int e = 0; - if ((e = pthread_join(thr, 0)) != 0) { - fatal_abort("pthread_join"); - } - need_join = false; - } - T& operator *() { return obj; } - T *operator ->() { return &obj; } - private: - static void *thread_main(void *arg) { - thread *p = static_cast(arg); - p->obj(); - return 0; - } - private: - T obj; - pthread_t thr; - bool need_join; - size_t stack_size; -}; -*/ - -}; - -#endif - diff --git a/storage/spider/hs_client/util.hpp b/storage/spider/hs_client/util.hpp deleted file mode 100644 index 60b5441703d..00000000000 --- a/storage/spider/hs_client/util.hpp +++ /dev/null @@ -1,25 +0,0 @@ - -// vim:sw=2:ai - -/* - * Copyright (C) 2010 DeNA Co.,Ltd.. All rights reserved. - * See COPYRIGHT.txt for details. - */ - -#ifndef DENA_UTIL_HPP -#define DENA_UTIL_HPP - -namespace dena { - -/* boost::noncopyable */ -struct noncopyable { - noncopyable() = default; - private: - noncopyable(const noncopyable&); - noncopyable& operator =(const noncopyable&); -}; - -}; - -#endif - diff --git a/storage/spider/spd_conn.cc b/storage/spider/spd_conn.cc index a9f89048966..1ac0c8f9b73 100644 --- a/storage/spider/spd_conn.cc +++ b/storage/spider/spd_conn.cc @@ -103,20 +103,6 @@ const char *spider_open_connections_func_name; const char *spider_open_connections_file_name; ulong spider_open_connections_line_no; pthread_mutex_t spider_conn_mutex; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -HASH spider_hs_r_conn_hash; -uint spider_hs_r_conn_hash_id; -const char *spider_hs_r_conn_hash_func_name; -const char *spider_hs_r_conn_hash_file_name; -ulong spider_hs_r_conn_hash_line_no; -pthread_mutex_t spider_hs_r_conn_mutex; -HASH spider_hs_w_conn_hash; -uint spider_hs_w_conn_hash_id; -const char *spider_hs_w_conn_hash_func_name; -const char *spider_hs_w_conn_hash_file_name; -ulong spider_hs_w_conn_hash_line_no; -pthread_mutex_t spider_hs_w_conn_mutex; -#endif /* for spider_open_connections and trx_conn_hash */ uchar *spider_conn_get_key( @@ -310,10 +296,6 @@ void spider_free_conn_from_trx( spider_conn_clear_queue(conn); conn->use_for_active_standby = FALSE; conn->error_mode = 1; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (conn->conn_kind == SPIDER_CONN_KIND_MYSQL) - { -#endif if ( trx_free || ( @@ -412,134 +394,6 @@ void spider_free_conn_from_trx( } } else if (roop_count) (*roop_count)++; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else if (conn->conn_kind == SPIDER_CONN_KIND_HS_READ) - { - spider_db_hs_request_buf_reset(conn); - if ( - trx_free || - ( - ( - conn->server_lost || - spider_param_hs_r_conn_recycle_mode(trx->thd) != 2 - ) && - !conn->opened_handlers - ) - ) { - conn->thd = NULL; -#ifdef HASH_UPDATE_WITH_HASH_VALUE - my_hash_delete_with_hash_value(&trx->trx_hs_r_conn_hash, - conn->conn_key_hash_value, (uchar*) conn); -#else - my_hash_delete(&trx->trx_hs_r_conn_hash, (uchar*) conn); -#endif - - DBUG_ASSERT(conn->opened_handlers == - conn->db_conn->get_opened_handler_count()); - if (conn->db_conn->get_opened_handler_count()) - { - conn->db_conn->reset_opened_handler(); - } - - if ( - !trx_free && - !conn->server_lost && - !conn->queued_connect && - spider_param_hs_r_conn_recycle_mode(trx->thd) == 1 - ) { - /* conn_recycle_mode == 1 */ - *conn->conn_key = '0'; - pthread_mutex_lock(&spider_hs_r_conn_mutex); - uint old_elements = spider_hs_r_conn_hash.array.max_element; -#ifdef HASH_UPDATE_WITH_HASH_VALUE - if (my_hash_insert_with_hash_value(&spider_hs_r_conn_hash, - conn->conn_key_hash_value, (uchar*) conn)) -#else - if (my_hash_insert(&spider_hs_r_conn_hash, (uchar*) conn)) -#endif - { - pthread_mutex_unlock(&spider_hs_r_conn_mutex); - spider_free_conn(conn); - } else { - if (spider_hs_r_conn_hash.array.max_element > old_elements) - { - spider_alloc_calc_mem(spider_current_trx, - spider_hs_r_conn_hash, - (spider_hs_r_conn_hash.array.max_element - old_elements) * - spider_hs_r_conn_hash.array.size_of_element); - } - pthread_mutex_unlock(&spider_hs_r_conn_mutex); - } - } else { - /* conn_recycle_mode == 0 */ - spider_free_conn(conn); - } - } else if (roop_count) - (*roop_count)++; - } else { - spider_db_hs_request_buf_reset(conn); - if ( - trx_free || - ( - ( - conn->server_lost || - spider_param_hs_w_conn_recycle_mode(trx->thd) != 2 - ) && - !conn->opened_handlers - ) - ) { - conn->thd = NULL; -#ifdef HASH_UPDATE_WITH_HASH_VALUE - my_hash_delete_with_hash_value(&trx->trx_hs_w_conn_hash, - conn->conn_key_hash_value, (uchar*) conn); -#else - my_hash_delete(&trx->trx_hs_w_conn_hash, (uchar*) conn); -#endif - - DBUG_ASSERT(conn->opened_handlers == - conn->db_conn->get_opened_handler_count()); - if (conn->db_conn->get_opened_handler_count()) - { - conn->db_conn->reset_opened_handler(); - } - - if ( - !trx_free && - !conn->server_lost && - !conn->queued_connect && - spider_param_hs_w_conn_recycle_mode(trx->thd) == 1 - ) { - /* conn_recycle_mode == 1 */ - *conn->conn_key = '0'; - pthread_mutex_lock(&spider_hs_w_conn_mutex); - uint old_elements = spider_hs_w_conn_hash.array.max_element; -#ifdef HASH_UPDATE_WITH_HASH_VALUE - if (my_hash_insert_with_hash_value(&spider_hs_w_conn_hash, - conn->conn_key_hash_value, (uchar*) conn)) -#else - if (my_hash_insert(&spider_hs_w_conn_hash, (uchar*) conn)) -#endif - { - pthread_mutex_unlock(&spider_hs_w_conn_mutex); - spider_free_conn(conn); - } else { - if (spider_hs_w_conn_hash.array.max_element > old_elements) - { - spider_alloc_calc_mem(spider_current_trx, - spider_hs_w_conn_hash, - (spider_hs_w_conn_hash.array.max_element - old_elements) * - spider_hs_w_conn_hash.array.size_of_element); - } - pthread_mutex_unlock(&spider_hs_w_conn_mutex); - } - } else { - /* conn_recycle_mode == 0 */ - spider_free_conn(conn); - } - } else if (roop_count) - (*roop_count)++; - } -#endif DBUG_VOID_RETURN; } @@ -567,10 +421,6 @@ SPIDER_CONN *spider_create_conn( UTC = my_tz_find(current_thd, &tz_00_name); } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (conn_kind == SPIDER_CONN_KIND_MYSQL) - { -#endif bool tables_on_different_db_are_joinable; if (share->sql_dbton_ids[link_idx] != SPIDER_DBTON_SIZE) { @@ -727,113 +577,13 @@ SPIDER_CONN *spider_create_conn( conn->tgt_port = share->tgt_ports[link_idx]; conn->tgt_ssl_vsc = share->tgt_ssl_vscs[link_idx]; conn->dbton_id = share->sql_dbton_ids[link_idx]; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else if (conn_kind == SPIDER_CONN_KIND_HS_READ) { - if (!(conn = (SPIDER_CONN *) - spider_bulk_malloc(spider_current_trx, SPD_MID_CREATE_CONN_3, MYF(MY_WME | MY_ZEROFILL), - &conn, (uint) (sizeof(*conn)), - &tmp_name, (uint) (share->hs_read_conn_keys_lengths[link_idx] + 1), - &tmp_host, (uint) (share->tgt_hosts_lengths[link_idx] + 1), - &tmp_socket, (uint) (share->hs_read_socks_lengths[link_idx] + 1), - &tmp_wrapper, - (uint) (share->tgt_wrappers_lengths[link_idx] + 1), - &need_mon, (uint) (sizeof(int)), - NullS)) - ) { - *error_num = HA_ERR_OUT_OF_MEM; - goto error_alloc_conn; - } - - conn->default_database.init_calc_mem(SPD_MID_CREATE_CONN_4); - conn->conn_key_length = share->hs_read_conn_keys_lengths[link_idx]; - conn->conn_key = tmp_name; - memcpy(conn->conn_key, share->hs_read_conn_keys[link_idx], - share->hs_read_conn_keys_lengths[link_idx]); -#ifdef SPIDER_HAS_HASH_VALUE_TYPE - conn->conn_key_hash_value = share->hs_read_conn_keys_hash_value[link_idx]; -#endif - conn->tgt_host_length = share->tgt_hosts_lengths[link_idx]; - conn->tgt_host = tmp_host; - memcpy(conn->tgt_host, share->tgt_hosts[link_idx], - share->tgt_hosts_lengths[link_idx]); - conn->hs_sock_length = share->hs_read_socks_lengths[link_idx]; - if (conn->hs_sock_length) - { - conn->hs_sock = tmp_socket; - memcpy(conn->hs_sock, share->hs_read_socks[link_idx], - share->hs_read_socks_lengths[link_idx]); - } else - conn->hs_sock = NULL; - conn->tgt_wrapper_length = share->tgt_wrappers_lengths[link_idx]; - conn->tgt_wrapper = tmp_wrapper; - memcpy(conn->tgt_wrapper, share->tgt_wrappers[link_idx], - share->tgt_wrappers_lengths[link_idx]); - conn->hs_port = share->hs_read_ports[link_idx]; - conn->dbton_id = share->hs_dbton_ids[link_idx]; - } else { - if (!(conn = (SPIDER_CONN *) - spider_bulk_malloc(spider_current_trx, SPD_MID_CREATE_CONN_5, MYF(MY_WME | MY_ZEROFILL), - &conn, (uint) (sizeof(*conn)), - &tmp_name, (uint) (share->hs_write_conn_keys_lengths[link_idx] + 1), - &tmp_host, (uint) (share->tgt_hosts_lengths[link_idx] + 1), - &tmp_socket, (uint) (share->hs_write_socks_lengths[link_idx] + 1), - &tmp_wrapper, - (uint) (share->tgt_wrappers_lengths[link_idx] + 1), - &need_mon, (uint) (sizeof(int)), - NullS)) - ) { - *error_num = HA_ERR_OUT_OF_MEM; - goto error_alloc_conn; - } - - conn->default_database.init_calc_mem(SPD_MID_CREATE_CONN_6); - conn->conn_key_length = share->hs_write_conn_keys_lengths[link_idx]; - conn->conn_key = tmp_name; - memcpy(conn->conn_key, share->hs_write_conn_keys[link_idx], - share->hs_write_conn_keys_lengths[link_idx]); -#ifdef SPIDER_HAS_HASH_VALUE_TYPE - conn->conn_key_hash_value = share->hs_write_conn_keys_hash_value[link_idx]; -#endif - conn->tgt_host_length = share->tgt_hosts_lengths[link_idx]; - conn->tgt_host = tmp_host; - memcpy(conn->tgt_host, share->tgt_hosts[link_idx], - share->tgt_hosts_lengths[link_idx]); - conn->hs_sock_length = share->hs_write_socks_lengths[link_idx]; - if (conn->hs_sock_length) - { - conn->hs_sock = tmp_socket; - memcpy(conn->hs_sock, share->hs_write_socks[link_idx], - share->hs_write_socks_lengths[link_idx]); - } else - conn->hs_sock = NULL; - conn->tgt_wrapper_length = share->tgt_wrappers_lengths[link_idx]; - conn->tgt_wrapper = tmp_wrapper; - memcpy(conn->tgt_wrapper, share->tgt_wrappers[link_idx], - share->tgt_wrappers_lengths[link_idx]); - conn->hs_port = share->hs_write_ports[link_idx]; - conn->dbton_id = share->hs_dbton_ids[link_idx]; - } -#endif if (conn->dbton_id == SPIDER_DBTON_SIZE) { -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (conn->conn_kind == SPIDER_CONN_KIND_MYSQL) - { -#endif my_printf_error( ER_SPIDER_SQL_WRAPPER_IS_INVALID_NUM, ER_SPIDER_SQL_WRAPPER_IS_INVALID_STR, MYF(0), conn->tgt_wrapper); *error_num = ER_SPIDER_SQL_WRAPPER_IS_INVALID_NUM; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else { - my_printf_error( - ER_SPIDER_NOSQL_WRAPPER_IS_INVALID_NUM, - ER_SPIDER_NOSQL_WRAPPER_IS_INVALID_STR, - MYF(0), conn->tgt_wrapper); - *error_num = ER_SPIDER_NOSQL_WRAPPER_IS_INVALID_NUM; - } -#endif goto error_invalid_wrapper; } if (!(conn->db_conn = spider_dbton[conn->dbton_id].create_db_conn(conn))) @@ -957,33 +707,11 @@ SPIDER_CONN *spider_get_conn( DBUG_PRINT("info",("spider link_idx=%u", link_idx)); DBUG_PRINT("info",("spider base_link_idx=%u", base_link_idx)); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (conn_kind == SPIDER_CONN_KIND_MYSQL) - { -#endif #ifdef DBUG_TRACE spider_print_keys(conn_key, share->conn_keys_lengths[link_idx]); #endif -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else if (conn_kind == SPIDER_CONN_KIND_HS_READ) - { - conn_key = share->hs_read_conn_keys[link_idx]; -#ifdef DBUG_TRACE - spider_print_keys(conn_key, share->hs_read_conn_keys_lengths[link_idx]); -#endif - } else { - conn_key = share->hs_write_conn_keys[link_idx]; -#ifdef DBUG_TRACE - spider_print_keys(conn_key, share->hs_write_conn_keys_lengths[link_idx]); -#endif - } -#endif #ifdef SPIDER_HAS_HASH_VALUE_TYPE if ( -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - (conn_kind == SPIDER_CONN_KIND_MYSQL && - ( -#endif (another && !(conn = (SPIDER_CONN*) my_hash_search_using_hash_value( &trx->trx_another_conn_hash, @@ -994,79 +722,25 @@ SPIDER_CONN *spider_get_conn( &trx->trx_conn_hash, share->conn_keys_hash_value[link_idx], (uchar*) conn_key, share->conn_keys_lengths[link_idx]))) -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - ) - ) || - (conn_kind == SPIDER_CONN_KIND_HS_READ && - !(conn = (SPIDER_CONN*) my_hash_search_using_hash_value( - &trx->trx_hs_r_conn_hash, - share->hs_read_conn_keys_hash_value[link_idx], - (uchar*) conn_key, share->hs_read_conn_keys_lengths[link_idx])) - ) || - (conn_kind == SPIDER_CONN_KIND_HS_WRITE && - !(conn = (SPIDER_CONN*) my_hash_search_using_hash_value( - &trx->trx_hs_w_conn_hash, - share->hs_write_conn_keys_hash_value[link_idx], - (uchar*) conn_key, share->hs_write_conn_keys_lengths[link_idx])) - ) -#endif ) #else if ( -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - (conn_kind == SPIDER_CONN_KIND_MYSQL && - ( -#endif (another && !(conn = (SPIDER_CONN*) my_hash_search(&trx->trx_another_conn_hash, (uchar*) conn_key, share->conn_keys_lengths[link_idx]))) || (!another && !(conn = (SPIDER_CONN*) my_hash_search(&trx->trx_conn_hash, (uchar*) conn_key, share->conn_keys_lengths[link_idx]))) -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - ) - ) || - (conn_kind == SPIDER_CONN_KIND_HS_READ && - !(conn = (SPIDER_CONN*) my_hash_search(&trx->trx_hs_r_conn_hash, - (uchar*) conn_key, share->hs_read_conn_keys_lengths[link_idx])) - ) || - (conn_kind == SPIDER_CONN_KIND_HS_WRITE && - !(conn = (SPIDER_CONN*) my_hash_search(&trx->trx_hs_w_conn_hash, - (uchar*) conn_key, share->hs_write_conn_keys_lengths[link_idx])) - ) -#endif ) #endif { if ( !trx->thd || -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - (conn_kind == SPIDER_CONN_KIND_MYSQL && -#endif ( (spider_param_conn_recycle_mode(trx->thd) & 1) || spider_param_conn_recycle_strict(trx->thd) ) -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - ) || - (conn_kind == SPIDER_CONN_KIND_HS_READ && - ( - (spider_param_hs_r_conn_recycle_mode(trx->thd) & 1) || - spider_param_hs_r_conn_recycle_strict(trx->thd) - ) - ) || - (conn_kind == SPIDER_CONN_KIND_HS_WRITE && - ( - (spider_param_hs_w_conn_recycle_mode(trx->thd) & 1) || - spider_param_hs_w_conn_recycle_strict(trx->thd) - ) - ) -#endif ) { -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (conn_kind == SPIDER_CONN_KIND_MYSQL) - { -#endif pthread_mutex_lock(&spider_conn_mutex); #ifdef SPIDER_HAS_HASH_VALUE_TYPE if (!(conn = (SPIDER_CONN*) my_hash_search_using_hash_value( @@ -1118,94 +792,6 @@ SPIDER_CONN *spider_get_conn( conn->use_for_active_standby = TRUE; } } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else if (conn_kind == SPIDER_CONN_KIND_HS_READ) - { - pthread_mutex_lock(&spider_hs_r_conn_mutex); -#ifdef SPIDER_HAS_HASH_VALUE_TYPE - if (!(conn = (SPIDER_CONN*) my_hash_search_using_hash_value( - &spider_hs_r_conn_hash, - share->hs_read_conn_keys_hash_value[link_idx], - (uchar*) share->hs_read_conn_keys[link_idx], - share->hs_read_conn_keys_lengths[link_idx]))) -#else - if (!(conn = (SPIDER_CONN*) my_hash_search(&spider_hs_r_conn_hash, - (uchar*) share->hs_read_conn_keys[link_idx], - share->hs_read_conn_keys_lengths[link_idx]))) -#endif - { - pthread_mutex_unlock(&spider_hs_r_conn_mutex); - DBUG_PRINT("info",("spider create new hs r conn")); - if (!(conn = spider_create_conn(share, spider, link_idx, - base_link_idx, conn_kind, error_num))) - goto error; - *conn->conn_key = *conn_key; - if (spider) - { - spider->hs_r_conns[base_link_idx] = conn; - if (spider_bit_is_set(spider->conn_can_fo, base_link_idx)) - conn->use_for_active_standby = TRUE; - } - } else { -#ifdef HASH_UPDATE_WITH_HASH_VALUE - my_hash_delete_with_hash_value(&spider_hs_r_conn_hash, - conn->conn_key_hash_value, (uchar*) conn); -#else - my_hash_delete(&spider_hs_r_conn_hash, (uchar*) conn); -#endif - pthread_mutex_unlock(&spider_hs_r_conn_mutex); - DBUG_PRINT("info",("spider get global hs r conn")); - if (spider) - { - spider->hs_r_conns[base_link_idx] = conn; - if (spider_bit_is_set(spider->conn_can_fo, base_link_idx)) - conn->use_for_active_standby = TRUE; - } - } - } else { - pthread_mutex_lock(&spider_hs_w_conn_mutex); -#ifdef SPIDER_HAS_HASH_VALUE_TYPE - if (!(conn = (SPIDER_CONN*) my_hash_search_using_hash_value( - &spider_hs_w_conn_hash, - share->hs_write_conn_keys_hash_value[link_idx], - (uchar*) share->hs_write_conn_keys[link_idx], - share->hs_write_conn_keys_lengths[link_idx]))) -#else - if (!(conn = (SPIDER_CONN*) my_hash_search(&spider_hs_w_conn_hash, - (uchar*) share->hs_write_conn_keys[link_idx], - share->hs_write_conn_keys_lengths[link_idx]))) -#endif - { - pthread_mutex_unlock(&spider_hs_w_conn_mutex); - DBUG_PRINT("info",("spider create new hs w conn")); - if (!(conn = spider_create_conn(share, spider, link_idx, - base_link_idx, conn_kind, error_num))) - goto error; - *conn->conn_key = *conn_key; - if (spider) - { - spider->hs_w_conns[base_link_idx] = conn; - if (spider_bit_is_set(spider->conn_can_fo, base_link_idx)) - conn->use_for_active_standby = TRUE; - } - } else { -#ifdef HASH_UPDATE_WITH_HASH_VALUE - my_hash_delete_with_hash_value(&spider_hs_w_conn_hash, - conn->conn_key_hash_value, (uchar*) conn); -#else - my_hash_delete(&spider_hs_w_conn_hash, (uchar*) conn); -#endif - pthread_mutex_unlock(&spider_hs_w_conn_mutex); - DBUG_PRINT("info",("spider get global hs w conn")); - if (spider) - { - spider->hs_w_conns[base_link_idx] = conn; - if (spider_bit_is_set(spider->conn_can_fo, base_link_idx)) - conn->use_for_active_standby = TRUE; - } - } - } -#endif } else { DBUG_PRINT("info",("spider create new conn")); /* conn_recycle_strict = 0 and conn_recycle_mode = 0 or 2 */ @@ -1215,19 +801,7 @@ SPIDER_CONN *spider_get_conn( *conn->conn_key = *conn_key; if (spider) { -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (conn_kind == SPIDER_CONN_KIND_MYSQL) - { -#endif spider->conns[base_link_idx] = conn; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else if (conn_kind == SPIDER_CONN_KIND_HS_READ) - { - spider->hs_r_conns[base_link_idx] = conn; - } else { - spider->hs_w_conns[base_link_idx] = conn; - } -#endif if (spider_bit_is_set(spider->conn_can_fo, base_link_idx)) conn->use_for_active_standby = TRUE; } @@ -1235,10 +809,6 @@ SPIDER_CONN *spider_get_conn( conn->thd = trx->thd; conn->priority = share->priority; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (conn_kind == SPIDER_CONN_KIND_MYSQL) - { -#endif if (another) { uint old_elements = trx->trx_another_conn_hash.array.max_element; @@ -1283,67 +853,9 @@ SPIDER_CONN *spider_get_conn( trx->trx_conn_hash.array.size_of_element); } } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else if (conn_kind == SPIDER_CONN_KIND_HS_READ) - { - uint old_elements = trx->trx_hs_r_conn_hash.array.max_element; -#ifdef HASH_UPDATE_WITH_HASH_VALUE - if (my_hash_insert_with_hash_value(&trx->trx_hs_r_conn_hash, - share->hs_read_conn_keys_hash_value[link_idx], - (uchar*) conn)) -#else - if (my_hash_insert(&trx->trx_hs_r_conn_hash, (uchar*) conn)) -#endif - { - spider_free_conn(conn); - *error_num = HA_ERR_OUT_OF_MEM; - goto error; - } - if (trx->trx_hs_r_conn_hash.array.max_element > old_elements) - { - spider_alloc_calc_mem(spider_current_trx, - trx->trx_hs_r_conn_hash, - (trx->trx_hs_r_conn_hash.array.max_element - old_elements) * - trx->trx_hs_r_conn_hash.array.size_of_element); - } - } else { - uint old_elements = trx->trx_hs_w_conn_hash.array.max_element; -#ifdef HASH_UPDATE_WITH_HASH_VALUE - if (my_hash_insert_with_hash_value(&trx->trx_hs_w_conn_hash, - share->hs_write_conn_keys_hash_value[link_idx], - (uchar*) conn)) -#else - if (my_hash_insert(&trx->trx_hs_w_conn_hash, (uchar*) conn)) -#endif - { - spider_free_conn(conn); - *error_num = HA_ERR_OUT_OF_MEM; - goto error; - } - if (trx->trx_hs_w_conn_hash.array.max_element > old_elements) - { - spider_alloc_calc_mem(spider_current_trx, - trx->trx_hs_w_conn_hash, - (trx->trx_hs_w_conn_hash.array.max_element - old_elements) * - trx->trx_hs_w_conn_hash.array.size_of_element); - } - } -#endif } else if (spider) { -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (conn_kind == SPIDER_CONN_KIND_MYSQL) - { -#endif spider->conns[base_link_idx] = conn; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else if (conn_kind == SPIDER_CONN_KIND_HS_READ) - { - spider->hs_r_conns[base_link_idx] = conn; - } else { - spider->hs_w_conns[base_link_idx] = conn; - } -#endif if (spider_bit_is_set(spider->conn_can_fo, base_link_idx)) conn->use_for_active_standby = TRUE; } @@ -1360,19 +872,12 @@ SPIDER_CONN *spider_get_conn( conn->queued_ping = FALSE; } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (conn_kind == SPIDER_CONN_KIND_MYSQL) - { -#endif if (unlikely(spider && spider->wide_handler->top_share && (*error_num = spider_conn_queue_loop_check( conn, spider, base_link_idx)))) { goto error; } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } -#endif DBUG_PRINT("info",("spider conn=%p", conn)); DBUG_RETURN(conn); @@ -2407,14 +1912,6 @@ int spider_set_conn_bg_param( ) { if ((error_num = spider_create_conn_thread(spider->conns[roop_count]))) DBUG_RETURN(error_num); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if ((error_num = spider_create_conn_thread( - spider->hs_r_conns[roop_count]))) - DBUG_RETURN(error_num); - if ((error_num = spider_create_conn_thread( - spider->hs_w_conns[roop_count]))) - DBUG_RETURN(error_num); -#endif } #ifdef SPIDER_HAS_GROUP_BY_HANDLER } @@ -2741,19 +2238,9 @@ int spider_bg_conn_search( bool with_lock = FALSE; DBUG_ENTER("spider_bg_conn_search"); DBUG_PRINT("info",("spider spider=%p", spider)); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (spider->conn_kind[link_idx] == SPIDER_CONN_KIND_MYSQL) - { -#endif conn = spider->conns[link_idx]; with_lock = (spider_conn_lock_mode(spider) != SPIDER_LOCK_MODE_NO_LOCK); first_conn = spider->conns[first_link_idx]; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else if (spider->conn_kind[link_idx] == SPIDER_CONN_KIND_HS_READ) - conn = spider->hs_r_conns[link_idx]; - else - conn = spider->hs_w_conns[link_idx]; -#endif if (first) { if (spider->use_pre_call) @@ -3212,21 +2699,12 @@ void *spider_bg_conn_action( !result_list->bgs_current->result ) { ulong sql_type; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (conn->conn_kind == SPIDER_CONN_KIND_MYSQL) - { -#endif if (spider->sql_kind[conn->link_idx] == SPIDER_SQL_KIND_SQL) { sql_type = SPIDER_SQL_TYPE_SELECT_SQL | SPIDER_SQL_TYPE_TMP_SQL; } else { sql_type = SPIDER_SQL_TYPE_HANDLER; } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else { - sql_type = SPIDER_SQL_TYPE_SELECT_HS; - } -#endif pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); if (spider->use_fields) { @@ -3554,27 +3032,12 @@ void *spider_bg_sts_action( uint *conn_link_idx; uchar *conn_can_fo; char **conn_keys; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - char **hs_r_conn_keys; - char **hs_w_conn_keys; -#endif spider_db_handler **dbton_hdl; THD *thd; my_thread_init(); DBUG_ENTER("spider_bg_sts_action"); /* init start */ char *ptr; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - ptr = (char *) my_alloca( - (sizeof(int) * share->link_count) + - (sizeof(SPIDER_CONN *) * share->link_count) + - (sizeof(uint) * share->link_count) + - (sizeof(uchar) * share->link_bitmap_size) + - (sizeof(char *) * share->link_count) + - (sizeof(char *) * share->link_count) + - (sizeof(char *) * share->link_count) + - (sizeof(spider_db_handler *) * SPIDER_DBTON_SIZE)); -#else ptr = (char *) my_alloca( (sizeof(int) * share->link_count) + (sizeof(SPIDER_CONN *) * share->link_count) + @@ -3582,7 +3045,6 @@ void *spider_bg_sts_action( (sizeof(uchar) * share->link_bitmap_size) + (sizeof(char *) * share->link_count) + (sizeof(spider_db_handler *) * SPIDER_DBTON_SIZE)); -#endif if (!ptr) { pthread_mutex_lock(&share->sts_mutex); @@ -3603,12 +3065,6 @@ void *spider_bg_sts_action( ptr += (sizeof(uchar) * share->link_bitmap_size); conn_keys = (char **) ptr; ptr += (sizeof(char *) * share->link_count); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - hs_r_conn_keys = (char **) ptr; - ptr += (sizeof(char *) * share->link_count); - hs_w_conn_keys = (char **) ptr; - ptr += (sizeof(char *) * share->link_count); -#endif dbton_hdl = (spider_db_handler **) ptr; pthread_mutex_lock(&share->sts_mutex); if (!(thd = SPIDER_new_THD(next_thread_id()))) @@ -3651,10 +3107,6 @@ void *spider_bg_sts_action( spider.need_mons = need_mons; spider.conn_keys_first_ptr = share->conn_keys[0]; spider.conn_keys = conn_keys; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - spider.hs_r_conn_keys = hs_r_conn_keys; - spider.hs_w_conn_keys = hs_w_conn_keys; -#endif spider.dbton_handler = dbton_hdl; memset(conns, 0, sizeof(SPIDER_CONN *) * share->link_count); memset(need_mons, 0, sizeof(int) * share->link_count); @@ -3908,27 +3360,12 @@ void *spider_bg_crd_action( uint *conn_link_idx; uchar *conn_can_fo; char **conn_keys; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - char **hs_r_conn_keys; - char **hs_w_conn_keys; -#endif spider_db_handler **dbton_hdl; THD *thd; my_thread_init(); DBUG_ENTER("spider_bg_crd_action"); /* init start */ char *ptr; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - ptr = (char *) my_alloca( - (sizeof(int) * share->link_count) + - (sizeof(SPIDER_CONN *) * share->link_count) + - (sizeof(uint) * share->link_count) + - (sizeof(uchar) * share->link_bitmap_size) + - (sizeof(char *) * share->link_count) + - (sizeof(char *) * share->link_count) + - (sizeof(char *) * share->link_count) + - (sizeof(spider_db_handler *) * SPIDER_DBTON_SIZE)); -#else ptr = (char *) my_alloca( (sizeof(int) * share->link_count) + (sizeof(SPIDER_CONN *) * share->link_count) + @@ -3936,7 +3373,6 @@ void *spider_bg_crd_action( (sizeof(uchar) * share->link_bitmap_size) + (sizeof(char *) * share->link_count) + (sizeof(spider_db_handler *) * SPIDER_DBTON_SIZE)); -#endif if (!ptr) { pthread_mutex_lock(&share->crd_mutex); @@ -3957,12 +3393,6 @@ void *spider_bg_crd_action( ptr += (sizeof(uchar) * share->link_bitmap_size); conn_keys = (char **) ptr; ptr += (sizeof(char *) * share->link_count); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - hs_r_conn_keys = (char **) ptr; - ptr += (sizeof(char *) * share->link_count); - hs_w_conn_keys = (char **) ptr; - ptr += (sizeof(char *) * share->link_count); -#endif dbton_hdl = (spider_db_handler **) ptr; pthread_mutex_lock(&share->crd_mutex); if (!(thd = SPIDER_new_THD(next_thread_id()))) @@ -4009,10 +3439,6 @@ void *spider_bg_crd_action( spider.need_mons = need_mons; spider.conn_keys_first_ptr = share->conn_keys[0]; spider.conn_keys = conn_keys; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - spider.hs_r_conn_keys = hs_r_conn_keys; - spider.hs_w_conn_keys = hs_w_conn_keys; -#endif spider.dbton_handler = dbton_hdl; memset(conns, 0, sizeof(SPIDER_CONN *) * share->link_count); memset(need_mons, 0, sizeof(int) * share->link_count); @@ -4694,51 +4120,14 @@ bool spider_conn_use_handler( DBUG_PRINT("info",("spider use_handler=%d", use_handler)); DBUG_PRINT("info",("spider spider->conn_kind[link_idx]=%u", spider->conn_kind[link_idx])); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (spider->conn_kind[link_idx] != SPIDER_CONN_KIND_MYSQL) - { - DBUG_PRINT("info",("spider TRUE by HS")); - spider->sql_kinds |= SPIDER_SQL_KIND_HS; - spider->sql_kind[link_idx] = SPIDER_SQL_KIND_HS; -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS - if ( - spider->do_direct_update && - spider_bit_is_set(spider->do_hs_direct_update, link_idx) - ) { - DBUG_PRINT("info",("spider using HS direct_update")); - spider->direct_update_kinds |= SPIDER_SQL_KIND_HS; - } -#endif - DBUG_RETURN(TRUE); - } -#endif #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS if (spider->do_direct_update) { spider->sql_kinds |= SPIDER_SQL_KIND_SQL; spider->sql_kind[link_idx] = SPIDER_SQL_KIND_SQL; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (spider_bit_is_set(spider->do_hs_direct_update, link_idx)) - { - spider->direct_update_kinds |= SPIDER_SQL_KIND_HS; - DBUG_PRINT("info",("spider TRUE by using HS direct_update")); - DBUG_RETURN(TRUE); - } else { -#endif spider->direct_update_kinds |= SPIDER_SQL_KIND_SQL; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } - if (spider->conn_kind[link_idx] == SPIDER_CONN_KIND_MYSQL) - { -#endif DBUG_PRINT("info",("spider FALSE by using direct_update")); DBUG_RETURN(FALSE); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else { - DBUG_PRINT("info",("spider TRUE by using BOTH")); - DBUG_RETURN(TRUE); - } -#endif } #endif if (spider->use_spatial_index) @@ -4796,173 +4185,12 @@ bool spider_conn_need_open_handler( uint idx, int link_idx ) { -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - SPIDER_CONN *conn; -#endif DBUG_ENTER("spider_conn_need_open_handler"); DBUG_PRINT("info",("spider spider=%p", spider)); if (spider->handler_opened(link_idx, spider->conn_kind[link_idx])) { -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS - if ( - spider->do_direct_update && - spider_bit_is_set(spider->do_hs_direct_update, link_idx) - ) { - conn = spider->hs_w_conns[link_idx]; - if ( - !conn->server_lost && - conn->hs_pre_age == spider->hs_w_conn_ages[link_idx] - ) { - DBUG_PRINT("info",("spider hs_write is already opened")); - DBUG_RETURN(FALSE); - } - } else -#endif - if (spider->conn_kind[link_idx] == SPIDER_CONN_KIND_MYSQL) - { -#endif DBUG_PRINT("info",("spider HA already opened")); DBUG_RETURN(FALSE); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else if (spider->conn_kind[link_idx] == SPIDER_CONN_KIND_HS_READ) - { - DBUG_PRINT("info",("spider r_handler_index[%d]=%d", - link_idx, spider->r_handler_index[link_idx])); - DBUG_PRINT("info",("spider idx=%d", idx)); - DBUG_PRINT("info",("spider hs_pushed_ret_fields_num=%zu", - spider->hs_pushed_ret_fields_num)); - DBUG_PRINT("info",("spider hs_r_ret_fields_num[%d]=%lu", - link_idx, spider->hs_r_ret_fields_num[link_idx])); - DBUG_PRINT("info",("spider hs_r_ret_fields[%d]=%p", - link_idx, spider->hs_r_ret_fields[link_idx])); -#ifndef DBUG_OFF - if ( - spider->hs_pushed_ret_fields_num < MAX_FIELDS && - spider->hs_r_ret_fields[link_idx] && - spider->hs_pushed_ret_fields_num == - spider->hs_r_ret_fields_num[link_idx] - ) { - int roop_count; - for (roop_count = 0; roop_count < (int) spider->hs_pushed_ret_fields_num; - ++roop_count) - { - DBUG_PRINT("info",("spider hs_pushed_ret_fields[%d]=%u", - roop_count, spider->hs_pushed_ret_fields[roop_count])); - DBUG_PRINT("info",("spider hs_r_ret_fields[%d][%d]=%u", - link_idx, roop_count, - spider->hs_r_ret_fields[link_idx][roop_count])); - } - } -#endif - if ( - spider->r_handler_index[link_idx] == idx -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS - && ( - ( - spider->hs_pushed_ret_fields_num == MAX_FIELDS && - spider->hs_r_ret_fields_num[link_idx] == MAX_FIELDS - ) || - ( - spider->hs_pushed_ret_fields_num < MAX_FIELDS && - spider->hs_r_ret_fields[link_idx] && - spider->hs_pushed_ret_fields_num == - spider->hs_r_ret_fields_num[link_idx] && - !memcmp(spider->hs_pushed_ret_fields, - spider->hs_r_ret_fields[link_idx], - sizeof(uint32) * spider->hs_pushed_ret_fields_num) - ) - ) -#endif - ) { - SPIDER_CONN *conn = spider->hs_r_conns[link_idx]; - DBUG_PRINT("info",("spider conn=%p", conn)); - DBUG_PRINT("info",("spider conn->conn_id=%llu", conn->conn_id)); - DBUG_PRINT("info",("spider conn->connection_id=%llu", - conn->connection_id)); - DBUG_PRINT("info",("spider conn->server_lost=%s", - conn->server_lost ? "TRUE" : "FALSE")); - DBUG_PRINT("info",("spider conn->hs_pre_age=%llu", conn->hs_pre_age)); - DBUG_PRINT("info",("spider hs_w_conn_ages[%d]=%llu", - link_idx, spider->hs_w_conn_ages[link_idx])); - if ( - !conn->server_lost && - conn->hs_pre_age == spider->hs_r_conn_ages[link_idx] - ) { - DBUG_PRINT("info",("spider hs_r same idx")); - DBUG_RETURN(FALSE); - } - } - } else if (spider->conn_kind[link_idx] == SPIDER_CONN_KIND_HS_WRITE) - { - DBUG_PRINT("info",("spider w_handler_index[%d]=%d", - link_idx, spider->w_handler_index[link_idx])); - DBUG_PRINT("info",("spider idx=%d", idx)); - DBUG_PRINT("info",("spider hs_pushed_ret_fields_num=%zu", - spider->hs_pushed_ret_fields_num)); - DBUG_PRINT("info",("spider hs_w_ret_fields_num[%d]=%lu", - link_idx, spider->hs_w_ret_fields_num[link_idx])); - DBUG_PRINT("info",("spider hs_w_ret_fields[%d]=%p", - link_idx, spider->hs_w_ret_fields[link_idx])); -#ifndef DBUG_OFF - if ( - spider->hs_pushed_ret_fields_num < MAX_FIELDS && - spider->hs_w_ret_fields[link_idx] && - spider->hs_pushed_ret_fields_num == - spider->hs_w_ret_fields_num[link_idx] - ) { - int roop_count; - for (roop_count = 0; roop_count < (int) spider->hs_pushed_ret_fields_num; - ++roop_count) - { - DBUG_PRINT("info",("spider hs_pushed_ret_fields[%d]=%u", - roop_count, spider->hs_pushed_ret_fields[roop_count])); - DBUG_PRINT("info",("spider hs_w_ret_fields[%d][%d]=%u", - link_idx, roop_count, - spider->hs_w_ret_fields[link_idx][roop_count])); - } - } -#endif - if ( - spider->w_handler_index[link_idx] == idx -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS - && ( - ( - spider->hs_pushed_ret_fields_num == MAX_FIELDS && - spider->hs_w_ret_fields_num[link_idx] == MAX_FIELDS - ) || - ( - spider->hs_pushed_ret_fields_num < MAX_FIELDS && - spider->hs_w_ret_fields[link_idx] && - spider->hs_pushed_ret_fields_num == - spider->hs_w_ret_fields_num[link_idx] && - !memcmp(spider->hs_pushed_ret_fields, - spider->hs_w_ret_fields[link_idx], - sizeof(uint32) * spider->hs_pushed_ret_fields_num) - ) - ) -#endif - ) { - SPIDER_CONN *conn = spider->hs_w_conns[link_idx]; - DBUG_PRINT("info",("spider conn=%p", conn)); - DBUG_PRINT("info",("spider conn->conn_id=%llu", conn->conn_id)); - DBUG_PRINT("info",("spider conn->connection_id=%llu", - conn->connection_id)); - DBUG_PRINT("info",("spider conn->server_lost=%s", - conn->server_lost ? "TRUE" : "FALSE")); - DBUG_PRINT("info",("spider conn->hs_pre_age=%llu", conn->hs_pre_age)); - DBUG_PRINT("info",("spider hs_w_conn_ages[%d]=%llu", - link_idx, spider->hs_w_conn_ages[link_idx])); - if ( - !conn->server_lost && - conn->hs_pre_age == spider->hs_w_conn_ages[link_idx] - ) { - DBUG_PRINT("info",("spider hs_w same idx")); - DBUG_RETURN(FALSE); - } - } - } -#endif } DBUG_RETURN(TRUE); } diff --git a/storage/spider/spd_db_conn.cc b/storage/spider/spd_db_conn.cc index a9f62e0626d..2498804ac06 100644 --- a/storage/spider/spd_db_conn.cc +++ b/storage/spider/spd_db_conn.cc @@ -132,36 +132,16 @@ int spider_db_connect( DBUG_PRINT("info",("spider net_read_timeout=%u", conn->net_read_timeout)); DBUG_PRINT("info",("spider net_write_timeout=%u", conn->net_write_timeout)); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (conn->conn_kind == SPIDER_CONN_KIND_MYSQL) - { -#endif if ((error_num = spider_reset_conn_setted_parameter(conn, thd))) DBUG_RETURN(error_num); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } -#endif if (conn->dbton_id == SPIDER_DBTON_SIZE) { -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (conn->conn_kind == SPIDER_CONN_KIND_MYSQL) - { -#endif my_printf_error( ER_SPIDER_SQL_WRAPPER_IS_INVALID_NUM, ER_SPIDER_SQL_WRAPPER_IS_INVALID_STR, MYF(0), conn->tgt_wrapper); DBUG_RETURN(ER_SPIDER_SQL_WRAPPER_IS_INVALID_NUM); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else { - my_printf_error( - ER_SPIDER_NOSQL_WRAPPER_IS_INVALID_NUM, - ER_SPIDER_NOSQL_WRAPPER_IS_INVALID_STR, - MYF(0), conn->tgt_wrapper); - DBUG_RETURN(ER_SPIDER_NOSQL_WRAPPER_IS_INVALID_NUM); - } -#endif } if ((error_num = conn->db_conn->connect( @@ -291,10 +271,6 @@ int spider_db_conn_queue_action( } pthread_mutex_assert_owner(&conn->mta_conn_mutex); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (conn->conn_kind == SPIDER_CONN_KIND_MYSQL) - { -#endif if (conn->queued_ping) { if ((error_num = spider_db_ping(conn->queued_ping_spider, conn, @@ -583,13 +559,6 @@ int spider_db_conn_queue_action( conn->db_conn->fin_loop_check(); } spider_conn_clear_queue(conn); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else if (conn->server_lost) - { - DBUG_PRINT("info", ("spider no connect queue")); - DBUG_RETURN(CR_SERVER_GONE_ERROR); - } -#endif DBUG_RETURN(0); } @@ -673,10 +642,6 @@ int spider_db_query( int error_num; DBUG_ENTER("spider_db_query"); pthread_mutex_assert_owner(&conn->mta_conn_mutex); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (conn->conn_kind == SPIDER_CONN_KIND_MYSQL) - { -#endif DBUG_PRINT("info", ("spider conn->db_conn %p", conn->db_conn)); if ( !conn->in_before_query && @@ -696,17 +661,6 @@ int spider_db_query( if ((error_num = conn->db_conn->exec_query(query, length, quick_mode))) DBUG_RETURN(error_num); DBUG_RETURN(0); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else { - if (conn->queued_net_timeout) - { - if (conn->db_conn->set_net_timeout()) - DBUG_RETURN(ER_SPIDER_HS_NUM); - conn->queued_net_timeout = FALSE; - } - DBUG_RETURN(conn->db_conn->exec_query(NULL, 0, quick_mode)); - } -#endif } int spider_db_errorno( @@ -716,10 +670,6 @@ int spider_db_errorno( DBUG_ENTER("spider_db_errorno"); DBUG_ASSERT(conn->need_mon); pthread_mutex_assert_owner(&conn->mta_conn_mutex); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (conn->conn_kind == SPIDER_CONN_KIND_MYSQL) - { -#endif if (conn->server_lost) { *conn->need_mon = ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM; @@ -819,57 +769,6 @@ int spider_db_errorno( } DBUG_RETURN(error_num); } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else { - if (conn->db_conn->is_server_gone_error(0)) - { - my_printf_error(ER_SPIDER_HS_NUM, ER_SPIDER_HS_STR, MYF(0), - conn->db_conn->get_errno(), conn->db_conn->get_error()); - *conn->need_mon = ER_SPIDER_HS_NUM; - DBUG_PRINT("info", ("spider conn=%p SERVER_LOST", conn)); - conn->server_lost = TRUE; - if (!conn->mta_conn_mutex_unlock_later) - { - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); - pthread_mutex_unlock(&conn->mta_conn_mutex); - } - DBUG_RETURN(ER_SPIDER_HS_NUM); - } else if (conn->db_conn->is_dup_entry_error(0)) - { - *conn->need_mon = 0; - if (!conn->mta_conn_mutex_unlock_later) - { - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); - pthread_mutex_unlock(&conn->mta_conn_mutex); - } - DBUG_RETURN(HA_ERR_FOUND_DUPP_KEY); - } - my_printf_error(ER_SPIDER_HS_NUM, ER_SPIDER_HS_STR, MYF(0), - conn->db_conn->get_errno(), conn->db_conn->get_error()); - if (spider_param_log_result_errors() >= 1) - { - time_t cur_time = (time_t) time((time_t*) 0); - struct tm lt; - struct tm *l_time = localtime_r(&cur_time, <); - fprintf(stderr, "%04d%02d%02d %02d:%02d:%02d [ERROR SPIDER RESULT] " - "to %ld: %d %s\n", - l_time->tm_year + 1900, l_time->tm_mon + 1, l_time->tm_mday, - l_time->tm_hour, l_time->tm_min, l_time->tm_sec, - (ulong) current_thd->thread_id, conn->db_conn->get_errno(), - conn->db_conn->get_error()); - } - *conn->need_mon = ER_SPIDER_HS_NUM; - if (!conn->mta_conn_mutex_unlock_later) - { - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); - pthread_mutex_unlock(&conn->mta_conn_mutex); - } - DBUG_RETURN(ER_SPIDER_HS_NUM); - } -#endif if (!conn->mta_conn_mutex_unlock_later) { DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); @@ -896,10 +795,6 @@ int spider_db_set_names_internal( int *need_mon ) { DBUG_ENTER("spider_db_set_names_internal"); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (conn->conn_kind == SPIDER_CONN_KIND_MYSQL) - { -#endif pthread_mutex_assert_owner(&conn->mta_conn_mutex); DBUG_ASSERT(conn->mta_conn_mutex_file_pos.file_name); DBUG_ASSERT(conn->mta_conn_mutex_lock_already); @@ -943,9 +838,6 @@ int spider_db_set_names_internal( share->tgt_dbs_lengths[all_link_idx] + 1); conn->default_database.length(share->tgt_dbs_lengths[all_link_idx]); } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } -#endif DBUG_RETURN(0); } @@ -1702,14 +1594,6 @@ int spider_db_append_key_where_internal( case SPIDER_SQL_TYPE_HANDLER: sql_kind = SPIDER_SQL_KIND_HANDLER; break; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - case SPIDER_SQL_TYPE_SELECT_HS: - case SPIDER_SQL_TYPE_INSERT_HS: - case SPIDER_SQL_TYPE_UPDATE_HS: - case SPIDER_SQL_TYPE_DELETE_HS: - sql_kind = SPIDER_SQL_KIND_HS; - break; -#endif default: sql_kind = SPIDER_SQL_KIND_SQL; break; @@ -1930,14 +1814,6 @@ int spider_db_append_key_where_internal( #endif } } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - else { - if (spider_dbton[share->use_hs_dbton_ids[0]].db_util-> - append_column_value(spider, NULL, field, ptr, - share->access_charset)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - } -#endif } else { DBUG_PRINT("info", ("spider start_key->flag=%d", start_key->flag)); switch (start_key->flag) @@ -2008,17 +1884,6 @@ int spider_db_append_key_where_internal( #endif } } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - else { - if (spider_dbton[share->use_hs_dbton_ids[0]].db_util-> - append_column_value(spider, NULL, field, ptr, - share->access_charset)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - if (str->reserve(SPIDER_SQL_HS_EQUAL_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(SPIDER_SQL_HS_EQUAL_STR, SPIDER_SQL_HS_EQUAL_LEN); - } -#endif break; case HA_READ_AFTER_KEY: if (sql_kind == SPIDER_SQL_KIND_SQL) @@ -2087,17 +1952,6 @@ int spider_db_append_key_where_internal( #endif } } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - else { - if (spider_dbton[share->use_hs_dbton_ids[0]].db_util-> - append_column_value(spider, NULL, field, ptr, - share->access_charset)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - if (str->reserve(SPIDER_SQL_HS_GT_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(SPIDER_SQL_HS_GT_STR, SPIDER_SQL_HS_GT_LEN); - } -#endif break; case HA_READ_BEFORE_KEY: result_list->desc_flg = TRUE; @@ -2167,17 +2021,6 @@ int spider_db_append_key_where_internal( #endif } } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - else { - if (spider_dbton[share->use_hs_dbton_ids[0]].db_util-> - append_column_value(spider, NULL, field, ptr, - share->access_charset)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - if (str->reserve(SPIDER_SQL_HS_LT_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(SPIDER_SQL_HS_LT_STR, SPIDER_SQL_HS_LT_LEN); - } -#endif break; case HA_READ_KEY_OR_PREV: case HA_READ_PREFIX_LAST_OR_PREV: @@ -2241,18 +2084,6 @@ int spider_db_append_key_where_internal( #endif } } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - else { - if (spider_dbton[share->use_hs_dbton_ids[0]].db_util-> - append_column_value(spider, NULL, field, ptr, - share->access_charset)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - if (str->reserve(SPIDER_SQL_HS_LTEQUAL_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(SPIDER_SQL_HS_LTEQUAL_STR, - SPIDER_SQL_HS_LTEQUAL_LEN); - } -#endif break; case HA_READ_MBR_CONTAIN: if (str->reserve(SPIDER_SQL_MBR_CONTAIN_LEN)) @@ -2393,18 +2224,6 @@ int spider_db_append_key_where_internal( #endif } } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - else { - if (spider_dbton[share->use_hs_dbton_ids[0]].db_util-> - append_column_value(spider, NULL, field, ptr, - share->access_charset)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - if (str->reserve(SPIDER_SQL_HS_GTEQUAL_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(SPIDER_SQL_HS_GTEQUAL_STR, - SPIDER_SQL_HS_GTEQUAL_LEN); - } -#endif break; } } @@ -2432,10 +2251,6 @@ int spider_db_append_key_where_internal( } } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (sql_kind != SPIDER_SQL_KIND_HS) - { -#endif if ( (key_eq && use_key == end_key) || (!key_eq && end_key_part_map) @@ -2659,9 +2474,6 @@ int spider_db_append_key_where_internal( } if (use_both && (!start_key_part_map || !end_key_part_map)) break; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } -#endif } if ((error_num = dbton_hdl->append_where_terminator_part(sql_type, set_order, key_count))) @@ -2705,15 +2517,6 @@ int spider_db_append_key_where( SPIDER_SQL_TYPE_HANDLER))) DBUG_RETURN(error_num); } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if ((spider->sql_kinds & SPIDER_SQL_KIND_HS)) - { - DBUG_PRINT("info",("spider call internal by SPIDER_SQL_KIND_HS")); - if ((error_num = spider->append_key_where_hs_part(start_key, end_key, - SPIDER_SQL_TYPE_SELECT_HS))) - DBUG_RETURN(error_num); - } -#endif DBUG_RETURN(0); } @@ -3119,10 +2922,6 @@ int spider_db_fetch_table( SPIDER_DB_ROW *row; Field **field; DBUG_ENTER("spider_db_fetch_table"); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (spider->conn_kind[spider->result_link_idx] == SPIDER_CONN_KIND_MYSQL) - { -#endif if (result_list->quick_mode == 0) { SPIDER_DB_RESULT *result = current->result; @@ -3205,21 +3004,7 @@ int spider_db_fetch_table( #ifdef SPIDER_HAS_GROUP_BY_HANDLER } #endif -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else { - if (!(row = result_list->hs_result->fetch_row_from_result_buffer( - result_list->hs_result_buf))) - { - table->status = STATUS_NOT_FOUND; - DBUG_RETURN(HA_ERR_END_OF_FILE); - } - } -#endif -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (spider->conn_kind[spider->result_link_idx] == SPIDER_CONN_KIND_MYSQL) - { -#endif for ( field = table->field; *field; @@ -3247,68 +3032,6 @@ int spider_db_fetch_table( } row->next(); } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else { -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS - if (spider->hs_pushed_ret_fields_num == MAX_FIELDS) - { -#endif - spider_db_handler *dbton_hdl = spider->dbton_handler[row->dbton_id]; - for ( - field = table->field; - *field; - field++ - ) { - if (dbton_hdl->minimum_select_bit_is_set((*field)->field_index)) - { -#ifndef DBUG_OFF - my_bitmap_map *tmp_map = - dbug_tmp_use_all_columns(table, table->write_set); -#endif - if ((error_num = spider_db_fetch_row(share, *field, row, ptr_diff))) - DBUG_RETURN(error_num); -#ifndef DBUG_OFF - dbug_tmp_restore_column_map(table->write_set, tmp_map); -#endif - row->next(); - } - } -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS - } else { - uint32 *field_idxs = spider->hs_pushed_ret_fields; - size_t field_idxs_num = spider->hs_pushed_ret_fields_num; - Field *tf; - int roop_count; - if (spider->hs_pushed_lcl_fields_num != - result_list->hs_result->num_fields()) - { - DBUG_PRINT("info", ("spider different field_num %zu %u", - spider->hs_pushed_lcl_fields_num, - result_list->hs_result->num_fields())); - DBUG_RETURN(ER_SPIDER_UNKNOWN_NUM); - } - for (roop_count = 0; roop_count < (int) field_idxs_num; - roop_count++) - { - tf = spider->get_top_table_field(field_idxs[roop_count]); - if ((tf = spider->field_exchange(tf))) - { -#ifndef DBUG_OFF - my_bitmap_map *tmp_map = - dbug_tmp_use_all_columns(table, table->write_set); -#endif - if ((error_num = spider_db_fetch_row(share, tf, row, ptr_diff))) - DBUG_RETURN(error_num); -#ifndef DBUG_OFF - dbug_tmp_restore_column_map(table->write_set, tmp_map); -#endif - row->next(); - } - } - } -#endif - } -#endif table->status = 0; DBUG_RETURN(0); } @@ -3561,10 +3284,6 @@ void spider_db_free_one_result_for_start_next( DBUG_ENTER("spider_db_free_one_result_for_start_next"); spider_bg_all_conn_break(spider); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (spider->conn_kind[spider->result_link_idx] == SPIDER_CONN_KIND_MYSQL) - { -#endif if (result_list->low_mem_read) { if (result) @@ -3593,24 +3312,6 @@ void spider_db_free_one_result_for_start_next( result = (SPIDER_RESULT *) result->next; } } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else { - if (result_list->hs_has_result) - { - if (result_list->hs_result) - { - result_list->hs_result->free_result(); - delete result_list->hs_result; - result_list->hs_result = NULL; - } - if (result_list->hs_result_buf) - { - result_list->hs_result_buf->clear(); - } - result_list->hs_has_result = FALSE; - } - } -#endif DBUG_VOID_RETURN; } @@ -3719,27 +3420,6 @@ int spider_db_free_result( delete tmp_pos_row; } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (result_list->hs_has_result) - { - if (result_list->hs_result) - { - result_list->hs_result->free_result(); - delete result_list->hs_result; - result_list->hs_result = NULL; - } - if (result_list->hs_result_buf) - { - if (result_list->hs_result_buf->check_size( - spider_param_hs_result_free_size(trx->thd, share->hs_result_free_size)) - ) { - trx->hs_result_free_count++; - } - result_list->hs_result_buf->clear(); - } - result_list->hs_has_result = FALSE; - } -#endif if ( final || @@ -3929,10 +3609,6 @@ int spider_db_store_result( SPIDER_RESULT_LIST *result_list = &spider->result_list; SPIDER_RESULT *current; DBUG_ENTER("spider_db_store_result"); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (spider->conn_kind[link_idx] == SPIDER_CONN_KIND_MYSQL) - { -#endif conn = spider->conns[link_idx]; DBUG_PRINT("info",("spider conn->connection_id=%llu", conn->connection_id)); @@ -4416,66 +4092,6 @@ int spider_db_store_result( DBUG_PRINT("info", ("spider first_position[]=%p", ¤t->first_position[result_list->current_row_num])); DBUG_PRINT("info", ("spider row=%p", current->first_position[result_list->current_row_num].row)); } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else { - if (spider->conn_kind[link_idx] == SPIDER_CONN_KIND_HS_READ) - conn = spider->hs_r_conns[link_idx]; - else - conn = spider->hs_w_conns[link_idx]; - DBUG_PRINT("info",("spider conn=%p", conn)); - DBUG_PRINT("info",("spider conn->connection_id=%llu", - conn->connection_id)); - DBUG_PRINT("info",("spider spider->connection_ids[%d]=%llu", - link_idx, spider->connection_ids[link_idx])); - if (conn->connection_id != spider->connection_ids[link_idx]) - { - my_message(ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM, - ER_SPIDER_REMOTE_SERVER_GONE_AWAY_STR, MYF(0)); - if (!conn->mta_conn_mutex_unlock_later) - { - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); - pthread_mutex_unlock(&conn->mta_conn_mutex); - } - DBUG_RETURN(ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM); - } - if (spider_bit_is_set(spider->db_request_phase, link_idx)) - { - spider_clear_bit(spider->db_request_phase, link_idx); - } - st_spider_db_request_key request_key; - request_key.spider_thread_id = spider->wide_handler->trx->spider_thread_id; - request_key.query_id = spider->wide_handler->trx->thd->query_id; - request_key.handler = spider; - request_key.request_id = spider->db_request_id[link_idx]; - request_key.next = NULL; - if (!(result_list->hs_result = conn->db_conn->store_result( - &result_list->hs_result_buf, &request_key, &error_num))) - { - if (!error_num) - { - spider_db_errorno(conn); - DBUG_RETURN(ER_SPIDER_HS_NUM); - } else { - if (!conn->mta_conn_mutex_unlock_later) - { - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); - pthread_mutex_unlock(&conn->mta_conn_mutex); - } - } - DBUG_RETURN(error_num); - } - result_list->hs_conn = conn->db_conn; - result_list->hs_has_result = TRUE; - if (!conn->mta_conn_mutex_unlock_later) - { - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); - pthread_mutex_unlock(&conn->mta_conn_mutex); - } - } -#endif DBUG_RETURN(0); } @@ -4489,9 +4105,6 @@ int spider_db_store_result_for_reuse_cursor( SPIDER_RESULT_LIST *result_list = &spider->result_list; SPIDER_RESULT *current; DBUG_ENTER("spider_db_store_result_for_reuse_cursor"); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - DBUG_ASSERT(spider->conn_kind[link_idx] == SPIDER_CONN_KIND_MYSQL); -#endif conn = spider->conns[link_idx]; DBUG_PRINT("info",("spider conn->connection_id=%llu", conn->connection_id)); @@ -5021,9 +4634,6 @@ int spider_db_seek_next( SPIDER_RESULT_LIST *result_list = &spider->result_list; DBUG_ENTER("spider_db_seek_next"); if ( -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - spider->conn_kind[spider->result_link_idx] == SPIDER_CONN_KIND_MYSQL && -#endif result_list->current_row_num >= result_list->current->record_num ) { DBUG_PRINT("info",("spider result_list->current_row_num=%lld", @@ -6488,9 +6098,6 @@ int spider_db_bulk_insert_init( DBUG_ENTER("spider_db_bulk_insert_init"); spider->sql_kinds = 0; spider->reset_sql_sql(SPIDER_SQL_TYPE_INSERT_SQL); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - spider->reset_hs_sql(SPIDER_SQL_TYPE_OTHER_HS); -#endif for ( roop_count = spider_conn_link_idx_next(share->link_statuses, spider->conn_link_idx, -1, share->link_count, @@ -6503,67 +6110,15 @@ int spider_db_bulk_insert_init( if (spider->conns[roop_count]) spider->conns[roop_count]->ignore_dup_key = spider->wide_handler->ignore_dup_key; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if ( - spider_conn_use_handler(spider, spider->lock_mode, roop_count) && - ( - !spider->handler_opened(roop_count, SPIDER_CONN_KIND_HS_WRITE) || -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS - spider->hs_w_ret_fields_num[roop_count] < MAX_FIELDS || -#endif - spider->hs_w_conns[roop_count]->server_lost - ) - ) { - if ((error_num = spider_db_open_handler(spider, - spider->hs_w_conns[roop_count], roop_count))) - { - if ( - share->monitoring_kind[roop_count] && - spider->need_mons[roop_count] - ) { - error_num = spider_ping_table_mon_from_table( - spider->wide_handler->trx, - spider->wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - spider->conn_link_idx[roop_count], - NULL, - 0, - share->monitoring_kind[roop_count], - share->monitoring_limit[roop_count], - share->monitoring_flag[roop_count], - TRUE - ); - } - DBUG_RETURN(error_num); - } - spider->set_handler_opened(roop_count); - } -#else spider_conn_use_handler(spider, spider->wide_handler->lock_mode, roop_count); -#endif } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (spider->sql_kinds & SPIDER_SQL_KIND_SQL) - { -#endif if ( (error_num = spider->append_insert_sql_part()) || (error_num = spider->append_into_sql_part( SPIDER_SQL_TYPE_INSERT_SQL)) ) DBUG_RETURN(error_num); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } - if (spider->sql_kinds & SPIDER_SQL_KIND_HS) - { - spider->result_list.hs_upd_rows = 0; - } -#endif DBUG_RETURN(0); } @@ -6574,19 +6129,12 @@ int spider_db_bulk_insert( bool bulk_end ) { int error_num, first_insert_link_idx = -1; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - SPIDER_RESULT_LIST *result_list = &spider->result_list; -#endif SPIDER_SHARE *share = spider->share; THD *thd = spider->wide_handler->trx->thd; DBUG_ENTER("spider_db_bulk_insert"); if (!bulk_end) { -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (spider->sql_kinds & SPIDER_SQL_KIND_SQL) - { -#endif if ((error_num = spider->append_insert_values_sql_part( SPIDER_SQL_TYPE_INSERT_SQL))) { @@ -6594,16 +6142,6 @@ int spider_db_bulk_insert( spider->set_insert_to_pos_sql(SPIDER_SQL_TYPE_INSERT_SQL); DBUG_RETURN(error_num); } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } - if (spider->sql_kinds & SPIDER_SQL_KIND_HS) - { - if ((error_num = spider->append_insert_values_hs_part( - SPIDER_SQL_TYPE_INSERT_HS))) - DBUG_RETURN(error_num); - result_list->hs_upd_rows++; - } -#endif } if (spider->is_bulk_insert_exec_period(bulk_end)) @@ -6633,10 +6171,6 @@ int spider_db_bulk_insert( ) { ulong sql_type; spider_db_handler *dbton_handler; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (spider->conn_kind[roop_count2] == SPIDER_CONN_KIND_MYSQL) - { -#endif sql_type = SPIDER_SQL_TYPE_INSERT_SQL; conn = spider->conns[roop_count2]; dbton_handler = spider->dbton_handler[conn->dbton_id]; @@ -6650,16 +6184,6 @@ int spider_db_bulk_insert( } pthread_mutex_lock(&conn->mta_conn_mutex); SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else { - sql_type = SPIDER_SQL_TYPE_INSERT_HS; - conn = spider->hs_w_conns[roop_count2]; - dbton_handler = spider->dbton_handler[conn->dbton_id]; - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); - } -#endif conn->need_mon = &spider->need_mons[roop_count2]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -6755,43 +6279,6 @@ int spider_db_bulk_insert( insert_info = conn->db_conn->inserted_info(dbton_handler, copy_info); } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (conn->conn_kind != SPIDER_CONN_KIND_MYSQL) - { - uint roop_count; - DBUG_PRINT("info",("spider conn=%p", conn)); - DBUG_PRINT("info",("spider result_list->hs_upd_rows=%llu", - result_list->hs_upd_rows)); - for (roop_count = 0; roop_count < result_list->hs_upd_rows; - roop_count++) - { - SPIDER_DB_RESULT *result; - if (spider_bit_is_set(spider->db_request_phase, roop_count2)) - { - spider_clear_bit(spider->db_request_phase, roop_count2); - } - st_spider_db_request_key request_key; - request_key.spider_thread_id = - spider->wide_handler->trx->spider_thread_id; - request_key.query_id = spider->wide_handler->trx->thd->query_id; - request_key.handler = spider; - request_key.request_id = spider->db_request_id[roop_count2]; - request_key.next = NULL; - if ((result = conn->db_conn->use_result(spider, &request_key, - &error_num))) - { - result->free_result(); - delete result; - } else { - if (!error_num) - { - error_num = spider_db_errorno(conn); - } - DBUG_RETURN(error_num); - } - } - } -#endif SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); if (first_insert_link_idx == -1) @@ -6892,16 +6379,7 @@ int spider_db_bulk_bulk_insert( spider->conn_link_idx, roop_count2, share->link_count, SPIDER_LINK_STATUS_RECOVERY) ) { -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (spider->conn_kind[roop_count2] == SPIDER_CONN_KIND_MYSQL) - { -#endif conn = spider->conns[roop_count2]; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else { - conn = spider->hs_w_conns[roop_count2]; - } -#endif pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); pthread_mutex_lock(&conn->mta_conn_mutex); SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); @@ -6918,44 +6396,6 @@ int spider_db_bulk_bulk_insert( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (conn->conn_kind != SPIDER_CONN_KIND_MYSQL) - { - uint roop_count; - SPIDER_RESULT_LIST *result_list = &spider->result_list; - DBUG_PRINT("info",("spider conn=%p", conn)); - DBUG_PRINT("info",("spider result_list->hs_upd_rows=%llu", - result_list->hs_upd_rows)); - for (roop_count = 0; roop_count < result_list->hs_upd_rows; - roop_count++) - { - SPIDER_DB_RESULT *result; - if (spider_bit_is_set(spider->db_request_phase, roop_count2)) - { - spider_clear_bit(spider->db_request_phase, roop_count2); - } - st_spider_db_request_key request_key; - request_key.spider_thread_id = - spider->wide_handler->trx->spider_thread_id; - request_key.query_id = spider->wide_handler->trx->thd->query_id; - request_key.handler = spider; - request_key.request_id = spider->db_request_id[roop_count2]; - request_key.next = NULL; - if ((result = conn->db_conn->use_result(spider, &request_key, - &error_num))) - { - result->free_result(); - delete result; - } else { - if (!error_num) - { - error_num = spider_db_errorno(conn); - } - DBUG_RETURN(error_num); - } - } - } -#endif SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); if (first_insert_link_idx == -1) @@ -7026,16 +6466,7 @@ int spider_db_update_auto_increment( (auto_increment_mode == 3 && !table->auto_increment_field_not_null) ) { last_insert_id = spider->conns[link_idx]->db_conn->last_insert_id(); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (spider->conn_kind[link_idx] == SPIDER_CONN_KIND_MYSQL) - { -#endif affected_rows = spider->conns[link_idx]->db_conn->affected_rows(); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else { - affected_rows = spider->result_list.hs_upd_rows; - } -#endif DBUG_PRINT("info",("spider last_insert_id=%llu", last_insert_id)); share->lgtm_tblhnd_share->auto_increment_value = last_insert_id + affected_rows; @@ -7503,27 +6934,8 @@ int spider_db_direct_update( spider->do_direct_update ? "TRUE" : "FALSE")); DBUG_PRINT("info", ("spider direct_update_kinds=%u", spider->direct_update_kinds)); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if ( -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS - ( - spider->do_direct_update && - (spider->direct_update_kinds & SPIDER_SQL_KIND_SQL) - ) || - ( - !spider->do_direct_update && -#endif - (spider->sql_kinds & SPIDER_SQL_KIND_SQL) -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS - ) -#endif - ) { -#endif if ((error_num = spider->append_update_sql_part())) DBUG_RETURN(error_num); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } -#endif /* SQL access -> SQL remote access @@ -7544,17 +6956,6 @@ int spider_db_direct_update( (spider->direct_update_kinds & SPIDER_SQL_KIND_HS) */ -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (spider->hs_increment || spider->hs_decrement) - { - if ( - (spider->direct_update_kinds & SPIDER_SQL_KIND_SQL) && - (error_num = spider->append_increment_update_set_sql_part()) - ) { - DBUG_RETURN(error_num); - } - } else { -#endif #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS if (!spider->do_direct_update) { @@ -7573,19 +6974,8 @@ int spider_db_direct_update( ) { DBUG_RETURN(error_num); } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if ( - (spider->direct_update_kinds & SPIDER_SQL_KIND_HS) && - (error_num = spider->append_direct_update_set_hs_part()) - ) { - DBUG_RETURN(error_num); - } -#endif } #endif -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } -#endif result_list->desc_flg = FALSE; result_list->sorted = TRUE; @@ -7615,22 +7005,6 @@ int spider_db_direct_update( DBUG_RETURN(error_num); } } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (spider->direct_update_kinds & SPIDER_SQL_KIND_HS) - { - if ( - (error_num = spider->append_key_where_hs_part( - (ranges && ranges->start_key.key) ? &ranges->start_key : NULL, - (ranges && ranges->end_key.key) ? &ranges->end_key : NULL, - SPIDER_SQL_TYPE_UPDATE_HS)) || - (error_num = spider->append_limit_hs_part( - result_list->internal_offset, result_list->limit_num, - SPIDER_SQL_TYPE_UPDATE_HS)) - ) { - DBUG_RETURN(error_num); - } - } -#endif for ( roop_count = spider_conn_link_idx_next(share->link_statuses, @@ -7642,20 +7016,9 @@ int spider_db_direct_update( SPIDER_LINK_STATUS_RECOVERY) ) { ulong sql_type; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (!spider_bit_is_set(spider->do_hs_direct_update, roop_count)) - { -#endif DBUG_PRINT("info", ("spider exec sql")); conn = spider->conns[roop_count]; sql_type = SPIDER_SQL_TYPE_UPDATE_SQL; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else { - DBUG_PRINT("info", ("spider exec hs")); - conn = spider->hs_w_conns[roop_count]; - sql_type = SPIDER_SQL_TYPE_UPDATE_HS; - } -#endif spider_db_handler *dbton_hdl = spider->dbton_handler[conn->dbton_id]; pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); if ((error_num = dbton_hdl->set_sql_for_exec(sql_type, roop_count))) @@ -7750,10 +7113,6 @@ int spider_db_direct_update( } DBUG_RETURN(error_num); } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (!spider_bit_is_set(spider->do_hs_direct_update, roop_count)) - { -#endif if (!counted) { *update_rows = spider->conns[roop_count]->db_conn->affected_rows(); @@ -7762,48 +7121,6 @@ int spider_db_direct_update( DBUG_PRINT("info", ("spider found_rows = %llu", *found_rows)); counted = TRUE; } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else { - SPIDER_DB_RESULT *result; - if (spider_bit_is_set(spider->db_request_phase, roop_count)) - { - spider_clear_bit(spider->db_request_phase, roop_count); - } - st_spider_db_request_key request_key; - request_key.spider_thread_id = - spider->wide_handler->trx->spider_thread_id; - request_key.query_id = spider->wide_handler->trx->thd->query_id; - request_key.handler = spider; - request_key.request_id = spider->db_request_id[roop_count]; - request_key.next = NULL; - if ((result = conn->db_conn->use_result(spider, &request_key, - &error_num))) - { - if (!counted) - { - *update_rows = conn->db_conn->affected_rows(); - DBUG_PRINT("info", ("spider update_rows = %llu", *update_rows)); - *found_rows = conn->db_conn->matched_rows(); - DBUG_PRINT("info", ("spider found_rows = %llu", *found_rows)); - counted = TRUE; - } - result->free_result(); - delete result; - } else { - if (!error_num) - { - error_num = spider_db_errorno(conn); - } - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(error_num); - } - } -#endif DBUG_ASSERT(conn->mta_conn_mutex_lock_already); DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; @@ -7815,11 +7132,6 @@ int spider_db_direct_update( pthread_mutex_unlock(&conn->mta_conn_mutex); } spider->reset_sql_sql(SPIDER_SQL_TYPE_UPDATE_SQL); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - spider->reset_hs_sql(SPIDER_SQL_TYPE_UPDATE_HS); - spider->reset_hs_keys(SPIDER_SQL_TYPE_UPDATE_HS); - spider->reset_hs_upds(SPIDER_SQL_TYPE_UPDATE_HS); -#endif DBUG_RETURN(0); } #else @@ -8061,18 +7373,8 @@ int spider_db_bulk_direct_update( spider->conn_link_idx, roop_count, share->link_count, SPIDER_LINK_STATUS_RECOVERY) ) { -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (!spider_bit_is_set(spider->do_hs_direct_update, roop_count)) - { -#endif DBUG_PRINT("info", ("spider exec sql")); conn = spider->conns[roop_count]; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else { - DBUG_PRINT("info", ("spider exec hs")); - conn = spider->hs_w_conns[roop_count]; - } -#endif pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); pthread_mutex_lock(&conn->mta_conn_mutex); SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); @@ -8085,10 +7387,6 @@ int spider_db_bulk_direct_update( { error_num = tmp_error_num; } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (!spider_bit_is_set(spider->do_hs_direct_update, roop_count)) - { -#endif if (!counted) { *update_rows = spider->conns[roop_count]->db_conn->affected_rows(); @@ -8097,48 +7395,6 @@ int spider_db_bulk_direct_update( DBUG_PRINT("info", ("spider found_rows = %llu", *found_rows)); counted = TRUE; } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else { - SPIDER_DB_RESULT *result; - if (spider_bit_is_set(spider->db_request_phase, roop_count)) - { - spider_clear_bit(spider->db_request_phase, roop_count); - } - st_spider_db_request_key request_key; - request_key.spider_thread_id = - spider->wide_handler->trx->spider_thread_id; - request_key.query_id = spider->wide_handler->trx->thd->query_id; - request_key.handler = spider; - request_key.request_id = spider->db_request_id[roop_count]; - request_key.next = NULL; - if ((result = conn->db_conn->use_result(spider, &request_key, - &error_num))) - { - if (!counted) - { - *update_rows = conn->db_conn->affected_rows(); - DBUG_PRINT("info", ("spider update_rows = %llu", *update_rows)); - *found_rows = conn->db_conn->matched_rows(); - DBUG_PRINT("info", ("spider found_rows = %llu", *found_rows)); - counted = TRUE; - } - result->free_result(); - delete result; - } else { - if (!error_num) - { - error_num = spider_db_errorno(conn); - } - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(error_num); - } - } -#endif DBUG_ASSERT(conn->mta_conn_mutex_lock_already); DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; @@ -8296,22 +7552,6 @@ int spider_db_direct_delete( DBUG_RETURN(error_num); } } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (spider->direct_update_kinds & SPIDER_SQL_KIND_HS) - { - if ( - (error_num = spider->append_key_where_hs_part( - (ranges && ranges->start_key.key) ? &ranges->start_key : NULL, - (ranges && ranges->end_key.key) ? &ranges->end_key : NULL, - SPIDER_SQL_TYPE_DELETE_HS)) || - (error_num = spider->append_limit_hs_part( - result_list->internal_offset, result_list->limit_num, - SPIDER_SQL_TYPE_DELETE_HS)) - ) { - DBUG_RETURN(error_num); - } - } -#endif for ( roop_count = spider_conn_link_idx_next(share->link_statuses, @@ -8323,20 +7563,9 @@ int spider_db_direct_delete( SPIDER_LINK_STATUS_RECOVERY) ) { ulong sql_type; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (!spider_bit_is_set(spider->do_hs_direct_update, roop_count)) - { -#endif DBUG_PRINT("info", ("spider exec sql")); conn = spider->conns[roop_count]; sql_type = SPIDER_SQL_TYPE_DELETE_SQL; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else { - DBUG_PRINT("info", ("spider exec hs")); - conn = spider->hs_w_conns[roop_count]; - sql_type = SPIDER_SQL_TYPE_DELETE_HS; - } -#endif spider_db_handler *dbton_hdl = spider->dbton_handler[conn->dbton_id]; pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); if ((error_num = dbton_hdl->set_sql_for_exec(sql_type, roop_count))) @@ -8429,50 +7658,12 @@ int spider_db_direct_delete( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (!spider_bit_is_set(spider->do_hs_direct_update, roop_count)) - { -#endif if (!counted) { *delete_rows = spider->conns[roop_count]->db_conn->affected_rows(); DBUG_PRINT("info", ("spider delete_rows = %llu", *delete_rows)); counted = TRUE; } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else { - SPIDER_DB_RESULT *result; - if (spider_bit_is_set(spider->db_request_phase, roop_count)) - { - spider_clear_bit(spider->db_request_phase, roop_count); - } - st_spider_db_request_key request_key; - request_key.spider_thread_id = - spider->wide_handler->trx->spider_thread_id; - request_key.query_id = spider->wide_handler->trx->thd->query_id; - request_key.handler = spider; - request_key.request_id = spider->db_request_id[roop_count]; - request_key.next = NULL; - if ((result = conn->db_conn->use_result(spider, &request_key, - &error_num))) - { - if (!counted) - { - *delete_rows = conn->db_conn->affected_rows(); - DBUG_PRINT("info", ("spider delete_rows = %llu", *delete_rows)); - counted = TRUE; - } - result->free_result(); - delete result; - } else { - if (!error_num) - { - error_num = spider_db_errorno(conn); - } - DBUG_RETURN(error_num); - } - } -#endif #ifdef HA_CAN_BULK_ACCESS } #endif @@ -8485,15 +7676,6 @@ int spider_db_direct_delete( if ((error_num = spider->reset_sql_sql(SPIDER_SQL_TYPE_DELETE_SQL))) error_num2 = error_num; } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (spider->direct_update_kinds & SPIDER_SQL_KIND_HS) - { - if ((error_num = spider->reset_hs_sql(SPIDER_SQL_TYPE_DELETE_HS))) - error_num2 = error_num; - if ((error_num = spider->reset_hs_keys(SPIDER_SQL_TYPE_DELETE_HS))) - error_num2 = error_num; - } -#endif DBUG_RETURN(error_num2); } #else @@ -10550,36 +9732,16 @@ int spider_db_udf_direct_sql_connect( DBUG_PRINT("info",("spider net_read_timeout=%u", conn->net_read_timeout)); DBUG_PRINT("info",("spider net_write_timeout=%u", conn->net_write_timeout)); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (direct_sql->access_mode == 0) - { -#endif if ((error_num = spider_reset_conn_setted_parameter(conn, thd))) DBUG_RETURN(error_num); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } -#endif if (conn->dbton_id == SPIDER_DBTON_SIZE) { -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (conn->conn_kind == SPIDER_CONN_KIND_MYSQL) - { -#endif my_printf_error( ER_SPIDER_SQL_WRAPPER_IS_INVALID_NUM, ER_SPIDER_SQL_WRAPPER_IS_INVALID_STR, MYF(0), conn->tgt_wrapper); DBUG_RETURN(ER_SPIDER_SQL_WRAPPER_IS_INVALID_NUM); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else { - my_printf_error( - ER_SPIDER_NOSQL_WRAPPER_IS_INVALID_NUM, - ER_SPIDER_NOSQL_WRAPPER_IS_INVALID_STR, - MYF(0), conn->tgt_wrapper); - DBUG_RETURN(ER_SPIDER_NOSQL_WRAPPER_IS_INVALID_NUM); - } -#endif } /* @@ -10616,10 +9778,6 @@ int spider_db_udf_direct_sql_ping( DBUG_RETURN(error_num); conn->server_lost = FALSE; } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (direct_sql->access_mode == 0) - { -#endif if ((error_num = conn->db_conn->ping())) { spider_db_disconnect(conn); @@ -10637,9 +9795,6 @@ int spider_db_udf_direct_sql_ping( DBUG_RETURN(error_num); } } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } -#endif conn->ping_time = (time_t) time((time_t*) 0); DBUG_RETURN(0); } @@ -10734,23 +9889,6 @@ int spider_db_udf_direct_sql( !(error_num = spider_db_udf_direct_sql_set_names(direct_sql, trx, conn)) && !(error_num = spider_db_udf_direct_sql_select_db(direct_sql, conn)) ) { -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (direct_sql->access_mode != 0) - { - st_spider_db_request_key request_key; - request_key.spider_thread_id = direct_sql->trx->spider_thread_id; - request_key.query_id = direct_sql->trx->thd->query_id; - request_key.handler = direct_sql; - request_key.request_id = 1; - request_key.next = NULL; - if ((error_num = conn->db_conn->append_sql( - direct_sql->sql, direct_sql->sql_length, &request_key))) - { - c_thd->lex->sql_command = sql_command_backup; - DBUG_RETURN(error_num); - } - } -#endif spider_conn_set_timeout_from_direct_sql(conn, thd, direct_sql); if (spider_db_query( conn, @@ -11004,9 +10142,6 @@ int spider_db_udf_direct_sql_select_db( DBUG_ENTER("spider_db_udf_direct_sql_select_db"); pthread_mutex_assert_owner(&conn->mta_conn_mutex); if ( -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - direct_sql->access_mode == 0 && -#endif spider_dbton[conn->dbton_id].db_util->database_has_default_value() ) { DBUG_ASSERT(conn->mta_conn_mutex_file_pos.file_name); @@ -11052,10 +10187,6 @@ int spider_db_udf_direct_sql_set_names( int error_num, need_mon = 0; DBUG_ENTER("spider_db_udf_direct_sql_set_names"); pthread_mutex_assert_owner(&conn->mta_conn_mutex); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (direct_sql->access_mode == 0) - { -#endif DBUG_ASSERT(conn->mta_conn_mutex_file_pos.file_name); if ( !conn->access_charset || @@ -11079,9 +10210,6 @@ int spider_db_udf_direct_sql_set_names( } conn->access_charset = trx->udf_access_charset; } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } -#endif DBUG_RETURN(0); } @@ -12147,15 +11275,7 @@ int spider_db_open_handler( int error_num; SPIDER_SHARE *share = spider->share; uint *handler_id_ptr = -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - conn->conn_kind == SPIDER_CONN_KIND_MYSQL ? -#endif &spider->m_handler_id[link_idx] -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - : conn->conn_kind == SPIDER_CONN_KIND_HS_READ ? - &spider->r_handler_id[link_idx] : - &spider->w_handler_id[link_idx] -#endif ; spider_db_handler *dbton_hdl = spider->dbton_handler[conn->dbton_id]; DBUG_ENTER("spider_db_open_handler"); @@ -12170,20 +11290,17 @@ int spider_db_open_handler( conn->mta_conn_mutex_unlock_later = TRUE; if (!spider->handler_opened(link_idx, conn->conn_kind)) *handler_id_ptr = conn->opened_handlers; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (conn->conn_kind == SPIDER_CONN_KIND_MYSQL) - { -#endif - if (!spider->handler_opened(link_idx, conn->conn_kind)) - my_sprintf(spider->m_handler_cid[link_idx], - (spider->m_handler_cid[link_idx], SPIDER_SQL_HANDLER_CID_FORMAT, - *handler_id_ptr)); + if (!spider->handler_opened(link_idx, conn->conn_kind)) + my_sprintf(spider->m_handler_cid[link_idx], + (spider->m_handler_cid[link_idx], + SPIDER_SQL_HANDLER_CID_FORMAT, + *handler_id_ptr)); - if ((error_num = dbton_hdl->append_open_handler_part( - SPIDER_SQL_TYPE_HANDLER, *handler_id_ptr, conn, link_idx))) - { - goto error; - } + if ((error_num = dbton_hdl->append_open_handler_part( + SPIDER_SQL_TYPE_HANDLER, *handler_id_ptr, conn, link_idx))) + { + goto error; + } spider_conn_set_timeout_from_share(conn, link_idx, spider->wide_handler->trx->thd, @@ -12198,154 +11315,6 @@ int spider_db_open_handler( goto error; } dbton_hdl->reset_sql(SPIDER_SQL_TYPE_HANDLER); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else { - uint reconnect = 0; - if (conn->hs_pre_age != conn->hs_age && conn->server_lost) - { - spider_conn_queue_connect(share, conn, link_idx); - reconnect |= 1; - } - if ((error_num = spider_db_conn_queue_action(conn))) - { - goto error; - } - if (conn->hs_pre_age != conn->hs_age) - { - if (conn->db_conn->ping()) - { - my_printf_error(ER_SPIDER_HS_NUM, ER_SPIDER_HS_STR, MYF(0), - conn->db_conn->get_errno(), conn->db_conn->get_error()); - spider->need_mons[link_idx] = ER_SPIDER_HS_NUM; - error_num = ER_SPIDER_HS_NUM; - goto error; - } - conn->opened_handlers = 0; - conn->db_conn->reset_opened_handler(); - conn->hs_age = conn->hs_pre_age; - reconnect |= 2; - } - if (conn->conn_kind == SPIDER_CONN_KIND_HS_READ) - { - if (spider->hs_r_conn_ages[link_idx] != conn->hs_age) - { - spider->clear_handler_opened(link_idx, SPIDER_CONN_KIND_HS_READ); - *handler_id_ptr = conn->opened_handlers; - } - } else { - if (spider->hs_w_conn_ages[link_idx] != conn->hs_age) - { - spider->clear_handler_opened(link_idx, SPIDER_CONN_KIND_HS_WRITE); - *handler_id_ptr = conn->opened_handlers; - } - } - -#ifdef HA_CAN_BULK_ACCESS - if (!spider->is_bulk_access_clone) - { -#endif - conn->db_conn->reset_request_queue(); -#ifdef HA_CAN_BULK_ACCESS - } else if (!spider->bulk_access_executing) - { - if (conn->conn_kind == SPIDER_CONN_KIND_HS_READ) - { - spider_set_bit(spider->result_list.hs_r_bulk_open_index, link_idx); - } else { - spider_set_bit(spider->result_list.hs_w_bulk_open_index, link_idx); - } - } -#endif - if ((error_num = dbton_hdl->append_open_handler_part( - SPIDER_SQL_TYPE_OTHER_HS, *handler_id_ptr, conn, link_idx))) - { - goto error; - } -#ifdef HA_CAN_BULK_ACCESS - if (spider->is_bulk_access_clone && !spider->bulk_access_executing) - { - spider->connection_ids[link_idx] = conn->connection_id; - spider_trx_add_bulk_access_conn(spider->wide_handler->trx, conn); - } else { -#endif - spider_conn_set_timeout_from_share(conn, link_idx, - spider->wide_handler->trx->thd, - share); - if (dbton_hdl->execute_sql( - SPIDER_SQL_TYPE_SELECT_HS, - conn, - -1, - &spider->need_mons[link_idx]) - ) { - error_num = spider_db_errorno(conn); - goto error; - } - - SPIDER_DB_RESULT *result; - if (spider_bit_is_set(spider->db_request_phase, link_idx)) - { - spider_clear_bit(spider->db_request_phase, link_idx); - } - st_spider_db_request_key request_key; - request_key.spider_thread_id = - spider->wide_handler->trx->spider_thread_id; - request_key.query_id = spider->wide_handler->trx->thd->query_id; - request_key.handler = spider; - request_key.request_id = spider->db_request_id[link_idx]; - request_key.next = NULL; - if (!(result = conn->db_conn->use_result(spider, &request_key, - &error_num))) - { - if (!error_num) - { - spider_db_errorno(conn); - error_num = ER_SPIDER_HS_NUM; - } - goto error; - } else { - conn->ping_time = (time_t) time((time_t*) 0); - } - result->free_result(); - delete result; -#ifdef HA_CAN_BULK_ACCESS - } -#endif - if (conn->conn_kind == SPIDER_CONN_KIND_HS_READ) - { - spider->r_handler_index[link_idx] = spider->active_index; - spider->hs_r_conn_ages[link_idx] = conn->hs_age; -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS - if ( - spider->sql_command != SQLCOM_HS_INSERT && - spider->hs_pushed_ret_fields_num < MAX_FIELDS - ) { - spider->hs_r_ret_fields_num[link_idx] = - spider->hs_pushed_ret_fields_num; - memcpy(spider->hs_r_ret_fields[link_idx], spider->hs_pushed_ret_fields, - sizeof(uint32) * spider->hs_pushed_ret_fields_num); - } else { - spider->hs_r_ret_fields_num[link_idx] = MAX_FIELDS; - } -#endif - } else { - spider->w_handler_index[link_idx] = spider->active_index; - spider->hs_w_conn_ages[link_idx] = conn->hs_age; -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS - if ( - spider->sql_command != SQLCOM_HS_INSERT && - spider->hs_pushed_ret_fields_num < MAX_FIELDS - ) { - spider->hs_w_ret_fields_num[link_idx] = - spider->hs_pushed_ret_fields_num; - memcpy(spider->hs_w_ret_fields[link_idx], spider->hs_pushed_ret_fields, - sizeof(uint32) * spider->hs_pushed_ret_fields_num); - } else { - spider->hs_w_ret_fields_num[link_idx] = MAX_FIELDS; - } -#endif - } - } -#endif if (!spider->handler_opened(link_idx, conn->conn_kind)) { if ((error_num = dbton_hdl->insert_opened_handler(conn, link_idx))) @@ -12379,74 +11348,10 @@ int spider_db_bulk_open_handler( int link_idx ) { int error_num = 0; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - bool opening_index = FALSE; -#endif DBUG_ENTER("spider_db_bulk_open_handler"); DBUG_PRINT("info",("spider spider=%p", spider)); DBUG_PRINT("info",("spider conn=%p", conn)); DBUG_PRINT("info",("spider link_idx=%d", link_idx)); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - DBUG_ASSERT(conn->conn_kind != SPIDER_CONN_KIND_MYSQL); - if (conn->conn_kind == SPIDER_CONN_KIND_HS_READ) - { - if (spider_bit_is_set(spider->result_list.hs_r_bulk_open_index, link_idx)) - { - DBUG_PRINT("info",("spider SPIDER_CONN_KIND_HS_READ")); - spider_clear_bit(spider->result_list.hs_r_bulk_open_index, link_idx); - opening_index = TRUE; - } - } else { - if (spider_bit_is_set(spider->result_list.hs_w_bulk_open_index, link_idx)) - { - DBUG_PRINT("info",("spider SPIDER_CONN_KIND_HS_WRITE")); - spider_clear_bit(spider->result_list.hs_w_bulk_open_index, link_idx); - opening_index = TRUE; - } - } - if (opening_index) - { - DBUG_PRINT("info",("spider conn->connection_id=%llu", - conn->connection_id)); - DBUG_PRINT("info",("spider spider->connection_ids[%d]=%llu", - link_idx, spider->connection_ids[link_idx])); - if (conn->connection_id != spider->connection_ids[link_idx]) - { - my_message(ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM, - ER_SPIDER_REMOTE_SERVER_GONE_AWAY_STR, MYF(0)); - DBUG_RETURN(ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM); - } - - bool tmp_mta_conn_mutex_unlock_later; - pthread_mutex_assert_owner(&conn->mta_conn_mutex); - tmp_mta_conn_mutex_unlock_later = conn->mta_conn_mutex_unlock_later; - conn->mta_conn_mutex_unlock_later = TRUE; - SPIDER_DB_RESULT *result; - if (spider_bit_is_set(spider->db_request_phase, link_idx)) - { - spider_clear_bit(spider->db_request_phase, link_idx); - } - st_spider_db_request_key request_key; - request_key.spider_thread_id = spider->wide_handler->trx->spider_thread_id; - request_key.query_id = spider->wide_handler->trx->thd->query_id; - request_key.handler = spider; - request_key.request_id = spider->db_request_id[link_idx]; - request_key.next = NULL; - if (!(result = conn->db_conn->use_result(spider, &request_key, - &error_num))) - { - if (!error_num) - { - spider_db_errorno(conn); - error_num = ER_SPIDER_HS_NUM; - } - } else { - result->free_result(); - delete result; - } - conn->mta_conn_mutex_unlock_later = tmp_mta_conn_mutex_unlock_later; - } -#endif DBUG_RETURN(error_num); } #endif @@ -12471,10 +11376,6 @@ int spider_db_close_handler( conn->mta_conn_mutex_unlock_later = TRUE; if (spider->handler_opened(link_idx, tgt_conn_kind)) { -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (conn->conn_kind == SPIDER_CONN_KIND_MYSQL) - { -#endif dbton_hdl->reset_sql(SPIDER_SQL_TYPE_HANDLER); if ((error_num = dbton_hdl->append_close_handler_part( SPIDER_SQL_TYPE_HANDLER, link_idx))) @@ -12501,14 +11402,6 @@ int spider_db_close_handler( goto error; } dbton_hdl->reset_sql(SPIDER_SQL_TYPE_HANDLER); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else { -/* - conn->hs_conn->close(); - conn->server_lost = TRUE; -*/ - } -#endif if ((error_num = dbton_hdl->delete_opened_handler(conn, link_idx))) goto error; conn->opened_handlers--; @@ -12532,22 +11425,6 @@ error: DBUG_RETURN(error_num); } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -void spider_db_hs_request_buf_reset( - SPIDER_CONN *conn -) { - DBUG_ENTER("spider_db_hs_request_buf_reset"); - if (conn->bulk_access_requests) - { - if (conn->db_conn->is_connected()) - { - conn->db_conn->reset_request_queue(); - } - conn->bulk_access_requests = 0; - } - DBUG_VOID_RETURN; -} -#endif bool spider_db_conn_is_network_error( int error_num diff --git a/storage/spider/spd_db_conn.h b/storage/spider/spd_db_conn.h index cbfc3e724ed..bae4ee35439 100644 --- a/storage/spider/spd_db_conn.h +++ b/storage/spider/spd_db_conn.h @@ -1217,11 +1217,6 @@ int spider_db_close_handler( uint tgt_conn_kind ); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -void spider_db_hs_request_buf_reset( - SPIDER_CONN *conn -); -#endif bool spider_db_conn_is_network_error( int error_num diff --git a/storage/spider/spd_db_handlersocket.cc b/storage/spider/spd_db_handlersocket.cc deleted file mode 100644 index a9d42f54c24..00000000000 --- a/storage/spider/spd_db_handlersocket.cc +++ /dev/null @@ -1,6311 +0,0 @@ -/* Copyright (C) 2012-2018 Kentoku Shiba - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; version 2 of the License. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ - -#define MYSQL_SERVER 1 -#include -#include "mysql_version.h" -#include "spd_environ.h" -#include "sql_priv.h" -#include "probes_mysql.h" -#include "sql_analyse.h" - -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -#include "spd_err.h" -#include "spd_param.h" -#include "spd_db_include.h" -#include "spd_include.h" -#include "spd_db_handlersocket.h" -#include "ha_spider.h" -#include "spd_db_conn.h" -#include "spd_trx.h" -#include "spd_conn.h" -#include "spd_malloc.h" - -extern handlerton *spider_hton_ptr; -extern HASH spider_open_connections; -extern HASH spider_ipport_conns; -extern SPIDER_DBTON spider_dbton[SPIDER_DBTON_SIZE]; -extern const char spider_dig_upper[]; - -#define SPIDER_SQL_INTERVAL_STR " + interval " -#define SPIDER_SQL_INTERVAL_LEN (sizeof(SPIDER_SQL_INTERVAL_STR) - 1) -#define SPIDER_SQL_NEGINTERVAL_STR " - interval " -#define SPIDER_SQL_NEGINTERVAL_LEN (sizeof(SPIDER_SQL_NEGINTERVAL_STR) - 1) - -#define SPIDER_SQL_NAME_QUOTE_STR "" -#define SPIDER_SQL_NAME_QUOTE_LEN (sizeof(SPIDER_SQL_NAME_QUOTE_STR) - 1) -static const char *name_quote_str = SPIDER_SQL_NAME_QUOTE_STR; - -#define SPIDER_SQL_TYPE_FULL_HS (SPIDER_SQL_TYPE_SELECT_HS | \ - SPIDER_SQL_TYPE_INSERT_HS | SPIDER_SQL_TYPE_UPDATE_HS | \ - SPIDER_SQL_TYPE_DELETE_HS | SPIDER_SQL_TYPE_OTHER_HS) - -static uchar SPIDER_SQL_LINESTRING_HEAD_STR[] = - {0x00,0x00,0x00,0x00,0x01,0x02,0x00,0x00,0x00,0x02,0x00,0x00,0x00}; -#define SPIDER_SQL_LINESTRING_HEAD_LEN sizeof(SPIDER_SQL_LINESTRING_HEAD_STR) - -static const char *spider_db_timefunc_interval_str[] = -{ - " year", " quarter", " month", " week", " day", - " hour", " minute", " second", " microsecond", - " year_month", " day_hour", " day_minute", - " day_second", " hour_minute", " hour_second", - " minute_second", " day_microsecond", " hour_microsecond", - " minute_microsecond", " second_microsecond" -}; - -static SPIDER_HS_STRING_REF spider_null_string_ref = SPIDER_HS_STRING_REF(); - -int spider_handlersocket_init() -{ - DBUG_ENTER("spider_handlersocket_init"); - DBUG_RETURN(0); -} - -int spider_handlersocket_deinit() -{ - DBUG_ENTER("spider_handlersocket_deinit"); - DBUG_RETURN(0); -} - -spider_db_share *spider_handlersocket_create_share( - SPIDER_SHARE *share -) { - DBUG_ENTER("spider_handlersocket_create_share"); - DBUG_RETURN(new spider_handlersocket_share(share)); -} - -spider_db_handler *spider_handlersocket_create_handler( - ha_spider *spider, - spider_db_share *db_share -) { - DBUG_ENTER("spider_handlersocket_create_handler"); - DBUG_RETURN(new spider_handlersocket_handler(spider, - (spider_handlersocket_share *) db_share)); -} - -SPIDER_DB_CONN *spider_handlersocket_create_conn( - SPIDER_CONN *conn -) { - DBUG_ENTER("spider_handlersocket_create_conn"); - DBUG_RETURN(new spider_db_handlersocket(conn)); -} - -bool spider_handlersocket_support_direct_join( -) { - DBUG_ENTER("spider_handlersocket_support_direct_join"); - DBUG_RETURN(FALSE); -} - -spider_db_handlersocket_util spider_db_handlersocket_utility; - -SPIDER_DBTON spider_dbton_handlersocket = { - 0, - SPIDER_DB_WRAPPER_MYSQL, - SPIDER_DB_ACCESS_TYPE_NOSQL, - spider_handlersocket_init, - spider_handlersocket_deinit, - spider_handlersocket_create_share, - spider_handlersocket_create_handler, - NULL, - spider_handlersocket_create_conn, - spider_handlersocket_support_direct_join, - &spider_db_handlersocket_utility, - "For communicating using the handlersocket protocol", - "0.1.0", - SPIDER_MATURITY_BETA -}; - -#ifndef HANDLERSOCKET_MYSQL_UTIL -spider_db_hs_string_ref_buffer::spider_db_hs_string_ref_buffer() -{ - DBUG_ENTER("spider_db_hs_string_ref_buffer::spider_db_hs_string_ref_buffer"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_VOID_RETURN; -} - -spider_db_hs_string_ref_buffer::~spider_db_hs_string_ref_buffer() -{ - DBUG_ENTER("spider_db_hs_string_ref_buffer::~spider_db_hs_string_ref_buffer"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_VOID_RETURN; -} - -int spider_db_hs_string_ref_buffer::init() -{ - DBUG_ENTER("spider_db_hs_string_ref_buffer::init"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN(0); -} - -void spider_db_hs_string_ref_buffer::clear() -{ - DBUG_ENTER("spider_db_hs_string_ref_buffer::clear"); - DBUG_PRINT("info",("spider this=%p", this)); - hs_conds.clear(); - DBUG_VOID_RETURN; -} - -int spider_db_hs_string_ref_buffer::push_back( - SPIDER_HS_STRING_REF &cond -) { - DBUG_ENTER("spider_db_hs_string_ref_buffer::push_back"); - DBUG_PRINT("info",("spider this=%p", this)); - hs_conds.push_back(cond); - DBUG_RETURN(0); -} - -SPIDER_HS_STRING_REF *spider_db_hs_string_ref_buffer::ptr() -{ - DBUG_ENTER("spider_db_hs_string_ref_buffer::ptr"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN(&hs_conds[0]); -} - -uint spider_db_hs_string_ref_buffer::size() -{ - DBUG_ENTER("spider_db_hs_string_ref_buffer::size"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN((uint) hs_conds.size()); -} -#else -spider_db_hs_string_ref_buffer::spider_db_hs_string_ref_buffer() : hs_da_init(FALSE) -{ - DBUG_ENTER("spider_db_hs_string_ref_buffer::spider_db_hs_string_ref_buffer"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_VOID_RETURN; -} - -spider_db_hs_string_ref_buffer::~spider_db_hs_string_ref_buffer() -{ - DBUG_ENTER("spider_db_hs_string_ref_buffer::~spider_db_hs_string_ref_buffer"); - DBUG_PRINT("info",("spider this=%p", this)); - if (hs_da_init) - { - spider_free_mem_calc(spider_current_trx, - hs_conds_id, hs_conds.max_element * hs_conds.size_of_element); - delete_dynamic(&hs_conds); - } - DBUG_VOID_RETURN; -} - -int spider_db_hs_string_ref_buffer::init() -{ - DBUG_ENTER("spider_db_hs_string_ref_buffer::init"); - DBUG_PRINT("info",("spider this=%p", this)); - if (!hs_da_init) - { - SPD_INIT_DYNAMIC_ARRAY2(&hs_conds, sizeof(SPIDER_HS_STRING_REF), - NULL, 16, 16, MYF(MY_WME)); - spider_alloc_calc_mem_init(hs_conds, SPD_MID_DB_HS_STRING_REF_BUFFER_INIT_1); - spider_alloc_calc_mem(spider_current_trx, - hs_conds, hs_conds.max_element * hs_conds.size_of_element); - hs_da_init = TRUE; - } - DBUG_RETURN(0); -} - -void spider_db_hs_string_ref_buffer::clear() -{ - DBUG_ENTER("spider_db_hs_string_ref_buffer::clear"); - DBUG_PRINT("info",("spider this=%p", this)); - hs_conds.elements = 0; - DBUG_VOID_RETURN; -} - -int spider_db_hs_string_ref_buffer::push_back( - SPIDER_HS_STRING_REF &cond -) { - uint old_elements = hs_conds.max_element; - DBUG_ENTER("spider_db_hs_string_ref_buffer::push_back"); - DBUG_PRINT("info",("spider this=%p", this)); - if (insert_dynamic(&hs_conds, (uchar *) &cond)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - if (hs_conds.max_element > old_elements) - { - spider_alloc_calc_mem(spider_current_trx, - hs_conds, - (hs_conds.max_element - old_elements) * hs_conds.size_of_element); - } - DBUG_RETURN(0); -} - -SPIDER_HS_STRING_REF *spider_db_hs_string_ref_buffer::ptr() -{ - DBUG_ENTER("spider_db_hs_string_ref_buffer::ptr"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN((SPIDER_HS_STRING_REF *) hs_conds.buffer); -} - -uint spider_db_hs_string_ref_buffer::size() -{ - DBUG_ENTER("spider_db_hs_string_ref_buffer::size"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN(hs_conds.elements); -} -#endif - -spider_db_hs_str_buffer::spider_db_hs_str_buffer() : hs_da_init(FALSE) -{ - DBUG_ENTER("spider_db_hs_str_buffer::spider_db_hs_str_buffer"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_VOID_RETURN; -} - -spider_db_hs_str_buffer::~spider_db_hs_str_buffer() -{ - DBUG_ENTER("spider_db_hs_str_buffer::~spider_db_hs_str_buffer"); - DBUG_PRINT("info",("spider this=%p", this)); - if (hs_da_init) - { - spider_free_mem_calc(spider_current_trx, - hs_conds_id, hs_conds.max_element * hs_conds.size_of_element); - delete_dynamic(&hs_conds); - } - DBUG_VOID_RETURN; -} - -int spider_db_hs_str_buffer::init() -{ - DBUG_ENTER("spider_db_hs_str_buffer::init"); - DBUG_PRINT("info",("spider this=%p", this)); - if (!hs_da_init) - { - SPD_INIT_DYNAMIC_ARRAY2(&hs_conds, sizeof(spider_string *), - NULL, 16, 16, MYF(MY_WME)); - spider_alloc_calc_mem_init(hs_conds, SPD_MID_DB_HS_STR_BUFFER_INIT_1); - spider_alloc_calc_mem(spider_current_trx, - hs_conds, hs_conds.max_element * hs_conds.size_of_element); - hs_da_init = TRUE; - } - DBUG_RETURN(0); -} - -void spider_db_hs_str_buffer::clear() -{ - uint i; - spider_string *element; - DBUG_ENTER("spider_db_hs_str_buffer::clear"); - DBUG_PRINT("info",("spider this=%p", this)); - for (i = 0; i < hs_conds.elements; i++) - { - get_dynamic(&hs_conds, (uchar *) &element, i); - element->free(); - spider_free(spider_current_trx, element, MYF(0)); - } - hs_conds.elements = 0; - DBUG_VOID_RETURN; -} - -spider_string *spider_db_hs_str_buffer::add( - uint *strs_pos, - const char *str, - uint str_len -) { - spider_string *element; - DBUG_ENTER("spider_db_hs_str_buffer::add"); - DBUG_PRINT("info",("spider this=%p", this)); - if (hs_conds.elements <= *strs_pos + 1) - { - if (!(element = (spider_string *) spider_malloc(spider_current_trx, SPD_MID_DB_HS_STR_BUFFER_ADD_1, - sizeof(spider_string), MYF(MY_WME | MY_ZEROFILL)))) - DBUG_RETURN(NULL); - element->init_calc_mem(SPD_MID_DB_HS_STR_BUFFER_ADD_2); - element->set_charset(&my_charset_bin); - if ((element->reserve(str_len + 1))) - { - spider_free(spider_current_trx, element, MYF(0)); - DBUG_RETURN(NULL); - } - element->q_append(str, str_len); - uint old_elements = hs_conds.max_element; - if (insert_dynamic(&hs_conds, (uchar *) &element)) - { - element->free(); - spider_free(spider_current_trx, element, MYF(0)); - DBUG_RETURN(NULL); - } - if (hs_conds.max_element > old_elements) - { - spider_alloc_calc_mem(spider_current_trx, - hs_conds, - (hs_conds.max_element - old_elements) * - hs_conds.size_of_element); - } - } else { - element = ((spider_string **) hs_conds.buffer)[*strs_pos]; - element->length(0); - if ((element->reserve(str_len + 1))) - DBUG_RETURN(NULL); - element->q_append(str, str_len); - } - (*strs_pos)++; - DBUG_RETURN(element); -} - -spider_db_handlersocket_row::spider_db_handlersocket_row() : - spider_db_row(spider_dbton_handlersocket.dbton_id), - hs_row(NULL), field_count(0), row_size(0), cloned(FALSE) -{ - DBUG_ENTER("spider_db_handlersocket_row::spider_db_handlersocket_row"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_VOID_RETURN; -} - -spider_db_handlersocket_row::~spider_db_handlersocket_row() -{ - DBUG_ENTER("spider_db_handlersocket_row::~spider_db_handlersocket_row"); - DBUG_PRINT("info",("spider this=%p", this)); - if (cloned) - { - spider_free(spider_current_trx, hs_row_first, MYF(0)); - } - DBUG_VOID_RETURN; -} - -int spider_db_handlersocket_row::store_to_field( - Field *field, - CHARSET_INFO *access_charset -) { - DBUG_ENTER("spider_db_handlersocket_row::store_to_field"); - DBUG_PRINT("info",("spider this=%p", this)); - if (!hs_row->begin()) - { - DBUG_PRINT("info", ("spider field is null")); - field->set_null(); - field->reset(); - } else { -#ifndef DBUG_OFF - char buf[MAX_FIELD_WIDTH]; - spider_string tmp_str(buf, MAX_FIELD_WIDTH, field->charset()); - tmp_str.init_calc_mem(SPD_MID_DB_HANDLERSOCKET_ROW_STORE_TO_FIELD_1); - tmp_str.length(0); - tmp_str.append(hs_row->begin(), hs_row->size(), &my_charset_bin); - DBUG_PRINT("info", ("spider val=%s", tmp_str.c_ptr_safe())); -#endif - field->set_notnull(); - if (field->flags & BLOB_FLAG) - { - DBUG_PRINT("info", ("spider blob field")); - ((Field_blob *)field)->set_ptr( - hs_row->size(), (uchar *) hs_row->begin()); - } else - field->store(hs_row->begin(), hs_row->size(), &my_charset_bin); - } - DBUG_RETURN(0); -} - -int spider_db_handlersocket_row::append_to_str( - spider_string *str -) { - DBUG_ENTER("spider_db_handlersocket_row::append_to_str"); - DBUG_PRINT("info",("spider this=%p", this)); - if (str->reserve(hs_row->size())) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(hs_row->begin(), hs_row->size()); - DBUG_RETURN(0); -} - -int spider_db_handlersocket_row::append_escaped_to_str( - spider_string *str, - uint dbton_id -) { - DBUG_ENTER("spider_db_handlersocket_row::append_escaped_to_str"); - DBUG_PRINT("info",("spider this=%p", this)); - spider_string tmp_str(hs_row->begin(), hs_row->size() + 1, &my_charset_bin); - tmp_str.init_calc_mem(SPD_MID_DB_HANDLERSOCKET_ROW_APPEND_ESCAPED_TO_STR_1); - tmp_str.length(hs_row->size()); - if (str->reserve(hs_row->size() * 2 + 2)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - spider_dbton[dbton_id].db_util->append_escaped_util(str, tmp_str.get_str()); - str->mem_calc(); - DBUG_RETURN(0); -} - -void spider_db_handlersocket_row::first() -{ - DBUG_ENTER("spider_db_handlersocket_row::first"); - DBUG_PRINT("info",("spider this=%p", this)); - hs_row = hs_row_first; - DBUG_VOID_RETURN; -} - -void spider_db_handlersocket_row::next() -{ - DBUG_ENTER("spider_db_handlersocket_row::next"); - DBUG_PRINT("info",("spider this=%p", this)); - hs_row++; - DBUG_VOID_RETURN; -} - -bool spider_db_handlersocket_row::is_null() -{ - DBUG_ENTER("spider_db_handlersocket_row::is_null"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN(!hs_row->begin()); -} - -int spider_db_handlersocket_row::val_int() -{ - DBUG_ENTER("spider_db_handlersocket_row::val_int"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN(atoi(hs_row->begin())); -} - -double spider_db_handlersocket_row::val_real() -{ - DBUG_ENTER("spider_db_handlersocket_row::val_real"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN(hs_row->begin() ? my_atof(hs_row->begin()) : 0.0); -} - -my_decimal *spider_db_handlersocket_row::val_decimal( - my_decimal *decimal_value, - CHARSET_INFO *access_charset -) { - DBUG_ENTER("spider_db_handlersocket_row::val_decimal"); - DBUG_PRINT("info",("spider this=%p", this)); - if (!hs_row->begin()) - DBUG_RETURN(NULL); - -#ifdef SPIDER_HAS_DECIMAL_OPERATION_RESULTS_VALUE_TYPE - decimal_operation_results(str2my_decimal(0, hs_row->begin(), hs_row->size(), - access_charset, decimal_value), "", ""); -#else - decimal_operation_results(str2my_decimal(0, hs_row->begin(), hs_row->size(), - access_charset, decimal_value)); -#endif - - DBUG_RETURN(decimal_value); -} - -SPIDER_DB_ROW *spider_db_handlersocket_row::clone() -{ - spider_db_handlersocket_row *clone_row; - char *tmp_char; - uint i; - DBUG_ENTER("spider_db_handlersocket_row::clone"); - DBUG_PRINT("info",("spider this=%p", this)); - if (!(clone_row = new spider_db_handlersocket_row(dbton_id))) - { - DBUG_RETURN(NULL); - } - if (!spider_bulk_malloc(spider_current_trx, SPD_MID_DB_HANDLERSOCKET_ROW_CLONE_1, MYF(MY_WME), - &clone_row->hs_row, (uint) (sizeof(SPIDER_HS_STRING_REF) * field_count), - &tmp_char, (uint) (row_size), - NullS) - ) { - delete clone_row; - DBUG_RETURN(NULL); - } - for (i = 0; i < field_count; i++) - { - memcpy(tmp_char, hs_row_first[i].begin(), hs_row_first[i].size()); - clone_row->hs_row[i].set(tmp_char, hs_row_first[i].size()); - tmp_char += hs_row_first[i].size(); - } - clone_row->hs_row_first = clone_row->hs_row; - clone_row->cloned = TRUE;; - clone_row->row_size = row_size;; - DBUG_RETURN(NULL); -} - -int spider_db_handlersocket_row::store_to_tmp_table( - TABLE *tmp_table, - spider_string *str -) { - uint i; - SPIDER_HS_STRING_REF *tmp_hs_row = hs_row; - DBUG_ENTER("spider_db_handlersocket_row::store_to_tmp_table"); - DBUG_PRINT("info",("spider this=%p", this)); - str->length(0); - for (i = 0; i < field_count; i++) - { - if (tmp_hs_row->begin()) - { - if (str->reserve(tmp_hs_row->size())) - { - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - } - str->q_append(tmp_hs_row->begin(), tmp_hs_row->size()); - } - tmp_hs_row++; - } - tmp_table->field[0]->set_notnull(); - tmp_table->field[0]->store( - (const char *) hs_row, - sizeof(SPIDER_HS_STRING_REF) * field_count, &my_charset_bin); - tmp_table->field[1]->set_notnull(); - tmp_table->field[1]->store( - str->ptr(), str->length(), &my_charset_bin); - tmp_table->field[2]->set_null(); - DBUG_RETURN(tmp_table->file->ha_write_row(tmp_table->record[0])); -} - -uint spider_db_handlersocket_row::get_byte_size() -{ - DBUG_ENTER("spider_db_handlersocket_row::get_byte_size"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN(row_size); -} - - -spider_db_handlersocket_result_buffer::spider_db_handlersocket_result_buffer( -) : spider_db_result_buffer() -{ - DBUG_ENTER("spider_db_handlersocket_result_buffer::spider_db_handlersocket_result_buffer"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_VOID_RETURN; -} - -spider_db_handlersocket_result_buffer::~spider_db_handlersocket_result_buffer() -{ - DBUG_ENTER( - "spider_db_handlersocket_result_buffer::~spider_db_handlersocket_result_buffer"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_VOID_RETURN; -} - -void spider_db_handlersocket_result_buffer::clear() -{ - DBUG_ENTER("spider_db_handlersocket_result_buffer::clear"); - DBUG_PRINT("info",("spider this=%p", this)); - hs_result.readbuf.clear(); - DBUG_VOID_RETURN; -} - -bool spider_db_handlersocket_result_buffer::check_size( - longlong size -) { - DBUG_ENTER("spider_db_handlersocket_result_buffer::check_size"); - DBUG_PRINT("info",("spider this=%p", this)); - if ((uint) hs_result.readbuf.real_size() > size) - { - hs_result.readbuf.real_free(); - DBUG_RETURN(TRUE); - } - DBUG_RETURN(FALSE); -} - -spider_db_handlersocket_result::spider_db_handlersocket_result( - SPIDER_DB_CONN *in_db_conn -) : spider_db_result(in_db_conn), row(in_db_conn->dbton_id) -{ - DBUG_ENTER("spider_db_handlersocket_result::spider_db_handlersocket_result"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_VOID_RETURN; -} - -spider_db_handlersocket_result::~spider_db_handlersocket_result() -{ - DBUG_ENTER( - "spider_db_handlersocket_result::~spider_db_handlersocket_result"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_VOID_RETURN; -} - -bool spider_db_handlersocket_result::has_result() -{ - DBUG_ENTER("spider_db_handlersocket_result::has_result"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN(((*hs_conn_p)->get_response_end_offset() > 0)); -} - -void spider_db_handlersocket_result::free_result() -{ - DBUG_ENTER("spider_db_handlersocket_result::free_result"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_PRINT("info",("spider hs hs_conn=%p", hs_conn_p)); - DBUG_PRINT("info",("spider hs num_req_bufd=%zu", - (*hs_conn_p)->get_num_req_bufd())); - DBUG_PRINT("info",("spider hs num_req_sent=%zu", - (*hs_conn_p)->get_num_req_sent())); - DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", - (*hs_conn_p)->get_num_req_rcvd())); - DBUG_PRINT("info",("spider hs response_end_offset=%zu", - (*hs_conn_p)->get_response_end_offset())); - if ((*hs_conn_p)->get_response_end_offset() > 0) - { - (*hs_conn_p)->response_buf_remove(); - if ((*hs_conn_p)->get_error_code()) - { - DBUG_PRINT("info",("spider hs %d %s", - (*hs_conn_p)->get_error_code(), - (*hs_conn_p)->get_error().ptr())); - (*hs_conn_p)->write_error_to_log(__func__, __FILE__, __LINE__); - } - DBUG_PRINT("info",("spider hs num_req_bufd=%zu", - (*hs_conn_p)->get_num_req_bufd())); - DBUG_PRINT("info",("spider hs num_req_sent=%zu", - (*hs_conn_p)->get_num_req_sent())); - DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", - (*hs_conn_p)->get_num_req_rcvd())); - DBUG_PRINT("info",("spider hs response_end_offset=%zu", - (*hs_conn_p)->get_response_end_offset())); - } - DBUG_VOID_RETURN; -} - -SPIDER_DB_ROW *spider_db_handlersocket_result::current_row() -{ - DBUG_ENTER("spider_db_handlersocket_result::current_row"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN((SPIDER_DB_ROW *) row.clone()); -} - -SPIDER_DB_ROW *spider_db_handlersocket_result::fetch_row() -{ - DBUG_ENTER("spider_db_handlersocket_result::fetch_row"); - DBUG_PRINT("info",("spider this=%p", this)); - if (!(row.hs_row = (SPIDER_HS_STRING_REF *) - (*hs_conn_p)->get_next_row())) - { - store_error_num = HA_ERR_END_OF_FILE; - DBUG_RETURN(NULL); - } - row.field_count = field_count; - row.hs_row_first = row.hs_row; - row.row_size = (*hs_conn_p)->get_row_size(); - DBUG_RETURN((SPIDER_DB_ROW *) &row); -} - -SPIDER_DB_ROW *spider_db_handlersocket_result::fetch_row_from_result_buffer( - spider_db_result_buffer *spider_res_buf -) { - spider_db_handlersocket_result_buffer *hs_res_buf; - DBUG_ENTER("spider_db_handlersocket_result::fetch_row_from_result_buffer"); - DBUG_PRINT("info",("spider this=%p", this)); - hs_res_buf = (spider_db_handlersocket_result_buffer *) spider_res_buf; - if (!(row.hs_row = (SPIDER_HS_STRING_REF *) - (*hs_conn_p)->get_next_row_from_result(hs_res_buf->hs_result))) - { - store_error_num = HA_ERR_END_OF_FILE; - DBUG_RETURN(NULL); - } - row.field_count = field_count; - row.hs_row_first = row.hs_row; - row.row_size = (*hs_conn_p)->get_row_size_from_result(hs_res_buf->hs_result); - DBUG_RETURN((SPIDER_DB_ROW *) &row); -} - -SPIDER_DB_ROW *spider_db_handlersocket_result::fetch_row_from_tmp_table( - TABLE *tmp_table -) { - uint i; - spider_string tmp_str1, tmp_str2; - const char *row_ptr; - SPIDER_HS_STRING_REF *tmp_hs_row; - uint field_count; - DBUG_ENTER("spider_db_handlersocket_result::fetch_row_from_tmp_table"); - DBUG_PRINT("info",("spider this=%p", this)); - tmp_str1.init_calc_mem(SPD_MID_DB_HANDLERSOCKET_RESULT_FETCH_ROW_FROM_TMP_TABLE_1); - tmp_str2.init_calc_mem(SPD_MID_DB_HANDLERSOCKET_RESULT_FETCH_ROW_FROM_TMP_TABLE_2); - tmp_table->field[0]->val_str(tmp_str1.get_str()); - tmp_table->field[1]->val_str(tmp_str2.get_str()); - tmp_str1.mem_calc(); - tmp_str2.mem_calc(); - row_ptr = tmp_str2.ptr(); - tmp_hs_row = (SPIDER_HS_STRING_REF *) tmp_str1.ptr(); - field_count = tmp_str1.length() / sizeof(SPIDER_HS_STRING_REF); - row.hs_row = tmp_hs_row; - row.field_count = field_count; - row.hs_row_first = row.hs_row; - for (i = 0; i < field_count; i++) - { - if (tmp_hs_row->begin()) - { - uint length = tmp_hs_row->size(); - tmp_hs_row->set(row_ptr, length); - row_ptr += length; - } - tmp_hs_row++; - } - row.row_size = row_ptr - tmp_str2.ptr(); - DBUG_RETURN((SPIDER_DB_ROW *) &row); -} - -int spider_db_handlersocket_result::fetch_table_status( - int mode, - ha_statistics &stat -) { - DBUG_ENTER("spider_db_handlersocket_result::fetch_table_status"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_db_handlersocket_result::fetch_table_records( - int mode, - ha_rows &records -) { - DBUG_ENTER("spider_db_handlersocket_result::fetch_table_records"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_db_handlersocket_result::fetch_table_cardinality( - int mode, - TABLE *table, - longlong *cardinality, - uchar *cardinality_upd, - int bitmap_size -) { - DBUG_ENTER("spider_db_handlersocket_result::fetch_table_cardinality"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_db_handlersocket_result::fetch_table_mon_status( - int &status -) { - DBUG_ENTER("spider_db_handlersocket_result::fetch_table_mon_status"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -longlong spider_db_handlersocket_result::num_rows() -{ - DBUG_ENTER("spider_db_handlersocket_result::num_rows"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN((longlong) 0); -} - -uint spider_db_handlersocket_result::num_fields() -{ - DBUG_ENTER("spider_db_handlersocket_result::num_fields"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN(field_count); -} - -void spider_db_handlersocket_result::move_to_pos( - longlong pos -) { - DBUG_ENTER("spider_db_handlersocket_result::move_to_pos"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_VOID_RETURN; -} - -int spider_db_handlersocket_result::get_errno() -{ - DBUG_ENTER("spider_db_handlersocket_result::get_errno"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_PRINT("info",("spider store_error_num=%d", store_error_num)); - DBUG_RETURN(store_error_num); -} - -#ifdef SPIDER_HAS_DISCOVER_TABLE_STRUCTURE -int spider_db_handlersocket_result::fetch_columns_for_discover_table_structure( - spider_string *str, - CHARSET_INFO *access_charset -) { - DBUG_ENTER("spider_db_handlersocket_result::fetch_columns_for_discover_table_structure"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN(HA_ERR_WRONG_COMMAND); -} - -int spider_db_handlersocket_result::fetch_index_for_discover_table_structure( - spider_string *str, - CHARSET_INFO *access_charset -) { - DBUG_ENTER("spider_db_handlersocket_result::fetch_index_for_discover_table_structure"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN(HA_ERR_WRONG_COMMAND); -} - -int spider_db_handlersocket_result::fetch_table_for_discover_table_structure( - spider_string *str, - SPIDER_SHARE *spider_share, - CHARSET_INFO *access_charset -) { - DBUG_ENTER("spider_db_handlersocket_result::fetch_table_for_discover_table_structure"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN(HA_ERR_WRONG_COMMAND); -} -#endif - -spider_db_handlersocket::spider_db_handlersocket( - SPIDER_CONN *conn -) : spider_db_conn(conn), - handler_open_array_inited(FALSE), - request_key_req_first(NULL), - request_key_req_last(NULL), - request_key_snd_first(NULL), - request_key_snd_last(NULL), - request_key_reuse_first(NULL), - request_key_reuse_last(NULL) -{ - DBUG_ENTER("spider_db_handlersocket::spider_db_handlersocket"); - DBUG_PRINT("info",("spider this=%p", this)); -#ifndef HANDLERSOCKET_MYSQL_UTIL -#else - hs_conn = NULL; -#endif - DBUG_VOID_RETURN; -} - -spider_db_handlersocket::~spider_db_handlersocket() -{ - st_spider_db_request_key *tmp_request_key; - DBUG_ENTER("spider_db_handlersocket::~spider_db_handlersocket"); - DBUG_PRINT("info",("spider this=%p", this)); - if (handler_open_array_inited) - { - reset_opened_handler(); - spider_free_mem_calc(spider_current_trx, - handler_open_array_id, - handler_open_array.max_element * - handler_open_array.size_of_element); - delete_dynamic(&handler_open_array); - } - while (request_key_req_first) - { - tmp_request_key = request_key_req_first->next; - spider_free(spider_current_trx, request_key_req_first, MYF(0)); - request_key_req_first = tmp_request_key; - } - while (request_key_snd_first) - { - tmp_request_key = request_key_snd_first->next; - spider_free(spider_current_trx, request_key_snd_first, MYF(0)); - request_key_snd_first = tmp_request_key; - } - while (request_key_reuse_first) - { - tmp_request_key = request_key_reuse_first->next; - spider_free(spider_current_trx, request_key_reuse_first, MYF(0)); - request_key_reuse_first = tmp_request_key; - } - DBUG_VOID_RETURN; -} - -int spider_db_handlersocket::init() -{ - DBUG_ENTER("spider_db_handlersocket::init"); - DBUG_PRINT("info",("spider this=%p", this)); - if ( - SPD_INIT_DYNAMIC_ARRAY2(&handler_open_array, - sizeof(SPIDER_LINK_FOR_HASH *), NULL, 16, 16, MYF(MY_WME)) - ) { - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - } - spider_alloc_calc_mem_init(handler_open_array, SPD_MID_DB_HANDLERSOCKET_INIT_1); - spider_alloc_calc_mem(spider_current_trx, - handler_open_array, - handler_open_array.max_element * - handler_open_array.size_of_element); - handler_open_array_inited = TRUE; - DBUG_RETURN(0); -} - -bool spider_db_handlersocket::is_connected() -{ - DBUG_ENTER("spider_db_handlersocket::is_connected"); - DBUG_PRINT("info",("spider this=%p", this)); -#ifndef HANDLERSOCKET_MYSQL_UTIL - DBUG_RETURN(hs_conn.operator->()); -#else - DBUG_RETURN(hs_conn); -#endif -} - -void spider_db_handlersocket::bg_connect() -{ - DBUG_ENTER("spider_db_handlersocket::bg_connect"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_VOID_RETURN; -} - -int spider_db_handlersocket::connect( - char *tgt_host, - char *tgt_username, - char *tgt_password, - long tgt_port, - char *tgt_socket, - char *server_name, - int connect_retry_count, - longlong connect_retry_interval -) { - DBUG_ENTER("spider_db_handlersocket::connect"); - DBUG_PRINT("info",("spider this=%p", this)); - SPIDER_HS_SOCKARGS sockargs; - sockargs.timeout = conn->connect_timeout; - sockargs.recv_timeout = conn->net_read_timeout; - sockargs.send_timeout = conn->net_write_timeout; - if (conn->hs_sock) - { - sockargs.family = AF_UNIX; - sockargs.set_unix_domain(conn->hs_sock); - } else { - char port_str[6]; - my_sprintf(port_str, (port_str, "%05ld", conn->hs_port)); - if (sockargs.resolve(conn->tgt_host, port_str) != 0) - { - my_error(ER_CONNECT_TO_FOREIGN_DATA_SOURCE, MYF(0), - conn->tgt_host); - DBUG_RETURN(ER_CONNECT_TO_FOREIGN_DATA_SOURCE); - } - } -#ifndef HANDLERSOCKET_MYSQL_UTIL - if (!(hs_conn.operator->())) -#else - if (!(hs_conn)) -#endif - { - hs_conn = SPIDER_HS_CONN_CREATE(sockargs); - } else { - hs_conn->reconnect(); - spider_db_hs_request_buf_reset(conn); - } -#ifndef HANDLERSOCKET_MYSQL_UTIL - if (!(hs_conn.operator->())) -#else - if (!(hs_conn)) -#endif - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - while (hs_conn->get_error_code()) - { - THD *thd = current_thd; - if ( - !connect_retry_count || - (thd && thd->killed) - ) { - my_error(ER_CONNECT_TO_FOREIGN_DATA_SOURCE, MYF(0), - conn->tgt_host); - DBUG_RETURN(ER_CONNECT_TO_FOREIGN_DATA_SOURCE); - } - connect_retry_count--; - my_sleep((ulong) connect_retry_interval); - hs_conn->reconnect(); - } - reset_request_key_req(); - reset_request_key_snd(); - DBUG_RETURN(0); -} - -int spider_db_handlersocket::ping() -{ - SPIDER_HS_CONN *hs_conn_p = &hs_conn; - DBUG_ENTER("spider_db_handlersocket::ping"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_PRINT("info",("spider hs num_req_bufd=%zu", - (*hs_conn_p)->get_num_req_bufd())); - DBUG_PRINT("info",("spider hs num_req_sent=%zu", - (*hs_conn_p)->get_num_req_sent())); - DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", - (*hs_conn_p)->get_num_req_rcvd())); - DBUG_PRINT("info",("spider hs response_end_offset=%zu", - (*hs_conn_p)->get_response_end_offset())); - if ((*hs_conn_p)->reconnect()) - { - DBUG_PRINT("info",("spider hs num_req_bufd=%zu", - (*hs_conn_p)->get_num_req_bufd())); - DBUG_PRINT("info",("spider hs num_req_sent=%zu", - (*hs_conn_p)->get_num_req_sent())); - DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", - (*hs_conn_p)->get_num_req_rcvd())); - DBUG_PRINT("info",("spider hs response_end_offset=%zu", - (*hs_conn_p)->get_response_end_offset())); - DBUG_RETURN(ER_SPIDER_HS_NUM); - } - DBUG_PRINT("info",("spider hs num_req_bufd=%zu", - (*hs_conn_p)->get_num_req_bufd())); - DBUG_PRINT("info",("spider hs num_req_sent=%zu", - (*hs_conn_p)->get_num_req_sent())); - DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", - (*hs_conn_p)->get_num_req_rcvd())); - DBUG_PRINT("info",("spider hs response_end_offset=%zu", - (*hs_conn_p)->get_response_end_offset())); - - reset_request_key_req(); - reset_request_key_snd(); - conn->opened_handlers = 0; - conn->db_conn->reset_opened_handler(); - ++conn->connection_id; - DBUG_RETURN(0); -} - -void spider_db_handlersocket::bg_disconnect() -{ - DBUG_ENTER("spider_db_handlersocket::bg_disconnect"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_VOID_RETURN; -} - -void spider_db_handlersocket::disconnect() -{ - DBUG_ENTER("spider_db_handlersocket::disconnect"); - DBUG_PRINT("info",("spider this=%p", this)); -#ifndef HANDLERSOCKET_MYSQL_UTIL - if (hs_conn.operator->()) -#else - DBUG_PRINT("info",("spider hs_conn=%p", hs_conn)); - if (hs_conn) -#endif - { - hs_conn->close(); -#ifndef HANDLERSOCKET_MYSQL_UTIL - SPIDER_HS_CONN tmp_hs_conn; - tmp_hs_conn = hs_conn; -#else - delete hs_conn; - hs_conn = NULL; -#endif - } - DBUG_VOID_RETURN; -} - -int spider_db_handlersocket::set_net_timeout() -{ - DBUG_ENTER("spider_db_handlersocket::set_net_timeout"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN(hs_conn->set_timeout( - conn->net_write_timeout, - conn->net_read_timeout - )); -} - -int spider_db_handlersocket::exec_query( - const char *query, - uint length, - int quick_mode -) { - DBUG_ENTER("spider_db_handlersocket::query"); - DBUG_PRINT("info",("spider this=%p", this)); - SPIDER_HS_CONN *hs_conn_p = &hs_conn; -#ifndef HANDLERSOCKET_MYSQL_UTIL - DBUG_PRINT("info", ("spider hs_conn %p", hs_conn.operator->())); -#else - DBUG_PRINT("info", ("spider hs_conn %p", hs_conn)); -#endif - DBUG_PRINT("info",("spider hs num_req_bufd=%zu", - (*hs_conn_p)->get_num_req_bufd())); - DBUG_PRINT("info",("spider hs num_req_sent=%zu", - (*hs_conn_p)->get_num_req_sent())); - DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", - (*hs_conn_p)->get_num_req_rcvd())); - DBUG_PRINT("info",("spider hs response_end_offset=%zu", - (*hs_conn_p)->get_response_end_offset())); - if (spider_param_general_log()) - { - const char *tgt_str = conn->hs_sock ? conn->hs_sock : conn->tgt_host; - uint32 tgt_len = strlen(tgt_str); - spider_string tmp_query_str((*hs_conn_p)->get_writebuf_size() + - conn->tgt_wrapper_length + - tgt_len + (SPIDER_SQL_SPACE_LEN * 2)); - tmp_query_str.init_calc_mem(SPD_MID_DB_HANDLERSOCKET_EXEC_QUERY_1); - tmp_query_str.length(0); - tmp_query_str.q_append(conn->tgt_wrapper, conn->tgt_wrapper_length); - tmp_query_str.q_append(SPIDER_SQL_SPACE_STR, SPIDER_SQL_SPACE_LEN); - tmp_query_str.q_append(tgt_str, tgt_len); - tmp_query_str.q_append(SPIDER_SQL_SPACE_STR, SPIDER_SQL_SPACE_LEN); - tmp_query_str.q_append((*hs_conn_p)->get_writebuf_begin(), - (*hs_conn_p)->get_writebuf_size()); - general_log_write(current_thd, COM_QUERY, tmp_query_str.ptr(), - tmp_query_str.length()); - } - if ((*hs_conn_p)->request_send() < 0) - { - DBUG_PRINT("info",("spider hs num_req_bufd=%zu", - (*hs_conn_p)->get_num_req_bufd())); - DBUG_PRINT("info",("spider hs num_req_sent=%zu", - (*hs_conn_p)->get_num_req_sent())); - DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", - (*hs_conn_p)->get_num_req_rcvd())); - DBUG_PRINT("info",("spider hs response_end_offset=%zu", - (*hs_conn_p)->get_response_end_offset())); - DBUG_RETURN(ER_SPIDER_HS_NUM); - } - DBUG_PRINT("info",("spider hs num_req_bufd=%zu", - (*hs_conn_p)->get_num_req_bufd())); - DBUG_PRINT("info",("spider hs num_req_sent=%zu", - (*hs_conn_p)->get_num_req_sent())); - DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", - (*hs_conn_p)->get_num_req_rcvd())); - DBUG_PRINT("info",("spider hs response_end_offset=%zu", - (*hs_conn_p)->get_response_end_offset())); - move_request_key_to_snd(); - DBUG_RETURN(0); -} - -int spider_db_handlersocket::get_errno() -{ - DBUG_ENTER("spider_db_handlersocket::get_errno"); - DBUG_PRINT("info",("spider this=%p", this)); - stored_error = hs_conn->get_error_code(); - DBUG_PRINT("info",("spider stored_error=%d", stored_error)); - DBUG_RETURN(stored_error); -} - -const char *spider_db_handlersocket::get_error() -{ - const char *error_ptr; - DBUG_ENTER("spider_db_handlersocket::get_error"); - DBUG_PRINT("info",("spider this=%p", this)); -#ifndef HANDLERSOCKET_MYSQL_UTIL - error_ptr = hs_conn->get_error().c_str(); -#else - error_ptr = hs_conn->get_error().c_ptr(); -#endif - DBUG_PRINT("info",("spider error=%s", error_ptr)); - DBUG_RETURN(error_ptr); -} - -bool spider_db_handlersocket::is_server_gone_error( - int error_num -) { - bool server_gone; - DBUG_ENTER("spider_db_handlersocket::is_server_gone_error"); - DBUG_PRINT("info",("spider this=%p", this)); - server_gone = (hs_conn->get_error_code() < 0); - DBUG_PRINT("info",("spider server_gone=%s", server_gone ? "TRUE" : "FALSE")); - DBUG_RETURN(server_gone); -} - -bool spider_db_handlersocket::is_dup_entry_error( - int error_num -) { - bool dup_entry; - DBUG_ENTER("spider_db_handlersocket::is_dup_entry_error"); - DBUG_PRINT("info",("spider this=%p", this)); -#ifndef HANDLERSOCKET_MYSQL_UTIL - const char *c_str = hs_conn->get_error().c_str(); -#else - const char *c_str = hs_conn->get_error().c_ptr_safe(); -#endif - dup_entry = - ( - c_str[0] == '1' && - c_str[1] == '2' && - c_str[2] == '1' && - c_str[3] == '\0' - ); - DBUG_PRINT("info",("spider dup_entry=%s", dup_entry ? "TRUE" : "FALSE")); - DBUG_RETURN(dup_entry); -} - -bool spider_db_handlersocket::is_xa_nota_error( - int error_num -) { - bool xa_nota; - DBUG_ENTER("spider_db_handlersocket::is_xa_nota_error"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - xa_nota = (stored_error == ER_XAER_NOTA); - DBUG_PRINT("info",("spider xa_nota=%s", xa_nota ? "TRUE" : "FALSE")); - DBUG_RETURN(xa_nota); -} - -spider_db_result *spider_db_handlersocket::store_result( - spider_db_result_buffer **spider_res_buf, - st_spider_db_request_key *request_key, - int *error_num -) { - int internal_error; - spider_db_handlersocket_result *result; - spider_db_handlersocket_result_buffer *hs_res_buf; - DBUG_ENTER("spider_db_handlersocket::store_result"); - DBUG_PRINT("info",("spider this=%p", this)); - if (*spider_res_buf) - { - hs_res_buf = (spider_db_handlersocket_result_buffer *) *spider_res_buf; - } else { - if (!(hs_res_buf = new spider_db_handlersocket_result_buffer())) - { - *error_num = HA_ERR_OUT_OF_MEM; - DBUG_RETURN(NULL); - } - *spider_res_buf = (spider_db_result_buffer *) hs_res_buf; - } - hs_res_buf->clear(); - if (!(result = new spider_db_handlersocket_result(this))) - { - *error_num = HA_ERR_OUT_OF_MEM; - DBUG_RETURN(NULL); - } - *error_num = 0; - result->hs_conn_p = &hs_conn; - size_t num_fields; - SPIDER_HS_CONN *hs_conn_p = &hs_conn; - DBUG_PRINT("info",("spider hs hs_conn=%p", hs_conn_p)); - if (request_key) - { - int tmp_res, tmp_err = (*hs_conn_p)->get_error_code(); - while ((tmp_res = check_request_key(request_key)) == 1) - { - DBUG_PRINT("info",("spider hs num_req_bufd=%zu", - (*hs_conn_p)->get_num_req_bufd())); - DBUG_PRINT("info",("spider hs num_req_sent=%zu", - (*hs_conn_p)->get_num_req_sent())); - DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", - (*hs_conn_p)->get_num_req_rcvd())); - DBUG_PRINT("info",("spider hs response_end_offset=%zu", - (*hs_conn_p)->get_response_end_offset())); - if ((internal_error = (*hs_conn_p)->response_recv(num_fields))) - { - if (!tmp_err && internal_error > 0) - { - (*hs_conn_p)->clear_error(); - } else { - (*hs_conn_p)->write_error_to_log(__func__, __FILE__, __LINE__); -#ifndef DBUG_OFF - if ((*hs_conn_p)->get_response_end_offset() > 0 && - (*hs_conn_p)->get_readbuf_begin()) - { - char tmp_buf[MAX_FIELD_WIDTH]; - String tmp_str(tmp_buf, MAX_FIELD_WIDTH, &my_charset_bin); - tmp_str.length(0); - tmp_str.append((*hs_conn_p)->get_readbuf_begin(), - (*hs_conn_p)->get_response_end_offset(), &my_charset_bin); - DBUG_PRINT("info",("spider hs readbuf01 size=%zu str=%s", - (*hs_conn_p)->get_response_end_offset(), tmp_str.c_ptr_safe())); - } -#endif - DBUG_PRINT("info",("spider hs num_req_bufd=%zu", - (*hs_conn_p)->get_num_req_bufd())); - DBUG_PRINT("info",("spider hs num_req_sent=%zu", - (*hs_conn_p)->get_num_req_sent())); - DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", - (*hs_conn_p)->get_num_req_rcvd())); - DBUG_PRINT("info",("spider hs response_end_offset=%zu", - (*hs_conn_p)->get_response_end_offset())); - if (internal_error > 0) - { - (*hs_conn_p)->response_buf_remove(); - if ((*hs_conn_p)->get_error_code()) - { - DBUG_PRINT("info",("spider hs %d %s", - (*hs_conn_p)->get_error_code(), - (*hs_conn_p)->get_error().ptr())); - (*hs_conn_p)->write_error_to_log(__func__, __FILE__, __LINE__); - } - DBUG_PRINT("info",("spider hs num_req_bufd=%zu", - (*hs_conn_p)->get_num_req_bufd())); - DBUG_PRINT("info",("spider hs num_req_sent=%zu", - (*hs_conn_p)->get_num_req_sent())); - DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", - (*hs_conn_p)->get_num_req_rcvd())); - DBUG_PRINT("info",("spider hs response_end_offset=%zu", - (*hs_conn_p)->get_response_end_offset())); - (*hs_conn_p)->clear_error(); - } - delete result; - DBUG_RETURN(NULL); - } - } - DBUG_PRINT("info",("spider hs num_req_bufd=%zu", - (*hs_conn_p)->get_num_req_bufd())); - DBUG_PRINT("info",("spider hs num_req_sent=%zu", - (*hs_conn_p)->get_num_req_sent())); - DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", - (*hs_conn_p)->get_num_req_rcvd())); - DBUG_PRINT("info",("spider hs response_end_offset=%zu", - (*hs_conn_p)->get_response_end_offset())); - (*hs_conn_p)->response_buf_remove(); - DBUG_PRINT("info",("spider hs num_req_bufd=%zu", - (*hs_conn_p)->get_num_req_bufd())); - DBUG_PRINT("info",("spider hs num_req_sent=%zu", - (*hs_conn_p)->get_num_req_sent())); - DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", - (*hs_conn_p)->get_num_req_rcvd())); - DBUG_PRINT("info",("spider hs response_end_offset=%zu", - (*hs_conn_p)->get_response_end_offset())); - } - if (tmp_res == -1) - { - DBUG_PRINT("info",("spider ER_SPIDER_REQUEST_KEY_NUM")); - *error_num = ER_SPIDER_REQUEST_KEY_NUM; - DBUG_RETURN(NULL); - } - } - DBUG_PRINT("info",("spider hs num_req_bufd=%zu", - (*hs_conn_p)->get_num_req_bufd())); - DBUG_PRINT("info",("spider hs num_req_sent=%zu", - (*hs_conn_p)->get_num_req_sent())); - DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", - (*hs_conn_p)->get_num_req_rcvd())); - DBUG_PRINT("info",("spider hs response_end_offset=%zu", - (*hs_conn_p)->get_response_end_offset())); - if ( - (internal_error = (*hs_conn_p)->response_recv(num_fields)) || - (*error_num = (*hs_conn_p)->get_result(hs_res_buf->hs_result)) - ) { - if (*error_num) - { - *error_num = HA_ERR_OUT_OF_MEM; - } - (*hs_conn_p)->write_error_to_log(__func__, __FILE__, __LINE__); -#ifndef DBUG_OFF - if ((*hs_conn_p)->get_response_end_offset() > 0 && - (*hs_conn_p)->get_readbuf_begin()) - { - char tmp_buf[MAX_FIELD_WIDTH]; - String tmp_str(tmp_buf, MAX_FIELD_WIDTH, &my_charset_bin); - tmp_str.length(0); - tmp_str.append((*hs_conn_p)->get_readbuf_begin(), - (*hs_conn_p)->get_response_end_offset(), &my_charset_bin); - DBUG_PRINT("info",("spider hs readbuf01 size=%zu str=%s", - (*hs_conn_p)->get_response_end_offset(), tmp_str.c_ptr_safe())); - } -#endif - DBUG_PRINT("info",("spider hs num_req_bufd=%zu", - (*hs_conn_p)->get_num_req_bufd())); - DBUG_PRINT("info",("spider hs num_req_sent=%zu", - (*hs_conn_p)->get_num_req_sent())); - DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", - (*hs_conn_p)->get_num_req_rcvd())); - DBUG_PRINT("info",("spider hs response_end_offset=%zu", - (*hs_conn_p)->get_response_end_offset())); - if (internal_error > 0) - { - (*hs_conn_p)->response_buf_remove(); - if ((*hs_conn_p)->get_error_code()) - { - DBUG_PRINT("info",("spider hs %d %s", - (*hs_conn_p)->get_error_code(), - (*hs_conn_p)->get_error().ptr())); - (*hs_conn_p)->write_error_to_log(__func__, __FILE__, __LINE__); - } - DBUG_PRINT("info",("spider hs num_req_bufd=%zu", - (*hs_conn_p)->get_num_req_bufd())); - DBUG_PRINT("info",("spider hs num_req_sent=%zu", - (*hs_conn_p)->get_num_req_sent())); - DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", - (*hs_conn_p)->get_num_req_rcvd())); - DBUG_PRINT("info",("spider hs response_end_offset=%zu", - (*hs_conn_p)->get_response_end_offset())); - } - delete result; - DBUG_RETURN(NULL); - } -#ifndef DBUG_OFF - if ((*hs_conn_p)->get_response_end_offset() > 0 && - (*hs_conn_p)->get_readbuf_begin()) - { - char tmp_buf[MAX_FIELD_WIDTH]; - String tmp_str(tmp_buf, MAX_FIELD_WIDTH, &my_charset_bin); - tmp_str.length(0); - tmp_str.append((*hs_conn_p)->get_readbuf_begin(), - (*hs_conn_p)->get_response_end_offset(), &my_charset_bin); - DBUG_PRINT("info",("spider hs readbuf02 size=%zu str=%s", - (*hs_conn_p)->get_response_end_offset(), tmp_str.c_ptr_safe())); - } -#endif - DBUG_PRINT("info",("spider hs num_req_bufd=%zu", - (*hs_conn_p)->get_num_req_bufd())); - DBUG_PRINT("info",("spider hs num_req_sent=%zu", - (*hs_conn_p)->get_num_req_sent())); - DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", - (*hs_conn_p)->get_num_req_rcvd())); - DBUG_PRINT("info",("spider hs response_end_offset=%zu", - (*hs_conn_p)->get_response_end_offset())); - (*hs_conn_p)->response_buf_remove(); - if ((*hs_conn_p)->get_error_code()) - { - DBUG_PRINT("info",("spider hs %d %s", - (*hs_conn_p)->get_error_code(), - (*hs_conn_p)->get_error().ptr())); - (*hs_conn_p)->write_error_to_log(__func__, __FILE__, __LINE__); - } - DBUG_PRINT("info",("spider hs num_req_bufd=%zu", - (*hs_conn_p)->get_num_req_bufd())); - DBUG_PRINT("info",("spider hs num_req_sent=%zu", - (*hs_conn_p)->get_num_req_sent())); - DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", - (*hs_conn_p)->get_num_req_rcvd())); - DBUG_PRINT("info",("spider hs response_end_offset=%zu", - (*hs_conn_p)->get_response_end_offset())); - field_count = (uint) num_fields; - result->field_count = field_count; - DBUG_RETURN(result); -} - -spider_db_result *spider_db_handlersocket::use_result( - ha_spider *spider, - st_spider_db_request_key *request_key, - int *error_num -) { - int internal_error; - spider_db_handlersocket_result *result; - DBUG_ENTER("spider_db_handlersocket::use_result"); - DBUG_PRINT("info",("spider this=%p", this)); - if (!(result = new spider_db_handlersocket_result(this))) - { - *error_num = HA_ERR_OUT_OF_MEM; - DBUG_RETURN(NULL); - } - *error_num = 0; - result->hs_conn_p = &hs_conn; - size_t num_fields; - SPIDER_HS_CONN *hs_conn_p = &hs_conn; - DBUG_PRINT("info",("spider hs hs_conn=%p", hs_conn_p)); - if (request_key) - { - int tmp_res, tmp_err = (*hs_conn_p)->get_error_code(); - while ((tmp_res = check_request_key(request_key)) == 1) - { - DBUG_PRINT("info",("spider hs num_req_bufd=%zu", - (*hs_conn_p)->get_num_req_bufd())); - DBUG_PRINT("info",("spider hs num_req_sent=%zu", - (*hs_conn_p)->get_num_req_sent())); - DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", - (*hs_conn_p)->get_num_req_rcvd())); - DBUG_PRINT("info",("spider hs response_end_offset=%zu", - (*hs_conn_p)->get_response_end_offset())); - if ((internal_error = (*hs_conn_p)->response_recv(num_fields))) - { - if (!tmp_err && internal_error > 0) - { - (*hs_conn_p)->clear_error(); - } else { - (*hs_conn_p)->write_error_to_log(__func__, __FILE__, __LINE__); -#ifndef DBUG_OFF - if ((*hs_conn_p)->get_response_end_offset() > 0 && - (*hs_conn_p)->get_readbuf_begin()) - { - char tmp_buf[MAX_FIELD_WIDTH]; - String tmp_str(tmp_buf, MAX_FIELD_WIDTH, &my_charset_bin); - tmp_str.length(0); - tmp_str.append((*hs_conn_p)->get_readbuf_begin(), - (*hs_conn_p)->get_response_end_offset(), &my_charset_bin); - DBUG_PRINT("info",("spider hs readbuf01 size=%zu str=%s", - (*hs_conn_p)->get_response_end_offset(), tmp_str.c_ptr_safe())); - } -#endif - DBUG_PRINT("info",("spider hs num_req_bufd=%zu", - (*hs_conn_p)->get_num_req_bufd())); - DBUG_PRINT("info",("spider hs num_req_sent=%zu", - (*hs_conn_p)->get_num_req_sent())); - DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", - (*hs_conn_p)->get_num_req_rcvd())); - DBUG_PRINT("info",("spider hs response_end_offset=%zu", - (*hs_conn_p)->get_response_end_offset())); - if (internal_error > 0) - { - (*hs_conn_p)->response_buf_remove(); - if ((*hs_conn_p)->get_error_code()) - { - DBUG_PRINT("info",("spider hs %d %s", - (*hs_conn_p)->get_error_code(), - (*hs_conn_p)->get_error().ptr())); - (*hs_conn_p)->write_error_to_log(__func__, __FILE__, __LINE__); - } - DBUG_PRINT("info",("spider hs num_req_bufd=%zu", - (*hs_conn_p)->get_num_req_bufd())); - DBUG_PRINT("info",("spider hs num_req_sent=%zu", - (*hs_conn_p)->get_num_req_sent())); - DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", - (*hs_conn_p)->get_num_req_rcvd())); - DBUG_PRINT("info",("spider hs response_end_offset=%zu", - (*hs_conn_p)->get_response_end_offset())); - (*hs_conn_p)->clear_error(); - } - delete result; - DBUG_RETURN(NULL); - } - } - DBUG_PRINT("info",("spider hs num_req_bufd=%zu", - (*hs_conn_p)->get_num_req_bufd())); - DBUG_PRINT("info",("spider hs num_req_sent=%zu", - (*hs_conn_p)->get_num_req_sent())); - DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", - (*hs_conn_p)->get_num_req_rcvd())); - DBUG_PRINT("info",("spider hs response_end_offset=%zu", - (*hs_conn_p)->get_response_end_offset())); - (*hs_conn_p)->response_buf_remove(); - DBUG_PRINT("info",("spider hs num_req_bufd=%zu", - (*hs_conn_p)->get_num_req_bufd())); - DBUG_PRINT("info",("spider hs num_req_sent=%zu", - (*hs_conn_p)->get_num_req_sent())); - DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", - (*hs_conn_p)->get_num_req_rcvd())); - DBUG_PRINT("info",("spider hs response_end_offset=%zu", - (*hs_conn_p)->get_response_end_offset())); - } - if (tmp_res == -1) - { - DBUG_PRINT("info",("spider ER_SPIDER_REQUEST_KEY_NUM")); - *error_num = ER_SPIDER_REQUEST_KEY_NUM; - DBUG_RETURN(NULL); - } - } - DBUG_PRINT("info",("spider hs num_req_bufd=%zu", - (*hs_conn_p)->get_num_req_bufd())); - DBUG_PRINT("info",("spider hs num_req_sent=%zu", - (*hs_conn_p)->get_num_req_sent())); - DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", - (*hs_conn_p)->get_num_req_rcvd())); - DBUG_PRINT("info",("spider hs response_end_offset=%zu", - (*hs_conn_p)->get_response_end_offset())); - if ( - (internal_error = (*hs_conn_p)->response_recv(num_fields)) - ) { - (*hs_conn_p)->write_error_to_log(__func__, __FILE__, __LINE__); -#ifndef DBUG_OFF - if ((*hs_conn_p)->get_response_end_offset() > 0 && - (*hs_conn_p)->get_readbuf_begin()) - { - char tmp_buf[MAX_FIELD_WIDTH]; - String tmp_str(tmp_buf, MAX_FIELD_WIDTH, &my_charset_bin); - tmp_str.length(0); - tmp_str.append((*hs_conn_p)->get_readbuf_begin(), - (*hs_conn_p)->get_response_end_offset(), &my_charset_bin); - DBUG_PRINT("info",("spider hs readbuf01 size=%zu str=%s", - (*hs_conn_p)->get_response_end_offset(), tmp_str.c_ptr_safe())); - } -#endif - DBUG_PRINT("info",("spider hs num_req_bufd=%zu", - (*hs_conn_p)->get_num_req_bufd())); - DBUG_PRINT("info",("spider hs num_req_sent=%zu", - (*hs_conn_p)->get_num_req_sent())); - DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", - (*hs_conn_p)->get_num_req_rcvd())); - DBUG_PRINT("info",("spider hs response_end_offset=%zu", - (*hs_conn_p)->get_response_end_offset())); - if (internal_error > 0) - { - (*hs_conn_p)->response_buf_remove(); - if ((*hs_conn_p)->get_error_code()) - { - DBUG_PRINT("info",("spider hs %d %s", - (*hs_conn_p)->get_error_code(), - (*hs_conn_p)->get_error().ptr())); - (*hs_conn_p)->write_error_to_log(__func__, __FILE__, __LINE__); - } - DBUG_PRINT("info",("spider hs num_req_bufd=%zu", - (*hs_conn_p)->get_num_req_bufd())); - DBUG_PRINT("info",("spider hs num_req_sent=%zu", - (*hs_conn_p)->get_num_req_sent())); - DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", - (*hs_conn_p)->get_num_req_rcvd())); - DBUG_PRINT("info",("spider hs response_end_offset=%zu", - (*hs_conn_p)->get_response_end_offset())); - } - delete result; - DBUG_RETURN(NULL); - } -#ifndef DBUG_OFF - if ((*hs_conn_p)->get_response_end_offset() > 0 && - (*hs_conn_p)->get_readbuf_begin()) - { - char tmp_buf[MAX_FIELD_WIDTH]; - String tmp_str(tmp_buf, MAX_FIELD_WIDTH, &my_charset_bin); - tmp_str.length(0); - tmp_str.append((*hs_conn_p)->get_readbuf_begin(), - (*hs_conn_p)->get_response_end_offset(), &my_charset_bin); - DBUG_PRINT("info",("spider hs readbuf02 size=%zu str=%s", - (*hs_conn_p)->get_response_end_offset(), tmp_str.c_ptr_safe())); - } -#endif - DBUG_PRINT("info",("spider hs num_req_bufd=%zu", - (*hs_conn_p)->get_num_req_bufd())); - DBUG_PRINT("info",("spider hs num_req_sent=%zu", - (*hs_conn_p)->get_num_req_sent())); - DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", - (*hs_conn_p)->get_num_req_rcvd())); - DBUG_PRINT("info",("spider hs response_end_offset=%zu", - (*hs_conn_p)->get_response_end_offset())); - field_count = (uint) num_fields; - result->field_count = field_count; - DBUG_RETURN(result); -} - -int spider_db_handlersocket::next_result() -{ - SPIDER_HS_CONN *hs_conn_p = &hs_conn; - DBUG_ENTER("spider_db_handlersocket::next_result"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_PRINT("info",("spider hs hs_conn=%p", hs_conn_p)); - if ((*hs_conn_p)->stable_point()) - DBUG_RETURN(-1); - DBUG_RETURN(0); -} - -uint spider_db_handlersocket::affected_rows() -{ - int error_num; - const SPIDER_HS_STRING_REF *hs_row; - SPIDER_HS_CONN *hs_conn_p = &hs_conn; - DBUG_ENTER("spider_db_handlersocket::affected_rows"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_PRINT("info",("spider hs hs_conn=%p", hs_conn_p)); - if ( - field_count != 1 || - !(hs_row = (*hs_conn_p)->get_next_row()) || - !hs_row->begin() - ) { - DBUG_RETURN(0); - } - DBUG_RETURN((uint) my_strtoll10(hs_row->begin(), (char**) NULL, &error_num)); -} - -uint spider_db_handlersocket::matched_rows() -{ - DBUG_ENTER("spider_db_handlersocket::matched_rows"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN(0); -} - -bool spider_db_handlersocket::inserted_info( - spider_db_handler *handler, - ha_copy_info *copy_info -) { - DBUG_ENTER("spider_db_handlersocket::inserted_info"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN(FALSE); -} - -ulonglong spider_db_handlersocket::last_insert_id() -{ - DBUG_ENTER("spider_db_handlersocket::last_insert_id"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN(0); -} - -int spider_db_handlersocket::set_character_set( - const char *csname -) { - DBUG_ENTER("spider_db_handlersocket::set_character_set"); - DBUG_PRINT("info",("spider this=%p", this)); - /* nothing to do */ - DBUG_RETURN(0); -} - -int spider_db_handlersocket::select_db( - const char *dbname -) { - DBUG_ENTER("spider_db_handlersocket::select_db"); - DBUG_PRINT("info",("spider this=%p", this)); - /* nothing to do */ - DBUG_RETURN(0); -} - -int spider_db_handlersocket::consistent_snapshot( - int *need_mon -) { - DBUG_ENTER("spider_db_handlersocket::consistent_snapshot"); - DBUG_PRINT("info",("spider this=%p", this)); - /* nothing to do */ - DBUG_RETURN(0); -} - -bool spider_db_handlersocket::trx_start_in_bulk_sql() -{ - DBUG_ENTER("spider_db_handlersocket::trx_start_in_bulk_sql"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN(FALSE); -} - -int spider_db_handlersocket::start_transaction( - int *need_mon -) { - DBUG_ENTER("spider_db_handlersocket::start_transaction"); - DBUG_PRINT("info",("spider this=%p", this)); - /* nothing to do */ - DBUG_RETURN(0); -} - -int spider_db_handlersocket::commit( - int *need_mon -) { - DBUG_ENTER("spider_db_handlersocket::commit"); - DBUG_PRINT("info",("spider this=%p", this)); - /* nothing to do */ - DBUG_RETURN(0); -} - -int spider_db_handlersocket::rollback( - int *need_mon -) { - DBUG_ENTER("spider_db_handlersocket::rollback"); - DBUG_PRINT("info",("spider this=%p", this)); - /* nothing to do */ - DBUG_RETURN(0); -} - -bool spider_db_handlersocket::xa_start_in_bulk_sql() -{ - DBUG_ENTER("spider_db_handlersocket::xa_start_in_bulk_sql"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN(FALSE); -} - -int spider_db_handlersocket::xa_start( - XID *xid, - int *need_mon -) { - DBUG_ENTER("spider_db_handlersocket::xa_start"); - DBUG_PRINT("info",("spider this=%p", this)); - /* nothing to do */ - DBUG_RETURN(0); -} - -int spider_db_handlersocket::xa_end( - XID *xid, - int *need_mon -) { - DBUG_ENTER("spider_db_handlersocket::xa_end"); - DBUG_PRINT("info",("spider this=%p", this)); - /* nothing to do */ - DBUG_RETURN(0); -} - -int spider_db_handlersocket::xa_prepare( - XID *xid, - int *need_mon -) { - DBUG_ENTER("spider_db_handlersocket::xa_prepare"); - DBUG_PRINT("info",("spider this=%p", this)); - /* nothing to do */ - DBUG_RETURN(0); -} - -int spider_db_handlersocket::xa_commit( - XID *xid, - int *need_mon -) { - DBUG_ENTER("spider_db_handlersocket::xa_commit"); - DBUG_PRINT("info",("spider this=%p", this)); - /* nothing to do */ - DBUG_RETURN(0); -} - -int spider_db_handlersocket::xa_rollback( - XID *xid, - int *need_mon -) { - DBUG_ENTER("spider_db_handlersocket::xa_rollback"); - DBUG_PRINT("info",("spider this=%p", this)); - /* nothing to do */ - DBUG_RETURN(0); -} - -bool spider_db_handlersocket::set_trx_isolation_in_bulk_sql() -{ - DBUG_ENTER("spider_db_handlersocket::set_trx_isolation_in_bulk_sql"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN(FALSE); -} - -int spider_db_handlersocket::set_trx_isolation( - int trx_isolation, - int *need_mon -) { - DBUG_ENTER("spider_db_handlersocket::set_trx_isolation"); - DBUG_PRINT("info",("spider this=%p", this)); - /* nothing to do */ - DBUG_RETURN(0); -} - -bool spider_db_handlersocket::set_autocommit_in_bulk_sql() -{ - DBUG_ENTER("spider_db_handlersocket::set_autocommit_in_bulk_sql"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN(FALSE); -} - -int spider_db_handlersocket::set_autocommit( - bool autocommit, - int *need_mon -) { - DBUG_ENTER("spider_db_handlersocket::set_autocommit"); - DBUG_PRINT("info",("spider this=%p", this)); - /* nothing to do */ - DBUG_RETURN(0); -} - -bool spider_db_handlersocket::set_sql_log_off_in_bulk_sql() -{ - DBUG_ENTER("spider_db_handlersocket::set_sql_log_off_in_bulk_sql"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN(FALSE); -} - -int spider_db_handlersocket::set_sql_log_off( - bool sql_log_off, - int *need_mon -) { - DBUG_ENTER("spider_db_handlersocket::set_sql_log_off"); - DBUG_PRINT("info",("spider this=%p", this)); - /* nothing to do */ - DBUG_RETURN(0); -} - -bool spider_db_handlersocket::set_wait_timeout_in_bulk_sql() -{ - DBUG_ENTER("spider_db_handlersocket::set_wait_timeout_in_bulk_sql"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN(FALSE); -} - -int spider_db_handlersocket::set_wait_timeout( - int wait_timeout, - int *need_mon -) { - DBUG_ENTER("spider_db_handlersocket::set_wait_timeout"); - DBUG_PRINT("info",("spider this=%p", this)); - /* nothing to do */ - DBUG_RETURN(0); -} - -bool spider_db_handlersocket::set_sql_mode_in_bulk_sql() -{ - DBUG_ENTER("spider_db_handlersocket::set_sql_mode_in_bulk_sql"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN(FALSE); -} - -int spider_db_handlersocket::set_sql_mode( - sql_mode_t sql_mode, - int *need_mon -) { - DBUG_ENTER("spider_db_handlersocket::set_sql_mode"); - DBUG_PRINT("info",("spider this=%p", this)); - /* nothing to do */ - DBUG_RETURN(0); -} - -bool spider_db_handlersocket::set_time_zone_in_bulk_sql() -{ - DBUG_ENTER("spider_db_handlersocket::set_time_zone_in_bulk_sql"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN(FALSE); -} - -int spider_db_handlersocket::set_time_zone( - Time_zone *time_zone, - int *need_mon -) { - DBUG_ENTER("spider_db_handlersocket::set_time_zone"); - DBUG_PRINT("info",("spider this=%p", this)); - /* nothing to do */ - DBUG_RETURN(0); -} - -int spider_db_handlersocket::show_master_status( - SPIDER_TRX *trx, - SPIDER_SHARE *share, - int all_link_idx, - int *need_mon, - TABLE *table, - spider_string *str, - int mode, - SPIDER_DB_RESULT **res1, - SPIDER_DB_RESULT **res2 -) { - DBUG_ENTER("spider_db_handlersocket::show_master_status"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN(0); -} - -int spider_db_handlersocket::append_sql( - char *sql, - ulong sql_length, - st_spider_db_request_key *request_key -) { - int error_num; - size_t req_num; - SPIDER_HS_CONN *hs_conn_p = &hs_conn; - DBUG_ENTER("spider_db_handlersocket::append_sql"); - DBUG_PRINT("info",("spider this=%p", this)); - if ((error_num = append_request_key(request_key))) - DBUG_RETURN(error_num); - DBUG_PRINT("info",("spider hs hs_conn=%p", hs_conn_p)); - DBUG_PRINT("info",("spider hs num_req_bufd=%zu", - (*hs_conn_p)->get_num_req_bufd())); - DBUG_PRINT("info",("spider hs num_req_sent=%zu", - (*hs_conn_p)->get_num_req_sent())); - DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", - (*hs_conn_p)->get_num_req_rcvd())); - DBUG_PRINT("info",("spider hs response_end_offset=%zu", - (*hs_conn_p)->get_response_end_offset())); - if (!(req_num = (*hs_conn_p)->request_buf_append(sql, sql + sql_length))) - { - DBUG_PRINT("info",("spider hs %d %s", - (*hs_conn_p)->get_error_code(), - (*hs_conn_p)->get_error().ptr())); - (*hs_conn_p)->write_error_to_log(__func__, __FILE__, __LINE__); - DBUG_RETURN((*hs_conn_p)->get_error_code()); - } - DBUG_PRINT("info",("spider hs num_req_bufd=%zu", - (*hs_conn_p)->get_num_req_bufd())); - DBUG_PRINT("info",("spider hs num_req_sent=%zu", - (*hs_conn_p)->get_num_req_sent())); - DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", - (*hs_conn_p)->get_num_req_rcvd())); - DBUG_PRINT("info",("spider hs response_end_offset=%zu", - (*hs_conn_p)->get_response_end_offset())); - while (req_num > 1) - { - if ((error_num = append_request_key(request_key))) - DBUG_RETURN(error_num); - --req_num; - } - DBUG_RETURN(0); -} - -int spider_db_handlersocket::append_open_handler( - uint handler_id, - const char *db_name, - const char *table_name, - const char *index_name, - const char *sql, - st_spider_db_request_key *request_key -) { - int error_num; - SPIDER_HS_CONN *hs_conn_p = &hs_conn; - DBUG_ENTER("spider_db_handlersocket::append_open_handler"); - DBUG_PRINT("info",("spider this=%p", this)); - if ((error_num = append_request_key(request_key))) - DBUG_RETURN(error_num); - DBUG_PRINT("info",("spider hs hs_conn=%p", hs_conn_p)); - DBUG_PRINT("info",("spider hs num_req_bufd=%zu", - (*hs_conn_p)->get_num_req_bufd())); - DBUG_PRINT("info",("spider hs num_req_sent=%zu", - (*hs_conn_p)->get_num_req_sent())); - DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", - (*hs_conn_p)->get_num_req_rcvd())); - DBUG_PRINT("info",("spider hs response_end_offset=%zu", - (*hs_conn_p)->get_response_end_offset())); - (*hs_conn_p)->request_buf_open_index( - handler_id, - db_name, - table_name, - index_name, - sql - ); - DBUG_PRINT("info",("spider hs num_req_bufd=%zu", - (*hs_conn_p)->get_num_req_bufd())); - DBUG_PRINT("info",("spider hs num_req_sent=%zu", - (*hs_conn_p)->get_num_req_sent())); - DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", - (*hs_conn_p)->get_num_req_rcvd())); - DBUG_PRINT("info",("spider hs response_end_offset=%zu", - (*hs_conn_p)->get_response_end_offset())); - DBUG_RETURN(0); -} - -int spider_db_handlersocket::append_select( - uint handler_id, - spider_string *sql, - SPIDER_DB_HS_STRING_REF_BUFFER *keys, - int limit, - int skip, - st_spider_db_request_key *request_key -) { - int error_num; - SPIDER_HS_CONN *hs_conn_p = &hs_conn; - DBUG_ENTER("spider_db_handlersocket::append_select"); - DBUG_PRINT("info",("spider this=%p", this)); - if ((error_num = append_request_key(request_key))) - DBUG_RETURN(error_num); - DBUG_PRINT("info",("spider hs hs_conn=%p", hs_conn_p)); - DBUG_PRINT("info",("spider hs num_req_bufd=%zu", - (*hs_conn_p)->get_num_req_bufd())); - DBUG_PRINT("info",("spider hs num_req_sent=%zu", - (*hs_conn_p)->get_num_req_sent())); - DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", - (*hs_conn_p)->get_num_req_rcvd())); - DBUG_PRINT("info",("spider hs response_end_offset=%zu", - (*hs_conn_p)->get_response_end_offset())); - (*hs_conn_p)->request_buf_exec_generic( - handler_id, - SPIDER_HS_STRING_REF(sql->ptr(), sql->length()), - keys->ptr(), (size_t) keys->size(), - limit, skip, - SPIDER_HS_STRING_REF(), - NULL, 0); - DBUG_PRINT("info",("spider hs num_req_bufd=%zu", - (*hs_conn_p)->get_num_req_bufd())); - DBUG_PRINT("info",("spider hs num_req_sent=%zu", - (*hs_conn_p)->get_num_req_sent())); - DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", - (*hs_conn_p)->get_num_req_rcvd())); - DBUG_PRINT("info",("spider hs response_end_offset=%zu", - (*hs_conn_p)->get_response_end_offset())); - DBUG_RETURN(0); -} - -int spider_db_handlersocket::append_insert( - uint handler_id, - SPIDER_DB_HS_STRING_REF_BUFFER *upds, - st_spider_db_request_key *request_key -) { - int error_num; - SPIDER_HS_CONN *hs_conn_p = &hs_conn; - DBUG_ENTER("spider_db_handlersocket::append_insert"); - DBUG_PRINT("info",("spider this=%p", this)); - if ((error_num = append_request_key(request_key))) - DBUG_RETURN(error_num); - DBUG_PRINT("info",("spider hs hs_conn=%p", hs_conn_p)); - DBUG_PRINT("info",("spider hs num_req_bufd=%zu", - (*hs_conn_p)->get_num_req_bufd())); - DBUG_PRINT("info",("spider hs num_req_sent=%zu", - (*hs_conn_p)->get_num_req_sent())); - DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", - (*hs_conn_p)->get_num_req_rcvd())); - DBUG_PRINT("info",("spider hs response_end_offset=%zu", - (*hs_conn_p)->get_response_end_offset())); - (*hs_conn_p)->request_buf_exec_generic( - handler_id, - SPIDER_HS_STRING_REF(SPIDER_SQL_HS_INSERT_STR, SPIDER_SQL_HS_INSERT_LEN), - upds->ptr(), (size_t) upds->size(), - 0, 0, - SPIDER_HS_STRING_REF(), NULL, 0); - DBUG_PRINT("info",("spider hs num_req_bufd=%zu", - (*hs_conn_p)->get_num_req_bufd())); - DBUG_PRINT("info",("spider hs num_req_sent=%zu", - (*hs_conn_p)->get_num_req_sent())); - DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", - (*hs_conn_p)->get_num_req_rcvd())); - DBUG_PRINT("info",("spider hs response_end_offset=%zu", - (*hs_conn_p)->get_response_end_offset())); - DBUG_RETURN(0); -} - -int spider_db_handlersocket::append_update( - uint handler_id, - spider_string *sql, - SPIDER_DB_HS_STRING_REF_BUFFER *keys, - SPIDER_DB_HS_STRING_REF_BUFFER *upds, - int limit, - int skip, - bool increment, - bool decrement, - st_spider_db_request_key *request_key -) { - int error_num; - SPIDER_HS_CONN *hs_conn_p = &hs_conn; - DBUG_ENTER("spider_db_handlersocket::append_update"); - DBUG_PRINT("info",("spider this=%p", this)); - if ((error_num = append_request_key(request_key))) - DBUG_RETURN(error_num); - DBUG_PRINT("info",("spider hs hs_conn=%p", hs_conn_p)); - DBUG_PRINT("info",("spider hs num_req_bufd=%zu", - (*hs_conn_p)->get_num_req_bufd())); - DBUG_PRINT("info",("spider hs num_req_sent=%zu", - (*hs_conn_p)->get_num_req_sent())); - DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", - (*hs_conn_p)->get_num_req_rcvd())); - DBUG_PRINT("info",("spider hs response_end_offset=%zu", - (*hs_conn_p)->get_response_end_offset())); - (*hs_conn_p)->request_buf_exec_generic( - handler_id, - SPIDER_HS_STRING_REF(sql->ptr(), sql->length()), - keys->ptr(), (size_t) keys->size(), - limit, skip, - increment ? - SPIDER_HS_STRING_REF(SPIDER_SQL_HS_INCREMENT_STR, - SPIDER_SQL_HS_INCREMENT_LEN) : - decrement ? - SPIDER_HS_STRING_REF(SPIDER_SQL_HS_DECREMENT_STR, - SPIDER_SQL_HS_DECREMENT_LEN) : - SPIDER_HS_STRING_REF(SPIDER_SQL_HS_UPDATE_STR, - SPIDER_SQL_HS_UPDATE_LEN), - upds->ptr(), (size_t) upds->size() - ); - DBUG_PRINT("info",("spider hs num_req_bufd=%zu", - (*hs_conn_p)->get_num_req_bufd())); - DBUG_PRINT("info",("spider hs num_req_sent=%zu", - (*hs_conn_p)->get_num_req_sent())); - DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", - (*hs_conn_p)->get_num_req_rcvd())); - DBUG_PRINT("info",("spider hs response_end_offset=%zu", - (*hs_conn_p)->get_response_end_offset())); - DBUG_RETURN(0); -} - -int spider_db_handlersocket::append_delete( - uint handler_id, - spider_string *sql, - SPIDER_DB_HS_STRING_REF_BUFFER *keys, - int limit, - int skip, - st_spider_db_request_key *request_key -) { - int error_num; - SPIDER_HS_CONN *hs_conn_p = &hs_conn; - DBUG_ENTER("spider_db_handlersocket::append_delete"); - DBUG_PRINT("info",("spider this=%p", this)); - if ((error_num = append_request_key(request_key))) - DBUG_RETURN(error_num); - DBUG_PRINT("info",("spider hs hs_conn=%p", hs_conn_p)); - DBUG_PRINT("info",("spider hs num_req_bufd=%zu", - (*hs_conn_p)->get_num_req_bufd())); - DBUG_PRINT("info",("spider hs num_req_sent=%zu", - (*hs_conn_p)->get_num_req_sent())); - DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", - (*hs_conn_p)->get_num_req_rcvd())); - DBUG_PRINT("info",("spider hs response_end_offset=%zu", - (*hs_conn_p)->get_response_end_offset())); - (*hs_conn_p)->request_buf_exec_generic( - handler_id, - SPIDER_HS_STRING_REF(sql->ptr(), sql->length()), - keys->ptr(), (size_t) keys->size(), - limit, skip, - SPIDER_HS_STRING_REF(SPIDER_SQL_HS_DELETE_STR, SPIDER_SQL_HS_DELETE_LEN), - NULL, 0); - DBUG_PRINT("info",("spider hs num_req_bufd=%zu", - (*hs_conn_p)->get_num_req_bufd())); - DBUG_PRINT("info",("spider hs num_req_sent=%zu", - (*hs_conn_p)->get_num_req_sent())); - DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", - (*hs_conn_p)->get_num_req_rcvd())); - DBUG_PRINT("info",("spider hs response_end_offset=%zu", - (*hs_conn_p)->get_response_end_offset())); - DBUG_RETURN(0); -} - -void spider_db_handlersocket::reset_request_queue() -{ - SPIDER_HS_CONN *hs_conn_p = &hs_conn; - DBUG_ENTER("spider_db_handlersocket::reset_request_queue"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_PRINT("info",("spider hs hs_conn=%p", hs_conn_p)); - DBUG_PRINT("info",("spider hs num_req_bufd=%zu", - (*hs_conn_p)->get_num_req_bufd())); - DBUG_PRINT("info",("spider hs num_req_sent=%zu", - (*hs_conn_p)->get_num_req_sent())); - DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", - (*hs_conn_p)->get_num_req_rcvd())); - DBUG_PRINT("info",("spider hs response_end_offset=%zu", - (*hs_conn_p)->get_response_end_offset())); - (*hs_conn_p)->request_reset(); - DBUG_PRINT("info",("spider hs num_req_bufd=%zu", - (*hs_conn_p)->get_num_req_bufd())); - DBUG_PRINT("info",("spider hs num_req_sent=%zu", - (*hs_conn_p)->get_num_req_sent())); - DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", - (*hs_conn_p)->get_num_req_rcvd())); - DBUG_PRINT("info",("spider hs response_end_offset=%zu", - (*hs_conn_p)->get_response_end_offset())); - reset_request_key_req(); - DBUG_VOID_RETURN; -} - -size_t spider_db_handlersocket::escape_string( - char *to, - const char *from, - size_t from_length -) { - DBUG_ENTER("spider_db_handlersocket::escape_string"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - memcpy(to, from, from_length); - DBUG_RETURN(from_length); -} - -bool spider_db_handlersocket::have_lock_table_list() -{ - DBUG_ENTER("spider_db_handlersocket::have_lock_table_list"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN(FALSE); -} - -int spider_db_handlersocket::append_lock_tables( - spider_string *str -) { - DBUG_ENTER("spider_db_handlersocket::lock_tables"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN(0); -} - -int spider_db_handlersocket::append_unlock_tables( - spider_string *str -) { - DBUG_ENTER("spider_db_handlersocket::append_unlock_tables"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN(0); -} - -uint spider_db_handlersocket::get_lock_table_hash_count() -{ - DBUG_ENTER("spider_db_handlersocket::get_lock_table_hash_count"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -void spider_db_handlersocket::reset_lock_table_hash() -{ - DBUG_ENTER("spider_db_handlersocket::reset_lock_table_hash"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_VOID_RETURN; -} - -uint spider_db_handlersocket::get_opened_handler_count() -{ - DBUG_ENTER("spider_db_handlersocket::get_opened_handler_count"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN(handler_open_array.elements); -} - -void spider_db_handlersocket::reset_opened_handler() -{ - ha_spider *tmp_spider; - int tmp_link_idx; - SPIDER_LINK_FOR_HASH **tmp_link_for_hash; - DBUG_ENTER("spider_db_handlersocket::reset_opened_handler"); - DBUG_PRINT("info",("spider this=%p", this)); - while ((tmp_link_for_hash = - (SPIDER_LINK_FOR_HASH **) pop_dynamic(&handler_open_array))) - { - tmp_spider = (*tmp_link_for_hash)->spider; - tmp_link_idx = (*tmp_link_for_hash)->link_idx; - tmp_spider->clear_handler_opened(tmp_link_idx, conn->conn_kind); - } - DBUG_VOID_RETURN; -} - -void spider_db_handlersocket::set_dup_key_idx( - ha_spider *spider, - int link_idx -) { - DBUG_ENTER("spider_db_handlersocket::set_dup_key_idx"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_VOID_RETURN; -} - -int spider_db_handlersocket::append_request_key( - st_spider_db_request_key *request_key -) { - st_spider_db_request_key *tmp_request_key; - DBUG_ENTER("spider_db_handlersocket::append_request_key"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_PRINT("info",("spider request_key=%p", request_key)); - if (request_key) - { - DBUG_PRINT("info",("spider request_key->spider_thread_id=%llu", - request_key->spider_thread_id)); - DBUG_PRINT("info",("spider request_key->query_id=%llu", - request_key->query_id)); - DBUG_PRINT("info",("spider request_key->handler=%p", - request_key->handler)); - DBUG_PRINT("info",("spider request_key->request_id=%llu", - request_key->request_id)); - if (request_key_reuse_first) - { - tmp_request_key = request_key_reuse_first; - request_key_reuse_first = request_key_reuse_first->next; - if (!request_key_reuse_first) - request_key_reuse_last = NULL; - } else { - if (!(tmp_request_key = (st_spider_db_request_key *) - spider_malloc(spider_current_trx, SPD_MID_DB_HANDLERSOCKET_APPEND_REQUEST_KEY_1, sizeof(st_spider_db_request_key), - MYF(MY_WME))) - ) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - } - *tmp_request_key = *request_key; - tmp_request_key->next = NULL; - if (request_key_req_last) - request_key_req_last->next = tmp_request_key; - else - request_key_req_first = tmp_request_key; - request_key_req_last = tmp_request_key; - } - DBUG_RETURN(0); -} - -void spider_db_handlersocket::reset_request_key_req() -{ - DBUG_ENTER("spider_db_handlersocket::reset_request_key_req"); - DBUG_PRINT("info",("spider this=%p", this)); - if (request_key_req_first) - { - if (request_key_reuse_last) - request_key_reuse_last->next = request_key_req_first; - else - request_key_reuse_first = request_key_req_first; - request_key_reuse_last = request_key_req_last; - request_key_req_first = NULL; - request_key_req_last = NULL; - } - DBUG_VOID_RETURN; -} - -void spider_db_handlersocket::reset_request_key_snd() -{ - DBUG_ENTER("spider_db_handlersocket::reset_request_key_snd"); - DBUG_PRINT("info",("spider this=%p", this)); - if (request_key_snd_first) - { - if (request_key_reuse_last) - request_key_reuse_last->next = request_key_snd_first; - else - request_key_reuse_first = request_key_snd_first; - request_key_reuse_last = request_key_snd_last; - request_key_snd_first = NULL; - request_key_snd_last = NULL; - } - DBUG_VOID_RETURN; -} - -void spider_db_handlersocket::move_request_key_to_snd() -{ - DBUG_ENTER("spider_db_handlersocket::move_request_key_to_snd"); - DBUG_PRINT("info",("spider this=%p", this)); - if (request_key_req_first) - { - if (request_key_snd_last) - request_key_snd_last->next = request_key_req_first; - else - request_key_snd_first = request_key_req_first; - request_key_snd_last = request_key_req_last; - request_key_req_first = NULL; - request_key_req_last = NULL; - } - DBUG_VOID_RETURN; -} - -int spider_db_handlersocket::check_request_key( - st_spider_db_request_key *request_key -) { - st_spider_db_request_key *tmp_request_key; - DBUG_ENTER("spider_db_handlersocket::check_request_key"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_PRINT("info",("spider request_key=%p", request_key)); - DBUG_PRINT("info",("spider request_key_snd_first=%p", - request_key_snd_first)); - if (!request_key_snd_first) - { - DBUG_PRINT("info",("spider -1")); - DBUG_RETURN(-1); - } - tmp_request_key = request_key_snd_first; - request_key_snd_first = request_key_snd_first->next; - if (!request_key_snd_first) - request_key_snd_last = NULL; - tmp_request_key->next = NULL; - if (request_key_reuse_last) - request_key_reuse_last->next = tmp_request_key; - else - request_key_reuse_first = tmp_request_key; - request_key_reuse_last = tmp_request_key; - - DBUG_PRINT("info",("spider tmp_request_key->spider_thread_id=%llu", - tmp_request_key->spider_thread_id)); - DBUG_PRINT("info",("spider request_key->spider_thread_id=%llu", - request_key->spider_thread_id)); - DBUG_PRINT("info",("spider tmp_request_key->query_id=%llu", - tmp_request_key->query_id)); - DBUG_PRINT("info",("spider request_key->query_id=%llu", - request_key->query_id)); - DBUG_PRINT("info",("spider tmp_request_key->handler=%p", - tmp_request_key->handler)); - DBUG_PRINT("info",("spider request_key->handler=%p", - request_key->handler)); - DBUG_PRINT("info",("spider tmp_request_key->request_id=%llu", - tmp_request_key->request_id)); - DBUG_PRINT("info",("spider request_key->request_id=%llu", - request_key->request_id)); - if ( - tmp_request_key->spider_thread_id != request_key->spider_thread_id || - tmp_request_key->query_id != request_key->query_id || - tmp_request_key->handler != request_key->handler || - tmp_request_key->request_id != request_key->request_id - ) { - DBUG_PRINT("info",("spider 1")); - DBUG_RETURN(1); - } - DBUG_PRINT("info",("spider 0")); - DBUG_RETURN(0); -} - -bool spider_db_handlersocket::cmp_request_key_to_snd( - st_spider_db_request_key *request_key -) { - DBUG_ENTER("spider_db_handlersocket::cmp_request_key_to_snd"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_PRINT("info",("spider request_key=%p", request_key)); - if ( - !request_key - ) { - DBUG_PRINT("info",("spider TRUE")); - DBUG_RETURN(TRUE); - } - DBUG_PRINT("info",("spider request_key_snd_first=%p", - request_key_snd_first)); - if ( - !request_key_snd_first - ) { - DBUG_PRINT("info",("spider FALSE")); - DBUG_RETURN(FALSE); - } - DBUG_PRINT("info",("spider request_key_snd_first->spider_thread_id=%llu", - request_key_snd_first->spider_thread_id)); - DBUG_PRINT("info",("spider request_key->spider_thread_id=%llu", - request_key->spider_thread_id)); - DBUG_PRINT("info",("spider request_key_snd_first->query_id=%llu", - request_key_snd_first->query_id)); - DBUG_PRINT("info",("spider request_key->query_id=%llu", - request_key->query_id)); - DBUG_PRINT("info",("spider request_key_snd_first->handler=%p", - request_key_snd_first->handler)); - DBUG_PRINT("info",("spider request_key->handler=%p", - request_key->handler)); - DBUG_PRINT("info",("spider request_key_snd_first->request_id=%llu", - request_key_snd_first->request_id)); - DBUG_PRINT("info",("spider request_key->request_id=%llu", - request_key->request_id)); - if ( - request_key_snd_first->spider_thread_id != request_key->spider_thread_id || - request_key_snd_first->query_id != request_key->query_id || - request_key_snd_first->handler != request_key->handler || - request_key_snd_first->request_id != request_key->request_id - ) { - DBUG_PRINT("info",("spider FALSE")); - DBUG_RETURN(FALSE); - } - DBUG_PRINT("info",("spider TRUE")); - DBUG_RETURN(TRUE); -} - -spider_db_handlersocket_util::spider_db_handlersocket_util() : spider_db_util() -{ - DBUG_ENTER("spider_db_handlersocket_util::spider_db_handlersocket_util"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_VOID_RETURN; -} - -spider_db_handlersocket_util::~spider_db_handlersocket_util() -{ - DBUG_ENTER("spider_db_handlersocket_util::~spider_db_handlersocket_util"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_VOID_RETURN; -} - -int spider_db_handlersocket_util::append_name( - spider_string *str, - const char *name, - uint name_length -) { - DBUG_ENTER("spider_db_handlersocket_util::append_name"); - str->q_append(name, name_length); - DBUG_RETURN(0); -} - -int spider_db_handlersocket_util::append_name_with_charset( - spider_string *str, - const char *name, - uint name_length, - CHARSET_INFO *name_charset -) { - DBUG_ENTER("spider_db_handlersocket_util::append_name_with_charset"); - if (str->reserve(SPIDER_SQL_NAME_QUOTE_LEN * 2 + name_length * 2)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(SPIDER_SQL_NAME_QUOTE_STR, SPIDER_SQL_NAME_QUOTE_LEN); - str->append(name, name_length, name_charset); - if (str->reserve(SPIDER_SQL_NAME_QUOTE_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(SPIDER_SQL_NAME_QUOTE_STR, SPIDER_SQL_NAME_QUOTE_LEN); - DBUG_RETURN(0); -} - -int spider_db_handlersocket_util::append_escaped_name( - spider_string *str, - const char *name, - uint name_length -) { - int error_num; - DBUG_ENTER("spider_db_handlersocket_util::append_name"); - if (str->reserve(SPIDER_SQL_NAME_QUOTE_LEN * 2 + name_length * 2)) - { - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - } - str->q_append(SPIDER_SQL_NAME_QUOTE_STR, SPIDER_SQL_NAME_QUOTE_LEN); - if ((error_num = spider_db_append_name_with_quote_str_internal( - str, name, name_length, dbton_id))) - { - DBUG_RETURN(error_num); - } - if (str->reserve(SPIDER_SQL_NAME_QUOTE_LEN)) - { - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - } - str->q_append(SPIDER_SQL_NAME_QUOTE_STR, SPIDER_SQL_NAME_QUOTE_LEN); - DBUG_RETURN(0); -} - -int spider_db_handlersocket_util::append_escaped_name_with_charset( - spider_string *str, - const char *name, - uint name_length, - CHARSET_INFO *name_charset -) { - int error_num; - DBUG_ENTER("spider_db_handlersocket_util::append_name_with_charset"); - if (str->reserve(SPIDER_SQL_NAME_QUOTE_LEN * 2 + name_length * 2)) - { - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - } - str->q_append(SPIDER_SQL_NAME_QUOTE_STR, SPIDER_SQL_NAME_QUOTE_LEN); - if ((error_num = spider_db_append_name_with_quote_str_internal( - str, name, name_length, name_charset, dbton_id))) - { - DBUG_RETURN(error_num); - } - if (str->reserve(SPIDER_SQL_NAME_QUOTE_LEN)) - { - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - } - str->q_append(SPIDER_SQL_NAME_QUOTE_STR, SPIDER_SQL_NAME_QUOTE_LEN); - DBUG_RETURN(0); -} - -bool spider_db_handlersocket_util::is_name_quote( - const char head_code -) { - DBUG_ENTER("spider_db_handlersocket_util::is_name_quote"); - DBUG_RETURN(head_code == *name_quote_str); -} - -int spider_db_handlersocket_util::append_escaped_name_quote( - spider_string *str -) { - DBUG_ENTER("spider_db_handlersocket_util::append_escaped_name_quote"); - if (str->reserve(SPIDER_SQL_NAME_QUOTE_LEN * 2)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(SPIDER_SQL_NAME_QUOTE_STR, SPIDER_SQL_NAME_QUOTE_LEN); - str->q_append(SPIDER_SQL_NAME_QUOTE_STR, SPIDER_SQL_NAME_QUOTE_LEN); - DBUG_RETURN(0); -} - -int spider_db_handlersocket_util::append_column_value( - ha_spider *spider, - spider_string *str, - Field *field, - const uchar *new_ptr, - CHARSET_INFO *access_charset -) { - char buf[MAX_FIELD_WIDTH]; - spider_string tmp_str(buf, MAX_FIELD_WIDTH, &my_charset_bin); - String *ptr; - uint length; - DBUG_ENTER("spider_db_handlersocket_util::append_column_value"); - tmp_str.init_calc_mem(SPD_MID_DB_HANDLERSOCKET_UTIL_APPEND_COLUMN_VALUE_1); - - if (new_ptr) - { - if ( - field->type() == MYSQL_TYPE_BLOB || - field->real_type() == MYSQL_TYPE_VARCHAR - ) { - length = uint2korr(new_ptr); - tmp_str.set_quick((char *) new_ptr + HA_KEY_BLOB_LENGTH, length, - &my_charset_bin); - ptr = tmp_str.get_str(); - } else if (field->type() == MYSQL_TYPE_GEOMETRY) - { -/* - uint mlength = SIZEOF_STORED_DOUBLE, lcnt; - uchar *dest = (uchar *) buf; - const uchar *source; - for (lcnt = 0; lcnt < 4; lcnt++) - { - mlength = SIZEOF_STORED_DOUBLE; - source = new_ptr + mlength + SIZEOF_STORED_DOUBLE * lcnt; - while (mlength--) - *dest++ = *--source; - } - tmp_str.length(SIZEOF_STORED_DOUBLE * lcnt); -*/ - double xmin, xmax, ymin, ymax; -/* - float8store(buf,xmin); - float8store(buf+8,xmax); - float8store(buf+16,ymin); - float8store(buf+24,ymax); - memcpy(&xmin,new_ptr,sizeof(xmin)); - memcpy(&xmax,new_ptr + 8,sizeof(xmax)); - memcpy(&ymin,new_ptr + 16,sizeof(ymin)); - memcpy(&ymax,new_ptr + 24,sizeof(ymax)); - float8get(xmin, buf); - float8get(xmax, buf + 8); - float8get(ymin, buf + 16); - float8get(ymax, buf + 24); - DBUG_PRINT("info", ("spider geo is %f %f %f %f", - xmin, xmax, ymin, ymax)); - DBUG_PRINT("info", ("spider geo is %.14g %.14g %.14g %.14g", - xmin, xmax, ymin, ymax)); -*/ - float8get(xmin, new_ptr); - float8get(xmax, new_ptr + 8); - float8get(ymin, new_ptr + 16); - float8get(ymax, new_ptr + 24); - DBUG_PRINT("info", ("spider geo is %f %f %f %f", - xmin, xmax, ymin, ymax)); -/* - float8get(xmin, new_ptr + SIZEOF_STORED_DOUBLE * 4); - float8get(xmax, new_ptr + SIZEOF_STORED_DOUBLE * 5); - float8get(ymin, new_ptr + SIZEOF_STORED_DOUBLE * 6); - float8get(ymax, new_ptr + SIZEOF_STORED_DOUBLE * 7); - DBUG_PRINT("info", ("spider geo is %f %f %f %f", - xmin, xmax, ymin, ymax)); - float8get(xmin, new_ptr + SIZEOF_STORED_DOUBLE * 8); - float8get(xmax, new_ptr + SIZEOF_STORED_DOUBLE * 9); - float8get(ymin, new_ptr + SIZEOF_STORED_DOUBLE * 10); - float8get(ymax, new_ptr + SIZEOF_STORED_DOUBLE * 11); - DBUG_PRINT("info", ("spider geo is %f %f %f %f", - xmin, xmax, ymin, ymax)); - float8get(xmin, new_ptr + SIZEOF_STORED_DOUBLE * 12); - float8get(xmax, new_ptr + SIZEOF_STORED_DOUBLE * 13); - float8get(ymin, new_ptr + SIZEOF_STORED_DOUBLE * 14); - float8get(ymax, new_ptr + SIZEOF_STORED_DOUBLE * 15); - DBUG_PRINT("info", ("spider geo is %f %f %f %f", - xmin, xmax, ymin, ymax)); -*/ -/* - tmp_str.set_quick((char *) new_ptr, SIZEOF_STORED_DOUBLE * 4, - &my_charset_bin); -*/ - tmp_str.length(0); - tmp_str.q_append((char *) SPIDER_SQL_LINESTRING_HEAD_STR, - SPIDER_SQL_LINESTRING_HEAD_LEN); - tmp_str.q_append((char *) new_ptr, SIZEOF_STORED_DOUBLE); - tmp_str.q_append((char *) new_ptr + SIZEOF_STORED_DOUBLE * 2, - SIZEOF_STORED_DOUBLE); - tmp_str.q_append((char *) new_ptr + SIZEOF_STORED_DOUBLE, - SIZEOF_STORED_DOUBLE); - tmp_str.q_append((char *) new_ptr + SIZEOF_STORED_DOUBLE * 3, - SIZEOF_STORED_DOUBLE); - ptr = tmp_str.get_str(); - } else { - ptr = field->val_str(tmp_str.get_str(), new_ptr); - tmp_str.mem_calc(); - } - } else { - ptr = field->val_str(tmp_str.get_str()); - tmp_str.mem_calc(); - } - DBUG_PRINT("info", ("spider field->type() is %d", field->type())); - DBUG_PRINT("info", ("spider ptr->length() is %d", ptr->length())); -/* - if ( - field->type() == MYSQL_TYPE_BIT || - (field->type() >= MYSQL_TYPE_TINY_BLOB && - field->type() <= MYSQL_TYPE_BLOB) - ) { - uchar *hex_ptr = (uchar *) ptr->ptr(), *end_ptr; - char *str_ptr; - DBUG_PRINT("info", ("spider HEX")); - if (str->reserve(SPIDER_SQL_HEX_LEN + ptr->length() * 2)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(SPIDER_SQL_HEX_STR, SPIDER_SQL_HEX_LEN); - str_ptr = (char *) str->ptr() + str->length(); - for (end_ptr = hex_ptr + ptr->length(); hex_ptr < end_ptr; hex_ptr++) - { - *str_ptr++ = spider_dig_upper[(*hex_ptr) >> 4]; - *str_ptr++ = spider_dig_upper[(*hex_ptr) & 0x0F]; - } - str->length(str->length() + ptr->length() * 2); - } else -*/ - spider_handlersocket_handler *hs_handler = (spider_handlersocket_handler *) - spider->dbton_handler[spider_dbton_handlersocket.dbton_id]; - spider_string *hs_str; - if (!(hs_str = hs_handler->hs_strs.add( - &hs_handler->hs_strs_pos, ptr->ptr(), ptr->length()))) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - SPIDER_HS_STRING_REF ref = - SPIDER_HS_STRING_REF(hs_str->ptr(), hs_str->length()); - if (hs_handler->hs_adding_keys) - { - DBUG_PRINT("info", ("spider add to key:%s", hs_str->c_ptr_safe())); - hs_handler->hs_keys.push_back(ref); - } else { - DBUG_PRINT("info", ("spider add to upd:%s", hs_str->c_ptr_safe())); - hs_handler->hs_upds.push_back(ref); - } - DBUG_RETURN(0); -} - -int spider_db_handlersocket_util::append_trx_isolation( - spider_string *str, - int trx_isolation -) { - DBUG_ENTER("spider_db_handlersocket_util::append_trx_isolation"); - DBUG_PRINT("info",("spider this=%p", this)); - /* nothing to do */ - DBUG_RETURN(0); -} - -int spider_db_handlersocket_util::append_autocommit( - spider_string *str, - bool autocommit -) { - DBUG_ENTER("spider_db_handlersocket_util::append_autocommit"); - DBUG_PRINT("info",("spider this=%p", this)); - /* nothing to do */ - DBUG_RETURN(0); -} - -int spider_db_handlersocket_util::append_sql_log_off( - spider_string *str, - bool sql_log_off -) { - DBUG_ENTER("spider_db_handlersocket_util::append_sql_log_off"); - DBUG_PRINT("info",("spider this=%p", this)); - /* nothing to do */ - DBUG_RETURN(0); -} - -int spider_db_handlersocket_util::append_wait_timeout( - spider_string *str, - int wait_timeout -) { - DBUG_ENTER("spider_db_handlersocket_util::append_wait_timeout"); - DBUG_PRINT("info",("spider this=%p", this)); - /* nothing to do */ - DBUG_RETURN(0); -} - -int spider_db_handlersocket_util::append_sql_mode( - spider_string *str, - sql_mode_t sql_mode -) { - DBUG_ENTER("spider_db_handlersocket_util::append_sql_mode"); - DBUG_PRINT("info",("spider this=%p", this)); - /* nothing to do */ - DBUG_RETURN(0); -} - -int spider_db_handlersocket_util::append_time_zone( - spider_string *str, - Time_zone *time_zone -) { - DBUG_ENTER("spider_db_handlersocket_util::append_time_zone"); - DBUG_PRINT("info",("spider this=%p", this)); - /* nothing to do */ - DBUG_RETURN(0); -} - -int spider_db_handlersocket_util::append_start_transaction( - spider_string *str -) { - DBUG_ENTER("spider_db_handlersocket_util::append_start_transaction"); - DBUG_PRINT("info",("spider this=%p", this)); - /* nothing to do */ - DBUG_RETURN(0); -} - -int spider_db_handlersocket_util::append_xa_start( - spider_string *str, - XID *xid -) { - DBUG_ENTER("spider_db_handlersocket_util::append_xa_start"); - DBUG_PRINT("info",("spider this=%p", this)); - /* nothing to do */ - DBUG_RETURN(0); -} - -int spider_db_handlersocket_util::append_lock_table_head( - spider_string *str -) { - DBUG_ENTER("spider_db_handlersocket_util::append_lock_table_head"); - DBUG_PRINT("info",("spider this=%p", this)); - /* nothing to do */ - DBUG_RETURN(0); -} - -int spider_db_handlersocket_util::append_lock_table_body( - spider_string *str, - const char *db_name, - uint db_name_length, - CHARSET_INFO *db_name_charset, - const char *table_name, - uint table_name_length, - CHARSET_INFO *table_name_charset, - int lock_type -) { - DBUG_ENTER("spider_db_handlersocket_util::append_lock_table_body"); - DBUG_PRINT("info",("spider this=%p", this)); - /* nothing to do */ - DBUG_RETURN(0); -} - -int spider_db_handlersocket_util::append_lock_table_tail( - spider_string *str -) { - DBUG_ENTER("spider_db_handlersocket_util::append_lock_table_tail"); - DBUG_PRINT("info",("spider this=%p", this)); - /* nothing to do */ - DBUG_RETURN(0); -} - -int spider_db_handlersocket_util::append_unlock_table( - spider_string *str -) { - DBUG_ENTER("spider_db_handlersocket_util::append_unlock_table"); - DBUG_PRINT("info",("spider this=%p", this)); - /* nothing to do */ - DBUG_RETURN(0); -} - -int spider_db_handlersocket_util::open_item_func( - Item_func *item_func, - ha_spider *spider, - spider_string *str, - const char *alias, - uint alias_length, - bool use_fields, - spider_fields *fields -) { - uint dbton_id = spider_dbton_handlersocket.dbton_id; - int error_num; - Item *item, **item_list = item_func->arguments(); - uint roop_count, item_count = item_func->argument_count(), start_item = 0; - const char *func_name = SPIDER_SQL_NULL_CHAR_STR, - *separator_str = SPIDER_SQL_NULL_CHAR_STR, - *last_str = SPIDER_SQL_NULL_CHAR_STR; - int func_name_length = SPIDER_SQL_NULL_CHAR_LEN, - separator_str_length = SPIDER_SQL_NULL_CHAR_LEN, - last_str_length = SPIDER_SQL_NULL_CHAR_LEN; - int use_pushdown_udf; - bool merge_func = FALSE; - DBUG_ENTER("spider_db_handlersocket_util::open_item_func"); - if (str) - { - if (str->reserve(SPIDER_SQL_OPEN_PAREN_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(SPIDER_SQL_OPEN_PAREN_STR, SPIDER_SQL_OPEN_PAREN_LEN); - } - DBUG_PRINT("info",("spider functype = %d", item_func->functype())); - switch (item_func->functype()) - { - case Item_func::ISNULL_FUNC: - last_str = SPIDER_SQL_IS_NULL_STR; - last_str_length = SPIDER_SQL_IS_NULL_LEN; - break; - case Item_func::ISNOTNULL_FUNC: - last_str = SPIDER_SQL_IS_NOT_NULL_STR; - last_str_length = SPIDER_SQL_IS_NOT_NULL_LEN; - break; - case Item_func::UNKNOWN_FUNC: - func_name = (char*) item_func->func_name(); - func_name_length = strlen(func_name); - DBUG_PRINT("info",("spider func_name = %s", func_name)); - DBUG_PRINT("info",("spider func_name_length = %d", func_name_length)); - if (func_name_length == 1 && - ( - !strncasecmp("+", func_name, func_name_length) || - !strncasecmp("-", func_name, func_name_length) || - !strncasecmp("*", func_name, func_name_length) || - !strncasecmp("/", func_name, func_name_length) || - !strncasecmp("%", func_name, func_name_length) || - !strncasecmp("&", func_name, func_name_length) || - !strncasecmp("|", func_name, func_name_length) || - !strncasecmp("^", func_name, func_name_length) - ) - ) { - /* no action */ - break; - } else if (func_name_length == 2 && - ( - !strncasecmp("<<", func_name, func_name_length) || - !strncasecmp(">>", func_name, func_name_length) - ) - ) { - /* no action */ - break; - } else if (func_name_length == 3 && - !strncasecmp("div", func_name, func_name_length) - ) { - /* no action */ - break; - } else if (func_name_length == 4) - { - if ( - !strncasecmp("rand", func_name, func_name_length) && -#ifdef SPIDER_Item_args_arg_count_IS_PROTECTED - !item_func->argument_count() -#else - !item_func->arg_count -#endif - ) { - if (str) - str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); - DBUG_RETURN(spider_db_open_item_int(item_func, NULL, spider, str, - alias, alias_length, dbton_id, use_fields, fields)); - } else if ( - !strncasecmp("case", func_name, func_name_length) - ) { -#ifdef ITEM_FUNC_CASE_PARAMS_ARE_PUBLIC - Item_func_case *item_func_case = (Item_func_case *) item_func; - if (str) - { - if (str->reserve(SPIDER_SQL_CASE_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(SPIDER_SQL_CASE_STR, SPIDER_SQL_CASE_LEN); - } - if (item_func_case->first_expr_num != -1) - { - if ((error_num = spider_db_print_item_type( - item_list[item_func_case->first_expr_num], NULL, spider, str, - alias, alias_length, dbton_id, use_fields, fields))) - DBUG_RETURN(error_num); - } - for (roop_count = 0; roop_count < item_func_case->ncases; - roop_count += 2) - { - if (str) - { - if (str->reserve(SPIDER_SQL_WHEN_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(SPIDER_SQL_WHEN_STR, SPIDER_SQL_WHEN_LEN); - } - if ((error_num = spider_db_print_item_type( - item_list[roop_count], NULL, spider, str, - alias, alias_length, dbton_id, use_fields, fields))) - DBUG_RETURN(error_num); - if (str) - { - if (str->reserve(SPIDER_SQL_THEN_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(SPIDER_SQL_THEN_STR, SPIDER_SQL_THEN_LEN); - } - if ((error_num = spider_db_print_item_type( - item_list[roop_count + 1], NULL, spider, str, - alias, alias_length, dbton_id, use_fields, fields))) - DBUG_RETURN(error_num); - } - if (item_func_case->else_expr_num != -1) - { - if (str) - { - if (str->reserve(SPIDER_SQL_ELSE_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(SPIDER_SQL_ELSE_STR, SPIDER_SQL_ELSE_LEN); - } - if ((error_num = spider_db_print_item_type( - item_list[item_func_case->else_expr_num], NULL, spider, str, - alias, alias_length, dbton_id, use_fields, fields))) - DBUG_RETURN(error_num); - } - if (str) - { - if (str->reserve(SPIDER_SQL_END_LEN + SPIDER_SQL_CLOSE_PAREN_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(SPIDER_SQL_END_STR, SPIDER_SQL_END_LEN); - str->q_append(SPIDER_SQL_CLOSE_PAREN_STR, - SPIDER_SQL_CLOSE_PAREN_LEN); - } - DBUG_RETURN(0); -#else - DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM); -#endif - } - } else if (func_name_length == 6 && - !strncasecmp("istrue", func_name, func_name_length) - ) { - last_str = SPIDER_SQL_IS_TRUE_STR; - last_str_length = SPIDER_SQL_IS_TRUE_LEN; - break; - } else if (func_name_length == 7) - { - if (!strncasecmp("isfalse", func_name, func_name_length)) - { - last_str = SPIDER_SQL_IS_FALSE_STR; - last_str_length = SPIDER_SQL_IS_FALSE_LEN; - break; - } else if ( - !strncasecmp("sysdate", func_name, func_name_length) || - !strncasecmp("curdate", func_name, func_name_length) || - !strncasecmp("curtime", func_name, func_name_length) - ) { - if (str) - str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); - DBUG_RETURN(spider_db_open_item_string(item_func, NULL, spider, str, - alias, alias_length, dbton_id, use_fields, fields)); - } else if ( - !strncasecmp("convert", func_name, func_name_length) - ) { - if (str) - { - if (str->reserve(func_name_length * 2 + SPIDER_SQL_OPEN_PAREN_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(func_name, func_name_length); - str->q_append(SPIDER_SQL_OPEN_PAREN_STR, - SPIDER_SQL_OPEN_PAREN_LEN); - last_str = SPIDER_SQL_CLOSE_PAREN_STR; - last_str_length = SPIDER_SQL_CLOSE_PAREN_LEN; - } - break; - } - } else if (func_name_length == 8 && - ( - !strncasecmp("utc_date", func_name, func_name_length) || - !strncasecmp("utc_time", func_name, func_name_length) - ) - ) { - if (str) - str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); - DBUG_RETURN(spider_db_open_item_string(item_func, NULL, spider, str, - alias, alias_length, dbton_id, use_fields, fields)); - } else if (func_name_length == 9 && - !strncasecmp("isnottrue", func_name, func_name_length) - ) { - last_str = SPIDER_SQL_IS_NOT_TRUE_STR; - last_str_length = SPIDER_SQL_IS_NOT_TRUE_LEN; - break; - } else if (func_name_length == 10) - { - if (!strncasecmp("isnotfalse", func_name, func_name_length)) - { - last_str = SPIDER_SQL_IS_NOT_FALSE_STR; - last_str_length = SPIDER_SQL_IS_NOT_FALSE_LEN; - break; - } else if (!strncasecmp("column_get", func_name, func_name_length)) - { - if (str) - { - str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); - if (str->reserve(func_name_length + SPIDER_SQL_OPEN_PAREN_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(func_name, func_name_length); - str->q_append(SPIDER_SQL_OPEN_PAREN_STR, SPIDER_SQL_OPEN_PAREN_LEN); - } - func_name = SPIDER_SQL_COMMA_STR; - func_name_length = SPIDER_SQL_COMMA_LEN; - separator_str = SPIDER_SQL_COMMA_STR; - separator_str_length = SPIDER_SQL_COMMA_LEN; - break; - } - } else if (func_name_length == 12) - { - if (!strncasecmp("cast_as_date", func_name, func_name_length)) - { - item = item_list[0]; - if (item->type() == Item::FUNC_ITEM) - { - DBUG_PRINT("info",("spider child is FUNC_ITEM")); - Item_func *ifunc = (Item_func *) item; - if (ifunc->functype() == Item_func::UNKNOWN_FUNC) - { - const char *child_func_name; - int child_func_name_length; - DBUG_PRINT("info",("spider child is UNKNOWN_FUNC")); - child_func_name = (char*) ifunc->func_name(); - child_func_name_length = strlen(child_func_name); - DBUG_PRINT("info",("spider child func_name is %s", child_func_name)); - if ( - child_func_name_length == 10 && - !strncasecmp("column_get", child_func_name, child_func_name_length) - ) { - DBUG_PRINT("info",("spider this is merge func")); - merge_func = TRUE; - } - } - } - - if (str) - { - str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); - if (!merge_func) - { - if (str->reserve(SPIDER_SQL_CAST_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(SPIDER_SQL_CAST_STR, SPIDER_SQL_CAST_LEN); - } - } - last_str = SPIDER_SQL_AS_DATE_STR; - last_str_length = SPIDER_SQL_AS_DATE_LEN; - break; - } else if (!strncasecmp("cast_as_time", func_name, func_name_length)) - { - item = item_list[0]; - if (item->type() == Item::FUNC_ITEM) - { - DBUG_PRINT("info",("spider child is FUNC_ITEM")); - Item_func *ifunc = (Item_func *) item; - if (ifunc->functype() == Item_func::UNKNOWN_FUNC) - { - const char *child_func_name; - int child_func_name_length; - DBUG_PRINT("info",("spider child is UNKNOWN_FUNC")); - child_func_name = (char*) ifunc->func_name(); - child_func_name_length = strlen(child_func_name); - DBUG_PRINT("info",("spider child func_name is %s", child_func_name)); - if ( - child_func_name_length == 10 && - !strncasecmp("column_get", child_func_name, child_func_name_length) - ) { - DBUG_PRINT("info",("spider this is merge func")); - merge_func = TRUE; - } - } - } - - if (str) - { - str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); - if (!merge_func) - { - if (str->reserve(SPIDER_SQL_CAST_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(SPIDER_SQL_CAST_STR, SPIDER_SQL_CAST_LEN); - } - } - last_str = SPIDER_SQL_AS_TIME_STR; - last_str_length = SPIDER_SQL_AS_TIME_LEN; - break; - } - } else if (func_name_length == 13) - { - if (!strncasecmp("utc_timestamp", func_name, func_name_length)) - { - if (str) - str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); - DBUG_RETURN(spider_db_open_item_string(item_func, NULL, spider, str, - alias, alias_length, dbton_id, use_fields, fields)); - } else if (!strncasecmp("timestampdiff", func_name, func_name_length)) - { - Item_func_timestamp_diff *item_func_timestamp_diff = - (Item_func_timestamp_diff *) item_func; - if (str) - { - const char *interval_str; - uint interval_len; - switch (item_func_timestamp_diff->get_int_type()) - { - case INTERVAL_YEAR: - interval_str = SPIDER_SQL_YEAR_STR; - interval_len = SPIDER_SQL_YEAR_LEN; - break; - case INTERVAL_QUARTER: - interval_str = SPIDER_SQL_QUARTER_STR; - interval_len = SPIDER_SQL_QUARTER_LEN; - break; - case INTERVAL_MONTH: - interval_str = SPIDER_SQL_MONTH_STR; - interval_len = SPIDER_SQL_MONTH_LEN; - break; - case INTERVAL_WEEK: - interval_str = SPIDER_SQL_WEEK_STR; - interval_len = SPIDER_SQL_WEEK_LEN; - break; - case INTERVAL_DAY: - interval_str = SPIDER_SQL_DAY_STR; - interval_len = SPIDER_SQL_DAY_LEN; - break; - case INTERVAL_HOUR: - interval_str = SPIDER_SQL_HOUR_STR; - interval_len = SPIDER_SQL_HOUR_LEN; - break; - case INTERVAL_MINUTE: - interval_str = SPIDER_SQL_MINUTE_STR; - interval_len = SPIDER_SQL_MINUTE_LEN; - break; - case INTERVAL_SECOND: - interval_str = SPIDER_SQL_SECOND_STR; - interval_len = SPIDER_SQL_SECOND_LEN; - break; - case INTERVAL_MICROSECOND: - interval_str = SPIDER_SQL_MICROSECOND_STR; - interval_len = SPIDER_SQL_MICROSECOND_LEN; - break; - default: - interval_str = ""; - interval_len = 0; - break; - } - str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); - if (str->reserve(func_name_length + SPIDER_SQL_OPEN_PAREN_LEN + - interval_len + SPIDER_SQL_COMMA_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(func_name, func_name_length); - str->q_append(SPIDER_SQL_OPEN_PAREN_STR, SPIDER_SQL_OPEN_PAREN_LEN); - str->q_append(interval_str, interval_len); - str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); - } - if ((error_num = spider_db_print_item_type(item_list[0], NULL, spider, - str, alias, alias_length, dbton_id, use_fields, fields))) - DBUG_RETURN(error_num); - if (str) - { - if (str->reserve(SPIDER_SQL_COMMA_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); - } - if ((error_num = spider_db_print_item_type(item_list[1], NULL, spider, - str, alias, alias_length, dbton_id, use_fields, fields))) - DBUG_RETURN(error_num); - if (str) - { - if (str->reserve(SPIDER_SQL_CLOSE_PAREN_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(SPIDER_SQL_CLOSE_PAREN_STR, - SPIDER_SQL_CLOSE_PAREN_LEN); - } - DBUG_RETURN(0); - } - } else if (func_name_length == 14) - { - if (!strncasecmp("cast_as_binary", func_name, func_name_length)) - { - item = item_list[0]; - if (item->type() == Item::FUNC_ITEM) - { - DBUG_PRINT("info",("spider child is FUNC_ITEM")); - Item_func *ifunc = (Item_func *) item; - if (ifunc->functype() == Item_func::UNKNOWN_FUNC) - { - const char *child_func_name; - int child_func_name_length; - DBUG_PRINT("info",("spider child is UNKNOWN_FUNC")); - child_func_name = (char*) ifunc->func_name(); - child_func_name_length = strlen(child_func_name); - DBUG_PRINT("info",("spider child func_name is %s", child_func_name)); - if ( - child_func_name_length == 10 && - !strncasecmp("column_get", child_func_name, child_func_name_length) - ) { - DBUG_PRINT("info",("spider this is merge func")); - merge_func = TRUE; - } - } - } - - if (str) - { - char tmp_buf[MAX_FIELD_WIDTH], *tmp_ptr, *tmp_ptr2; - spider_string tmp_str(tmp_buf, MAX_FIELD_WIDTH, str->charset()); - tmp_str.init_calc_mem(SPD_MID_DB_HANDLERSOCKET_UTIL_OPEN_ITEM_FUNC_1); - tmp_str.length(0); - str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); - if (!merge_func) - { - if (str->reserve(SPIDER_SQL_CAST_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(SPIDER_SQL_CAST_STR, SPIDER_SQL_CAST_LEN); - } - item_func->print(tmp_str.get_str(), QT_TO_SYSTEM_CHARSET); - tmp_str.mem_calc(); - if (tmp_str.reserve(1)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - tmp_ptr = tmp_str.c_ptr_quick(); - DBUG_PRINT("info",("spider tmp_ptr = %s", tmp_ptr)); - while ((tmp_ptr2 = strstr(tmp_ptr, SPIDER_SQL_AS_BINARY_STR))) - tmp_ptr = tmp_ptr2 + 1; - last_str = tmp_ptr - 1; - last_str_length = strlen(last_str) - SPIDER_SQL_CLOSE_PAREN_LEN; - } - break; - } else if (!strncasecmp("cast_as_signed", func_name, func_name_length)) - { - item = item_list[0]; - if (item->type() == Item::FUNC_ITEM) - { - DBUG_PRINT("info",("spider child is FUNC_ITEM")); - Item_func *ifunc = (Item_func *) item; - if (ifunc->functype() == Item_func::UNKNOWN_FUNC) - { - const char *child_func_name; - int child_func_name_length; - DBUG_PRINT("info",("spider child is UNKNOWN_FUNC")); - child_func_name = (char*) ifunc->func_name(); - child_func_name_length = strlen(child_func_name); - DBUG_PRINT("info",("spider child func_name is %s", child_func_name)); - if ( - child_func_name_length == 10 && - !strncasecmp("column_get", child_func_name, child_func_name_length) - ) { - DBUG_PRINT("info",("spider this is merge func")); - merge_func = TRUE; - } - } - } - - if (str) - { - str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); - if (!merge_func) - { - if (str->reserve(SPIDER_SQL_CAST_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(SPIDER_SQL_CAST_STR, SPIDER_SQL_CAST_LEN); - } - } - last_str = SPIDER_SQL_AS_SIGNED_STR; - last_str_length = SPIDER_SQL_AS_SIGNED_LEN; - break; - } - } else if (func_name_length == 16) - { - if (!strncasecmp("cast_as_unsigned", func_name, func_name_length)) - { - item = item_list[0]; - if (item->type() == Item::FUNC_ITEM) - { - DBUG_PRINT("info",("spider child is FUNC_ITEM")); - Item_func *ifunc = (Item_func *) item; - if (ifunc->functype() == Item_func::UNKNOWN_FUNC) - { - const char *child_func_name; - int child_func_name_length; - DBUG_PRINT("info",("spider child is UNKNOWN_FUNC")); - child_func_name = (char*) ifunc->func_name(); - child_func_name_length = strlen(child_func_name); - DBUG_PRINT("info",("spider child func_name is %s", child_func_name)); - if ( - child_func_name_length == 10 && - !strncasecmp("column_get", child_func_name, child_func_name_length) - ) { - DBUG_PRINT("info",("spider this is merge func")); - merge_func = TRUE; - } - } - } - - if (str) - { - str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); - if (!merge_func) - { - if (str->reserve(SPIDER_SQL_CAST_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(SPIDER_SQL_CAST_STR, SPIDER_SQL_CAST_LEN); - } - } - last_str = SPIDER_SQL_AS_UNSIGNED_STR; - last_str_length = SPIDER_SQL_AS_UNSIGNED_LEN; - break; - } else if (!strncasecmp("decimal_typecast", func_name, - func_name_length)) - { - item = item_list[0]; - if (item->type() == Item::FUNC_ITEM) - { - DBUG_PRINT("info",("spider child is FUNC_ITEM")); - Item_func *ifunc = (Item_func *) item; - if (ifunc->functype() == Item_func::UNKNOWN_FUNC) - { - const char *child_func_name; - int child_func_name_length; - DBUG_PRINT("info",("spider child is UNKNOWN_FUNC")); - child_func_name = (char*) ifunc->func_name(); - child_func_name_length = strlen(child_func_name); - DBUG_PRINT("info",("spider child func_name is %s", child_func_name)); - if ( - child_func_name_length == 10 && - !strncasecmp("column_get", child_func_name, child_func_name_length) - ) { - DBUG_PRINT("info",("spider this is merge func")); - merge_func = TRUE; - } - } - } - - if (str) - { - char tmp_buf[MAX_FIELD_WIDTH], *tmp_ptr, *tmp_ptr2; - spider_string tmp_str(tmp_buf, MAX_FIELD_WIDTH, str->charset()); - tmp_str.init_calc_mem(SPD_MID_DB_HANDLERSOCKET_UTIL_OPEN_ITEM_FUNC_2); - tmp_str.length(0); - str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); - if (!merge_func) - { - if (str->reserve(SPIDER_SQL_CAST_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(SPIDER_SQL_CAST_STR, SPIDER_SQL_CAST_LEN); - } - item_func->print(tmp_str.get_str(), QT_TO_SYSTEM_CHARSET); - tmp_str.mem_calc(); - if (tmp_str.reserve(1)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - tmp_ptr = tmp_str.c_ptr_quick(); - DBUG_PRINT("info",("spider tmp_ptr = %s", tmp_ptr)); - while ((tmp_ptr2 = strstr(tmp_ptr, SPIDER_SQL_AS_DECIMAL_STR))) - tmp_ptr = tmp_ptr2 + 1; - last_str = tmp_ptr - 1; - last_str_length = strlen(last_str) - SPIDER_SQL_CLOSE_PAREN_LEN; - } - break; - } else if (!strncasecmp("cast_as_datetime", func_name, - func_name_length)) - { - item = item_list[0]; - if (item->type() == Item::FUNC_ITEM) - { - DBUG_PRINT("info",("spider child is FUNC_ITEM")); - Item_func *ifunc = (Item_func *) item; - if (ifunc->functype() == Item_func::UNKNOWN_FUNC) - { - const char *child_func_name; - int child_func_name_length; - DBUG_PRINT("info",("spider child is UNKNOWN_FUNC")); - child_func_name = (char*) ifunc->func_name(); - child_func_name_length = strlen(child_func_name); - DBUG_PRINT("info",("spider child func_name is %s", child_func_name)); - if ( - child_func_name_length == 10 && - !strncasecmp("column_get", child_func_name, child_func_name_length) - ) { - DBUG_PRINT("info",("spider this is merge func")); - merge_func = TRUE; - } - } - } - - if (str) - { - str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); - if (!merge_func) - { - if (str->reserve(SPIDER_SQL_CAST_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(SPIDER_SQL_CAST_STR, SPIDER_SQL_CAST_LEN); - } - } - last_str = SPIDER_SQL_AS_DATETIME_STR; - last_str_length = SPIDER_SQL_AS_DATETIME_LEN; - break; - } - } else if (func_name_length == 17) - { - if (!strncasecmp("date_add_interval", func_name, func_name_length)) - { - Item_date_add_interval *item_date_add_interval = - (Item_date_add_interval *) item_func; - func_name = spider_db_timefunc_interval_str[ - item_date_add_interval->int_type]; - func_name_length = strlen(func_name); - if ((error_num = spider_db_print_item_type(item_list[0], NULL, spider, - str, alias, alias_length, dbton_id, use_fields, fields))) - DBUG_RETURN(error_num); - if (str) - { - if (item_date_add_interval->date_sub_interval) - { - if (str->reserve(SPIDER_SQL_NEGINTERVAL_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(SPIDER_SQL_NEGINTERVAL_STR, - SPIDER_SQL_NEGINTERVAL_LEN); - } else { - if (str->reserve(SPIDER_SQL_INTERVAL_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(SPIDER_SQL_INTERVAL_STR, SPIDER_SQL_INTERVAL_LEN); - } - } - if ((error_num = spider_db_print_item_type(item_list[1], NULL, spider, - str, alias, alias_length, dbton_id, use_fields, fields))) - DBUG_RETURN(error_num); - if (str) - { - if (str->reserve(func_name_length + SPIDER_SQL_CLOSE_PAREN_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(func_name, func_name_length); - str->q_append(SPIDER_SQL_CLOSE_PAREN_STR, - SPIDER_SQL_CLOSE_PAREN_LEN); - } - DBUG_RETURN(0); - } - } - if (str) - { - if (str->reserve(func_name_length + SPIDER_SQL_OPEN_PAREN_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(func_name, func_name_length); - str->q_append(SPIDER_SQL_OPEN_PAREN_STR, SPIDER_SQL_OPEN_PAREN_LEN); - } - func_name = SPIDER_SQL_COMMA_STR; - func_name_length = SPIDER_SQL_COMMA_LEN; - separator_str = SPIDER_SQL_COMMA_STR; - separator_str_length = SPIDER_SQL_COMMA_LEN; - last_str = SPIDER_SQL_CLOSE_PAREN_STR; - last_str_length = SPIDER_SQL_CLOSE_PAREN_LEN; - break; - case Item_func::NOW_FUNC: - if (str) - str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); - DBUG_RETURN(spider_db_open_item_string(item_func, NULL, spider, str, - alias, alias_length, dbton_id, use_fields, fields)); - case Item_func::CHAR_TYPECAST_FUNC: - DBUG_PRINT("info",("spider CHAR_TYPECAST_FUNC")); - { - item = item_list[0]; - if (item->type() == Item::FUNC_ITEM) - { - DBUG_PRINT("info",("spider child is FUNC_ITEM")); - Item_func *ifunc = (Item_func *) item; - if (ifunc->functype() == Item_func::UNKNOWN_FUNC) - { - const char *child_func_name; - int child_func_name_length; - DBUG_PRINT("info",("spider child is UNKNOWN_FUNC")); - child_func_name = (char*) ifunc->func_name(); - child_func_name_length = strlen(child_func_name); - DBUG_PRINT("info",("spider child func_name is %s", child_func_name)); - if ( - child_func_name_length == 10 && - !strncasecmp("column_get", child_func_name, child_func_name_length) - ) { - DBUG_PRINT("info",("spider this is merge func")); - merge_func = TRUE; - } - } - } - - if (str) - { - char tmp_buf[MAX_FIELD_WIDTH], *tmp_ptr, *tmp_ptr2; - spider_string tmp_str(tmp_buf, MAX_FIELD_WIDTH, str->charset()); - tmp_str.init_calc_mem(SPD_MID_DB_HANDLERSOCKET_UTIL_OPEN_ITEM_FUNC_3); - tmp_str.length(0); - str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); - if (!merge_func) - { - if (str->reserve(SPIDER_SQL_CAST_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(SPIDER_SQL_CAST_STR, SPIDER_SQL_CAST_LEN); - } - item_func->print(tmp_str.get_str(), QT_TO_SYSTEM_CHARSET); - tmp_str.mem_calc(); - if (tmp_str.reserve(1)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - tmp_ptr = tmp_str.c_ptr_quick(); - DBUG_PRINT("info",("spider tmp_ptr = %s", tmp_ptr)); - while ((tmp_ptr2 = strstr(tmp_ptr, SPIDER_SQL_AS_CHAR_STR))) - tmp_ptr = tmp_ptr2 + 1; - last_str = tmp_ptr - 1; - last_str_length = strlen(last_str) - SPIDER_SQL_CLOSE_PAREN_LEN; - } - } - break; - case Item_func::NOT_FUNC: - DBUG_PRINT("info",("spider NOT_FUNC")); - if (item_list[0]->type() == Item::COND_ITEM) - { - DBUG_PRINT("info",("spider item_list[0] is COND_ITEM")); - Item_cond *item_cond = (Item_cond *) item_list[0]; - if (item_cond->functype() == Item_func::COND_AND_FUNC) - { - DBUG_PRINT("info",("spider item_cond is COND_AND_FUNC")); - List_iterator_fast lif(*(item_cond->argument_list())); - bool has_expr_cache_item = FALSE; - bool has_isnotnull_func = FALSE; - bool has_other_item = FALSE; - while((item = lif++)) - { -#ifdef SPIDER_HAS_EXPR_CACHE_ITEM - if ( - item->type() == Item::EXPR_CACHE_ITEM - ) { - DBUG_PRINT("info",("spider EXPR_CACHE_ITEM")); - has_expr_cache_item = TRUE; - } else -#endif - if ( - item->type() == Item::FUNC_ITEM && - ((Item_func *) item)->functype() == Item_func::ISNOTNULL_FUNC - ) { - DBUG_PRINT("info",("spider ISNOTNULL_FUNC")); - has_isnotnull_func = TRUE; - } else { - DBUG_PRINT("info",("spider has other item")); - DBUG_PRINT("info",("spider COND type=%d", item->type())); - has_other_item = TRUE; - } - } - if (has_expr_cache_item && has_isnotnull_func && !has_other_item) - { - DBUG_PRINT("info",("spider NOT EXISTS skip")); - DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM); - } - } - } - if (str) - { - func_name = (char*) item_func->func_name(); - func_name_length = strlen(func_name); - if (str->reserve(func_name_length + SPIDER_SQL_SPACE_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(func_name, func_name_length); - str->q_append(SPIDER_SQL_SPACE_STR, SPIDER_SQL_SPACE_LEN); - } - break; - case Item_func::NEG_FUNC: - if (str) - { - func_name = (char*) item_func->func_name(); - func_name_length = strlen(func_name); - if (str->reserve(func_name_length + SPIDER_SQL_SPACE_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(func_name, func_name_length); - str->q_append(SPIDER_SQL_SPACE_STR, SPIDER_SQL_SPACE_LEN); - } - break; - case Item_func::IN_FUNC: - if (((Item_func_opt_neg *) item_func)->negated) - { - func_name = SPIDER_SQL_NOT_IN_STR; - func_name_length = SPIDER_SQL_NOT_IN_LEN; - separator_str = SPIDER_SQL_COMMA_STR; - separator_str_length = SPIDER_SQL_COMMA_LEN; - last_str = SPIDER_SQL_CLOSE_PAREN_STR; - last_str_length = SPIDER_SQL_CLOSE_PAREN_LEN; - } else { - func_name = SPIDER_SQL_IN_STR; - func_name_length = SPIDER_SQL_IN_LEN; - separator_str = SPIDER_SQL_COMMA_STR; - separator_str_length = SPIDER_SQL_COMMA_LEN; - last_str = SPIDER_SQL_CLOSE_PAREN_STR; - last_str_length = SPIDER_SQL_CLOSE_PAREN_LEN; - } - break; - case Item_func::BETWEEN: - if (((Item_func_opt_neg *) item_func)->negated) - { - func_name = SPIDER_SQL_NOT_BETWEEN_STR; - func_name_length = SPIDER_SQL_NOT_BETWEEN_LEN; - separator_str = SPIDER_SQL_AND_STR; - separator_str_length = SPIDER_SQL_AND_LEN; - } else { - func_name = (char*) item_func->func_name(); - func_name_length = strlen(func_name); - separator_str = SPIDER_SQL_AND_STR; - separator_str_length = SPIDER_SQL_AND_LEN; - } - break; - case Item_func::UDF_FUNC: - use_pushdown_udf = spider_param_use_pushdown_udf(spider->trx->thd, - spider->share->use_pushdown_udf); - if (!use_pushdown_udf) - DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM); - if (str) - { - func_name = (char*) item_func->func_name(); - func_name_length = strlen(func_name); - DBUG_PRINT("info",("spider func_name = %s", func_name)); - DBUG_PRINT("info",("spider func_name_length = %d", func_name_length)); - if (str->reserve(func_name_length + SPIDER_SQL_OPEN_PAREN_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(func_name, func_name_length); - str->q_append(SPIDER_SQL_OPEN_PAREN_STR, SPIDER_SQL_OPEN_PAREN_LEN); - } - func_name = SPIDER_SQL_COMMA_STR; - func_name_length = SPIDER_SQL_COMMA_LEN; - separator_str = SPIDER_SQL_COMMA_STR; - separator_str_length = SPIDER_SQL_COMMA_LEN; - last_str = SPIDER_SQL_CLOSE_PAREN_STR; - last_str_length = SPIDER_SQL_CLOSE_PAREN_LEN; - break; - case Item_func::XOR_FUNC: - if (str) - str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); - DBUG_RETURN( - spider_db_open_item_cond((Item_cond *) item_func, spider, str, - alias, alias_length, dbton_id, use_fields, fields)); - case Item_func::TRIG_COND_FUNC: - DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM); - case Item_func::GUSERVAR_FUNC: - if (str) - str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); - if (item_func->result_type() == STRING_RESULT) - DBUG_RETURN(spider_db_open_item_string(item_func, NULL, spider, str, - alias, alias_length, dbton_id, use_fields, fields)); - else - DBUG_RETURN(spider_db_open_item_int(item_func, NULL, spider, str, - alias, alias_length, dbton_id, use_fields, fields)); - case Item_func::FT_FUNC: - if (spider_db_check_ft_idx(item_func, spider) == MAX_KEY) - DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM); - start_item = 1; - if (str) - { - if (str->reserve(SPIDER_SQL_MATCH_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(SPIDER_SQL_MATCH_STR, SPIDER_SQL_MATCH_LEN); - } - separator_str = SPIDER_SQL_COMMA_STR; - separator_str_length = SPIDER_SQL_COMMA_LEN; - last_str = SPIDER_SQL_CLOSE_PAREN_STR; - last_str_length = SPIDER_SQL_CLOSE_PAREN_LEN; - break; - case Item_func::SP_EQUALS_FUNC: - if (str) - { - func_name = SPIDER_SQL_MBR_EQUAL_STR; - func_name_length = SPIDER_SQL_MBR_EQUAL_LEN; - DBUG_PRINT("info",("spider func_name = %s", func_name)); - DBUG_PRINT("info",("spider func_name_length = %d", func_name_length)); - if (str->reserve(func_name_length)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(func_name, func_name_length); - } - func_name = SPIDER_SQL_COMMA_STR; - func_name_length = SPIDER_SQL_COMMA_LEN; - separator_str = SPIDER_SQL_COMMA_STR; - separator_str_length = SPIDER_SQL_COMMA_LEN; - last_str = SPIDER_SQL_CLOSE_PAREN_STR; - last_str_length = SPIDER_SQL_CLOSE_PAREN_LEN; - break; - case Item_func::SP_DISJOINT_FUNC: - case Item_func::SP_INTERSECTS_FUNC: - case Item_func::SP_TOUCHES_FUNC: - case Item_func::SP_CROSSES_FUNC: - case Item_func::SP_WITHIN_FUNC: - case Item_func::SP_CONTAINS_FUNC: - case Item_func::SP_OVERLAPS_FUNC: - if (str) - { - func_name = (char*) item_func->func_name(); - func_name_length = strlen(func_name); - DBUG_PRINT("info",("spider func_name = %s", func_name)); - DBUG_PRINT("info",("spider func_name_length = %d", func_name_length)); - if (str->reserve( -#ifndef SPIDER_ITEM_GEOFUNC_NAME_HAS_MBR - SPIDER_SQL_MBR_LEN + -#endif - func_name_length + SPIDER_SQL_OPEN_PAREN_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); -#ifndef SPIDER_ITEM_GEOFUNC_NAME_HAS_MBR - str->q_append(SPIDER_SQL_MBR_STR, SPIDER_SQL_MBR_LEN); -#endif - str->q_append(func_name, func_name_length); - str->q_append(SPIDER_SQL_OPEN_PAREN_STR, SPIDER_SQL_OPEN_PAREN_LEN); - } - func_name = SPIDER_SQL_COMMA_STR; - func_name_length = SPIDER_SQL_COMMA_LEN; - separator_str = SPIDER_SQL_COMMA_STR; - separator_str_length = SPIDER_SQL_COMMA_LEN; - last_str = SPIDER_SQL_CLOSE_PAREN_STR; - last_str_length = SPIDER_SQL_CLOSE_PAREN_LEN; - break; - case Item_func::EQ_FUNC: - case Item_func::EQUAL_FUNC: - case Item_func::NE_FUNC: - case Item_func::LT_FUNC: - case Item_func::LE_FUNC: - case Item_func::GE_FUNC: - case Item_func::GT_FUNC: - case Item_func::LIKE_FUNC: - if (str) - { - func_name = (char*) item_func->func_name(); - func_name_length = strlen(func_name); - } - break; - default: - THD *thd = spider->trx->thd; - SPIDER_SHARE *share = spider->share; - if (spider_param_skip_default_condition(thd, - share->skip_default_condition)) - DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM); - if (str) - { - func_name = (char*) item_func->func_name(); - func_name_length = strlen(func_name); - } - break; - } - DBUG_PRINT("info",("spider func_name = %s", func_name)); - DBUG_PRINT("info",("spider func_name_length = %d", func_name_length)); - DBUG_PRINT("info",("spider separator_str = %s", separator_str)); - DBUG_PRINT("info",("spider separator_str_length = %d", separator_str_length)); - DBUG_PRINT("info",("spider last_str = %s", last_str)); - DBUG_PRINT("info",("spider last_str_length = %d", last_str_length)); - if (item_count) - { - item_count--; - for (roop_count = start_item; roop_count < item_count; roop_count++) - { - item = item_list[roop_count]; - if ((error_num = spider_db_print_item_type(item, NULL, spider, str, - alias, alias_length, dbton_id, use_fields, fields))) - DBUG_RETURN(error_num); - if (roop_count == 1) - { - func_name = separator_str; - func_name_length = separator_str_length; - } - if (str) - { - if (str->reserve(func_name_length + SPIDER_SQL_SPACE_LEN * 2)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(SPIDER_SQL_SPACE_STR, SPIDER_SQL_SPACE_LEN); - str->q_append(func_name, func_name_length); - str->q_append(SPIDER_SQL_SPACE_STR, SPIDER_SQL_SPACE_LEN); - } - } - item = item_list[roop_count]; - if ((error_num = spider_db_print_item_type(item, NULL, spider, str, - alias, alias_length, dbton_id, use_fields, fields))) - DBUG_RETURN(error_num); - } - if (item_func->functype() == Item_func::FT_FUNC) - { - Item_func_match *item_func_match = (Item_func_match *)item_func; - if (str) - { - if (str->reserve(SPIDER_SQL_AGAINST_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(SPIDER_SQL_AGAINST_STR, SPIDER_SQL_AGAINST_LEN); - } - item = item_list[0]; - if ((error_num = spider_db_print_item_type(item, NULL, spider, str, - alias, alias_length, dbton_id, use_fields, fields))) - DBUG_RETURN(error_num); - if (str) - { - if (str->reserve( - ((item_func_match->flags & FT_BOOL) ? - SPIDER_SQL_IN_BOOLEAN_MODE_LEN : 0) + - ((item_func_match->flags & FT_EXPAND) ? - SPIDER_SQL_WITH_QUERY_EXPANSION_LEN : 0) - )) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - if (item_func_match->flags & FT_BOOL) - str->q_append(SPIDER_SQL_IN_BOOLEAN_MODE_STR, - SPIDER_SQL_IN_BOOLEAN_MODE_LEN); - if (item_func_match->flags & FT_EXPAND) - str->q_append(SPIDER_SQL_WITH_QUERY_EXPANSION_STR, - SPIDER_SQL_WITH_QUERY_EXPANSION_LEN); - } - } else if (item_func->functype() == Item_func::UNKNOWN_FUNC) - { - if ( - func_name_length == 7 && - !strncasecmp("convert", func_name, func_name_length) - ) { - if (str) - { - Item_func_conv_charset *item_func_conv_charset = - (Item_func_conv_charset *)item_func; - CHARSET_INFO *conv_charset = - item_func_conv_charset->SPIDER_Item_func_conv_charset_conv_charset; - uint cset_length = strlen(conv_charset->csname); - if (str->reserve(SPIDER_SQL_USING_LEN + cset_length)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(SPIDER_SQL_USING_STR, SPIDER_SQL_USING_LEN); - str->q_append(conv_charset->csname, cset_length); - } - } - } - if (str) - { - if (merge_func) - str->length(str->length() - SPIDER_SQL_CLOSE_PAREN_LEN); - if (str->reserve(last_str_length + SPIDER_SQL_CLOSE_PAREN_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(last_str, last_str_length); - str->q_append(SPIDER_SQL_CLOSE_PAREN_STR, SPIDER_SQL_CLOSE_PAREN_LEN); - } - DBUG_RETURN(0); -} - -#ifdef HANDLER_HAS_DIRECT_AGGREGATE -int spider_db_handlersocket_util::open_item_sum_func( - Item_sum *item_sum, - ha_spider *spider, - spider_string *str, - const char *alias, - uint alias_length, - bool use_fields, - spider_fields *fields -) { - uint dbton_id = spider_dbton_handlersocket.dbton_id; - uint roop_count, item_count = item_sum->get_arg_count(); - int error_num; - DBUG_ENTER("spider_db_handlersocket_util::open_item_sum_func"); - DBUG_PRINT("info",("spider Sumfunctype = %d", item_sum->sum_func())); - switch (item_sum->sum_func()) - { - case Item_sum::COUNT_FUNC: - case Item_sum::SUM_FUNC: - case Item_sum::MIN_FUNC: - case Item_sum::MAX_FUNC: - { - const char *func_name = item_sum->func_name(); - uint func_name_length = strlen(func_name); - Item *item, **args = item_sum->get_args(); - if (str) - { - if (str->reserve(func_name_length)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(func_name, func_name_length); - } - if (item_count) - { - item_count--; - for (roop_count = 0; roop_count < item_count; roop_count++) - { - item = args[roop_count]; - if ((error_num = spider_db_print_item_type(item, NULL, spider, str, - alias, alias_length, dbton_id, use_fields, fields))) - DBUG_RETURN(error_num); - if (str) - { - if (str->reserve(SPIDER_SQL_COMMA_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); - } - } - item = args[roop_count]; - if ((error_num = spider_db_print_item_type(item, NULL, spider, str, - alias, alias_length, dbton_id, use_fields, fields))) - DBUG_RETURN(error_num); - } - if (str) - { - if (str->reserve(SPIDER_SQL_CLOSE_PAREN_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(SPIDER_SQL_CLOSE_PAREN_STR, - SPIDER_SQL_CLOSE_PAREN_LEN); - } - } - break; - case Item_sum::COUNT_DISTINCT_FUNC: - case Item_sum::SUM_DISTINCT_FUNC: - case Item_sum::AVG_FUNC: - case Item_sum::AVG_DISTINCT_FUNC: - case Item_sum::STD_FUNC: - case Item_sum::VARIANCE_FUNC: - case Item_sum::SUM_BIT_FUNC: - case Item_sum::UDF_SUM_FUNC: - case Item_sum::GROUP_CONCAT_FUNC: - default: - DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM); - } - DBUG_RETURN(0); -} -#endif - -int spider_db_handlersocket_util::append_escaped_util( - spider_string *to, - String *from -) { - DBUG_ENTER("spider_db_handlersocket_util::append_escaped_util"); - DBUG_PRINT("info",("spider this=%p", this)); - to->append_escape_string(from->ptr(), from->length()); - DBUG_RETURN(0); -} - -#ifdef SPIDER_HAS_GROUP_BY_HANDLER -int spider_db_handlersocket_util::append_from_and_tables( - ha_spider *spider, - spider_fields *fields, - spider_string *str, - TABLE_LIST *table_list, - uint table_count -) { - DBUG_ENTER("spider_db_handlersocket_util::append_from_and_tables"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_db_handlersocket_util::reappend_tables( - spider_fields *fields, - SPIDER_LINK_IDX_CHAIN *link_idx_chain, - spider_string *str -) { - DBUG_ENTER("spider_db_handlersocket_util::reappend_tables"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_db_handlersocket_util::append_where( - spider_string *str -) { - DBUG_ENTER("spider_db_handlersocket_util::append_where"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_db_handlersocket_util::append_having( - spider_string *str -) { - DBUG_ENTER("spider_db_handlersocket_util::append_having"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} -#endif - -spider_handlersocket_share::spider_handlersocket_share( - st_spider_share *share -) : spider_db_share( - share, - spider_dbton_handlersocket.dbton_id -), - table_names_str(NULL), - db_names_str(NULL), - db_table_str(NULL), -#ifdef SPIDER_HAS_HASH_VALUE_TYPE - db_table_str_hash_value(NULL), -#endif - table_nm_max_length(0), - db_nm_max_length(0), - column_name_str(NULL), - same_db_table_name(TRUE), - first_all_link_idx(-1) -{ - DBUG_ENTER("spider_handlersocket_share::spider_handlersocket_share"); - DBUG_PRINT("info",("spider this=%p", this)); - spider_alloc_calc_mem_init(mem_calc, SPD_MID_HANDLERSOCKET_SHARE_SPIDER_HANDLERSOCKET_SHARE_1); - spider_alloc_calc_mem(spider_current_trx, mem_calc, sizeof(*this)); - DBUG_VOID_RETURN; -} - -spider_handlersocket_share::~spider_handlersocket_share() -{ - DBUG_ENTER("spider_handlersocket_share::~spider_handlersocket_share"); - DBUG_PRINT("info",("spider this=%p", this)); - free_column_name_str(); - free_table_names_str(); -#ifdef SPIDER_HAS_HASH_VALUE_TYPE - if (db_table_str_hash_value) - { - spider_free(spider_current_trx, db_table_str_hash_value, MYF(0)); - } -#endif - spider_free_mem_calc(spider_current_trx, mem_calc_id, sizeof(*this)); - DBUG_VOID_RETURN; -} - -int spider_handlersocket_share::init() -{ - int error_num; - DBUG_ENTER("spider_handlersocket_share::init"); - DBUG_PRINT("info",("spider this=%p", this)); -#ifdef SPIDER_HAS_HASH_VALUE_TYPE - if (!(db_table_str_hash_value = (my_hash_value_type *) - spider_bulk_alloc_mem(spider_current_trx, SPD_MID_HANDLERSOCKET_SHARE_INIT_1, - __func__, __FILE__, __LINE__, MYF(MY_WME | MY_ZEROFILL), - &db_table_str_hash_value, - sizeof(my_hash_value_type) * spider_share->all_link_count, - NullS)) - ) { - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - } -#endif - - if ( - (error_num = create_table_names_str()) || - ( - spider_share->table_share && - (error_num = create_column_name_str()) - ) - ) { - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - } - DBUG_RETURN(0); -} - -int spider_handlersocket_share::append_table_name( - spider_string *str, - int all_link_idx -) { - const char *db_nm = db_names_str[all_link_idx].ptr(); - uint db_nm_len = db_names_str[all_link_idx].length(); - const char *table_nm = table_names_str[all_link_idx].ptr(); - uint table_nm_len = table_names_str[all_link_idx].length(); - DBUG_ENTER("spider_handlersocket_share::append_table_name"); - DBUG_PRINT("info",("spider this=%p", this)); - if (str->reserve(db_nm_len + SPIDER_SQL_DOT_LEN + table_nm_len + - /* SPIDER_SQL_NAME_QUOTE_LEN */ 4)) - { - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - } - spider_db_handlersocket_utility.append_name(str, db_nm, db_nm_len); - str->q_append(SPIDER_SQL_DOT_STR, SPIDER_SQL_DOT_LEN); - spider_db_handlersocket_utility.append_name(str, table_nm, table_nm_len); - DBUG_RETURN(0); -} - -int spider_handlersocket_share::create_table_names_str() -{ - int error_num, roop_count; - uint table_nm_len, db_nm_len; - spider_string *str, *first_tbl_nm_str, *first_db_nm_str, *first_db_tbl_str; - char *first_tbl_nm, *first_db_nm; - uint dbton_id = spider_dbton_handlersocket.dbton_id; - DBUG_ENTER("spider_handlersocket_share::create_table_names_str"); - table_names_str = NULL; - db_names_str = NULL; - db_table_str = NULL; - if ( - !(table_names_str = new spider_string[spider_share->all_link_count]) || - !(db_names_str = new spider_string[spider_share->all_link_count]) || - !(db_table_str = new spider_string[spider_share->all_link_count]) - ) { - error_num = HA_ERR_OUT_OF_MEM; - goto error; - } - - same_db_table_name = TRUE; - first_tbl_nm = spider_share->tgt_table_names[0]; - first_db_nm = spider_share->tgt_dbs[0]; - table_nm_len = spider_share->tgt_table_names_lengths[0]; - db_nm_len = spider_share->tgt_dbs_lengths[0]; - first_tbl_nm_str = &table_names_str[0]; - first_db_nm_str = &db_names_str[0]; - first_db_tbl_str = &db_table_str[0]; - for (roop_count = 0; roop_count < (int) spider_share->all_link_count; - roop_count++) - { - table_names_str[roop_count].init_calc_mem(SPD_MID_HANDLERSOCKET_SHARE_CREATE_TABLE_NAMES_STR_1); - db_names_str[roop_count].init_calc_mem(SPD_MID_HANDLERSOCKET_SHARE_CREATE_TABLE_NAMES_STR_2); - db_table_str[roop_count].init_calc_mem(SPD_MID_HANDLERSOCKET_SHARE_CREATE_TABLE_NAMES_STR_3); - if (spider_share->sql_dbton_ids[roop_count] != dbton_id) - continue; - if (first_all_link_idx == -1) - first_all_link_idx = roop_count; - - str = &table_names_str[roop_count]; - if ( - roop_count != 0 && - same_db_table_name && - spider_share->tgt_table_names_lengths[roop_count] == table_nm_len && - !memcmp(first_tbl_nm, spider_share->tgt_table_names[roop_count], - table_nm_len) - ) { - if (str->copy(*first_tbl_nm_str)) - { - error_num = HA_ERR_OUT_OF_MEM; - goto error; - } - } else { - str->set_charset(spider_share->access_charset); - if ((error_num = spider_db_append_name_with_quote_str(str, - spider_share->tgt_table_names[roop_count], dbton_id))) - goto error; - if (roop_count) - { - same_db_table_name = FALSE; - DBUG_PRINT("info", ("spider found different table name %s", - spider_share->tgt_table_names[roop_count])); - if (str->length() > table_nm_max_length) - table_nm_max_length = str->length(); - } else - table_nm_max_length = str->length(); - } - - str = &db_names_str[roop_count]; - if ( - roop_count != 0 && - same_db_table_name && - spider_share->tgt_dbs_lengths[roop_count] == db_nm_len && - !memcmp(first_db_nm, spider_share->tgt_dbs[roop_count], - db_nm_len) - ) { - if (str->copy(*first_db_nm_str)) - { - error_num = HA_ERR_OUT_OF_MEM; - goto error; - } - } else { - str->set_charset(spider_share->access_charset); - if ((error_num = spider_db_append_name_with_quote_str(str, - spider_share->tgt_dbs[roop_count], dbton_id))) - goto error; - if (roop_count) - { - same_db_table_name = FALSE; - DBUG_PRINT("info", ("spider found different db name %s", - spider_share->tgt_dbs[roop_count])); - if (str->length() > db_nm_max_length) - db_nm_max_length = str->length(); - } else - db_nm_max_length = str->length(); - } - - str = &db_table_str[roop_count]; - if ( - roop_count != 0 && - same_db_table_name - ) { - if (str->copy(*first_db_tbl_str)) - { - error_num = HA_ERR_OUT_OF_MEM; - goto error; - } - } else { - str->set_charset(spider_share->access_charset); - if ((error_num = append_table_name(str, roop_count))) - goto error; - } -#ifdef SPIDER_HAS_HASH_VALUE_TYPE - db_table_str_hash_value[roop_count] = my_calc_hash( - &spider_open_connections, (uchar*) str->ptr(), str->length()); -#endif - } - DBUG_RETURN(0); - -error: - if (db_table_str) - { - delete [] db_table_str; - db_table_str = NULL; - } - if (db_names_str) - { - delete [] db_names_str; - db_names_str = NULL; - } - if (table_names_str) - { - delete [] table_names_str; - table_names_str = NULL; - } - DBUG_RETURN(error_num); -} - -void spider_handlersocket_share::free_table_names_str() -{ - DBUG_ENTER("spider_handlersocket_share::free_table_names_str"); - if (db_table_str) - { - delete [] db_table_str; - db_table_str = NULL; - } - if (db_names_str) - { - delete [] db_names_str; - db_names_str = NULL; - } - if (table_names_str) - { - delete [] table_names_str; - table_names_str = NULL; - } - DBUG_VOID_RETURN; -} - -int spider_handlersocket_share::create_column_name_str() -{ - spider_string *str; - int error_num; - Field **field; - TABLE_SHARE *table_share = spider_share->table_share; - uint dbton_id = spider_dbton_handlersocket.dbton_id; - DBUG_ENTER("spider_handlersocket_share::create_column_name_str"); - if ( - table_share->fields && - !(column_name_str = new spider_string[table_share->fields]) - ) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - for (field = table_share->field, str = column_name_str; - *field; field++, str++) - { - str->init_calc_mem(SPD_MID_HANDLERSOCKET_SHARE_CREATE_COLUMN_NAME_STR_1); - str->set_charset(spider_share->access_charset); - if ((error_num = spider_db_append_name_with_quote_str(str, - (*field)->field_name, dbton_id))) - goto error; - } - DBUG_RETURN(0); - -error: - if (column_name_str) - { - delete [] column_name_str; - column_name_str = NULL; - } - DBUG_RETURN(error_num); -} - -void spider_handlersocket_share::free_column_name_str() -{ - DBUG_ENTER("spider_handlersocket_share::free_column_name_str"); - if (column_name_str) - { - delete [] column_name_str; - column_name_str = NULL; - } - DBUG_VOID_RETURN; -} - -uint spider_handlersocket_share::get_column_name_length( - uint field_index -) { - DBUG_ENTER("spider_handlersocket_share::get_column_name_length"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN(column_name_str[field_index].length()); -} - -int spider_handlersocket_share::append_column_name( - spider_string *str, - uint field_index -) { - int error_num; - DBUG_ENTER("spider_handlersocket_share::append_column_name"); - DBUG_PRINT("info",("spider this=%p", this)); - error_num = spider_db_handlersocket_utility.append_name(str, - column_name_str[field_index].ptr(), column_name_str[field_index].length()); - DBUG_RETURN(error_num); -} - -int spider_handlersocket_share::append_column_name_with_alias( - spider_string *str, - uint field_index, - const char *alias, - uint alias_length -) { - DBUG_ENTER("spider_handlersocket_share::append_column_name_with_alias"); - DBUG_PRINT("info",("spider this=%p", this)); - if (str->reserve( - alias_length + - column_name_str[field_index].length() + - /* SPIDER_SQL_NAME_QUOTE_LEN */ 2)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(alias, alias_length); - append_column_name(str, field_index); - DBUG_RETURN(0); -} - -bool spider_handlersocket_share::need_change_db_table_name() -{ - DBUG_ENTER("spider_handlersocket_share::need_change_db_table_name"); - DBUG_RETURN(!same_db_table_name); -} - -#ifdef SPIDER_HAS_DISCOVER_TABLE_STRUCTURE -int spider_handlersocket_share::discover_table_structure( - SPIDER_TRX *trx, - SPIDER_SHARE *spider_share, - spider_string *str -) { - DBUG_ENTER("spider_handlersocket_share::discover_table_structure"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN(HA_ERR_WRONG_COMMAND); -} -#endif - -spider_handlersocket_handler::spider_handlersocket_handler( - ha_spider *spider, - spider_handlersocket_share *db_share -) : spider_db_handler( - spider, - db_share -), - handlersocket_share(db_share), - link_for_hash(NULL) -{ - DBUG_ENTER("spider_handlersocket_handler::spider_handlersocket_handler"); - DBUG_PRINT("info",("spider this=%p", this)); - spider_alloc_calc_mem_init(mem_calc, SPD_MID_HANDLERSOCKET_HANDLER_SPIDER_HANDLERSOCKET_HANDLER_1); - spider_alloc_calc_mem(spider_current_trx, mem_calc, sizeof(*this)); - DBUG_VOID_RETURN; -} - -spider_handlersocket_handler::~spider_handlersocket_handler() -{ - DBUG_ENTER("spider_handlersocket_handler::~spider_handlersocket_handler"); - DBUG_PRINT("info",("spider this=%p", this)); - if (link_for_hash) - { - spider_free(spider_current_trx, link_for_hash, MYF(0)); - } - spider_free_mem_calc(spider_current_trx, mem_calc_id, sizeof(*this)); - DBUG_VOID_RETURN; -} - -int spider_handlersocket_handler::init() -{ - st_spider_share *share = spider->share; - TABLE *table = spider->get_table(); - DBUG_ENTER("spider_handlersocket_handler::init"); - DBUG_PRINT("info",("spider this=%p", this)); - if (!(link_for_hash = (SPIDER_LINK_FOR_HASH *) - spider_bulk_alloc_mem(spider_current_trx, SPD_MID_HANDLERSOCKET_HANDLER_INIT_1, - __func__, __FILE__, __LINE__, MYF(MY_WME | MY_ZEROFILL), - &link_for_hash, - sizeof(SPIDER_LINK_FOR_HASH) * share->link_count, - &minimum_select_bitmap, - table ? sizeof(uchar) * no_bytes_in_map(table->read_set) : 0, - NullS)) - ) { - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - } - uint roop_count; - for (roop_count = 0; roop_count < share->link_count; roop_count++) - { - link_for_hash[roop_count].spider = spider; - link_for_hash[roop_count].link_idx = roop_count; - link_for_hash[roop_count].db_table_str = - &handlersocket_share->db_table_str[roop_count]; -#ifdef SPIDER_HAS_HASH_VALUE_TYPE - link_for_hash[roop_count].db_table_str_hash_value = - handlersocket_share->db_table_str_hash_value[roop_count]; -#endif - } - hs_sql.init_calc_mem(SPD_MID_HANDLERSOCKET_HANDLER_INIT_2); - hs_sql.set_charset(share->access_charset); - hs_keys.init(); - hs_upds.init(); - hs_strs.init(); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_index_hint( - spider_string *str, - int link_idx, - ulong sql_type - ) -{ - DBUG_ENTER("spider_handlersocket_handler::append_index_hint"); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_table_name_with_adjusting( - spider_string *str, - int link_idx, - ulong sql_type -) { - DBUG_ENTER("spider_handlersocket_handler::append_table_name_with_adjusting"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_tmp_table_and_sql_for_bka( - const key_range *start_key -) { - DBUG_ENTER("spider_handlersocket_handler::append_tmp_table_and_sql_for_bka"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::reuse_tmp_table_and_sql_for_bka() -{ - DBUG_ENTER("spider_handlersocket_handler::reuse_tmp_table_and_sql_for_bka"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_union_table_and_sql_for_bka( - const key_range *start_key -) { - DBUG_ENTER("spider_handlersocket_handler::append_union_table_and_sql_for_bka"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::reuse_union_table_and_sql_for_bka() -{ - DBUG_ENTER("spider_handlersocket_handler::reuse_union_table_and_sql_for_bka"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_insert_for_recovery( - ulong sql_type, - int link_idx -) { - DBUG_ENTER("spider_handlersocket_handler::append_insert_for_recovery"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_update( - const TABLE *table, - my_ptrdiff_t ptr_diff -) { - DBUG_ENTER("spider_handlersocket_handler::append_update"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_update( - const TABLE *table, - my_ptrdiff_t ptr_diff, - int link_idx -) { - DBUG_ENTER("spider_handlersocket_handler::append_update"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_delete( - const TABLE *table, - my_ptrdiff_t ptr_diff -) { - DBUG_ENTER("spider_handlersocket_handler::append_delete"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_delete( - const TABLE *table, - my_ptrdiff_t ptr_diff, - int link_idx -) { - DBUG_ENTER("spider_handlersocket_handler::append_delete"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_insert_part() -{ - DBUG_ENTER("spider_handlersocket_handler::append_insert_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_update_part() -{ - DBUG_ENTER("spider_handlersocket_handler::append_update_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_delete_part() -{ - DBUG_ENTER("spider_handlersocket_handler::append_delete_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS -int spider_handlersocket_handler::append_increment_update_set_part() -{ - DBUG_ENTER("spider_handlersocket_handler::append_increment_update_set_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} -#endif - -int spider_handlersocket_handler::append_update_set_part() -{ - DBUG_ENTER("spider_handlersocket_handler::append_update_set_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS -int spider_handlersocket_handler::append_direct_update_set_part() -{ - SPIDER_SHARE *share = spider->share; - DBUG_ENTER("spider_handlersocket_handler::append_direct_update_set_part"); - if ( - spider->do_direct_update && - (spider->direct_update_kinds & SPIDER_SQL_KIND_HS) - ) { - DBUG_PRINT("info",("spider add set for DU SPIDER_SQL_KIND_HS")); - size_t roop_count; - Field *field; - hs_adding_keys = FALSE; - for (roop_count = 0; roop_count < spider->hs_pushed_ret_fields_num; - roop_count++) - { - Field *top_table_field = - spider->get_top_table_field(spider->hs_pushed_ret_fields[roop_count]); - if (!(field = spider->field_exchange(top_table_field))) - continue; - if (top_table_field->is_null()) - { - hs_upds.push_back(spider_null_string_ref); - } else { - if (spider_db_handlersocket_utility. - append_column_value(spider, NULL, top_table_field, NULL, - share->access_charset)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - } - } - } - DBUG_RETURN(0); -} -#endif - -int spider_handlersocket_handler::append_minimum_select_without_quote( - spider_string *str -) { - TABLE *table = spider->get_table(); - Field **field; - int field_length; - bool appended = FALSE; - DBUG_ENTER("spider_handlersocket_handler::append_minimum_select_without_quote"); - minimum_select_bitmap_create(); - for (field = table->field; *field; field++) - { - if (minimum_select_bit_is_set((*field)->field_index)) - { -/* - spider_set_bit(minimum_select_bitmap, (*field)->field_index); -*/ - field_length = - handlersocket_share->column_name_str[(*field)->field_index].length(); - if (str->reserve(field_length + SPIDER_SQL_COMMA_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append( - handlersocket_share->column_name_str[(*field)->field_index].ptr(), - handlersocket_share->column_name_str[(*field)->field_index].length()); - str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); - appended = TRUE; - } - } - if (appended) - str->length(str->length() - SPIDER_SQL_COMMA_LEN); - DBUG_RETURN(0); -} - -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS -int spider_handlersocket_handler::append_minimum_select_by_field_idx_list( - spider_string *str, - uint32 *field_idxs, - size_t field_idxs_num -) { - Field *field; - int roop_count, field_length; - bool appended = FALSE; - DBUG_ENTER("spider_handlersocket_handler::append_minimum_select_by_field_idx_list"); - for (roop_count = 0; roop_count < (int) field_idxs_num; roop_count++) - { - field = spider->get_top_table_field(field_idxs[roop_count]); - if ((field = spider->field_exchange(field))) - { - field_length = - handlersocket_share->column_name_str[field->field_index].length(); - if (str->reserve(field_length + SPIDER_SQL_COMMA_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append( - handlersocket_share->column_name_str[field->field_index].ptr(), - handlersocket_share->column_name_str[field->field_index].length()); - str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); - appended = TRUE; - } - } - if (appended) - str->length(str->length() - SPIDER_SQL_COMMA_LEN); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_dup_update_pushdown_part( - const char *alias, - uint alias_length -) { - DBUG_ENTER("spider_handlersocket_handler::append_dup_update_pushdown_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_update_columns_part( - const char *alias, - uint alias_length -) { - DBUG_ENTER("spider_handlersocket_handler::append_update_columns_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::check_update_columns_part() -{ - DBUG_ENTER("spider_handlersocket_handler::check_update_columns_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} -#endif - -int spider_handlersocket_handler::append_select_part( - ulong sql_type -) { - DBUG_ENTER("spider_handlersocket_handler::append_select_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_table_select_part( - ulong sql_type -) { - DBUG_ENTER("spider_handlersocket_handler::append_table_select_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_key_select_part( - ulong sql_type, - uint idx -) { - DBUG_ENTER("spider_handlersocket_handler::append_key_select_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_minimum_select_part( - ulong sql_type -) { - DBUG_ENTER("spider_handlersocket_handler::append_minimum_select_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_hint_after_table_part( - ulong sql_type -) { - DBUG_ENTER("spider_handlersocket_handler::append_hint_after_table_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -void spider_handlersocket_handler::set_where_pos( - ulong sql_type -) { - DBUG_ENTER("spider_handlersocket_handler::set_where_pos"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_VOID_RETURN; -} - -void spider_handlersocket_handler::set_where_to_pos( - ulong sql_type -) { - DBUG_ENTER("spider_handlersocket_handler::set_where_to_pos"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_VOID_RETURN; -} - -int spider_handlersocket_handler::check_item_type( - Item *item -) { - DBUG_ENTER("spider_handlersocket_handler::check_item_type"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_values_connector_part( - ulong sql_type -) { - DBUG_ENTER("spider_handlersocket_handler::append_values_connector_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_values_terminator_part( - ulong sql_type -) { - DBUG_ENTER("spider_handlersocket_handler::append_values_terminator_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_union_table_connector_part( - ulong sql_type -) { - DBUG_ENTER("spider_handlersocket_handler::append_union_table_connector_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_union_table_terminator_part( - ulong sql_type -) { - DBUG_ENTER("spider_handlersocket_handler::append_union_table_terminator_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_key_column_values_part( - const key_range *start_key, - ulong sql_type -) { - DBUG_ENTER("spider_handlersocket_handler::append_key_column_values_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_key_column_values_with_name_part( - const key_range *start_key, - ulong sql_type -) { - DBUG_ENTER("spider_handlersocket_handler::append_key_column_values_with_name_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_key_where_part( - const key_range *start_key, - const key_range *end_key, - ulong sql_type -) { - int error_num; - spider_string *str; - bool set_order; - DBUG_ENTER("spider_handlersocket_handler::append_key_where_part"); - switch (sql_type) - { - case SPIDER_SQL_TYPE_SELECT_HS: - case SPIDER_SQL_TYPE_INSERT_HS: - case SPIDER_SQL_TYPE_UPDATE_HS: - case SPIDER_SQL_TYPE_DELETE_HS: - str = &hs_sql; - str->length(0); - hs_adding_keys = TRUE; - set_order = FALSE; - break; - default: - DBUG_RETURN(0); - } - error_num = append_key_where(str, NULL, NULL, start_key, end_key, - sql_type, set_order); - DBUG_RETURN(error_num); -} - -int spider_handlersocket_handler::append_key_where( - spider_string *str, - spider_string *str_part, - spider_string *str_part2, - const key_range *start_key, - const key_range *end_key, - ulong sql_type, - bool set_order -) { - int error_num; - DBUG_ENTER("spider_handlersocket_handler::append_key_where"); - error_num = spider_db_append_key_where_internal(str, str_part, str_part2, - start_key, end_key, spider, set_order, sql_type, - spider_dbton_handlersocket.dbton_id); - DBUG_RETURN(error_num); -} - -int spider_handlersocket_handler::append_is_null_part( - ulong sql_type, - KEY_PART_INFO *key_part, - const key_range *key, - const uchar **ptr, - bool key_eq, - bool tgt_final -) { - int error_num; - spider_string *str; - DBUG_ENTER("spider_handlersocket_handler::append_is_null_part"); - DBUG_PRINT("info",("spider this=%p", this)); - switch (sql_type) - { - case SPIDER_SQL_TYPE_SELECT_HS: - case SPIDER_SQL_TYPE_INSERT_HS: - case SPIDER_SQL_TYPE_UPDATE_HS: - case SPIDER_SQL_TYPE_DELETE_HS: - str = &hs_sql; - break; - default: - DBUG_RETURN(0); - } - error_num = append_is_null(sql_type, str, NULL, NULL, key_part, key, ptr, - key_eq, tgt_final); - DBUG_RETURN(error_num); -} - -int spider_handlersocket_handler::append_is_null( - ulong sql_type, - spider_string *str, - spider_string *str_part, - spider_string *str_part2, - KEY_PART_INFO *key_part, - const key_range *key, - const uchar **ptr, - bool key_eq, - bool tgt_final -) { - DBUG_ENTER("spider_handlersocket_handler::append_is_null"); - DBUG_PRINT("info",("spider this=%p", this)); - if (key_part->null_bit) - { - if (*(*ptr)++) - { - hs_keys.push_back(spider_null_string_ref); - DBUG_RETURN(-1); - } - } - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_where_terminator_part( - ulong sql_type, - bool set_order, - int key_count -) { - DBUG_ENTER("spider_handlersocket_handler::append_where_terminator_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_match_where_part( - ulong sql_type -) { - DBUG_ENTER("spider_handlersocket_handler::append_match_where_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_condition_part( - const char *alias, - uint alias_length, - ulong sql_type, - bool test_flg -) { - DBUG_ENTER("spider_handlersocket_handler::append_condition_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_match_select_part( - ulong sql_type, - const char *alias, - uint alias_length -) { - DBUG_ENTER("spider_handlersocket_handler::append_match_select_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -#ifdef HANDLER_HAS_DIRECT_AGGREGATE -int spider_handlersocket_handler::append_sum_select_part( - ulong sql_type, - const char *alias, - uint alias_length -) { - DBUG_ENTER("spider_handlersocket_handler::append_sum_select_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} -#endif - -void spider_handlersocket_handler::set_order_pos( - ulong sql_type -) { - DBUG_ENTER("spider_handlersocket_handler::set_order_pos"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_VOID_RETURN; -} - -void spider_handlersocket_handler::set_order_to_pos( - ulong sql_type -) { - DBUG_ENTER("spider_handlersocket_handler::set_order_to_pos"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_VOID_RETURN; -} - -#ifdef HANDLER_HAS_DIRECT_AGGREGATE -int spider_handlersocket_handler::append_group_by_part( - const char *alias, - uint alias_length, - ulong sql_type -) { - DBUG_ENTER("spider_handlersocket_handler::append_group_by_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} -#endif - -int spider_handlersocket_handler::append_key_order_for_merge_with_alias_part( - const char *alias, - uint alias_length, - ulong sql_type -) { - DBUG_ENTER("spider_handlersocket_handler::append_key_order_for_merge_with_alias_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_key_order_for_direct_order_limit_with_alias_part( - const char *alias, - uint alias_length, - ulong sql_type -) { - DBUG_ENTER("spider_handlersocket_handler::append_key_order_for_direct_order_limit_with_alias_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_key_order_with_alias_part( - const char *alias, - uint alias_length, - ulong sql_type -) { - DBUG_ENTER("spider_handlersocket_handler::append_key_order_with_alias_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_limit_part( - longlong offset, - longlong limit, - ulong sql_type -) { - DBUG_ENTER("spider_handlersocket_handler::append_limit_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_PRINT("info", ("spider offset=%lld", offset)); - DBUG_PRINT("info", ("spider limit=%lld", limit)); - hs_skip = (int) offset; - hs_limit = (int) limit; - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::reappend_limit_part( - longlong offset, - longlong limit, - ulong sql_type -) { - DBUG_ENTER("spider_handlersocket_handler::reappend_limit_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_select_lock_part( - ulong sql_type -) { - DBUG_ENTER("spider_handlersocket_handler::append_select_lock_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_union_all_start_part( - ulong sql_type -) { - DBUG_ENTER("spider_handlersocket_handler::append_union_all_start_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_union_all_part( - ulong sql_type -) { - DBUG_ENTER("spider_handlersocket_handler::append_union_all_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_union_all_end_part( - ulong sql_type -) { - DBUG_ENTER("spider_handlersocket_handler::append_union_all_end_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_multi_range_cnt_part( - ulong sql_type, - uint multi_range_cnt, - bool with_comma -) { - DBUG_ENTER("spider_handlersocket_handler::append_multi_range_cnt_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_multi_range_cnt_with_name_part( - ulong sql_type, - uint multi_range_cnt -) { - DBUG_ENTER("spider_handlersocket_handler::append_multi_range_cnt_with_name_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_open_handler_part( - ulong sql_type, - uint handler_id, - SPIDER_CONN *conn, - int link_idx -) { - int error_num; - spider_string *str; - DBUG_ENTER("spider_handlersocket_handler::append_open_handler_part"); - DBUG_PRINT("info",("spider this=%p", this)); - switch (sql_type) - { - case SPIDER_SQL_TYPE_OTHER_HS: - str = &hs_sql; - break; - default: - DBUG_RETURN(0); - } - error_num = append_open_handler(str, handler_id, conn, link_idx); - DBUG_RETURN(error_num); -} - -int spider_handlersocket_handler::append_open_handler( - spider_string *str, - uint handler_id, - SPIDER_CONN *conn, - int link_idx -) { - int error_num; - DBUG_ENTER("spider_handlersocket_handler::append_open_handler"); - DBUG_PRINT("info",("spider this=%p", this)); - if ( - str->length() == 0 && -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS - ( - ( - ( - spider->sql_command == SQLCOM_HS_INSERT || - spider->hs_pushed_ret_fields_num == MAX_FIELDS - ) && -#endif - (error_num = append_minimum_select_without_quote(str)) -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS - ) || - ( - ( - spider->sql_command != SQLCOM_HS_INSERT && - spider->hs_pushed_ret_fields_num < MAX_FIELDS - ) && - (error_num = append_minimum_select_by_field_idx_list(str, - spider->hs_pushed_ret_fields, spider->hs_pushed_ret_fields_num)) - ) - ) -#endif - ) { - DBUG_RETURN(error_num); - } - - TABLE *table = spider->get_table(); - SPIDER_SHARE *share = spider->share; - DBUG_PRINT("info",("spider field list=%s", str->c_ptr_safe())); - if (!spider_bit_is_set(spider->db_request_phase, link_idx)) - { - spider_set_bit(spider->db_request_phase, link_idx); - ++spider->db_request_id[link_idx]; - } - st_spider_db_request_key request_key; - request_key.spider_thread_id = spider->trx->spider_thread_id; - request_key.query_id = spider->trx->thd->query_id; - request_key.handler = spider; - request_key.request_id = spider->db_request_id[link_idx]; - request_key.next = NULL; - conn->db_conn->append_open_handler( - handler_id, - share->tgt_dbs[spider->conn_link_idx[link_idx]], - share->tgt_table_names[spider->conn_link_idx[link_idx]], - spider->active_index < MAX_KEY ? - table->key_info[spider->active_index].name : - "0", - str->c_ptr_safe(), - &request_key - ); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_close_handler_part( - ulong sql_type, - int link_idx -) { - DBUG_ENTER("spider_handlersocket_handler::append_close_handler_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_insert_terminator_part( - ulong sql_type -) { - DBUG_ENTER("spider_handlersocket_handler::append_insert_terminator_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_insert_values_part( - ulong sql_type -) { - int error_num; - spider_string *str; - DBUG_ENTER("spider_mysql_handler::append_insert_values_part"); - DBUG_PRINT("info",("spider this=%p", this)); - switch (sql_type) - { - case SPIDER_SQL_TYPE_INSERT_HS: - str = &hs_sql; - break; - default: - DBUG_RETURN(0); - } - error_num = append_insert_values(str); - DBUG_RETURN(error_num); -} - -int spider_handlersocket_handler::append_insert_values( - spider_string *str -) { - SPIDER_SHARE *share = spider->share; - TABLE *table = spider->get_table(); - Field **field; - DBUG_ENTER("spider_mysql_handler::append_insert_values"); - DBUG_PRINT("info",("spider this=%p", this)); - hs_adding_keys = FALSE; - for (field = table->field; *field; field++) - { - DBUG_PRINT("info",("spider field_index=%u", (*field)->field_index)); - if ( - bitmap_is_set(table->write_set, (*field)->field_index) || - bitmap_is_set(table->read_set, (*field)->field_index) - ) { -#ifndef DBUG_OFF - my_bitmap_map *tmp_map = - dbug_tmp_use_all_columns(table, table->read_set); -#endif - DBUG_PRINT("info",("spider is_null()=%s", - (*field)->is_null() ? "TRUE" : "FALSE")); - DBUG_PRINT("info",("spider table->next_number_field=%p", - table->next_number_field)); - DBUG_PRINT("info",("spider *field=%p", *field)); - DBUG_PRINT("info",("spider force_auto_increment=%s", - (table->next_number_field && spider->force_auto_increment) ? - "TRUE" : "FALSE")); - if ( - (*field)->is_null() || - ( - table->next_number_field == *field && - !table->auto_increment_field_not_null && - !spider->force_auto_increment - ) - ) { - hs_upds.push_back(spider_null_string_ref); - } else { - spider_db_handlersocket_utility. - append_column_value(spider, NULL, *field, NULL, - share->access_charset); - } -#ifndef DBUG_OFF - dbug_tmp_restore_column_map(table->read_set, tmp_map); -#endif - } - } - int error_num; - int roop_count2; - for ( - roop_count2 = spider_conn_link_idx_next(share->link_statuses, - spider->conn_link_idx, -1, share->link_count, - SPIDER_LINK_STATUS_RECOVERY); - roop_count2 < (int) share->link_count; - roop_count2 = spider_conn_link_idx_next(share->link_statuses, - spider->conn_link_idx, roop_count2, share->link_count, - SPIDER_LINK_STATUS_RECOVERY) - ) { - if (spider->sql_kind[roop_count2] == SPIDER_SQL_KIND_HS) - { - SPIDER_CONN *conn = spider->hs_w_conns[roop_count2]; - if (conn->dbton_id == spider_dbton_handlersocket.dbton_id) - { - if ((error_num = request_buf_insert(roop_count2))) - DBUG_RETURN(error_num); -#ifdef HA_CAN_BULK_ACCESS - if (spider->is_bulk_access_clone) - { - spider->connection_ids[roop_count2] = conn->connection_id; - spider_trx_add_bulk_access_conn(spider->trx, conn); - } -#endif - } - } - } - hs_upds.clear(); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_into_part( - ulong sql_type -) { - DBUG_ENTER("spider_handlersocket_handler::append_into_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -void spider_handlersocket_handler::set_insert_to_pos( - ulong sql_type -) { - DBUG_ENTER("spider_handlersocket_handler::set_insert_to_pos"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_VOID_RETURN; -} - -int spider_handlersocket_handler::append_from_part( - ulong sql_type, - int link_idx -) { - DBUG_ENTER("spider_handlersocket_handler::append_from_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_delete_all_rows_part( - ulong sql_type -) { - DBUG_ENTER("spider_handlersocket_handler::append_delete_all_rows_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_explain_select_part( - const key_range *start_key, - const key_range *end_key, - ulong sql_type, - int link_idx -) { - DBUG_ENTER("spider_handlersocket_handler::append_explain_select_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::is_sole_projection_field( - uint16 field_index -) { - DBUG_ENTER("spider_handlersocket_handler::is_sole_projection_field"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -bool spider_handlersocket_handler::is_bulk_insert_exec_period( - bool bulk_end -) { - DBUG_ENTER("spider_handlersocket_handler::is_bulk_insert_exec_period"); - DBUG_PRINT("info",("spider this=%p", this)); - if (!spider->bulk_insert || bulk_end) - DBUG_RETURN(TRUE); - DBUG_RETURN(FALSE); -} - -bool spider_handlersocket_handler::sql_is_filled_up( - ulong sql_type -) { - DBUG_ENTER("spider_handlersocket_handler::sql_is_filled_up"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(FALSE); -} - -bool spider_handlersocket_handler::sql_is_empty( - ulong sql_type -) { - DBUG_ENTER("spider_handlersocket_handler::sql_is_empty"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(FALSE); -} - -bool spider_handlersocket_handler::support_multi_split_read() -{ - DBUG_ENTER("spider_handlersocket_handler::support_multi_split_read"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(FALSE); -} - -bool spider_handlersocket_handler::support_bulk_update() -{ - DBUG_ENTER("spider_handlersocket_handler::support_bulk_update"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(FALSE); -} - -int spider_handlersocket_handler::bulk_tmp_table_insert() -{ - DBUG_ENTER("spider_handlersocket_handler::bulk_tmp_table_insert"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::bulk_tmp_table_insert( - int link_idx -) { - DBUG_ENTER("spider_handlersocket_handler::bulk_tmp_table_insert"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::bulk_tmp_table_end_bulk_insert() -{ - DBUG_ENTER("spider_handlersocket_handler::bulk_tmp_table_end_bulk_insert"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::bulk_tmp_table_rnd_init() -{ - DBUG_ENTER("spider_handlersocket_handler::bulk_tmp_table_rnd_init"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::bulk_tmp_table_rnd_next() -{ - DBUG_ENTER("spider_handlersocket_handler::bulk_tmp_table_rnd_next"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::bulk_tmp_table_rnd_end() -{ - DBUG_ENTER("spider_handlersocket_handler::bulk_tmp_table_rnd_end"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -bool spider_handlersocket_handler::need_copy_for_update( - int link_idx -) { - DBUG_ENTER("spider_handlersocket_handler::need_copy_for_update"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(TRUE); -} - -bool spider_handlersocket_handler::bulk_tmp_table_created() -{ - DBUG_ENTER("spider_handlersocket_handler::bulk_tmp_table_created"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(FALSE); -} - -int spider_handlersocket_handler::mk_bulk_tmp_table_and_bulk_start() -{ - DBUG_ENTER("spider_handlersocket_handler::mk_bulk_tmp_table_and_bulk_start"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -void spider_handlersocket_handler::rm_bulk_tmp_table() -{ - DBUG_ENTER("spider_handlersocket_handler::rm_bulk_tmp_table"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_VOID_RETURN; -} - -int spider_handlersocket_handler::insert_lock_tables_list( - SPIDER_CONN *conn, - int link_idx -) { - DBUG_ENTER("spider_handlersocket_handler::insert_lock_tables_list"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_lock_tables_list( - SPIDER_CONN *conn, - int link_idx, - int *appended -) { - DBUG_ENTER("spider_handlersocket_handler::append_lock_tables_list"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::realloc_sql( - ulong *realloced -) { - THD *thd = spider->trx->thd; - st_spider_share *share = spider->share; - int init_sql_alloc_size = - spider_param_init_sql_alloc_size(thd, share->init_sql_alloc_size); - DBUG_ENTER("spider_handlersocket_handler::realloc_sql"); - DBUG_PRINT("info",("spider this=%p", this)); - if ((int) hs_sql.alloced_length() > init_sql_alloc_size * 2) - { - hs_sql.free(); - if (hs_sql.real_alloc(init_sql_alloc_size)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - *realloced |= SPIDER_SQL_TYPE_FULL_HS; - } - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::reset_sql( - ulong sql_type -) { - DBUG_ENTER("spider_handlersocket_handler::reset_sql"); - DBUG_PRINT("info",("spider this=%p", this)); - if (sql_type & SPIDER_SQL_TYPE_FULL_HS) - { - hs_sql.length(0); - } - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::reset_keys( - ulong sql_type -) { - DBUG_ENTER("spider_handlersocket_handler::reset_keys"); - DBUG_PRINT("info",("spider this=%p", this)); - if (sql_type & SPIDER_SQL_TYPE_FULL_HS) - { - hs_keys.clear(); - } - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::reset_upds( - ulong sql_type -) { - DBUG_ENTER("spider_handlersocket_handler::reset_upds"); - DBUG_PRINT("info",("spider this=%p", this)); - if (sql_type & SPIDER_SQL_TYPE_FULL_HS) - { - hs_upds.clear(); - } - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::reset_strs( - ulong sql_type -) { - DBUG_ENTER("spider_handlersocket_handler::reset_strs"); - DBUG_PRINT("info",("spider this=%p", this)); - if (sql_type & SPIDER_SQL_TYPE_FULL_HS) - { - hs_strs.clear(); - } - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::reset_strs_pos( - ulong sql_type -) { - DBUG_ENTER("spider_handlersocket_handler::reset_strs_pos"); - DBUG_PRINT("info",("spider this=%p", this)); - if (sql_type & SPIDER_SQL_TYPE_FULL_HS) - { - hs_strs_pos = 0; - } - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::push_back_upds( - SPIDER_HS_STRING_REF &info -) { - int error_num; - DBUG_ENTER("spider_handlersocket_handler::push_back_upds"); - DBUG_PRINT("info",("spider this=%p", this)); - error_num = hs_upds.push_back(info); - DBUG_RETURN(error_num); -} - -int spider_handlersocket_handler::request_buf_find( - int link_idx -) { - int error_num; - spider_string *hs_str; - SPIDER_CONN *conn; - uint handler_id; - DBUG_ENTER("spider_handlersocket_handler::request_buf_find"); - DBUG_PRINT("info",("spider this=%p", this)); - if (!(hs_str = hs_strs.add(&hs_strs_pos, hs_sql.ptr(), hs_sql.length()))) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - if (spider->conn_kind[link_idx] == SPIDER_CONN_KIND_HS_READ) - { - conn = spider->hs_r_conns[link_idx]; - handler_id = spider->r_handler_id[link_idx]; - } else { - conn = spider->hs_w_conns[link_idx]; - handler_id = spider->w_handler_id[link_idx]; - } - if ((error_num = spider_db_conn_queue_action(conn))) - DBUG_RETURN(error_num); - if (!spider_bit_is_set(spider->db_request_phase, link_idx)) - { - spider_set_bit(spider->db_request_phase, link_idx); - ++spider->db_request_id[link_idx]; - } - st_spider_db_request_key request_key; - request_key.spider_thread_id = spider->trx->spider_thread_id; - request_key.query_id = spider->trx->thd->query_id; - request_key.handler = spider; - request_key.request_id = spider->db_request_id[link_idx]; - request_key.next = NULL; - conn->db_conn->append_select( - handler_id, hs_str, &hs_keys, - hs_limit, hs_skip, &request_key); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::request_buf_insert( - int link_idx -) { - int error_num; - DBUG_ENTER("spider_handlersocket_handler::request_buf_insert"); - DBUG_PRINT("info",("spider this=%p", this)); - if ((error_num = spider_db_conn_queue_action(spider->hs_w_conns[link_idx]))) - DBUG_RETURN(error_num); - if (!spider_bit_is_set(spider->db_request_phase, link_idx)) - { - spider_set_bit(spider->db_request_phase, link_idx); - ++spider->db_request_id[link_idx]; - } - st_spider_db_request_key request_key; - request_key.spider_thread_id = spider->trx->spider_thread_id; - request_key.query_id = spider->trx->thd->query_id; - request_key.handler = spider; - request_key.request_id = spider->db_request_id[link_idx]; - request_key.next = NULL; - spider->hs_w_conns[link_idx]->db_conn->append_insert( - spider->w_handler_id[link_idx], &hs_upds, &request_key); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::request_buf_update( - int link_idx -) { - int error_num; - spider_string *hs_str; - DBUG_ENTER("spider_handlersocket_handler::request_buf_update"); - DBUG_PRINT("info",("spider this=%p", this)); - if (!(hs_str = hs_strs.add(&hs_strs_pos, hs_sql.ptr(), hs_sql.length()))) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - if ((error_num = spider_db_conn_queue_action(spider->hs_w_conns[link_idx]))) - DBUG_RETURN(error_num); - if (!spider_bit_is_set(spider->db_request_phase, link_idx)) - { - spider_set_bit(spider->db_request_phase, link_idx); - ++spider->db_request_id[link_idx]; - } - st_spider_db_request_key request_key; - request_key.spider_thread_id = spider->trx->spider_thread_id; - request_key.query_id = spider->trx->thd->query_id; - request_key.handler = spider; - request_key.request_id = spider->db_request_id[link_idx]; - request_key.next = NULL; - spider->hs_w_conns[link_idx]->db_conn->append_update( - spider->w_handler_id[link_idx], hs_str, &hs_keys, &hs_upds, - hs_limit, hs_skip, - spider->hs_increment, spider->hs_decrement, &request_key - ); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::request_buf_delete( - int link_idx -) { - int error_num; - spider_string *hs_str; - DBUG_ENTER("spider_handlersocket_handler::request_buf_delete"); - DBUG_PRINT("info",("spider this=%p", this)); - if (!(hs_str = hs_strs.add(&hs_strs_pos, hs_sql.ptr(), hs_sql.length()))) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - if ((error_num = spider_db_conn_queue_action(spider->hs_w_conns[link_idx]))) - DBUG_RETURN(error_num); - if (!spider_bit_is_set(spider->db_request_phase, link_idx)) - { - spider_set_bit(spider->db_request_phase, link_idx); - ++spider->db_request_id[link_idx]; - } - st_spider_db_request_key request_key; - request_key.spider_thread_id = spider->trx->spider_thread_id; - request_key.query_id = spider->trx->thd->query_id; - request_key.handler = spider; - request_key.request_id = spider->db_request_id[link_idx]; - request_key.next = NULL; - spider->hs_w_conns[link_idx]->db_conn->append_delete( - spider->w_handler_id[link_idx], hs_str, &hs_keys, - hs_limit, hs_skip, &request_key); - DBUG_RETURN(0); -} - -bool spider_handlersocket_handler::need_lock_before_set_sql_for_exec( - ulong sql_type -) { - DBUG_ENTER("spider_handlersocket_handler::need_lock_before_set_sql_for_exec"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN(TRUE); -} - -#ifdef SPIDER_HAS_GROUP_BY_HANDLER -int spider_handlersocket_handler::set_sql_for_exec( - ulong sql_type, - int link_idx, - SPIDER_LINK_IDX_CHAIN *link_idx_chain -) { - DBUG_ENTER("spider_handlersocket_handler::set_sql_for_exec"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} -#endif - -int spider_handlersocket_handler::set_sql_for_exec( - ulong sql_type, - int link_idx -) { - DBUG_ENTER("spider_handlersocket_handler::set_sql_for_exec"); - DBUG_PRINT("info",("spider this=%p", this)); - if (sql_type & SPIDER_SQL_TYPE_SELECT_HS) - { - DBUG_RETURN(request_buf_find(link_idx)); - } - if (sql_type & SPIDER_SQL_TYPE_INSERT_HS) - { - DBUG_RETURN(request_buf_insert(link_idx)); - } - if (sql_type & SPIDER_SQL_TYPE_UPDATE_HS) - { - DBUG_RETURN(request_buf_update(link_idx)); - } - if (sql_type & SPIDER_SQL_TYPE_DELETE_HS) - { - DBUG_RETURN(request_buf_delete(link_idx)); - } - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::set_sql_for_exec( - spider_db_copy_table *tgt_ct, - ulong sql_type -) { - DBUG_ENTER("spider_handlersocket_handler::set_sql_for_exec"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::execute_sql( - ulong sql_type, - SPIDER_CONN *conn, - int quick_mode, - int *need_mon -) { - DBUG_ENTER("spider_handlersocket_handler::execute_sql"); - DBUG_PRINT("info",("spider this=%p", this)); - if (!(sql_type & SPIDER_SQL_TYPE_FULL_HS)) - { - /* nothing to do */ - DBUG_RETURN(0); - } - DBUG_RETURN(spider_db_query( - conn, - NULL, - 0, - quick_mode, - need_mon - )); -} - -int spider_handlersocket_handler::reset() -{ - DBUG_ENTER("spider_handlersocket_handler::reset"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::sts_mode_exchange( - int sts_mode -) { - DBUG_ENTER("spider_handlersocket_handler::sts_mode_exchange"); - DBUG_PRINT("info",("spider sts_mode=%d", sts_mode)); - DBUG_RETURN(sts_mode); -} - -int spider_handlersocket_handler::show_table_status( - int link_idx, - int sts_mode, - uint flag -) { - spider_db_handlersocket_result res(NULL); - SPIDER_SHARE *share = spider->share; - ulonglong auto_increment_value = 0; - DBUG_ENTER("spider_handlersocket_show_table_status"); - res.fetch_table_status( - sts_mode, - share->stat - ); - if (auto_increment_value > share->lgtm_tblhnd_share->auto_increment_value) - { - share->lgtm_tblhnd_share->auto_increment_value = auto_increment_value; - DBUG_PRINT("info",("spider auto_increment_value=%llu", - share->lgtm_tblhnd_share->auto_increment_value)); - } - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::crd_mode_exchange( - int crd_mode -) { - DBUG_ENTER("spider_handlersocket_handler::crd_mode_exchange"); - DBUG_PRINT("info",("spider crd_mode=%d", crd_mode)); - DBUG_RETURN(crd_mode); -} - -int spider_handlersocket_handler::show_index( - int link_idx, - int crd_mode -) { - DBUG_ENTER("spider_handlersocket_handler::show_index"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::show_records( - int link_idx -) { - DBUG_ENTER("spider_handlersocket_handler::show_records"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::show_last_insert_id( - int link_idx, - ulonglong &last_insert_id -) { - DBUG_ENTER("spider_handlersocket_handler::show_last_insert_id"); - last_insert_id = 0; - DBUG_RETURN(0); -} - -ha_rows spider_handlersocket_handler::explain_select( - key_range *start_key, - key_range *end_key, - int link_idx -) { - DBUG_ENTER("spider_handlersocket_handler::explain_select"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::lock_tables( - int link_idx -) { - DBUG_ENTER("spider_handlersocket_handler::lock_tables"); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::unlock_tables( - int link_idx -) { - DBUG_ENTER("spider_handlersocket_handler::unlock_tables"); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::disable_keys( - SPIDER_CONN *conn, - int link_idx -) { - DBUG_ENTER("spider_handlersocket_handler::disable_keys"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::enable_keys( - SPIDER_CONN *conn, - int link_idx -) { - DBUG_ENTER("spider_handlersocket_handler::enable_keys"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::check_table( - SPIDER_CONN *conn, - int link_idx, - HA_CHECK_OPT* check_opt -) { - DBUG_ENTER("spider_handlersocket_handler::check_table"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::repair_table( - SPIDER_CONN *conn, - int link_idx, - HA_CHECK_OPT* check_opt -) { - DBUG_ENTER("spider_handlersocket_handler::repair_table"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::analyze_table( - SPIDER_CONN *conn, - int link_idx -) { - DBUG_ENTER("spider_handlersocket_handler::analyze_table"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::optimize_table( - SPIDER_CONN *conn, - int link_idx -) { - DBUG_ENTER("spider_handlersocket_handler::optimize_table"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::flush_tables( - SPIDER_CONN *conn, - int link_idx, - bool lock -) { - DBUG_ENTER("spider_handlersocket_handler::flush_tables"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::flush_logs( - SPIDER_CONN *conn, - int link_idx -) { - DBUG_ENTER("spider_handlersocket_handler::flush_logs"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::insert_opened_handler( - SPIDER_CONN *conn, - int link_idx -) { - spider_db_handlersocket *db_conn = (spider_db_handlersocket *) conn->db_conn; - SPIDER_LINK_FOR_HASH *tmp_link_for_hash = &link_for_hash[link_idx]; - DBUG_ASSERT(tmp_link_for_hash->spider == spider); - DBUG_ASSERT(tmp_link_for_hash->link_idx == link_idx); - uint old_elements = db_conn->handler_open_array.max_element; - DBUG_ENTER("spider_handlersocket_handler::insert_opened_handler"); - DBUG_PRINT("info",("spider this=%p", this)); - if (insert_dynamic(&db_conn->handler_open_array, - (uchar*) &tmp_link_for_hash)) - { - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - } - if (db_conn->handler_open_array.max_element > old_elements) - { - spider_alloc_calc_mem(spider_current_trx, - db_conn->handler_open_array, - (db_conn->handler_open_array.max_element - old_elements) * - db_conn->handler_open_array.size_of_element); - } - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::delete_opened_handler( - SPIDER_CONN *conn, - int link_idx -) { - spider_db_handlersocket *db_conn = (spider_db_handlersocket *) conn->db_conn; - uint roop_count, elements = db_conn->handler_open_array.elements; - SPIDER_LINK_FOR_HASH *tmp_link_for_hash; - DBUG_ENTER("spider_handlersocket_handler::delete_opened_handler"); - DBUG_PRINT("info",("spider this=%p", this)); - for (roop_count = 0; roop_count < elements; roop_count++) - { - get_dynamic(&db_conn->handler_open_array, (uchar *) &tmp_link_for_hash, - roop_count); - if (tmp_link_for_hash == &link_for_hash[link_idx]) - { - delete_dynamic_element(&db_conn->handler_open_array, roop_count); - break; - } - } - DBUG_ASSERT(roop_count < elements); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::sync_from_clone_source( - spider_db_handler *dbton_hdl -) { - spider_handlersocket_handler *hs_hdl = - (spider_handlersocket_handler *) dbton_hdl; - DBUG_ENTER("spider_handlersocket_handler::sync_from_clone_source"); - DBUG_PRINT("info",("spider this=%p", this)); - hs_strs_pos = hs_hdl->hs_strs_pos; - DBUG_RETURN(0); -} - -bool spider_handlersocket_handler::support_use_handler( - int use_handler -) { - DBUG_ENTER("spider_handlersocket_handler::support_use_handler"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN(TRUE); -} - -void spider_handlersocket_handler::minimum_select_bitmap_create() -{ - TABLE *table = spider->get_table(); - Field **field_p; - DBUG_ENTER("spider_handlersocket_handler::minimum_select_bitmap_create"); - memset(minimum_select_bitmap, 0, no_bytes_in_map(table->read_set)); - if ( - spider->use_index_merge || -#ifdef HA_CAN_BULK_ACCESS - (spider->is_clone && !spider->is_bulk_access_clone) -#else - spider->is_clone -#endif - ) { - /* need preparing for cmp_ref */ - TABLE_SHARE *table_share = table->s; - if ( - table_share->primary_key == MAX_KEY - ) { - /* need all columns */ - memset(minimum_select_bitmap, 0xFF, no_bytes_in_map(table->read_set)); - DBUG_VOID_RETURN; - } else { - /* need primary key columns */ - uint roop_count; - KEY *key_info; - KEY_PART_INFO *key_part; - Field *field; - key_info = &table_share->key_info[table_share->primary_key]; - key_part = key_info->key_part; - for (roop_count = 0; - roop_count < spider_user_defined_key_parts(key_info); - roop_count++) - { - field = key_part[roop_count].field; - spider_set_bit(minimum_select_bitmap, field->field_index); - } - } - } - for (field_p = table->field; *field_p; field_p++) - { - uint field_index = (*field_p)->field_index; - if ( - spider_bit_is_set(spider->searched_bitmap, field_index) || - bitmap_is_set(table->read_set, field_index) || - bitmap_is_set(table->write_set, field_index) - ) { - spider_set_bit(minimum_select_bitmap, field_index); - } - } - DBUG_VOID_RETURN; -} - -bool spider_handlersocket_handler::minimum_select_bit_is_set( - uint field_index -) { - DBUG_ENTER("spider_handlersocket_handler::minimum_select_bit_is_set"); - DBUG_PRINT("info",("spider field_index=%u", field_index)); - DBUG_PRINT("info",("spider minimum_select_bitmap=%s", - spider_bit_is_set(minimum_select_bitmap, field_index) ? - "TRUE" : "FALSE")); - DBUG_RETURN(spider_bit_is_set(minimum_select_bitmap, field_index)); -} - -void spider_handlersocket_handler::copy_minimum_select_bitmap( - uchar *bitmap -) { - int roop_count; - TABLE *table = spider->get_table(); - DBUG_ENTER("spider_handlersocket_handler::copy_minimum_select_bitmap"); - for (roop_count = 0; - roop_count < (int) ((table->s->fields + 7) / 8); - roop_count++) - { - bitmap[roop_count] = - minimum_select_bitmap[roop_count]; - DBUG_PRINT("info",("spider roop_count=%d", roop_count)); - DBUG_PRINT("info",("spider bitmap=%d", - bitmap[roop_count])); - } - DBUG_VOID_RETURN; -} - -int spider_handlersocket_handler::init_union_table_name_pos() -{ - DBUG_ENTER("spider_handlersocket_handler::init_union_table_name_pos"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::set_union_table_name_pos() -{ - DBUG_ENTER("spider_handlersocket_handler::set_union_table_name_pos"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::reset_union_table_name( - spider_string *str, - int link_idx, - ulong sql_type -) { - DBUG_ENTER("spider_handlersocket_handler::reset_union_table_name"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -#ifdef SPIDER_HAS_GROUP_BY_HANDLER -int spider_handlersocket_handler::append_list_item_select_part( - List *select, - const char *alias, - uint alias_length, - bool use_fields, - spider_fields *fields, - ulong sql_type -) { - DBUG_ENTER("spider_handlersocket_handler::append_list_item_select_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_from_and_tables_part( - spider_fields *fields, - ulong sql_type -) { - DBUG_ENTER("spider_handlersocket_handler::append_from_and_tables_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::reappend_tables_part( - spider_fields *fields, - ulong sql_type -) { - DBUG_ENTER("spider_handlersocket_handler::reappend_tables_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_where_part( - ulong sql_type -) { - DBUG_ENTER("spider_handlersocket_handler::append_where_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_having_part( - ulong sql_type -) { - DBUG_ENTER("spider_handlersocket_handler::append_having_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_item_type_part( - Item *item, - const char *alias, - uint alias_length, - bool use_fields, - spider_fields *fields, - ulong sql_type -) { - DBUG_ENTER("spider_handlersocket_handler::append_item_type_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_group_by_part( - ORDER *order, - const char *alias, - uint alias_length, - bool use_fields, - spider_fields *fields, - ulong sql_type -) { - DBUG_ENTER("spider_handlersocket_handler::append_group_by_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_order_by_part( - ORDER *order, - const char *alias, - uint alias_length, - bool use_fields, - spider_fields *fields, - ulong sql_type -) { - DBUG_ENTER("spider_handlersocket_handler::append_order_by_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} -#endif -#endif diff --git a/storage/spider/spd_db_handlersocket.h b/storage/spider/spd_db_handlersocket.h deleted file mode 100644 index f7a454b66af..00000000000 --- a/storage/spider/spd_db_handlersocket.h +++ /dev/null @@ -1,1091 +0,0 @@ -/* Copyright (C) 2012-2018 Kentoku Shiba - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; version 2 of the License. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ - -#define SPIDER_HS_CONN dena::hstcpcli_ptr -#define SPIDER_HS_CONN_CREATE dena::hstcpcli_i::create -#define SPIDER_HS_RESULT dena::hstresult -#define SPIDER_HS_SOCKARGS dena::socket_args - -class spider_db_handlersocket_util: public spider_db_util -{ -public: - spider_db_handlersocket_util(); - ~spider_db_handlersocket_util(); - int append_name( - spider_string *str, - const char *name, - uint name_length - ); - int append_name_with_charset( - spider_string *str, - const char *name, - uint name_length, - CHARSET_INFO *name_charset - ); - int append_escaped_name( - spider_string *str, - const char *name, - uint name_length - ); - int append_escaped_name_with_charset( - spider_string *str, - const char *name, - uint name_length, - CHARSET_INFO *name_charset - ); - bool is_name_quote( - const char head_code - ); - int append_escaped_name_quote( - spider_string *str - ); - int append_column_value( - ha_spider *spider, - spider_string *str, - Field *field, - const uchar *new_ptr, - CHARSET_INFO *access_charset - ); - int append_trx_isolation( - spider_string *str, - int trx_isolation - ); - int append_autocommit( - spider_string *str, - bool autocommit - ); - int append_sql_log_off( - spider_string *str, - bool sql_log_off - ); - int append_wait_timeout( - spider_string *str, - int wait_timeout - ); - int append_sql_mode( - spider_string *str, - sql_mode_t sql_mode - ); - int append_time_zone( - spider_string *str, - Time_zone *time_zone - ); - int append_start_transaction( - spider_string *str - ); - int append_xa_start( - spider_string *str, - XID *xid - ); - int append_lock_table_head( - spider_string *str - ); - int append_lock_table_body( - spider_string *str, - const char *db_name, - uint db_name_length, - CHARSET_INFO *db_name_charset, - const char *table_name, - uint table_name_length, - CHARSET_INFO *table_name_charset, - int lock_type - ); - int append_lock_table_tail( - spider_string *str - ); - int append_unlock_table( - spider_string *str - ); - int open_item_func( - Item_func *item_func, - ha_spider *spider, - spider_string *str, - const char *alias, - uint alias_length, - bool use_fields, - spider_fields *fields - ); -#ifdef HANDLER_HAS_DIRECT_AGGREGATE - int open_item_sum_func( - Item_sum *item_sum, - ha_spider *spider, - spider_string *str, - const char *alias, - uint alias_length, - bool use_fields, - spider_fields *fields - ); -#endif - int append_escaped_util( - spider_string *to, - String *from - ); - int append_escaped_util( - spider_string *to, - String *from - ); -#ifdef SPIDER_HAS_GROUP_BY_HANDLER - int append_from_and_tables( - ha_spider *spider, - spider_fields *fields, - spider_string *str, - TABLE_LIST *table_list, - uint table_count - ); - int reappend_tables( - spider_fields *fields, - SPIDER_LINK_IDX_CHAIN *link_idx_chain, - spider_string *str - ); - int append_where( - spider_string *str - ); - int append_having( - spider_string *str - ); -#endif -}; - -class spider_db_handlersocket_row: public spider_db_row -{ -public: - SPIDER_HS_STRING_REF *hs_row; - SPIDER_HS_STRING_REF *hs_row_first; - uint field_count; - uint row_size; - bool cloned; - spider_db_handlersocket_row(); - ~spider_db_handlersocket_row(); - int store_to_field( - Field *field, - CHARSET_INFO *access_charset - ); - int append_to_str( - spider_string *str - ); - int append_escaped_to_str( - spider_string *str, - uint dbton_id - ); - void first(); - void next(); - bool is_null(); - int val_int(); - double val_real(); - my_decimal *val_decimal( - my_decimal *decimal_value, - CHARSET_INFO *access_charset - ); - SPIDER_DB_ROW *clone(); - int store_to_tmp_table( - TABLE *tmp_table, - spider_string *str - ); - uint get_byte_size(); -}; - -class spider_db_handlersocket_result_buffer: public spider_db_result_buffer -{ -public: - SPIDER_HS_RESULT hs_result; - spider_db_handlersocket_result_buffer(); - ~spider_db_handlersocket_result_buffer(); - void clear(); - bool check_size( - longlong size - ); -}; - -class spider_db_handlersocket_result: public spider_db_result -{ -public: - SPIDER_HS_CONN *hs_conn_p; - spider_db_handlersocket_row row; - SPIDER_HS_STRING_REF hs_row; - uint field_count; - int store_error_num; - spider_db_handlersocket_result(SPIDER_DB_CONN *in_db_conn); - ~spider_db_handlersocket_result(); - bool has_result(); - void free_result(); - SPIDER_DB_ROW *current_row(); - SPIDER_DB_ROW *fetch_row(); - SPIDER_DB_ROW *fetch_row_from_result_buffer( - spider_db_result_buffer *spider_res_buf - ); - SPIDER_DB_ROW *fetch_row_from_tmp_table( - TABLE *tmp_table - ); - int fetch_table_status( - int mode, - ha_statistics &stat - ); - int fetch_table_records( - int mode, - ha_rows &records - ); - int fetch_table_cardinality( - int mode, - TABLE *table, - longlong *cardinality, - uchar *cardinality_upd, - int bitmap_size - ); - int fetch_table_mon_status( - int &status - ); - longlong num_rows(); - uint num_fields(); - void move_to_pos( - longlong pos - ); - int get_errno(); -#ifdef SPIDER_HAS_DISCOVER_TABLE_STRUCTURE - int fetch_columns_for_discover_table_structure( - spider_string *str, - CHARSET_INFO *access_charset - ); - int fetch_index_for_discover_table_structure( - spider_string *str, - CHARSET_INFO *access_charset - ); - int fetch_table_for_discover_table_structure( - spider_string *str, - SPIDER_SHARE *spider_share, - CHARSET_INFO *access_charset - ); -#endif -}; - -class spider_db_handlersocket: public spider_db_conn -{ - SPIDER_HS_CONN hs_conn; - int stored_error; - uint field_count; -public: - DYNAMIC_ARRAY handler_open_array; - bool handler_open_array_inited; - uint handler_open_array_id; - const char *handler_open_array_func_name; - const char *handler_open_array_file_name; - ulong handler_open_array_line_no; - st_spider_db_request_key *request_key_req_first; - st_spider_db_request_key *request_key_req_last; - st_spider_db_request_key *request_key_snd_first; - st_spider_db_request_key *request_key_snd_last; - st_spider_db_request_key *request_key_reuse_first; - st_spider_db_request_key *request_key_reuse_last; - spider_db_handlersocket( - SPIDER_CONN *conn - ); - ~spider_db_handlersocket(); - int init(); - bool is_connected(); - void bg_connect(); - int connect( - char *tgt_host, - char *tgt_username, - char *tgt_password, - long tgt_port, - char *tgt_socket, - char *server_name, - int connect_retry_count, - longlong connect_retry_interval - ); - int ping(); - void bg_disconnect(); - void disconnect(); - int set_net_timeout(); - int exec_query( - const char *query, - uint length, - int quick_mode - ); - int get_errno(); - const char *get_error(); - bool is_server_gone_error( - int error_num - ); - bool is_dup_entry_error( - int error_num - ); - bool is_xa_nota_error( - int error_num - ); - spider_db_result *store_result( - spider_db_result_buffer **spider_res_buf, - st_spider_db_request_key *request_key, - int *error_num - ); - spider_db_result *use_result( - ha_spider *spider, - st_spider_db_request_key *request_key, - int *error_num - ); - int next_result(); - uint affected_rows(); - uint matched_rows(); - bool inserted_info( - spider_db_handler *handler, - spider_copy_info *copy_info - ); - ulonglong last_insert_id(); - int set_character_set( - const char *csname - ); - int select_db( - const char *dbname - ); - int consistent_snapshot( - int *need_mon - ); - bool trx_start_in_bulk_sql(); - int start_transaction( - int *need_mon - ); - int commit( - int *need_mon - ); - int rollback( - int *need_mon - ); - bool xa_start_in_bulk_sql(); - int xa_start( - XID *xid, - int *need_mon - ); - int xa_end( - XID *xid, - int *need_mon - ); - int xa_prepare( - XID *xid, - int *need_mon - ); - int xa_commit( - XID *xid, - int *need_mon - ); - int xa_rollback( - XID *xid, - int *need_mon - ); - bool set_trx_isolation_in_bulk_sql(); - int set_trx_isolation( - int trx_isolation, - int *need_mon - ); - bool set_autocommit_in_bulk_sql(); - int set_autocommit( - bool autocommit, - int *need_mon - ); - bool set_sql_log_off_in_bulk_sql(); - int set_sql_log_off( - bool sql_log_off, - int *need_mon - ); - bool set_wait_timeout_in_bulk_sql(); - int set_wait_timeout( - int wait_timeout, - int *need_mon - ); - bool set_sql_mode_in_bulk_sql(); - int set_sql_mode( - sql_mode_t sql_mode, - int *need_mon - ); - bool set_time_zone_in_bulk_sql(); - int set_time_zone( - Time_zone *time_zone, - int *need_mon - ); - int show_master_status( - SPIDER_TRX *trx, - SPIDER_SHARE *share, - int all_link_idx, - int *need_mon, - TABLE *table, - spider_string *str, - int mode, - SPIDER_DB_RESULT **res1, - SPIDER_DB_RESULT **res2 - ); - int append_sql( - char *sql, - ulong sql_length, - st_spider_db_request_key *request_key - ); - int append_open_handler( - uint handler_id, - const char *db_name, - const char *table_name, - const char *index_name, - const char *sql, - st_spider_db_request_key *request_key - ); - int append_select( - uint handler_id, - spider_string *sql, - SPIDER_DB_HS_STRING_REF_BUFFER *keys, - int limit, - int skip, - st_spider_db_request_key *request_key - ); - int append_insert( - uint handler_id, - SPIDER_DB_HS_STRING_REF_BUFFER *upds, - st_spider_db_request_key *request_key - ); - int append_update( - uint handler_id, - spider_string *sql, - SPIDER_DB_HS_STRING_REF_BUFFER *keys, - SPIDER_DB_HS_STRING_REF_BUFFER *upds, - int limit, - int skip, - bool increment, - bool decrement, - st_spider_db_request_key *request_key - ); - int append_delete( - uint handler_id, - spider_string *sql, - SPIDER_DB_HS_STRING_REF_BUFFER *keys, - int limit, - int skip, - st_spider_db_request_key *request_key - ); - void reset_request_queue(); - size_t escape_string( - char *to, - const char *from, - size_t from_length - ); - bool have_lock_table_list(); - int append_lock_tables( - spider_string *str - ); - int append_unlock_tables( - spider_string *str - ); - uint get_lock_table_hash_count(); - void reset_lock_table_hash(); - uint get_opened_handler_count(); - void reset_opened_handler(); - void set_dup_key_idx( - ha_spider *spider, - int link_idx - ); - int append_request_key( - st_spider_db_request_key *request_key - ); - void reset_request_key_req(); - void reset_request_key_snd(); - void move_request_key_to_snd(); - int check_request_key( - st_spider_db_request_key *request_key - ); - bool cmp_request_key_to_snd( - st_spider_db_request_key *request_key - ); -}; - -class spider_handlersocket_share: public spider_db_share -{ -public: - spider_string *table_names_str; - spider_string *db_names_str; - spider_string *db_table_str; -#ifdef SPIDER_HAS_HASH_VALUE_TYPE - my_hash_value_type *db_table_str_hash_value; -#endif - uint table_nm_max_length; - uint db_nm_max_length; - spider_string *column_name_str; - bool same_db_table_name; - int first_all_link_idx; - spider_handlersocket_share( - st_spider_share *share - ); - ~spider_handlersocket_share(); - int init(); - int append_table_name( - spider_string *str, - int all_link_idx - ); - int create_table_names_str(); - void free_table_names_str(); - int create_column_name_str(); - void free_column_name_str(); - uint get_column_name_length( - uint field_index - ); - int append_column_name( - spider_string *str, - uint field_index - ); - int append_column_name_with_alias( - spider_string *str, - uint field_index, - const char *alias, - uint alias_length - ); - bool need_change_db_table_name(); -#ifdef SPIDER_HAS_DISCOVER_TABLE_STRUCTURE - int discover_table_structure( - SPIDER_TRX *trx, - SPIDER_SHARE *spider_share, - spider_string *str - ); -#endif -}; - -class spider_handlersocket_handler: public spider_db_handler -{ - spider_string hs_sql; -public: - bool hs_adding_keys; - SPIDER_DB_HS_STRING_REF_BUFFER hs_keys; - SPIDER_DB_HS_STRING_REF_BUFFER hs_upds; - SPIDER_DB_HS_STR_BUFFER hs_strs; - uint hs_strs_pos; - int hs_limit; - int hs_skip; - spider_handlersocket_share *handlersocket_share; - SPIDER_LINK_FOR_HASH *link_for_hash; - uchar *minimum_select_bitmap; - spider_handlersocket_handler( - ha_spider *spider, - spider_handlersocket_share *db_share - ); - ~spider_handlersocket_handler(); - int init(); - int append_index_hint( - spider_string *str, - int link_idx, - ulong sql_type - ); - int append_table_name_with_adjusting( - spider_string *str, - int link_idx, - ulong sql_type - ); - int append_tmp_table_and_sql_for_bka( - const key_range *start_key - ); - int reuse_tmp_table_and_sql_for_bka(); - int append_union_table_and_sql_for_bka( - const key_range *start_key - ); - int reuse_union_table_and_sql_for_bka(); - int append_insert_for_recovery( - ulong sql_type, - int link_idx - ); - int append_update( - const TABLE *table, - my_ptrdiff_t ptr_diff - ); - int append_update( - const TABLE *table, - my_ptrdiff_t ptr_diff, - int link_idx - ); - int append_delete( - const TABLE *table, - my_ptrdiff_t ptr_diff - ); - int append_delete( - const TABLE *table, - my_ptrdiff_t ptr_diff, - int link_idx - ); - int append_insert_part(); - int append_update_part(); - int append_delete_part(); -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS - int append_increment_update_set_part(); -#endif - int append_update_set_part(); -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS - int append_direct_update_set_part(); -#endif - int append_minimum_select_without_quote( - spider_string *str - ); -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS - int append_minimum_select_by_field_idx_list( - spider_string *str, - uint32 *field_idxs, - size_t field_idxs_num - ); - int append_dup_update_pushdown_part( - const char *alias, - uint alias_length - ); - int append_update_columns_part( - const char *alias, - uint alias_length - ); - int check_update_columns_part(); - int append_select_part( - ulong sql_type - ); -#endif - int append_table_select_part( - ulong sql_type - ); - int append_key_select_part( - ulong sql_type, - uint idx - ); - int append_minimum_select_part( - ulong sql_type - ); - int append_hint_after_table_part( - ulong sql_type - ); - void set_where_pos( - ulong sql_type - ); - void set_where_to_pos( - ulong sql_type - ); - int check_item_type( - Item *item - ); - int append_values_connector_part( - ulong sql_type - ); - int append_values_terminator_part( - ulong sql_type - ); - int append_union_table_connector_part( - ulong sql_type - ); - int append_union_table_terminator_part( - ulong sql_type - ); - int append_key_column_values_part( - const key_range *start_key, - ulong sql_type - ); - int append_key_column_values_with_name_part( - const key_range *start_key, - ulong sql_type - ); - int append_key_where_part( - const key_range *start_key, - const key_range *end_key, - ulong sql_type - ); - int append_key_where( - spider_string *str, - spider_string *str_part, - spider_string *str_part2, - const key_range *start_key, - const key_range *end_key, - ulong sql_type, - bool set_order - ); - int append_is_null_part( - ulong sql_type, - KEY_PART_INFO *key_part, - const key_range *key, - const uchar **ptr, - bool key_eq, - bool tgt_final - ); - int append_is_null( - ulong sql_type, - spider_string *str, - spider_string *str_part, - spider_string *str_part2, - KEY_PART_INFO *key_part, - const key_range *key, - const uchar **ptr, - bool key_eq, - bool tgt_final - ); - int append_where_terminator_part( - ulong sql_type, - bool set_order, - int key_count - ); - int append_match_where_part( - ulong sql_type - ); - int append_condition_part( - const char *alias, - uint alias_length, - ulong sql_type, - bool test_flg - ); - int append_match_select_part( - ulong sql_type, - const char *alias, - uint alias_length - ); -#ifdef HANDLER_HAS_DIRECT_AGGREGATE - int append_sum_select_part( - ulong sql_type, - const char *alias, - uint alias_length - ); -#endif - void set_order_pos( - ulong sql_type - ); - void set_order_to_pos( - ulong sql_type - ); -#ifdef HANDLER_HAS_DIRECT_AGGREGATE - int append_group_by_part( - const char *alias, - uint alias_length, - ulong sql_type - ); -#endif - int append_key_order_for_merge_with_alias_part( - const char *alias, - uint alias_length, - ulong sql_type - ); - int append_key_order_for_direct_order_limit_with_alias_part( - const char *alias, - uint alias_length, - ulong sql_type - ); - int append_key_order_with_alias_part( - const char *alias, - uint alias_length, - ulong sql_type - ); - int append_limit_part( - longlong offset, - longlong limit, - ulong sql_type - ); - int reappend_limit_part( - longlong offset, - longlong limit, - ulong sql_type - ); - int append_select_lock_part( - ulong sql_type - ); - int append_union_all_start_part( - ulong sql_type - ); - int append_union_all_part( - ulong sql_type - ); - int append_union_all_end_part( - ulong sql_type - ); - int append_multi_range_cnt_part( - ulong sql_type, - uint multi_range_cnt, - bool with_comma - ); - int append_multi_range_cnt_with_name_part( - ulong sql_type, - uint multi_range_cnt - ); - int append_open_handler_part( - ulong sql_type, - uint handler_id, - SPIDER_CONN *conn, - int link_idx - ); - int append_open_handler( - spider_string *str, - uint handler_id, - SPIDER_CONN *conn, - int link_idx - ); - int append_close_handler_part( - ulong sql_type, - int link_idx - ); - int append_insert_terminator_part( - ulong sql_type - ); - int append_insert_values_part( - ulong sql_type - ); - int append_insert_values( - spider_string *str - ); - int append_into_part( - ulong sql_type - ); - void set_insert_to_pos( - ulong sql_type - ); - int append_from_part( - ulong sql_type, - int link_idx - ); - int append_delete_all_rows_part( - ulong sql_type - ); - int append_explain_select_part( - const key_range *start_key, - const key_range *end_key, - ulong sql_type, - int link_idx - ); - bool is_sole_projection_field( - uint16 field_index - ); - bool is_bulk_insert_exec_period( - bool bulk_end - ); - bool sql_is_filled_up( - ulong sql_type - ); - bool sql_is_empty( - ulong sql_type - ); - bool support_multi_split_read(); - bool support_bulk_update(); - int bulk_tmp_table_insert(); - int bulk_tmp_table_insert( - int link_idx - ); - int bulk_tmp_table_end_bulk_insert(); - int bulk_tmp_table_rnd_init(); - int bulk_tmp_table_rnd_next(); - int bulk_tmp_table_rnd_end(); - bool need_copy_for_update( - int link_idx - ); - bool bulk_tmp_table_created(); - int mk_bulk_tmp_table_and_bulk_start(); - void rm_bulk_tmp_table(); - int insert_lock_tables_list( - SPIDER_CONN *conn, - int link_idx - ); - int append_lock_tables_list( - SPIDER_CONN *conn, - int link_idx, - int *appended - ); - int realloc_sql( - ulong *realloced - ); - int reset_sql( - ulong sql_type - ); - int reset_keys( - ulong sql_type - ); - int reset_upds( - ulong sql_type - ); - int reset_strs( - ulong sql_type - ); - int reset_strs_pos( - ulong sql_type - ); - int push_back_upds( - SPIDER_HS_STRING_REF &info - ); - int request_buf_find( - int link_idx - ); - int request_buf_insert( - int link_idx - ); - int request_buf_update( - int link_idx - ); - int request_buf_delete( - int link_idx - ); - bool need_lock_before_set_sql_for_exec( - ulong sql_type - ); -#ifdef SPIDER_HAS_GROUP_BY_HANDLER - int set_sql_for_exec( - ulong sql_type, - int link_idx, - SPIDER_LINK_IDX_CHAIN *link_idx_chain - ); -#endif - int set_sql_for_exec( - ulong sql_type, - int link_idx - ); - int set_sql_for_exec( - spider_db_copy_table *tgt_ct, - ulong sql_type - ); - int execute_sql( - ulong sql_type, - SPIDER_CONN *conn, - int quick_mode, - int *need_mon - ); - int reset(); - int sts_mode_exchange( - int sts_mode - ); - int show_table_status( - int link_idx, - int sts_mode, - uint flag - ); - int crd_mode_exchange( - int crd_mode - ); - int show_index( - int link_idx, - int crd_mode - ); - int show_records( - int link_idx - ); - int show_last_insert_id( - int link_idx, - ulonglong &last_insert_id - ); - ha_rows explain_select( - const key_range *start_key, - const key_range *end_key, - int link_idx - ); - int lock_tables( - int link_idx - ); - int unlock_tables( - int link_idx - ); - int disable_keys( - SPIDER_CONN *conn, - int link_idx - ); - int enable_keys( - SPIDER_CONN *conn, - int link_idx - ); - int check_table( - SPIDER_CONN *conn, - int link_idx, - HA_CHECK_OPT* check_opt - ); - int repair_table( - SPIDER_CONN *conn, - int link_idx, - HA_CHECK_OPT* check_opt - ); - int analyze_table( - SPIDER_CONN *conn, - int link_idx - ); - int optimize_table( - SPIDER_CONN *conn, - int link_idx - ); - int flush_tables( - SPIDER_CONN *conn, - int link_idx, - bool lock - ); - int flush_logs( - SPIDER_CONN *conn, - int link_idx - ); - int insert_opened_handler( - SPIDER_CONN *conn, - int link_idx - ); - int delete_opened_handler( - SPIDER_CONN *conn, - int link_idx - ); - int sync_from_clone_source( - spider_db_handler *dbton_hdl - ); - bool support_use_handler( - int use_handler - ); - void minimum_select_bitmap_create(); - bool minimum_select_bit_is_set( - uint field_index - ); - void copy_minimum_select_bitmap( - uchar *bitmap - ); - int init_union_table_name_pos(); - int set_union_table_name_pos(); - int reset_union_table_name( - spider_string *str, - int link_idx, - ulong sql_type - ); -#ifdef SPIDER_HAS_GROUP_BY_HANDLER - int append_from_and_tables_part( - spider_fields *fields, - ulong sql_type - ); - int reappend_tables_part( - spider_fields *fields, - ulong sql_type - ); - int append_where_part( - ulong sql_type - ); - int append_having_part( - ulong sql_type - ); - int append_item_type_part( - Item *item, - const char *alias, - uint alias_length, - bool use_fields, - spider_fields *fields, - ulong sql_type - ); - int append_list_item_select_part( - List *select, - const char *alias, - uint alias_length, - bool use_fields, - spider_fields *fields, - ulong sql_type - ); - int append_group_by_part( - ORDER *order, - const char *alias, - uint alias_length, - bool use_fields, - spider_fields *fields, - ulong sql_type - ); - int append_order_by_part( - ORDER *order, - const char *alias, - uint alias_length, - bool use_fields, - spider_fields *fields, - ulong sql_type - ); -#endif -}; diff --git a/storage/spider/spd_db_include.h b/storage/spider/spd_db_include.h index 1a1179183ab..eef5ea0927a 100644 --- a/storage/spider/spd_db_include.h +++ b/storage/spider/spd_db_include.h @@ -15,9 +15,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ #include "hs_compat.h" -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -#include "hstcpcli.hpp" -#endif #define SPIDER_DBTON_SIZE 15 @@ -91,26 +88,6 @@ typedef st_spider_result SPIDER_RESULT; #define SPIDER_SQL_TABLE_NAME_STR "`table_name`" #define SPIDER_SQL_TABLE_NAME_LEN sizeof(SPIDER_SQL_TABLE_NAME_STR) - 1 -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -#define SPIDER_SQL_HS_EQUAL_STR "=" -#define SPIDER_SQL_HS_EQUAL_LEN (sizeof(SPIDER_SQL_HS_EQUAL_STR) - 1) -#define SPIDER_SQL_HS_GT_STR ">" -#define SPIDER_SQL_HS_GT_LEN (sizeof(SPIDER_SQL_HS_GT_STR) - 1) -#define SPIDER_SQL_HS_GTEQUAL_STR ">=" -#define SPIDER_SQL_HS_GTEQUAL_LEN (sizeof(SPIDER_SQL_HS_GTEQUAL_STR) - 1) -#define SPIDER_SQL_HS_LT_STR "<" -#define SPIDER_SQL_HS_LT_LEN (sizeof(SPIDER_SQL_HS_LT_STR) - 1) -#define SPIDER_SQL_HS_INSERT_STR "+" -#define SPIDER_SQL_HS_INSERT_LEN (sizeof(SPIDER_SQL_HS_INSERT_STR) - 1) -#define SPIDER_SQL_HS_UPDATE_STR "U" -#define SPIDER_SQL_HS_UPDATE_LEN (sizeof(SPIDER_SQL_HS_UPDATE_STR) - 1) -#define SPIDER_SQL_HS_DELETE_STR "D" -#define SPIDER_SQL_HS_DELETE_LEN (sizeof(SPIDER_SQL_HS_DELETE_STR) - 1) -#define SPIDER_SQL_HS_INCREMENT_STR "+" -#define SPIDER_SQL_HS_INCREMENT_LEN (sizeof(SPIDER_SQL_HS_INCREMENT_STR) - 1) -#define SPIDER_SQL_HS_DECREMENT_STR "-" -#define SPIDER_SQL_HS_DECREMENT_LEN (sizeof(SPIDER_SQL_HS_DECREMENT_STR) - 1) -#endif #define SPIDER_SQL_HS_LTEQUAL_STR "<=" #define SPIDER_SQL_HS_LTEQUAL_LEN (sizeof(SPIDER_SQL_HS_LTEQUAL_STR) - 1) @@ -202,16 +179,9 @@ typedef st_spider_result SPIDER_RESULT; #define SPIDER_SQL_LOP_CHK_PRM_PRF_LEN (sizeof(SPIDER_SQL_LOP_CHK_PRM_PRF_STR) - 1) #define SPIDER_CONN_KIND_MYSQL (1 << 0) -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -#define SPIDER_CONN_KIND_HS_READ (1 << 2) -#define SPIDER_CONN_KIND_HS_WRITE (1 << 3) -#endif #define SPIDER_SQL_KIND_SQL (1 << 0) #define SPIDER_SQL_KIND_HANDLER (1 << 1) -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -#define SPIDER_SQL_KIND_HS (1 << 2) -#endif #define SPIDER_SQL_TYPE_SELECT_SQL (1 << 0) #define SPIDER_SQL_TYPE_INSERT_SQL (1 << 1) @@ -689,70 +659,6 @@ public: ); }; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -#define SPIDER_HS_UINT32_INFO dena::uint32_info -#define SPIDER_HS_STRING_REF dena::string_ref -#ifndef HANDLERSOCKET_MYSQL_UTIL -#define SPIDER_HS_VECTOR std::vector -class spider_db_hs_string_ref_buffer -{ - SPIDER_HS_VECTOR hs_conds; -public: - spider_db_hs_string_ref_buffer(); - ~spider_db_hs_string_ref_buffer(); - int init(); - void clear(); - int push_back( - SPIDER_HS_STRING_REF &cond - ); - SPIDER_HS_STRING_REF *ptr(); - uint size(); -}; -#else -class spider_db_hs_string_ref_buffer -{ - bool hs_da_init; - DYNAMIC_ARRAY hs_conds; - uint hs_conds_id; - const char *hs_conds_func_name; - const char *hs_conds_file_name; - ulong hs_conds_line_no; -public: - spider_db_hs_string_ref_buffer(); - ~spider_db_hs_string_ref_buffer(); - int init(); - void clear(); - int push_back( - SPIDER_HS_STRING_REF &cond - ); - SPIDER_HS_STRING_REF *ptr(); - uint size(); -}; -#endif - -class spider_db_hs_str_buffer -{ - bool hs_da_init; - DYNAMIC_ARRAY hs_conds; - uint hs_conds_id; - const char *hs_conds_func_name; - const char *hs_conds_file_name; - ulong hs_conds_line_no; -public: - spider_db_hs_str_buffer(); - ~spider_db_hs_str_buffer(); - int init(); - void clear(); - spider_string *add( - uint *strs_pos, - const char *str, - uint str_len - ); -}; - -#define SPIDER_DB_HS_STRING_REF_BUFFER spider_db_hs_string_ref_buffer -#define SPIDER_DB_HS_STR_BUFFER spider_db_hs_str_buffer -#endif struct st_spider_db_request_key { @@ -1155,54 +1061,6 @@ public: SPIDER_DB_RESULT **res1, SPIDER_DB_RESULT **res2 ) = 0; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - virtual int append_sql( - char *sql, - ulong sql_length, - st_spider_db_request_key *request_key - ) = 0; - virtual int append_open_handler( - uint handler_id, - const char *db_name, - const char *table_name, - const char *index_name, - const char *sql, - st_spider_db_request_key *request_key - ) = 0; - virtual int append_select( - uint handler_id, - spider_string *sql, - SPIDER_DB_HS_STRING_REF_BUFFER *keys, - int limit, - int skip, - st_spider_db_request_key *request_key - ) = 0; - virtual int append_insert( - uint handler_id, - SPIDER_DB_HS_STRING_REF_BUFFER *upds, - st_spider_db_request_key *request_key - ) = 0; - virtual int append_update( - uint handler_id, - spider_string *sql, - SPIDER_DB_HS_STRING_REF_BUFFER *keys, - SPIDER_DB_HS_STRING_REF_BUFFER *upds, - int limit, - int skip, - bool increment, - bool decrement, - st_spider_db_request_key *request_key - ) = 0; - virtual int append_delete( - uint handler_id, - spider_string *sql, - SPIDER_DB_HS_STRING_REF_BUFFER *keys, - int limit, - int skip, - st_spider_db_request_key *request_key - ) = 0; - virtual void reset_request_queue() = 0; -#endif virtual size_t escape_string( char *to, const char *from, @@ -1336,11 +1194,6 @@ public: virtual int append_insert_part() = 0; virtual int append_update_part() = 0; virtual int append_delete_part() = 0; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS - virtual int append_increment_update_set_part() = 0; -#endif -#endif virtual int append_update_set_part() = 0; #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS virtual int append_direct_update_set_part() = 0; @@ -1579,23 +1432,6 @@ public: virtual int reset_sql( ulong sql_type ) = 0; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - virtual int reset_keys( - ulong sql_type - ) = 0; - virtual int reset_upds( - ulong sql_type - ) = 0; - virtual int reset_strs( - ulong sql_type - ) = 0; - virtual int reset_strs_pos( - ulong sql_type - ) = 0; - virtual int push_back_upds( - SPIDER_HS_STRING_REF &info - ) = 0; -#endif #ifdef SPIDER_HAS_GROUP_BY_HANDLER virtual int set_sql_for_exec( ulong sql_type, @@ -1958,18 +1794,7 @@ typedef struct st_spider_result_list SPIDER_RESULT *current; KEY *key_info; int key_order; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - ulonglong hs_upd_rows; - SPIDER_DB_RESULT *hs_result; - SPIDER_DB_RESULT_BUFFER *hs_result_buf; - bool hs_has_result; - SPIDER_DB_CONN *hs_conn; -#endif #ifdef HA_CAN_BULK_ACCESS -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - uchar *hs_r_bulk_open_index; - uchar *hs_w_bulk_open_index; -#endif #endif spider_string *sqls; int ha_read_kind; diff --git a/storage/spider/spd_db_mysql.cc b/storage/spider/spd_db_mysql.cc index 53fcda4c17c..847e9413f3b 100644 --- a/storage/spider/spd_db_mysql.cc +++ b/storage/spider/spd_db_mysql.cc @@ -3546,96 +3546,6 @@ int spider_db_mbase::select_binlog_gtid_pos( DBUG_RETURN(0); } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -int spider_db_mbase::append_sql( - char *sql, - ulong sql_length, - st_spider_db_request_key *request_key -) { - DBUG_ENTER("spider_db_mbase::append_sql"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_db_mbase::append_open_handler( - uint handler_id, - const char *db_name, - const char *table_name, - const char *index_name, - const char *sql, - st_spider_db_request_key *request_key -) { - DBUG_ENTER("spider_db_mbase::append_open_handler"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_db_mbase::append_select( - uint handler_id, - spider_string *sql, - SPIDER_DB_HS_STRING_REF_BUFFER *keys, - int limit, - int skip, - st_spider_db_request_key *request_key -) { - DBUG_ENTER("spider_db_mbase::append_select"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_db_mbase::append_insert( - uint handler_id, - SPIDER_DB_HS_STRING_REF_BUFFER *upds, - st_spider_db_request_key *request_key -) { - DBUG_ENTER("spider_db_mbase::append_insert"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_db_mbase::append_update( - uint handler_id, - spider_string *sql, - SPIDER_DB_HS_STRING_REF_BUFFER *keys, - SPIDER_DB_HS_STRING_REF_BUFFER *upds, - int limit, - int skip, - bool increment, - bool decrement, - st_spider_db_request_key *request_key -) { - DBUG_ENTER("spider_db_mbase::append_update"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_db_mbase::append_delete( - uint handler_id, - spider_string *sql, - SPIDER_DB_HS_STRING_REF_BUFFER *keys, - int limit, - int skip, - st_spider_db_request_key *request_key -) { - DBUG_ENTER("spider_db_mbase::append_delete"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -void spider_db_mbase::reset_request_queue() -{ - DBUG_ENTER("spider_db_mbase::reset_request_queue"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_VOID_RETURN; -} -#endif size_t spider_db_mbase::escape_string( char *to, @@ -8437,9 +8347,6 @@ int spider_mbase_handler::init() mysql_share->db_table_str_hash_value[roop_count]; #endif } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - hs_upds.init(); -#endif DBUG_RETURN(0); } @@ -9350,66 +9257,6 @@ int spider_mbase_handler::append_delete( DBUG_RETURN(0); } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS -int spider_mbase_handler::append_increment_update_set_part() -{ - int error_num; - DBUG_ENTER("spider_mbase_handler::append_increment_update_set_part"); - DBUG_PRINT("info",("spider this=%p", this)); - error_num = append_increment_update_set(&update_sql); - DBUG_RETURN(error_num); -} - -int spider_mbase_handler::append_increment_update_set( - spider_string *str -) { - uint field_name_length; - uint roop_count; - Field *field; - DBUG_ENTER("spider_mbase_handler::append_increment_update_set"); - if (str->reserve(SPIDER_SQL_SET_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(SPIDER_SQL_SET_STR, SPIDER_SQL_SET_LEN); - const SPIDER_HS_STRING_REF *value = hs_upds.ptr(); - for (roop_count = 0; roop_count < hs_upds.size(); - roop_count++) - { - if ( - value[roop_count].size() == 1 && - *(value[roop_count].begin()) == '0' - ) - continue; - - Field *top_table_field = - spider->get_top_table_field(spider->hs_pushed_ret_fields[roop_count]); - if (!(field = spider->field_exchange(top_table_field))) - continue; - field_name_length = - mysql_share->column_name_str[field->field_index].length(); - - if (str->reserve(field_name_length * 2 + /* SPIDER_SQL_NAME_QUOTE_LEN */ - 4 + SPIDER_SQL_EQUAL_LEN + SPIDER_SQL_HS_INCREMENT_LEN + - SPIDER_SQL_COMMA_LEN + value[roop_count].size())) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - - mysql_share->append_column_name(str, field->field_index); - str->q_append(SPIDER_SQL_EQUAL_STR, SPIDER_SQL_EQUAL_LEN); - mysql_share->append_column_name(str, field->field_index); - if (spider->hs_increment) - str->q_append(SPIDER_SQL_HS_INCREMENT_STR, - SPIDER_SQL_HS_INCREMENT_LEN); - else - str->q_append(SPIDER_SQL_HS_DECREMENT_STR, - SPIDER_SQL_HS_DECREMENT_LEN); - str->q_append(value[roop_count].begin(), value[roop_count].size()); - str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); - } - str->length(str->length() - SPIDER_SQL_COMMA_LEN); - DBUG_RETURN(0); -} -#endif -#endif int spider_mbase_handler::append_update_set_part() { @@ -9490,13 +9337,6 @@ int spider_mbase_handler::append_direct_update_set_part() int spider_mbase_handler::append_direct_update_set( spider_string *str ) { -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - uint field_name_length; - SPIDER_SHARE *share = spider->share; -#ifndef DBUG_OFF - TABLE *table = spider->get_table(); -#endif -#endif DBUG_ENTER("spider_mbase_handler::append_direct_update_set"); if ( spider->direct_update_kinds == SPIDER_SQL_KIND_SQL && @@ -9512,61 +9352,7 @@ int spider_mbase_handler::append_direct_update_set( if ( (spider->direct_update_kinds & SPIDER_SQL_KIND_SQL) ) { -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - size_t roop_count; - Field *field; - if (str->reserve(SPIDER_SQL_SET_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(SPIDER_SQL_SET_STR, SPIDER_SQL_SET_LEN); - for (roop_count = 0; roop_count < spider->hs_pushed_ret_fields_num; - roop_count++) - { - Field *top_table_field = - spider->get_top_table_field(spider->hs_pushed_ret_fields[roop_count]); - if (!(field = spider->field_exchange(top_table_field))) - continue; - field_name_length = - mysql_share->column_name_str[field->field_index].length(); - if (top_table_field->is_null()) - { - if (str->reserve(field_name_length + /* SPIDER_SQL_NAME_QUOTE_LEN */ - 2 + SPIDER_SQL_EQUAL_LEN + SPIDER_SQL_NULL_LEN + - SPIDER_SQL_COMMA_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - mysql_share->append_column_name(str, field->field_index); - str->q_append(SPIDER_SQL_EQUAL_STR, SPIDER_SQL_EQUAL_LEN); - str->q_append(SPIDER_SQL_NULL_STR, SPIDER_SQL_NULL_LEN); - } else { - if (str->reserve(field_name_length + /* SPIDER_SQL_NAME_QUOTE_LEN */ - 2 + SPIDER_SQL_EQUAL_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - mysql_share->append_column_name(str, field->field_index); - str->q_append(SPIDER_SQL_EQUAL_STR, SPIDER_SQL_EQUAL_LEN); -#ifndef DBUG_OFF - my_bitmap_map *tmp_map = dbug_tmp_use_all_columns(table, - table->read_set); -#endif - if ( - spider_db_mbase_utility-> - append_column_value(spider, str, top_table_field, NULL, - share->access_charset) || - str->reserve(SPIDER_SQL_COMMA_LEN) - ) { -#ifndef DBUG_OFF - dbug_tmp_restore_column_map(table->read_set, tmp_map); -#endif - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - } -#ifndef DBUG_OFF - dbug_tmp_restore_column_map(table->read_set, tmp_map); -#endif - } - str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); - } - str->length(str->length() - SPIDER_SQL_COMMA_LEN); -#else DBUG_ASSERT(0); -#endif } DBUG_RETURN(0); } @@ -13549,53 +13335,6 @@ int spider_mbase_handler::reset_sql( DBUG_RETURN(0); } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -int spider_mbase_handler::reset_keys( - ulong sql_type -) { - DBUG_ENTER("spider_mbase_handler::reset_keys"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_mbase_handler::reset_upds( - ulong sql_type -) { - DBUG_ENTER("spider_mbase_handler::reset_upds"); - DBUG_PRINT("info",("spider this=%p", this)); - hs_upds.clear(); - DBUG_RETURN(0); -} - -int spider_mbase_handler::reset_strs( - ulong sql_type -) { - DBUG_ENTER("spider_mbase_handler::reset_strs"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_mbase_handler::reset_strs_pos( - ulong sql_type -) { - DBUG_ENTER("spider_mbase_handler::reset_strs_pos"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_mbase_handler::push_back_upds( - SPIDER_HS_STRING_REF &info -) { - int error_num; - DBUG_ENTER("spider_mbase_handler::push_back_upds"); - DBUG_PRINT("info",("spider this=%p", this)); - error_num = hs_upds.push_back(info); - DBUG_RETURN(error_num); -} -#endif #ifdef SPIDER_HAS_GROUP_BY_HANDLER int spider_mbase_handler::set_sql_for_exec( diff --git a/storage/spider/spd_db_mysql.h b/storage/spider/spd_db_mysql.h index 9e4d0e8f261..846289f54e7 100644 --- a/storage/spider/spd_db_mysql.h +++ b/storage/spider/spd_db_mysql.h @@ -560,54 +560,6 @@ public: uint binlog_pos_length, SPIDER_DB_RESULT **res ); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - int append_sql( - char *sql, - ulong sql_length, - st_spider_db_request_key *request_key - ); - int append_open_handler( - uint handler_id, - const char *db_name, - const char *table_name, - const char *index_name, - const char *sql, - st_spider_db_request_key *request_key - ); - int append_select( - uint handler_id, - spider_string *sql, - SPIDER_DB_HS_STRING_REF_BUFFER *keys, - int limit, - int skip, - st_spider_db_request_key *request_key - ); - int append_insert( - uint handler_id, - SPIDER_DB_HS_STRING_REF_BUFFER *upds, - st_spider_db_request_key *request_key - ); - int append_update( - uint handler_id, - spider_string *sql, - SPIDER_DB_HS_STRING_REF_BUFFER *keys, - SPIDER_DB_HS_STRING_REF_BUFFER *upds, - int limit, - int skip, - bool increment, - bool decrement, - st_spider_db_request_key *request_key - ); - int append_delete( - uint handler_id, - spider_string *sql, - SPIDER_DB_HS_STRING_REF_BUFFER *keys, - int limit, - int skip, - st_spider_db_request_key *request_key - ); - void reset_request_queue(); -#endif size_t escape_string( char *to, const char *from, @@ -798,9 +750,6 @@ protected: spider_string *exec_ha_sql; bool reading_from_bulk_tmp_table; bool filled_up; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - SPIDER_DB_HS_STRING_REF_BUFFER hs_upds; -#endif SPIDER_INT_HLD *union_table_name_pos_first; SPIDER_INT_HLD *union_table_name_pos_current; public: @@ -907,14 +856,6 @@ public: int append_delete( spider_string *str ); - #if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS - int append_increment_update_set_part(); - int append_increment_update_set( - spider_string *str - ); - #endif - #endif int append_update_set_part(); int append_update_set( spider_string *str @@ -1445,23 +1386,6 @@ public: int reset_sql( ulong sql_type ); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - int reset_keys( - ulong sql_type - ); - int reset_upds( - ulong sql_type - ); - int reset_strs( - ulong sql_type - ); - int reset_strs_pos( - ulong sql_type - ); - int push_back_upds( - SPIDER_HS_STRING_REF &info - ); -#endif #ifdef SPIDER_HAS_GROUP_BY_HANDLER int set_sql_for_exec( ulong sql_type, diff --git a/storage/spider/spd_db_oracle.cc b/storage/spider/spd_db_oracle.cc index 3f64423f042..a452cd2c8dc 100644 --- a/storage/spider/spd_db_oracle.cc +++ b/storage/spider/spd_db_oracle.cc @@ -2249,96 +2249,6 @@ int spider_db_oracle::show_master_status( DBUG_RETURN(0); } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -int spider_db_oracle::append_sql( - char *sql, - ulong sql_length, - st_spider_db_request_key *request_key -) { - DBUG_ENTER("spider_db_oracle::append_sql"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_db_oracle::append_open_handler( - uint handler_id, - const char *db_name, - const char *table_name, - const char *index_name, - const char *sql, - st_spider_db_request_key *request_key -) { - DBUG_ENTER("spider_db_oracle::append_sql"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_db_oracle::append_select( - uint handler_id, - spider_string *sql, - SPIDER_DB_HS_STRING_REF_BUFFER *keys, - int limit, - int skip, - st_spider_db_request_key *request_key -) { - DBUG_ENTER("spider_db_oracle::append_select"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_db_oracle::append_insert( - uint handler_id, - SPIDER_DB_HS_STRING_REF_BUFFER *upds, - st_spider_db_request_key *request_key -) { - DBUG_ENTER("spider_db_oracle::append_insert"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_db_oracle::append_update( - uint handler_id, - spider_string *sql, - SPIDER_DB_HS_STRING_REF_BUFFER *keys, - SPIDER_DB_HS_STRING_REF_BUFFER *upds, - int limit, - int skip, - bool increment, - bool decrement, - st_spider_db_request_key *request_key -) { - DBUG_ENTER("spider_db_oracle::append_update"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_db_oracle::append_delete( - uint handler_id, - spider_string *sql, - SPIDER_DB_HS_STRING_REF_BUFFER *keys, - int limit, - int skip, - st_spider_db_request_key *request_key -) { - DBUG_ENTER("spider_db_oracle::append_delete"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -void spider_db_oracle::reset_request_queue() -{ - DBUG_ENTER("spider_db_oracle::reset_request_queue"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_VOID_RETURN; -} -#endif size_t spider_db_oracle::escape_string( char *to, @@ -5593,9 +5503,6 @@ int spider_oracle_handler::init() oracle_share->db_table_str_hash_value[roop_count]; #endif } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - hs_upds.init(); -#endif DBUG_RETURN(0); } @@ -6364,77 +6271,6 @@ int spider_oracle_handler::append_delete( DBUG_RETURN(0); } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS -int spider_oracle_handler::append_increment_update_set_part() -{ - int error_num; - DBUG_ENTER("spider_oracle_handler::append_increment_update_set_part"); - DBUG_PRINT("info",("spider this=%p", this)); - error_num = append_increment_update_set(&update_sql); - DBUG_RETURN(error_num); -} - -int spider_oracle_handler::append_increment_update_set( - spider_string *str -) { - uint field_name_length; - uint roop_count; - Field *field; - DBUG_ENTER("spider_oracle_handler::append_increment_update_set"); - if (str->reserve(SPIDER_SQL_SET_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(SPIDER_SQL_SET_STR, SPIDER_SQL_SET_LEN); - const SPIDER_HS_STRING_REF *value = hs_upds.ptr(); - for (roop_count = 0; roop_count < hs_upds.size(); - roop_count++) - { - DBUG_PRINT("info",("spider value_size[%u]=%zu", roop_count, - value[roop_count].size())); -#ifndef DBUG_OFF - char print_buf[MAX_FIELD_WIDTH]; - if (value[roop_count].size() < MAX_FIELD_WIDTH) - { - memcpy(print_buf, value[roop_count].begin(), value[roop_count].size()); - print_buf[value[roop_count].size()] = '\0'; - DBUG_PRINT("info",("spider value[%u]=%s", roop_count, print_buf)); - } -#endif - if ( - value[roop_count].size() == 1 && - *(value[roop_count].begin()) == '0' - ) - continue; - - Field *top_table_field = - spider->get_top_table_field(spider->hs_pushed_ret_fields[roop_count]); - if (!(field = spider->field_exchange(top_table_field))) - continue; - field_name_length = - oracle_share->column_name_str[field->field_index].length(); - - if (str->reserve(field_name_length * 2 + /* SPIDER_SQL_NAME_QUOTE_LEN */ - 4 + SPIDER_SQL_EQUAL_LEN + SPIDER_SQL_HS_INCREMENT_LEN + - SPIDER_SQL_COMMA_LEN + value[roop_count].size())) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - - oracle_share->append_column_name(str, field->field_index); - str->q_append(SPIDER_SQL_EQUAL_STR, SPIDER_SQL_EQUAL_LEN); - oracle_share->append_column_name(str, field->field_index); - if (spider->hs_increment) - str->q_append(SPIDER_SQL_HS_INCREMENT_STR, - SPIDER_SQL_HS_INCREMENT_LEN); - else - str->q_append(SPIDER_SQL_HS_DECREMENT_STR, - SPIDER_SQL_HS_DECREMENT_LEN); - str->q_append(value[roop_count].begin(), value[roop_count].size()); - str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); - } - str->length(str->length() - SPIDER_SQL_COMMA_LEN); - DBUG_RETURN(0); -} -#endif -#endif int spider_oracle_handler::append_update_set_part() { @@ -6520,13 +6356,6 @@ int spider_oracle_handler::append_direct_update_set_part() int spider_oracle_handler::append_direct_update_set( spider_string *str ) { -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - uint field_name_length; - SPIDER_SHARE *share = spider->share; -#ifndef DBUG_OFF - TABLE *table = spider->get_table(); -#endif -#endif DBUG_ENTER("spider_oracle_handler::append_direct_update_set"); if ( spider->direct_update_kinds == SPIDER_SQL_KIND_SQL && @@ -6541,61 +6370,7 @@ int spider_oracle_handler::append_direct_update_set( if ( (spider->direct_update_kinds & SPIDER_SQL_KIND_SQL) ) { -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - size_t roop_count; - Field *field; - if (str->reserve(SPIDER_SQL_SET_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(SPIDER_SQL_SET_STR, SPIDER_SQL_SET_LEN); - for (roop_count = 0; roop_count < spider->hs_pushed_ret_fields_num; - roop_count++) - { - Field *top_table_field = - spider->get_top_table_field(spider->hs_pushed_ret_fields[roop_count]); - if (!(field = spider->field_exchange(top_table_field))) - continue; - field_name_length = - oracle_share->column_name_str[field->field_index].length(); - if (top_table_field->is_null()) - { - if (str->reserve(field_name_length + /* SPIDER_SQL_NAME_QUOTE_LEN */ - 2 + SPIDER_SQL_EQUAL_LEN + SPIDER_SQL_NULL_LEN + - SPIDER_SQL_COMMA_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - oracle_share->append_column_name(str, field->field_index); - str->q_append(SPIDER_SQL_EQUAL_STR, SPIDER_SQL_EQUAL_LEN); - str->q_append(SPIDER_SQL_NULL_STR, SPIDER_SQL_NULL_LEN); - } else { - if (str->reserve(field_name_length + /* SPIDER_SQL_NAME_QUOTE_LEN */ - 2 + SPIDER_SQL_EQUAL_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - oracle_share->append_column_name(str, field->field_index); - str->q_append(SPIDER_SQL_EQUAL_STR, SPIDER_SQL_EQUAL_LEN); -#ifndef DBUG_OFF - my_bitmap_map *tmp_map = dbug_tmp_use_all_columns(table, - table->read_set); -#endif - if ( - spider_db_oracle_utility. - append_column_value(spider, str, top_table_field, NULL, - share->access_charset) || - str->reserve(SPIDER_SQL_COMMA_LEN) - ) { -#ifndef DBUG_OFF - dbug_tmp_restore_column_map(table->read_set, tmp_map); -#endif - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - } -#ifndef DBUG_OFF - dbug_tmp_restore_column_map(table->read_set, tmp_map); -#endif - } - str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); - } - str->length(str->length() - SPIDER_SQL_COMMA_LEN); -#else DBUG_ASSERT(0); -#endif } DBUG_RETURN(0); } @@ -10727,53 +10502,6 @@ int spider_oracle_handler::reset_sql( DBUG_RETURN(0); } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -int spider_oracle_handler::reset_keys( - ulong sql_type -) { - DBUG_ENTER("spider_oracle_handler::reset_keys"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_oracle_handler::reset_upds( - ulong sql_type -) { - DBUG_ENTER("spider_oracle_handler::reset_upds"); - DBUG_PRINT("info",("spider this=%p", this)); - hs_upds.clear(); - DBUG_RETURN(0); -} - -int spider_oracle_handler::reset_strs( - ulong sql_type -) { - DBUG_ENTER("spider_oracle_handler::reset_strs"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_oracle_handler::reset_strs_pos( - ulong sql_type -) { - DBUG_ENTER("spider_oracle_handler::reset_strs_pos"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_oracle_handler::push_back_upds( - SPIDER_HS_STRING_REF &info -) { - int error_num; - DBUG_ENTER("spider_oracle_handler::push_back_upds"); - DBUG_PRINT("info",("spider this=%p", this)); - error_num = hs_upds.push_back(info); - DBUG_RETURN(error_num); -} -#endif bool spider_oracle_handler::need_lock_before_set_sql_for_exec( ulong sql_type diff --git a/storage/spider/spd_db_oracle.h b/storage/spider/spd_db_oracle.h index c8c1522599f..357fee35c67 100644 --- a/storage/spider/spd_db_oracle.h +++ b/storage/spider/spd_db_oracle.h @@ -473,54 +473,6 @@ public: SPIDER_DB_RESULT **res1, SPIDER_DB_RESULT **res2 ); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - int append_sql( - char *sql, - ulong sql_length, - st_spider_db_request_key *request_key - ); - int append_open_handler( - uint handler_id, - const char *db_name, - const char *table_name, - const char *index_name, - const char *sql, - st_spider_db_request_key *request_key - ); - int append_select( - uint handler_id, - spider_string *sql, - SPIDER_DB_HS_STRING_REF_BUFFER *keys, - int limit, - int skip, - st_spider_db_request_key *request_key - ); - int append_insert( - uint handler_id, - SPIDER_DB_HS_STRING_REF_BUFFER *upds, - st_spider_db_request_key *request_key - ); - int append_update( - uint handler_id, - spider_string *sql, - SPIDER_DB_HS_STRING_REF_BUFFER *keys, - SPIDER_DB_HS_STRING_REF_BUFFER *upds, - int limit, - int skip, - bool increment, - bool decrement, - st_spider_db_request_key *request_key - ); - int append_delete( - uint handler_id, - spider_string *sql, - SPIDER_DB_HS_STRING_REF_BUFFER *keys, - int limit, - int skip, - st_spider_db_request_key *request_key - ); - void reset_request_queue(); -#endif size_t escape_string( char *to, const char *from, @@ -685,9 +637,6 @@ private: bool filled_up; bool select_rownum_appended; bool update_rownum_appended; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - SPIDER_DB_HS_STRING_REF_BUFFER hs_upds; -#endif SPIDER_INT_HLD *union_table_name_pos_first; SPIDER_INT_HLD *union_table_name_pos_current; public: @@ -792,14 +741,6 @@ public: int append_delete( spider_string *str ); - #if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS - int append_increment_update_set_part(); - int append_increment_update_set( - spider_string *str - ); - #endif - #endif int append_update_set_part(); int append_update_set( spider_string *str @@ -1330,23 +1271,6 @@ public: int reset_sql( ulong sql_type ); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - int reset_keys( - ulong sql_type - ); - int reset_upds( - ulong sql_type - ); - int reset_strs( - ulong sql_type - ); - int reset_strs_pos( - ulong sql_type - ); - int push_back_upds( - SPIDER_HS_STRING_REF &info - ); -#endif bool need_lock_before_set_sql_for_exec( ulong sql_type ); diff --git a/storage/spider/spd_direct_sql.cc b/storage/spider/spd_direct_sql.cc index 524e8b7443a..15b777ea739 100644 --- a/storage/spider/spd_direct_sql.cc +++ b/storage/spider/spd_direct_sql.cc @@ -197,54 +197,23 @@ int spider_udf_direct_sql_create_conn_key( spider_dbton[roop_count2].wrapper && !strcmp(direct_sql->tgt_wrapper, spider_dbton[roop_count2].wrapper) ) { -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (direct_sql->access_mode == 0) - { -#endif if (spider_dbton[roop_count2].db_access_type == SPIDER_DB_ACCESS_TYPE_SQL) { direct_sql->dbton_id = roop_count2; break; } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else { - if (spider_dbton[roop_count2].db_access_type == - SPIDER_DB_ACCESS_TYPE_NOSQL) - { - direct_sql->dbton_id = roop_count2; - break; - } - } -#endif } } if (direct_sql->dbton_id == SPIDER_DBTON_SIZE) { -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (direct_sql->access_mode == 0) - { -#endif my_printf_error( ER_SPIDER_SQL_WRAPPER_IS_INVALID_NUM, ER_SPIDER_SQL_WRAPPER_IS_INVALID_STR, MYF(0), direct_sql->tgt_wrapper); DBUG_RETURN(ER_SPIDER_SQL_WRAPPER_IS_INVALID_NUM); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else { - my_printf_error( - ER_SPIDER_NOSQL_WRAPPER_IS_INVALID_NUM, - ER_SPIDER_NOSQL_WRAPPER_IS_INVALID_STR, - MYF(0), direct_sql->tgt_wrapper); - DBUG_RETURN(ER_SPIDER_NOSQL_WRAPPER_IS_INVALID_NUM); - } -#endif } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (direct_sql->access_mode == 0) - { -#endif tables_on_different_db_are_joinable = spider_dbton[direct_sql->dbton_id].db_util-> tables_on_different_db_are_joinable(); @@ -267,16 +236,6 @@ int spider_udf_direct_sql_create_conn_key( + direct_sql->tgt_default_file_length + 1 + direct_sql->tgt_default_group_length + 1 + direct_sql->tgt_dsn_length; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else { - direct_sql->conn_key_length - = 1 - + direct_sql->tgt_wrapper_length + 1 - + direct_sql->tgt_host_length + 1 - + 5 + 1 - + direct_sql->tgt_socket_length; - } -#endif if (!(direct_sql->conn_key = (char *) spider_malloc(spider_current_trx, SPD_MID_UDF_DIRECT_SQL_CREATE_CONN_KEY_1, direct_sql->conn_key_length + 1, MYF(MY_WME | MY_ZEROFILL))) @@ -299,20 +258,16 @@ int spider_udf_direct_sql_create_conn_key( tmp_name = strmov(tmp_name + 1, direct_sql->tgt_socket); } else tmp_name++; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (direct_sql->access_mode == 0) + if (!tables_on_different_db_are_joinable) { -#endif - if (!tables_on_different_db_are_joinable) + if (direct_sql->tgt_default_db_name) { - if (direct_sql->tgt_default_db_name) - { - DBUG_PRINT("info",("spider tgt_default_db_name=%s", - direct_sql->tgt_default_db_name)); - tmp_name = strmov(tmp_name + 1, direct_sql->tgt_default_db_name); - } else - tmp_name++; - } + DBUG_PRINT("info",("spider tgt_default_db_name=%s", + direct_sql->tgt_default_db_name)); + tmp_name = strmov(tmp_name + 1, direct_sql->tgt_default_db_name); + } else + tmp_name++; + } if (direct_sql->tgt_username) { DBUG_PRINT("info",("spider tgt_username=%s", direct_sql->tgt_username)); @@ -380,9 +335,6 @@ int spider_udf_direct_sql_create_conn_key( tmp_name = strmov(tmp_name + 1, direct_sql->tgt_dsn); } else tmp_name++; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } -#endif #ifdef SPIDER_HAS_HASH_VALUE_TYPE direct_sql->conn_key_hash_value = my_calc_hash(&spider_open_connections, (uchar*) direct_sql->conn_key, direct_sql->conn_key_length); @@ -428,10 +380,6 @@ SPIDER_CONN *spider_udf_direct_sql_create_conn( UTC = my_tz_find(current_thd, &tz_00_name); } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (direct_sql->access_mode == 0) - { -#endif tables_on_different_db_are_joinable = spider_dbton[direct_sql->dbton_id].db_util-> tables_on_different_db_are_joinable(); @@ -464,24 +412,6 @@ SPIDER_CONN *spider_udf_direct_sql_create_conn( goto error_alloc_conn; } conn->default_database.init_calc_mem(SPD_MID_UDF_DIRECT_SQL_CREATE_CONN_2); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else { - if (!(conn = (SPIDER_CONN *) - spider_bulk_malloc(spider_current_trx, SPD_MID_UDF_DIRECT_SQL_CREATE_CONN_3, MYF(MY_WME | MY_ZEROFILL), - &conn, (uint) (sizeof(*conn)), - &tmp_name, (uint) (direct_sql->conn_key_length + 1), - &tmp_host, (uint) (direct_sql->tgt_host_length + 1), - &tmp_socket, (uint) (direct_sql->tgt_socket_length + 1), - &tmp_wrapper, (uint) (direct_sql->tgt_wrapper_length + 1), - &need_mon, (uint) (sizeof(int)), - NullS)) - ) { - *error_num = HA_ERR_OUT_OF_MEM; - goto error_alloc_conn; - } - conn->default_database.init_calc_mem(SPD_MID_UDF_DIRECT_SQL_CREATE_CONN_4); - } -#endif conn->conn_key_length = direct_sql->conn_key_length; conn->conn_key = tmp_name; @@ -493,10 +423,6 @@ SPIDER_CONN *spider_udf_direct_sql_create_conn( conn->tgt_host_length = direct_sql->tgt_host_length; conn->tgt_host = tmp_host; memcpy(conn->tgt_host, direct_sql->tgt_host, direct_sql->tgt_host_length); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (direct_sql->access_mode == 0) - { -#endif conn->tgt_port = direct_sql->tgt_port; spider_maybe_memcpy_string( &conn->tgt_socket, direct_sql->tgt_socket, tmp_socket, @@ -536,18 +462,6 @@ SPIDER_CONN *spider_udf_direct_sql_create_conn( &conn->tgt_dsn, direct_sql->tgt_dsn, tmp_dsn, &conn->tgt_dsn_length, direct_sql->tgt_dsn_length); conn->tgt_ssl_vsc = direct_sql->tgt_ssl_vsc; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else { - conn->hs_port = direct_sql->tgt_port; - if (direct_sql->tgt_socket) - { - conn->hs_sock_length = direct_sql->tgt_socket_length; - conn->hs_sock = tmp_socket; - memcpy(conn->hs_sock, direct_sql->tgt_socket, - direct_sql->tgt_socket_length); - } - } -#endif conn->dbton_id = direct_sql->dbton_id; conn->conn_need_mon = need_mon; conn->need_mon = need_mon; @@ -566,19 +480,7 @@ SPIDER_CONN *spider_udf_direct_sql_create_conn( conn->semi_trx_isolation = -2; conn->semi_trx_isolation_chk = FALSE; conn->semi_trx_chk = FALSE; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (direct_sql->access_mode == 0) - { -#endif conn->conn_kind = SPIDER_CONN_KIND_MYSQL; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else if (direct_sql->access_mode == 1) - { - conn->conn_kind = SPIDER_CONN_KIND_HS_READ; - } else { - conn->conn_kind = SPIDER_CONN_KIND_HS_WRITE; - } -#endif if (mysql_mutex_init(spd_key_mutex_mta_conn, &conn->mta_conn_mutex, MY_MUTEX_INIT_FAST)) @@ -665,82 +567,26 @@ SPIDER_CONN *spider_udf_direct_sql_get_conn( ) { SPIDER_CONN *conn = NULL; DBUG_ENTER("spider_udf_direct_sql_get_conn"); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - DBUG_PRINT("info",("spider direct_sql->access_mode=%d", - direct_sql->access_mode)); -#endif #ifdef SPIDER_HAS_HASH_VALUE_TYPE if ( -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - (direct_sql->access_mode == 0 && -#endif !(conn = (SPIDER_CONN*) my_hash_search_using_hash_value( &trx->trx_conn_hash, direct_sql->conn_key_hash_value, (uchar*) direct_sql->conn_key, direct_sql->conn_key_length)) -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - ) || - (direct_sql->access_mode == 1 && - !(conn = (SPIDER_CONN*) my_hash_search_using_hash_value( - &trx->trx_direct_hs_r_conn_hash, direct_sql->conn_key_hash_value, - (uchar*) direct_sql->conn_key, direct_sql->conn_key_length)) - ) || - (direct_sql->access_mode == 2 && - !(conn = (SPIDER_CONN*) my_hash_search_using_hash_value( - &trx->trx_direct_hs_w_conn_hash, direct_sql->conn_key_hash_value, - (uchar*) direct_sql->conn_key, direct_sql->conn_key_length)) - ) -#endif ) #else if ( -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - (direct_sql->access_mode == 0 && -#endif !(conn = (SPIDER_CONN*) my_hash_search(&trx->trx_conn_hash, (uchar*) direct_sql->conn_key, direct_sql->conn_key_length)) -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - ) || - (direct_sql->access_mode == 1 && - !(conn = (SPIDER_CONN*) my_hash_search(&trx->trx_direct_hs_r_conn_hash, - (uchar*) direct_sql->conn_key, direct_sql->conn_key_length)) - ) || - (direct_sql->access_mode == 2 && - !(conn = (SPIDER_CONN*) my_hash_search(&trx->trx_direct_hs_w_conn_hash, - (uchar*) direct_sql->conn_key, direct_sql->conn_key_length)) - ) -#endif ) #endif { if ( -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - (direct_sql->access_mode == 0 && -#endif ( (spider_param_conn_recycle_mode(trx->thd) & 1) || spider_param_conn_recycle_strict(trx->thd) ) -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - ) || - (direct_sql->access_mode == 1 && - ( - (spider_param_hs_r_conn_recycle_mode(trx->thd) & 1) || - spider_param_hs_r_conn_recycle_strict(trx->thd) - ) - ) || - (direct_sql->access_mode == 2 && - ( - (spider_param_hs_w_conn_recycle_mode(trx->thd) & 1) || - spider_param_hs_w_conn_recycle_strict(trx->thd) - ) - ) -#endif ) { -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (direct_sql->access_mode == 0) - { -#endif pthread_mutex_lock(&spider_conn_mutex); #ifdef SPIDER_HAS_HASH_VALUE_TYPE if (!(conn = (SPIDER_CONN*) my_hash_search_using_hash_value( @@ -766,9 +612,6 @@ SPIDER_CONN *spider_udf_direct_sql_get_conn( pthread_mutex_unlock(&spider_conn_mutex); DBUG_PRINT("info",("spider get global conn")); } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } -#endif } else { DBUG_PRINT("info",("spider create new conn")); /* conn_recycle_strict = 0 and conn_recycle_mode = 0 or 2 */ @@ -778,10 +621,6 @@ SPIDER_CONN *spider_udf_direct_sql_get_conn( conn->thd = trx->thd; conn->priority = direct_sql->priority; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (direct_sql->access_mode == 0) - { -#endif uint old_elements = trx->trx_conn_hash.array.max_element; #ifdef HASH_UPDATE_WITH_HASH_VALUE if (my_hash_insert_with_hash_value(&trx->trx_conn_hash, @@ -801,50 +640,6 @@ SPIDER_CONN *spider_udf_direct_sql_get_conn( (trx->trx_conn_hash.array.max_element - old_elements) * trx->trx_conn_hash.array.size_of_element); } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else if (direct_sql->access_mode == 1) - { - uint old_elements = trx->trx_direct_hs_r_conn_hash.array.max_element; -#ifdef HASH_UPDATE_WITH_HASH_VALUE - if (my_hash_insert_with_hash_value(&trx->trx_direct_hs_r_conn_hash, - direct_sql->conn_key_hash_value, (uchar*) conn)) -#else - if (my_hash_insert(&trx->trx_direct_hs_r_conn_hash, (uchar*) conn)) -#endif - { - spider_free_conn(conn); - *error_num = HA_ERR_OUT_OF_MEM; - goto error; - } - if (trx->trx_direct_hs_r_conn_hash.array.max_element > old_elements) - { - spider_alloc_calc_mem(spider_current_trx, - trx->trx_direct_hs_r_conn_hash, - (trx->trx_direct_hs_r_conn_hash.array.max_element - old_elements) * - trx->trx_direct_hs_r_conn_hash.array.size_of_element); - } - } else { - uint old_elements = trx->trx_direct_hs_w_conn_hash.array.max_element; -#ifdef HASH_UPDATE_WITH_HASH_VALUE - if (my_hash_insert_with_hash_value(&trx->trx_direct_hs_w_conn_hash, - direct_sql->conn_key_hash_value, (uchar*) conn)) -#else - if (my_hash_insert(&trx->trx_direct_hs_w_conn_hash, (uchar*) conn)) -#endif - { - spider_free_conn(conn); - *error_num = HA_ERR_OUT_OF_MEM; - goto error; - } - if (trx->trx_direct_hs_w_conn_hash.array.max_element > old_elements) - { - spider_alloc_calc_mem(spider_current_trx, - trx->trx_direct_hs_w_conn_hash, - (trx->trx_direct_hs_w_conn_hash.array.max_element - old_elements) * - trx->trx_direct_hs_w_conn_hash.array.size_of_element); - } - } -#endif } if (conn->queued_connect) @@ -1080,9 +875,6 @@ static void spider_minus_1(SPIDER_DIRECT_SQL *direct_sql) direct_sql->net_write_timeout = -1; direct_sql->bulk_insert_rows = -1; direct_sql->connection_channel = -1; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - direct_sql->access_mode = -1; -#endif direct_sql->use_real_table = -1; direct_sql->error_rw_mode = -1; for (int i = 0; i < direct_sql->table_count; i++) @@ -1133,9 +925,6 @@ int spider_udf_parse_direct_sql_param( error_num= parse.fail(true); goto error; case 3: -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - SPIDER_PARAM_INT_WITH_MAX("acm", access_mode, 0, 2); -#endif SPIDER_PARAM_LONGLONG("bir", bulk_insert_rows, 0); SPIDER_PARAM_INT_WITH_MAX("cch", connection_channel, 0, 63); SPIDER_PARAM_INT("cto", connect_timeout, 0); @@ -1188,9 +977,6 @@ int spider_udf_parse_direct_sql_param( error_num= parse.fail(true); goto error; case 11: -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - SPIDER_PARAM_INT_WITH_MAX("access_mode", access_mode, 0, 2); -#endif error_num= parse.fail(true); goto error; case 12: @@ -1263,9 +1049,6 @@ int spider_udf_set_direct_sql_param_default( } if ( -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - direct_sql->access_mode == 0 && -#endif !direct_sql->tgt_socket && (!direct_sql->tgt_host || !strcmp(direct_sql->tgt_host, my_localhost)) ) { @@ -1392,20 +1175,9 @@ int spider_udf_set_direct_sql_param_default( } } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (direct_sql->access_mode == -1) - direct_sql->access_mode = 0; -#endif if (direct_sql->tgt_port == -1) { -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (direct_sql->access_mode == 1) - direct_sql->tgt_port = 9998; - else if (direct_sql->access_mode == 2) - direct_sql->tgt_port = 9999; - else -#endif direct_sql->tgt_port = MYSQL_PORT; } else if (direct_sql->tgt_port < 0) @@ -1640,15 +1412,8 @@ long long spider_direct_sql_body( goto error; } } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (trx->trx_start && direct_sql->access_mode != 1) - { -#endif trx->updated_in_this_trx = TRUE; DBUG_PRINT("info",("spider trx->updated_in_this_trx=TRUE")); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } -#endif use_real_table = spider_param_udf_ds_use_real_table(thd, direct_sql->use_real_table); for (roop_count = 0; roop_count < direct_sql->table_count; roop_count++) diff --git a/storage/spider/spd_include.h b/storage/spider/spd_include.h index d6525b7b730..09482b276e8 100644 --- a/storage/spider/spd_include.h +++ b/storage/spider/spd_include.h @@ -611,11 +611,6 @@ typedef struct st_spider_conn #endif int link_idx; spider_db_conn *db_conn; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - query_id_t hsc_query_id; - ulonglong hs_pre_age; - ulonglong hs_age; -#endif uint opened_handlers; ulonglong conn_id; ulonglong connection_id; @@ -687,10 +682,6 @@ typedef struct st_spider_conn char *tgt_dsn; long tgt_port; long tgt_ssl_vsc; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - char *hs_sock; - long hs_port; -#endif uint tgt_host_length; uint tgt_username_length; @@ -706,9 +697,6 @@ typedef struct st_spider_conn uint tgt_default_file_length; uint tgt_default_group_length; uint tgt_dsn_length; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - uint hs_sock_length; -#endif uint dbton_id; #ifndef WITHOUT_SPIDER_BG_SEARCH @@ -898,11 +886,6 @@ typedef struct st_spider_wide_handler uchar *rnd_write_bitmap; SPIDER_CONDITION *condition; void *owner; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS - uint32 *hs_pushed_ret_fields; -#endif -#endif #ifdef WITH_PARTITION_STORAGE_ENGINE SPIDER_PARTITION_HANDLER *partition_handler; #endif @@ -913,11 +896,6 @@ typedef struct st_spider_wide_handler TABLE_SHARE *top_share; enum thr_lock_type lock_type; uchar lock_table_type; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS - uint32 hs_pushed_strref_num; -#endif -#endif int lock_mode; int external_lock_type; int cond_check_error; @@ -930,13 +908,6 @@ typedef struct st_spider_wide_handler #endif #ifdef HA_CAN_BULK_ACCESS ulonglong external_lock_cnt; -#endif -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS - size_t hs_pushed_ret_fields_num; - size_t hs_pushed_ret_fields_size; - size_t hs_pushed_lcl_fields_num; -#endif #endif bool between_flg; bool idx_bitmap_is_set; @@ -954,12 +925,6 @@ typedef struct st_spider_wide_handler bool write_can_replace; bool insert_with_update; bool cond_check; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS - bool hs_increment; - bool hs_decrement; -#endif -#endif bool semi_table_lock; } SPIDER_WIDE_HANDLER; @@ -995,30 +960,6 @@ typedef struct st_spider_transaction const char *trx_another_conn_hash_func_name; const char *trx_another_conn_hash_file_name; ulong trx_another_conn_hash_line_no; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - HASH trx_hs_r_conn_hash; - uint trx_hs_r_conn_hash_id; - const char *trx_hs_r_conn_hash_func_name; - const char *trx_hs_r_conn_hash_file_name; - ulong trx_hs_r_conn_hash_line_no; - HASH trx_hs_w_conn_hash; - uint trx_hs_w_conn_hash_id; - const char *trx_hs_w_conn_hash_func_name; - const char *trx_hs_w_conn_hash_file_name; - ulong trx_hs_w_conn_hash_line_no; -#endif -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - HASH trx_direct_hs_r_conn_hash; - uint trx_direct_hs_r_conn_hash_id; - const char *trx_direct_hs_r_conn_hash_func_name; - const char *trx_direct_hs_r_conn_hash_file_name; - ulong trx_direct_hs_r_conn_hash_line_no; - HASH trx_direct_hs_w_conn_hash; - uint trx_direct_hs_w_conn_hash_id; - const char *trx_direct_hs_w_conn_hash_func_name; - const char *trx_direct_hs_w_conn_hash_file_name; - ulong trx_direct_hs_w_conn_hash_line_no; -#endif HASH trx_alter_table_hash; uint trx_alter_table_hash_id; const char *trx_alter_table_hash_func_name; @@ -1034,10 +975,6 @@ typedef struct st_spider_transaction SPIDER_CONN *join_trx_top; ulonglong spider_thread_id; ulonglong trx_conn_adjustment; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - ulonglong trx_hs_r_conn_adjustment; - ulonglong trx_hs_w_conn_adjustment; -#endif uint locked_connections; ulonglong direct_update_count; @@ -1045,9 +982,6 @@ typedef struct st_spider_transaction ulonglong direct_order_limit_count; ulonglong direct_aggregate_count; ulonglong parallel_search_count; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - ulonglong hs_result_free_count; -#endif #ifdef HA_CAN_BULK_ACCESS SPIDER_CONN *bulk_access_conn_first; @@ -1263,9 +1197,6 @@ typedef struct st_spider_share int error_read_mode; int error_write_mode; int active_link_count; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - longlong hs_result_free_size; -#endif #ifdef HA_CAN_BULK_ACCESS int bulk_access_free; #endif @@ -1284,10 +1215,6 @@ typedef struct st_spider_share #ifdef SPIDER_HAS_HASH_VALUE_TYPE my_hash_value_type *conn_keys_hash_value; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - my_hash_value_type *hs_read_conn_keys_hash_value; - my_hash_value_type *hs_write_conn_keys_hash_value; -#endif #endif char **server_names; char **tgt_table_names; @@ -1309,12 +1236,6 @@ typedef struct st_spider_share char **tgt_pk_names; char **tgt_sequence_names; char **conn_keys; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - char **hs_read_socks; - char **hs_write_socks; - char **hs_read_conn_keys; - char **hs_write_conn_keys; -#endif long *tgt_ports; long *tgt_ssl_vscs; long *link_statuses; @@ -1330,13 +1251,6 @@ typedef struct st_spider_share #endif longlong *monitoring_limit; longlong *monitoring_sid; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - long *use_hs_reads; - long *use_hs_writes; - long *hs_read_ports; - long *hs_write_ports; - long *hs_write_to_reads; -#endif long *use_handlers; long *connect_timeouts; long *net_read_timeouts; @@ -1365,17 +1279,8 @@ typedef struct st_spider_share uint *tgt_pk_names_lengths; uint *tgt_sequence_names_lengths; uint *conn_keys_lengths; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - uint *hs_read_socks_lengths; - uint *hs_write_socks_lengths; - uint *hs_read_conn_keys_lengths; - uint *hs_write_conn_keys_lengths; -#endif /* The index in `spider_dbton' of each data node link. */ uint *sql_dbton_ids; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - uint *hs_dbton_ids; -#endif uint server_names_charlen; uint tgt_table_names_charlen; @@ -1397,12 +1302,6 @@ typedef struct st_spider_share uint tgt_pk_names_charlen; uint tgt_sequence_names_charlen; uint conn_keys_charlen; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - uint hs_read_socks_charlen; - uint hs_write_socks_charlen; - uint hs_read_conn_keys_charlen; - uint hs_write_conn_keys_charlen; -#endif uint server_names_length; uint tgt_table_names_length; @@ -1424,12 +1323,6 @@ typedef struct st_spider_share uint tgt_pk_names_length; uint tgt_sequence_names_length; uint conn_keys_length; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - uint hs_read_socks_length; - uint hs_write_socks_length; - uint hs_read_conn_keys_length; - uint hs_write_conn_keys_length; -#endif uint tgt_ports_length; uint tgt_ssl_vscs_length; uint link_statuses_length; @@ -1445,13 +1338,6 @@ typedef struct st_spider_share #endif uint monitoring_limit_length; uint monitoring_sid_length; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - uint use_hs_reads_length; - uint use_hs_writes_length; - uint hs_read_ports_length; - uint hs_write_ports_length; - uint hs_write_to_reads_length; -#endif uint use_handlers_length; uint connect_timeouts_length; uint net_read_timeouts_length; @@ -1475,14 +1361,6 @@ typedef struct st_spider_share uint use_sql_dbton_ids[SPIDER_DBTON_SIZE]; /* Inverse map of `use_sql_dbton_ids'. */ uint sql_dbton_id_to_seq[SPIDER_DBTON_SIZE]; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - uint use_hs_dbton_count; - /* Actual size is `use_hs_dbton_count'. Values are the indices of - item in `spider_dbton'. */ - uint use_hs_dbton_ids[SPIDER_DBTON_SIZE]; - /* Inverse map of `use_hs_dbton_ids'. */ - uint hs_dbton_id_to_seq[SPIDER_DBTON_SIZE]; -#endif SPIDER_ALTER_TABLE alter_table; SPIDER_WIDE_SHARE *wide_share; @@ -1538,9 +1416,6 @@ typedef struct st_spider_direct_sql int net_write_timeout; longlong bulk_insert_rows; int connection_channel; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - int access_mode; -#endif int use_real_table; int error_rw_mode; diff --git a/storage/spider/spd_param.cc b/storage/spider/spd_param.cc index db3c958c955..12080cc2a27 100644 --- a/storage/spider/spd_param.cc +++ b/storage/spider/spd_param.cc @@ -171,19 +171,6 @@ static int spider_parallel_search(THD *thd, SHOW_VAR *var, void *, DBUG_RETURN(error_num); } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -static int spider_hs_result_free(THD *thd, SHOW_VAR *var, void *, - system_status_var *, enum_var_type) -{ - int error_num = 0; - SPIDER_TRX *trx; - DBUG_ENTER("spider_hs_result_free"); - var->type = SHOW_LONGLONG; - if ((trx = spider_get_trx(thd, TRUE, &error_num))) - var->value = (char *) &trx->hs_result_free_count; - DBUG_RETURN(error_num); -} -#endif struct st_mysql_show_var spider_status_variables[] = { @@ -214,13 +201,6 @@ struct st_mysql_show_var spider_status_variables[] = (char *) &spider_direct_aggregate, SHOW_FUNC}, {"Spider_parallel_search", (char *) &spider_parallel_search, SHOW_FUNC}, -#endif -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -#ifdef SPIDER_HAS_SHOW_SIMPLE_FUNC - {"Spider_hs_result_free", (char *) &spider_hs_result_free, SHOW_SIMPLE_FUNC}, -#else - {"Spider_hs_result_free", (char *) &spider_hs_result_free, SHOW_FUNC}, -#endif #endif {NullS, NullS, SHOW_LONG} }; @@ -582,25 +562,6 @@ static MYSQL_THDVAR_INT( SPIDER_THDVAR_OVERRIDE_VALUE_FUNC(int, reset_sql_alloc) -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -/* - -1 :fallback to default - 0-:result free size for handlersocket - */ -static MYSQL_THDVAR_LONGLONG( - hs_result_free_size, /* name */ - PLUGIN_VAR_RQCMDARG, /* opt */ - "Result free size for handlersocket", /* comment */ - NULL, /* check */ - NULL, /* update */ - 1048576, /* def */ - -1, /* min */ - 9223372036854775807LL, /* max */ - 0 /* blk */ -); - -SPIDER_THDVAR_OVERRIDE_VALUE_FUN(longlong, hs_result_free_size) -#endif /* -1 :fallback to default @@ -1536,25 +1497,6 @@ static MYSQL_THDVAR_INT( SPIDER_THDVAR_VALUE_FUNC(double, ping_interval_at_trx_start) -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -/* - 0 :always ping - 1-:interval - */ -static MYSQL_THDVAR_INT( - hs_ping_interval, /* name */ - PLUGIN_VAR_RQCMDARG, /* opt */ - "Ping interval for handlersocket", /* comment */ - NULL, /* check */ - NULL, /* update */ - 30, /* def */ - 0, /* min */ - 2147483647, /* max */ - 0 /* blk */ -); - -SPIDER_THDVAR_VALUE_FUNC(double, hs_ping_interval) -#endif /* -1 :fallback to default @@ -1960,119 +1902,6 @@ static MYSQL_SYSVAR_LONGLONG( SPIDER_SYSVAR_OVERRIDE_VALUE_FUNC(longlong, udf_ct_bulk_insert_rows) -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -/* - 0: no recycle - 1: recycle in instance - 2: recycle in thread - */ -static MYSQL_THDVAR_UINT( - hs_r_conn_recycle_mode, /* name */ - PLUGIN_VAR_RQCMDARG, /* opt */ - "Handlersocket connection recycle mode", /* comment */ - NULL, /* check */ - NULL, /* update */ - 2, /* def */ - 0, /* min */ - 2, /* max */ - 0 /* blk */ -); - -SPIDER_THDVAR_VALUE_FUNC(uint, hs_r_conn_recycle_mode) - -/* - 0: weak - 1: strict - */ -static MYSQL_THDVAR_UINT( - hs_r_conn_recycle_strict, /* name */ - PLUGIN_VAR_RQCMDARG, /* opt */ - "Strict handlersocket connection recycle", /* comment */ - NULL, /* check */ - NULL, /* update */ - 0, /* def */ - 0, /* min */ - 1, /* max */ - 0 /* blk */ -); - -SPIDER_THDVAR_VALUE_FUNC(uint, hs_r_conn_recycle_strict) - -/* - 0: no recycle - 1: recycle in instance - 2: recycle in thread - */ -static MYSQL_THDVAR_UINT( - hs_w_conn_recycle_mode, /* name */ - PLUGIN_VAR_RQCMDARG, /* opt */ - "Handlersocket connection recycle mode", /* comment */ - NULL, /* check */ - NULL, /* update */ - 2, /* def */ - 0, /* min */ - 2, /* max */ - 0 /* blk */ -); - -SPIDER_THDVAR_VALUE_FUNC(uint, hs_w_conn_recycle_mode) - -/* - 0: weak - 1: strict - */ -static MYSQL_THDVAR_UINT( - hs_w_conn_recycle_strict, /* name */ - PLUGIN_VAR_RQCMDARG, /* opt */ - "Strict handlersocket connection recycle", /* comment */ - NULL, /* check */ - NULL, /* update */ - 0, /* def */ - 0, /* min */ - 1, /* max */ - 0 /* blk */ -); - -SPIDER_THDVAR_VALUE_FUNC(uint, hs_w_conn_recycle_strict) - -/* - -1 :fallback to default - 0 :not use - 1 :use handlersocket - */ -static MYSQL_THDVAR_INT( - use_hs_read, /* name */ - PLUGIN_VAR_RQCMDARG, /* opt */ - "Use handlersocket for reading", /* comment */ - NULL, /* check */ - NULL, /* update */ - 0, /* def */ - -1, /* min */ - 1, /* max */ - 0 /* blk */ -); - -SPIDER_THDVAR_OVERRIDE_VALUE_FUN(int, use_hs_read) - -/* - -1 :fallback to default - 0 :not use - 1 :use handlersocket - */ -static MYSQL_THDVAR_INT( - use_hs_write, /* name */ - PLUGIN_VAR_RQCMDARG, /* opt */ - "Use handlersocket for writing", /* comment */ - NULL, /* check */ - NULL, /* update */ - 0, /* def */ - -1, /* min */ - 1, /* max */ - 0 /* blk */ -); - -SPIDER_THDVAR_OVERRIDE_VALUE_FUN(int, use_hs_write) -#endif /* -1 :fallback to default @@ -2744,9 +2573,6 @@ static struct st_mysql_sys_var* spider_system_variables[] = { MYSQL_SYSVAR(semi_split_read_limit), MYSQL_SYSVAR(init_sql_alloc_size), MYSQL_SYSVAR(reset_sql_alloc), -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - MYSQL_SYSVAR(hs_result_free_size), -#endif MYSQL_SYSVAR(multi_split_read), MYSQL_SYSVAR(max_order), MYSQL_SYSVAR(semi_trx_isolation), @@ -2807,9 +2633,6 @@ static struct st_mysql_sys_var* spider_system_variables[] = { MYSQL_SYSVAR(sts_bg_mode), #endif MYSQL_SYSVAR(ping_interval_at_trx_start), -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - MYSQL_SYSVAR(hs_ping_interval), -#endif MYSQL_SYSVAR(auto_increment_mode), MYSQL_SYSVAR(same_server_link), MYSQL_SYSVAR(local_lock_table), @@ -2832,14 +2655,6 @@ static struct st_mysql_sys_var* spider_system_variables[] = { MYSQL_SYSVAR(bka_mode), MYSQL_SYSVAR(udf_ct_bulk_insert_interval), MYSQL_SYSVAR(udf_ct_bulk_insert_rows), -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - MYSQL_SYSVAR(hs_r_conn_recycle_mode), - MYSQL_SYSVAR(hs_r_conn_recycle_strict), - MYSQL_SYSVAR(hs_w_conn_recycle_mode), - MYSQL_SYSVAR(hs_w_conn_recycle_strict), - MYSQL_SYSVAR(use_hs_read), - MYSQL_SYSVAR(use_hs_write), -#endif MYSQL_SYSVAR(use_handler), MYSQL_SYSVAR(error_read_mode), MYSQL_SYSVAR(error_write_mode), diff --git a/storage/spider/spd_param.h b/storage/spider/spd_param.h index e4ea26c610f..d7d35b17df5 100644 --- a/storage/spider/spd_param.h +++ b/storage/spider/spd_param.h @@ -73,12 +73,6 @@ int spider_param_reset_sql_alloc( THD *thd, int reset_sql_alloc ); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -longlong spider_param_hs_result_free_size( - THD *thd, - longlong hs_result_free_size -); -#endif int spider_param_multi_split_read( THD *thd, int multi_split_read @@ -261,11 +255,6 @@ int spider_param_sts_bg_mode( double spider_param_ping_interval_at_trx_start( THD *thd ); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -double spider_param_hs_ping_interval( - THD *thd -); -#endif int spider_param_auto_increment_mode( THD *thd, int auto_increment_mode @@ -320,28 +309,6 @@ int spider_param_udf_ct_bulk_insert_interval( longlong spider_param_udf_ct_bulk_insert_rows( longlong udf_ct_bulk_insert_rows ); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -uint spider_param_hs_r_conn_recycle_mode( - THD *thd -); -uint spider_param_hs_r_conn_recycle_strict( - THD *thd -); -uint spider_param_hs_w_conn_recycle_mode( - THD *thd -); -uint spider_param_hs_w_conn_recycle_strict( - THD *thd -); -int spider_param_use_hs_read( - THD *thd, - int use_hs_read -); -int spider_param_use_hs_write( - THD *thd, - int use_hs_write -); -#endif int spider_param_use_handler( THD *thd, int use_handler diff --git a/storage/spider/spd_table.cc b/storage/spider/spd_table.cc index 9a2f41ca658..5c1c0d27820 100644 --- a/storage/spider/spd_table.cc +++ b/storage/spider/spd_table.cc @@ -129,9 +129,6 @@ handlerton *spider_hton_ptr; SPIDER_DBTON spider_dbton[SPIDER_DBTON_SIZE]; extern SPIDER_DBTON spider_dbton_mysql; extern SPIDER_DBTON spider_dbton_mariadb; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -extern SPIDER_DBTON spider_dbton_handlersocket; -#endif #ifdef HAVE_ORACLE_OCI extern SPIDER_DBTON spider_dbton_oracle; #endif @@ -153,10 +150,6 @@ PSI_mutex_key spd_key_mutex_wide_share; #endif PSI_mutex_key spd_key_mutex_lgtm_tblhnd_share; PSI_mutex_key spd_key_mutex_conn; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -PSI_mutex_key spd_key_mutex_hs_r_conn; -PSI_mutex_key spd_key_mutex_hs_w_conn; -#endif PSI_mutex_key spd_key_mutex_open_conn; PSI_mutex_key spd_key_mutex_allocated_thds; PSI_mutex_key spd_key_mutex_mon_table_cache; @@ -203,10 +196,6 @@ static PSI_mutex_info all_spider_mutexes[]= #endif { &spd_key_mutex_lgtm_tblhnd_share, "lgtm_tblhnd_share", PSI_FLAG_GLOBAL}, { &spd_key_mutex_conn, "conn", PSI_FLAG_GLOBAL}, -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - { &spd_key_mutex_hs_r_conn, "hs_r_conn", PSI_FLAG_GLOBAL}, - { &spd_key_mutex_hs_w_conn, "hs_w_conn", PSI_FLAG_GLOBAL}, -#endif { &spd_key_mutex_open_conn, "open_conn", PSI_FLAG_GLOBAL}, { &spd_key_mutex_allocated_thds, "allocated_thds", PSI_FLAG_GLOBAL}, { &spd_key_mutex_mon_table_cache, "mon_table_cache", PSI_FLAG_GLOBAL}, @@ -315,20 +304,6 @@ extern const char *spider_open_connections_func_name; extern const char *spider_open_connections_file_name; extern ulong spider_open_connections_line_no; extern pthread_mutex_t spider_conn_mutex; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -extern HASH spider_hs_r_conn_hash; -extern uint spider_hs_r_conn_hash_id; -extern const char *spider_hs_r_conn_hash_func_name; -extern const char *spider_hs_r_conn_hash_file_name; -extern ulong spider_hs_r_conn_hash_line_no; -extern pthread_mutex_t spider_hs_r_conn_mutex; -extern HASH spider_hs_w_conn_hash; -extern uint spider_hs_w_conn_hash_id; -extern const char *spider_hs_w_conn_hash_func_name; -extern const char *spider_hs_w_conn_hash_file_name; -extern ulong spider_hs_w_conn_hash_line_no; -extern pthread_mutex_t spider_hs_w_conn_mutex; -#endif extern HASH *spider_udf_table_mon_list_hash; extern uint spider_udf_table_mon_list_hash_id; extern const char *spider_udf_table_mon_list_hash_func_name; @@ -826,30 +801,6 @@ int spider_free_share_alloc( } spider_free(spider_current_trx, share->static_link_ids, MYF(0)); } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (share->hs_read_socks) - { - for (roop_count = 0; roop_count < (int) share->hs_read_socks_length; - roop_count++) - { - if (share->hs_read_socks[roop_count]) - spider_free(spider_current_trx, share->hs_read_socks[roop_count], - MYF(0)); - } - spider_free(spider_current_trx, share->hs_read_socks, MYF(0)); - } - if (share->hs_write_socks) - { - for (roop_count = 0; roop_count < (int) share->hs_write_socks_length; - roop_count++) - { - if (share->hs_write_socks[roop_count]) - spider_free(spider_current_trx, share->hs_write_socks[roop_count], - MYF(0)); - } - spider_free(spider_current_trx, share->hs_write_socks, MYF(0)); - } -#endif if (share->bka_engine) spider_free(spider_current_trx, share->bka_engine, MYF(0)); if (share->conn_keys) @@ -872,18 +823,6 @@ int spider_free_share_alloc( spider_free(spider_current_trx, share->monitoring_flag, MYF(0)); if (share->monitoring_kind) spider_free(spider_current_trx, share->monitoring_kind, MYF(0)); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (share->use_hs_reads) - spider_free(spider_current_trx, share->use_hs_reads, MYF(0)); - if (share->use_hs_writes) - spider_free(spider_current_trx, share->use_hs_writes, MYF(0)); - if (share->hs_read_ports) - spider_free(spider_current_trx, share->hs_read_ports, MYF(0)); - if (share->hs_write_ports) - spider_free(spider_current_trx, share->hs_write_ports, MYF(0)); - if (share->hs_write_to_reads) - spider_free(spider_current_trx, share->hs_write_to_reads, MYF(0)); -#endif if (share->use_handlers) spider_free(spider_current_trx, share->use_handlers, MYF(0)); if (share->connect_timeouts) @@ -1018,18 +957,6 @@ void spider_free_tmp_share_alloc( spider_free(spider_current_trx, share->static_link_ids[0], MYF(0)); share->static_link_ids[0] = NULL; } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (share->hs_read_socks && share->hs_read_socks[0]) - { - spider_free(spider_current_trx, share->hs_read_socks[0], MYF(0)); - share->hs_read_socks[0] = NULL; - } - if (share->hs_write_socks && share->hs_write_socks[0]) - { - spider_free(spider_current_trx, share->hs_write_socks[0], MYF(0)); - share->hs_write_socks[0] = NULL; - } -#endif if (share->bka_engine) { spider_free(spider_current_trx, share->bka_engine, MYF(0)); @@ -1913,9 +1840,6 @@ static void spider_minus_1(SPIDER_SHARE *share, TABLE_SHARE *table_share) share->error_read_mode = -1; share->error_write_mode = -1; share->active_link_count = -1; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - share->hs_result_free_size = -1; -#endif #ifdef HA_CAN_BULK_ACCESS share->bulk_access_free = -1; #endif @@ -2286,17 +2210,6 @@ int spider_parse_connect_info( SPIDER_PARAM_INT_WITH_MAX("fbu", force_bulk_update, 0, 1); #endif SPIDER_PARAM_LONGLONG("frd", first_read, 0); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - SPIDER_PARAM_LONGLONG("hrf", hs_result_free_size, 0); - SPIDER_PARAM_LONG_LIST_WITH_MAX( - "hrp", hs_read_ports, 0, 65535); - SPIDER_PARAM_STR_LIST("hrs", hs_read_socks); - SPIDER_PARAM_LONG_LIST_WITH_MAX( - "hwp", hs_write_ports, 0, 65535); - SPIDER_PARAM_LONG_LIST_WITH_MAX( - "hwr", hs_write_to_reads, 0, 1); - SPIDER_PARAM_STR_LIST("hws", hs_write_socks); -#endif SPIDER_PARAM_INT("isa", init_sql_alloc_size, 0); SPIDER_PARAM_LONGLONG("ilm", internal_limit, 0); SPIDER_PARAM_LONGLONG("ios", internal_offset, 0); @@ -2371,12 +2284,6 @@ int spider_parse_connect_info( SPIDER_PARAM_STR_LIST("tbl", tgt_table_names); SPIDER_PARAM_INT_WITH_MAX("tcm", table_count_mode, 0, 3); SPIDER_PARAM_LONG_LIST_WITH_MAX("uhd", use_handlers, 0, 3); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - SPIDER_PARAM_LONG_LIST_WITH_MAX( - "uhr", use_hs_reads, 0, 1); - SPIDER_PARAM_LONG_LIST_WITH_MAX( - "uhw", use_hs_writes, 0, 1); -#endif SPIDER_PARAM_INT_WITH_MAX("upu", use_pushdown_udf, 0, 1); SPIDER_PARAM_INT_WITH_MAX("utc", use_table_charset, 0, 1); error_num = parse.fail(true); @@ -2452,9 +2359,6 @@ int spider_parse_connect_info( #endif SPIDER_PARAM_LONG_LIST_WITH_MAX("link_status", link_statuses, 0, 3); SPIDER_PARAM_LONG_LIST_WITH_MAX("use_handler", use_handlers, 0, 3); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - SPIDER_PARAM_LONG_LIST_WITH_MAX("use_hs_read", use_hs_reads, 0, 1); -#endif SPIDER_PARAM_INT_WITH_MAX("casual_read", casual_read, 0, 63); SPIDER_PARAM_INT("buffer_size", buffer_size, 0); error_num = parse.fail(true); @@ -2464,20 +2368,10 @@ int spider_parse_connect_info( SPIDER_PARAM_DOUBLE("crd_interval", crd_interval, 0); SPIDER_PARAM_INT_WITH_MAX("low_mem_read", low_mem_read, 0, 1); SPIDER_PARAM_STR_LIST("default_file", tgt_default_files); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - SPIDER_PARAM_LONG_LIST_WITH_MAX( - "use_hs_write", use_hs_writes, 0, 1); - SPIDER_PARAM_LONG_LIST_WITH_MAX( - "hs_read_port", hs_read_ports, 0, 65535); -#endif error_num = parse.fail(true); goto error; case 13: SPIDER_PARAM_STR_LIST("default_group", tgt_default_groups); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - SPIDER_PARAM_LONG_LIST_WITH_MAX( - "hs_write_port", hs_write_ports, 0, 65535); -#endif SPIDER_PARAM_STR_LIST("sequence_name", tgt_sequence_names); error_num = parse.fail(true); goto error; @@ -2485,10 +2379,6 @@ int spider_parse_connect_info( SPIDER_PARAM_LONGLONG("internal_limit", internal_limit, 0); #ifndef WITHOUT_SPIDER_BG_SEARCH SPIDER_PARAM_LONGLONG("bgs_first_read", bgs_first_read, 0); -#endif -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - SPIDER_PARAM_STR_LIST( - "hs_read_socket", hs_read_socks); #endif SPIDER_PARAM_INT_WITH_MAX("read_only_mode", read_only_mode, 0, 1); SPIDER_PARAM_LONG_LIST_WITH_MAX("access_balance", access_balances, 0, @@ -2510,10 +2400,6 @@ int spider_parse_connect_info( SPIDER_PARAM_LONG_LIST_WITH_MAX("monitoring_flag", monitoring_flag, 0, 1); SPIDER_PARAM_LONG_LIST_WITH_MAX("monitoring_kind", monitoring_kind, 0, 3); SPIDER_PARAM_DOUBLE("semi_split_read", semi_split_read, 0); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - SPIDER_PARAM_STR_LIST( - "hs_write_socket", hs_write_socks); -#endif SPIDER_PARAM_LONG_LIST_WITH_MAX("connect_timeout", connect_timeouts, 0, 2147483647); SPIDER_PARAM_LONG_LIST_WITH_MAX("strict_group_by", @@ -2537,10 +2423,6 @@ int spider_parse_connect_info( SPIDER_PARAM_INT("bulk_update_size", bulk_update_size, 0); SPIDER_PARAM_LONG_LIST_WITH_MAX("net_read_timeout", net_read_timeouts, 0, 2147483647); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - SPIDER_PARAM_LONG_LIST_WITH_MAX( - "hs_write_to_read", hs_write_to_reads, 0, 1); -#endif SPIDER_PARAM_INT_WITH_MAX( "error_write_mode", error_write_mode, 0, 1); #ifdef HA_CAN_BULK_ACCESS @@ -2588,9 +2470,6 @@ int spider_parse_connect_info( SPIDER_PARAM_INT("init_sql_alloc_size", init_sql_alloc_size, 0); SPIDER_PARAM_INT_WITH_MAX( "auto_increment_mode", auto_increment_mode, 0, 3); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - SPIDER_PARAM_LONGLONG("hs_result_free_size", hs_result_free_size, 0); -#endif SPIDER_PARAM_LONG_LIST_WITH_MAX("bka_table_name_type", bka_table_name_types, 0, 1); SPIDER_PARAM_INT_WITH_MAX( @@ -2720,22 +2599,6 @@ int spider_parse_connect_info( share->all_link_count = share->monitoring_bg_kind_length; if (share->all_link_count < share->monitoring_bg_interval_length) share->all_link_count = share->monitoring_bg_interval_length; -#endif -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (share->all_link_count < share->use_hs_reads_length) - share->all_link_count = share->use_hs_reads_length; - if (share->all_link_count < share->use_hs_writes_length) - share->all_link_count = share->use_hs_writes_length; - if (share->all_link_count < share->hs_read_ports_length) - share->all_link_count = share->hs_read_ports_length; - if (share->all_link_count < share->hs_write_ports_length) - share->all_link_count = share->hs_write_ports_length; - if (share->all_link_count < share->hs_read_socks_length) - share->all_link_count = share->hs_read_socks_length; - if (share->all_link_count < share->hs_write_socks_length) - share->all_link_count = share->hs_write_socks_length; - if (share->all_link_count < share->hs_write_to_reads_length) - share->all_link_count = share->hs_write_to_reads_length; #endif if (share->all_link_count < share->use_handlers_length) share->all_link_count = share->use_handlers_length; @@ -2943,47 +2806,6 @@ int spider_parse_connect_info( &share->monitoring_sid_length, share->all_link_count))) goto error; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if ((error_num = spider_increase_long_list( - &share->use_hs_reads, - &share->use_hs_reads_length, - share->all_link_count))) - goto error; - if ((error_num = spider_increase_long_list( - &share->use_hs_writes, - &share->use_hs_writes_length, - share->all_link_count))) - goto error; - if ((error_num = spider_increase_long_list( - &share->hs_read_ports, - &share->hs_read_ports_length, - share->all_link_count))) - goto error; - if ((error_num = spider_increase_long_list( - &share->hs_write_ports, - &share->hs_write_ports_length, - share->all_link_count))) - goto error; - if ((error_num = spider_increase_string_list( - &share->hs_read_socks, - &share->hs_read_socks_lengths, - &share->hs_read_socks_length, - &share->hs_read_socks_charlen, - share->all_link_count))) - goto error; - if ((error_num = spider_increase_string_list( - &share->hs_write_socks, - &share->hs_write_socks_lengths, - &share->hs_write_socks_length, - &share->hs_write_socks_charlen, - share->all_link_count))) - goto error; - if ((error_num = spider_increase_long_list( - &share->hs_write_to_reads, - &share->hs_write_to_reads_length, - share->all_link_count))) - goto error; -#endif if ((error_num = spider_increase_long_list( &share->use_handlers, &share->use_handlers_length, @@ -3817,38 +3639,6 @@ int spider_set_connect_info_default( if (share->monitoring_sid[roop_count] == -1) share->monitoring_sid[roop_count] = global_system_variables.server_id; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (share->hs_read_ports[roop_count] == -1) - { - share->hs_read_ports[roop_count] = 9998; - } else if (share->hs_read_ports[roop_count] < 0) - { - share->hs_read_ports[roop_count] = 0; - } else if (share->hs_read_ports[roop_count] > 65535) - { - share->hs_read_ports[roop_count] = 65535; - } - if (share->hs_write_ports[roop_count] == -1) - { - share->hs_write_ports[roop_count] = 9999; - } else if (share->hs_write_ports[roop_count] < 0) - { - share->hs_write_ports[roop_count] = 0; - } else if (share->hs_write_ports[roop_count] > 65535) - { - share->hs_write_ports[roop_count] = 65535; - } - if (share->hs_write_to_reads[roop_count] == -1) - { - share->hs_write_to_reads[roop_count] = 1; - } else if (share->hs_write_to_reads[roop_count] < 0) - { - share->hs_write_to_reads[roop_count] = 0; - } else if (share->hs_write_to_reads[roop_count] > 1) - { - share->hs_write_to_reads[roop_count] = 1; - } -#endif if (share->access_balances[roop_count] == -1) share->access_balances[roop_count] = 100; } @@ -4035,23 +3825,12 @@ int spider_create_conn_keys( ) { int roop_count, roop_count2; char *tmp_name, port_str[6]; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - char *tmp_hs_r_name, *tmp_hs_w_name; -#endif uint length_base = sizeof(uint) * share->all_link_count; uint *conn_keys_lengths; uint *sql_dbton_ids; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - uint *hs_dbton_ids; - uint *hs_r_conn_keys_lengths; - uint *hs_w_conn_keys_lengths; -#endif DBUG_ENTER("spider_create_conn_keys"); char *ptr; uint length = length_base * 2; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - length += length_base * 3; -#endif ptr = (char *) my_alloca(length); if (!ptr) { @@ -4060,26 +3839,11 @@ int spider_create_conn_keys( conn_keys_lengths = (uint *) ptr; ptr += length_base; sql_dbton_ids = (uint *) ptr; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - ptr += length_base; - hs_dbton_ids = (uint *) ptr; - ptr += length_base; - hs_r_conn_keys_lengths = (uint *) ptr; - ptr += length_base; - hs_w_conn_keys_lengths = (uint *) ptr; -#endif share->conn_keys_charlen = 0; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - share->hs_read_conn_keys_charlen = 0; - share->hs_write_conn_keys_charlen = 0; -#endif for (roop_count = 0; roop_count < (int) share->all_link_count; roop_count++) { bool get_sql_id = FALSE; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - bool get_nosql_id = FALSE; -#endif for (roop_count2 = 0; roop_count2 < SPIDER_DBTON_SIZE; roop_count2++) { DBUG_PRINT("info",("spider share->tgt_wrappers[%d]=%s", roop_count, @@ -4099,35 +3863,12 @@ int spider_create_conn_keys( ) { sql_dbton_ids[roop_count] = roop_count2; get_sql_id = TRUE; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (get_nosql_id) -#endif - break; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - else - continue; -#endif - } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if ( - !get_nosql_id && - spider_dbton[roop_count2].db_access_type == - SPIDER_DB_ACCESS_TYPE_NOSQL - ) { - hs_dbton_ids[roop_count] = roop_count2; - get_nosql_id = TRUE; - if (get_sql_id) break; } -#endif } } if (!get_sql_id) sql_dbton_ids[roop_count] = SPIDER_DBTON_SIZE; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (!get_nosql_id) - hs_dbton_ids[roop_count] = SPIDER_DBTON_SIZE; -#endif bool tables_on_different_db_are_joinable; if (get_sql_id) @@ -4158,24 +3899,6 @@ int spider_create_conn_keys( + share->tgt_default_groups_lengths[roop_count] + 1 + share->tgt_dsns_lengths[roop_count]; share->conn_keys_charlen += conn_keys_lengths[roop_count] + 2; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - hs_r_conn_keys_lengths[roop_count] - = 1 - + share->tgt_wrappers_lengths[roop_count] + 1 - + share->tgt_hosts_lengths[roop_count] + 1 - + 5 + 1 - + share->hs_read_socks_lengths[roop_count]; - share->hs_read_conn_keys_charlen += - hs_r_conn_keys_lengths[roop_count] + 2; - hs_w_conn_keys_lengths[roop_count] - = 1 - + share->tgt_wrappers_lengths[roop_count] + 1 - + share->tgt_hosts_lengths[roop_count] + 1 - + 5 + 1 - + share->hs_write_socks_lengths[roop_count]; - share->hs_write_conn_keys_charlen += - hs_w_conn_keys_lengths[roop_count] + 2; -#endif } if (!(share->conn_keys = (char **) spider_bulk_alloc_mem(spider_current_trx, SPD_MID_CREATE_CONN_KEYS_1, @@ -4187,26 +3910,7 @@ int spider_create_conn_keys( sizeof(my_hash_value_type) * share->all_link_count, #endif &tmp_name, sizeof(char) * share->conn_keys_charlen, -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - &share->hs_read_conn_keys, sizeof(char *) * share->all_link_count, - &share->hs_read_conn_keys_lengths, length_base, -#ifdef SPIDER_HAS_HASH_VALUE_TYPE - &share->hs_read_conn_keys_hash_value, - sizeof(my_hash_value_type) * share->all_link_count, -#endif - &tmp_hs_r_name, sizeof(char) * share->hs_read_conn_keys_charlen, - &share->hs_write_conn_keys, sizeof(char *) * share->all_link_count, - &share->hs_write_conn_keys_lengths, length_base, -#ifdef SPIDER_HAS_HASH_VALUE_TYPE - &share->hs_write_conn_keys_hash_value, - sizeof(my_hash_value_type) * share->all_link_count, -#endif - &tmp_hs_w_name, sizeof(char) * share->hs_write_conn_keys_charlen, -#endif &share->sql_dbton_ids, length_base, -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - &share->hs_dbton_ids, length_base, -#endif NullS)) ) { my_afree(conn_keys_lengths); @@ -4216,15 +3920,6 @@ int spider_create_conn_keys( memcpy(share->conn_keys_lengths, conn_keys_lengths, length_base); memcpy(share->sql_dbton_ids, sql_dbton_ids, length_base); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - share->hs_read_conn_keys_length = share->all_link_count; - share->hs_write_conn_keys_length = share->all_link_count; - memcpy(share->hs_read_conn_keys_lengths, hs_r_conn_keys_lengths, - length_base); - memcpy(share->hs_write_conn_keys_lengths, hs_w_conn_keys_lengths, - length_base); - memcpy(share->hs_dbton_ids, hs_dbton_ids, length_base); -#endif my_afree(conn_keys_lengths); @@ -4346,83 +4041,15 @@ int spider_create_conn_keys( share->conn_keys_hash_value[roop_count] = my_calc_hash( &spider_open_connections, (uchar*) share->conn_keys[roop_count], share->conn_keys_lengths[roop_count]); -#endif -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - share->hs_read_conn_keys[roop_count] = tmp_hs_r_name; - *tmp_hs_r_name = '0'; - DBUG_PRINT("info",("spider tgt_wrappers[%d]=%s", roop_count, - share->tgt_wrappers[roop_count])); - tmp_hs_r_name = strmov(tmp_hs_r_name + 1, share->tgt_wrappers[roop_count]); - DBUG_PRINT("info",("spider tgt_hosts[%d]=%s", roop_count, - share->tgt_hosts[roop_count])); - tmp_hs_r_name = strmov(tmp_hs_r_name + 1, share->tgt_hosts[roop_count]); - my_sprintf(port_str, (port_str, "%05ld", - share->hs_read_ports[roop_count])); - DBUG_PRINT("info",("spider port_str=%s", port_str)); - tmp_hs_r_name = strmov(tmp_hs_r_name + 1, port_str); - if (share->hs_read_socks[roop_count]) - { - DBUG_PRINT("info",("spider hs_read_socks[%d]=%s", roop_count, - share->hs_read_socks[roop_count])); - tmp_hs_r_name = strmov(tmp_hs_r_name + 1, - share->hs_read_socks[roop_count]); - } else - tmp_hs_r_name++; - tmp_hs_r_name++; - tmp_hs_r_name++; -#ifdef SPIDER_HAS_HASH_VALUE_TYPE - share->hs_read_conn_keys_hash_value[roop_count] = my_calc_hash( - &spider_open_connections, (uchar*) share->hs_read_conn_keys[roop_count], - share->hs_read_conn_keys_lengths[roop_count]); -#endif - share->hs_write_conn_keys[roop_count] = tmp_hs_w_name; - *tmp_hs_w_name = '0'; - DBUG_PRINT("info",("spider tgt_wrappers[%d]=%s", roop_count, - share->tgt_wrappers[roop_count])); - tmp_hs_w_name = strmov(tmp_hs_w_name + 1, share->tgt_wrappers[roop_count]); - DBUG_PRINT("info",("spider tgt_hosts[%d]=%s", roop_count, - share->tgt_hosts[roop_count])); - tmp_hs_w_name = strmov(tmp_hs_w_name + 1, share->tgt_hosts[roop_count]); - my_sprintf(port_str, (port_str, "%05ld", - share->hs_write_ports[roop_count])); - DBUG_PRINT("info",("spider port_str=%s", port_str)); - tmp_hs_w_name = strmov(tmp_hs_w_name + 1, port_str); - if (share->hs_write_socks[roop_count]) - { - DBUG_PRINT("info",("spider hs_write_socks[%d]=%s", roop_count, - share->hs_write_socks[roop_count])); - tmp_hs_w_name = strmov(tmp_hs_w_name + 1, - share->hs_write_socks[roop_count]); - } else - tmp_hs_w_name++; - tmp_hs_w_name++; - tmp_hs_w_name++; -#ifdef SPIDER_HAS_HASH_VALUE_TYPE - share->hs_write_conn_keys_hash_value[roop_count] = my_calc_hash( - &spider_open_connections, (uchar*) share->hs_write_conn_keys[roop_count], - share->hs_write_conn_keys_lengths[roop_count]); -#endif #endif } for (roop_count2 = 0; roop_count2 < SPIDER_DBTON_SIZE; roop_count2++) { if (spider_bit_is_set(share->dbton_bitmap, roop_count2)) { -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (spider_dbton[roop_count2].db_access_type == - SPIDER_DB_ACCESS_TYPE_SQL) - { -#endif share->use_sql_dbton_ids[share->use_dbton_count] = roop_count2; share->sql_dbton_id_to_seq[roop_count2] = share->use_dbton_count; share->use_sql_dbton_count++; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else { - share->use_hs_dbton_ids[share->use_hs_dbton_count] = roop_count2; - share->hs_dbton_id_to_seq[roop_count2] = share->use_hs_dbton_count; - share->use_hs_dbton_count++; - } -#endif share->use_dbton_ids[share->use_dbton_count] = roop_count2; share->dbton_id_to_seq[roop_count2] = share->use_dbton_count; share->use_dbton_count++; @@ -4479,9 +4106,6 @@ SPIDER_SHARE *spider_create_share( SPD_INIT_ALLOC_ROOT(&share->mem_root, 4096, 0, MYF(MY_WME)); share->use_count = 0; share->use_dbton_count = 0; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - share->use_hs_dbton_count = 0; -#endif share->table_name_length = length; share->table_name = tmp_name; strmov(share->table_name, table_name); @@ -4662,12 +4286,6 @@ SPIDER_SHARE *spider_get_share( SPIDER_RESULT_LIST *result_list = &spider->result_list; uint length, tmp_conn_link_idx = 0, buf_sz; char *tmp_name, *tmp_cid; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - char *tmp_hs_r_name, *tmp_hs_w_name; -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS - uint32 *tmp_hs_r_ret_fields, *tmp_hs_w_ret_fields; -#endif -#endif int roop_count; double sts_interval; int sts_mode; @@ -4992,16 +4610,6 @@ SPIDER_SHARE *spider_get_share( &spider->conns, sizeof(SPIDER_CONN *) * share->link_count, &spider->conn_link_idx, sizeof(uint) * share->link_count, &spider->conn_can_fo, sizeof(uchar) * share->link_bitmap_size, -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - &spider->hs_r_conn_keys, sizeof(char *) * share->link_count, - &tmp_hs_r_name, sizeof(char) * share->hs_read_conn_keys_charlen, - &spider->hs_r_conns, sizeof(SPIDER_CONN *) * share->link_count, - &spider->hs_r_conn_ages, sizeof(ulonglong) * share->link_count, - &spider->hs_w_conn_keys, sizeof(char *) * share->link_count, - &tmp_hs_w_name, sizeof(char) * share->hs_write_conn_keys_charlen, - &spider->hs_w_conns, sizeof(SPIDER_CONN *) * share->link_count, - &spider->hs_w_conn_ages, sizeof(ulonglong) * share->link_count, -#endif &spider->sql_kind, sizeof(uint) * share->link_count, &spider->connection_ids, sizeof(ulonglong) * share->link_count, &spider->conn_kind, sizeof(uint) * share->link_count, @@ -5010,26 +4618,6 @@ SPIDER_SHARE *spider_get_share( &spider->m_handler_opened, sizeof(uchar) * share->link_bitmap_size, &spider->m_handler_id, sizeof(uint) * share->link_count, &spider->m_handler_cid, sizeof(char *) * share->link_count, -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - &spider->r_handler_opened, sizeof(uchar) * share->link_bitmap_size, - &spider->r_handler_id, sizeof(uint) * share->link_count, - &spider->r_handler_index, sizeof(uint) * share->link_count, - &spider->w_handler_opened, sizeof(uchar) * share->link_bitmap_size, - &spider->w_handler_id, sizeof(uint) * share->link_count, - &spider->w_handler_index, sizeof(uint) * share->link_count, -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS - &spider->do_hs_direct_update, sizeof(uchar) * share->link_bitmap_size, - &spider->hs_r_ret_fields, sizeof(uint32 *) * share->link_count, - &spider->hs_w_ret_fields, sizeof(uint32 *) * share->link_count, - &spider->hs_r_ret_fields_num, sizeof(size_t) * share->link_count, - &spider->hs_w_ret_fields_num, sizeof(size_t) * share->link_count, - &tmp_hs_r_ret_fields, - sizeof(uint32) * share->link_count * table_share->fields, - &tmp_hs_w_ret_fields, - sizeof(uint32) * share->link_count * table_share->fields, - &spider->tmp_column_bitmap, sizeof(uchar) * share->bitmap_size, -#endif -#endif &tmp_cid, sizeof(char) * (SPIDER_SQL_HANDLER_CID_LEN + 1) * share->link_count, &spider->need_mons, sizeof(int) * share->link_count, @@ -5042,12 +4630,6 @@ SPIDER_SHARE *spider_get_share( &result_list->tmp_table_created, sizeof(uchar) * share->link_bitmap_size, #ifdef HA_CAN_BULK_ACCESS -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - &result_list->hs_r_bulk_open_index, - sizeof(uchar) * share->link_bitmap_size, - &result_list->hs_w_bulk_open_index, - sizeof(uchar) * share->link_bitmap_size, -#endif #endif &result_list->sql_kind_backup, sizeof(uint) * share->link_count, &result_list->casual_read, sizeof(int) * share->link_count, @@ -5062,12 +4644,6 @@ SPIDER_SHARE *spider_get_share( goto error_but_no_delete; } memcpy(tmp_name, share->conn_keys[0], share->conn_keys_charlen); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - memcpy(tmp_hs_r_name, share->hs_read_conn_keys[0], - share->hs_read_conn_keys_charlen); - memcpy(tmp_hs_w_name, share->hs_write_conn_keys[0], - share->hs_write_conn_keys_charlen); -#endif spider->conn_keys_first_ptr = tmp_name; for (roop_count = 0; roop_count < (int) share->link_count; roop_count++) @@ -5075,18 +4651,6 @@ SPIDER_SHARE *spider_get_share( spider->conn_keys[roop_count] = tmp_name; *tmp_name = first_byte; tmp_name += share->conn_keys_lengths[roop_count] + 1; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - spider->hs_r_conn_keys[roop_count] = tmp_hs_r_name; - tmp_hs_r_name += share->hs_read_conn_keys_lengths[roop_count] + 1; - spider->hs_w_conn_keys[roop_count] = tmp_hs_w_name; - tmp_hs_w_name += share->hs_write_conn_keys_lengths[roop_count] + 1; -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS - spider->hs_r_ret_fields[roop_count] = tmp_hs_r_ret_fields; - tmp_hs_r_ret_fields += table_share->fields; - spider->hs_w_ret_fields[roop_count] = tmp_hs_w_ret_fields; - tmp_hs_w_ret_fields += table_share->fields; -#endif -#endif spider->m_handler_cid[roop_count] = tmp_cid; tmp_cid += SPIDER_SQL_HANDLER_CID_LEN + 1; result_list->upd_tmp_tbl_prms[roop_count].init(); @@ -5534,16 +5098,6 @@ SPIDER_SHARE *spider_get_share( &spider->conns, sizeof(SPIDER_CONN *) * share->link_count, &spider->conn_link_idx, sizeof(uint) * share->link_count, &spider->conn_can_fo, sizeof(uchar) * share->link_bitmap_size, -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - &spider->hs_r_conn_keys, sizeof(char *) * share->link_count, - &tmp_hs_r_name, sizeof(char) * share->hs_read_conn_keys_charlen, - &spider->hs_r_conns, sizeof(SPIDER_CONN *) * share->link_count, - &spider->hs_r_conn_ages, sizeof(ulonglong) * share->link_count, - &spider->hs_w_conn_keys, sizeof(char *) * share->link_count, - &tmp_hs_w_name, sizeof(char) * share->hs_write_conn_keys_charlen, - &spider->hs_w_conns, sizeof(SPIDER_CONN *) * share->link_count, - &spider->hs_w_conn_ages, sizeof(ulonglong) * share->link_count, -#endif &spider->sql_kind, sizeof(uint) * share->link_count, &spider->connection_ids, sizeof(ulonglong) * share->link_count, &spider->conn_kind, sizeof(uint) * share->link_count, @@ -5552,26 +5106,6 @@ SPIDER_SHARE *spider_get_share( &spider->m_handler_opened, sizeof(uchar) * share->link_bitmap_size, &spider->m_handler_id, sizeof(uint) * share->link_count, &spider->m_handler_cid, sizeof(char *) * share->link_count, -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - &spider->r_handler_opened, sizeof(uchar) * share->link_bitmap_size, - &spider->r_handler_id, sizeof(uint) * share->link_count, - &spider->r_handler_index, sizeof(uint) * share->link_count, - &spider->w_handler_opened, sizeof(uchar) * share->link_bitmap_size, - &spider->w_handler_id, sizeof(uint) * share->link_count, - &spider->w_handler_index, sizeof(uint) * share->link_count, -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS - &spider->do_hs_direct_update, sizeof(uchar) * share->link_bitmap_size, - &spider->hs_r_ret_fields, sizeof(uint32 *) * share->link_count, - &spider->hs_w_ret_fields, sizeof(uint32 *) * share->link_count, - &spider->hs_r_ret_fields_num, sizeof(size_t) * share->link_count, - &spider->hs_w_ret_fields_num, sizeof(size_t) * share->link_count, - &tmp_hs_r_ret_fields, - sizeof(uint32) * share->link_count * table_share->fields, - &tmp_hs_w_ret_fields, - sizeof(uint32) * share->link_count * table_share->fields, - &spider->tmp_column_bitmap, sizeof(uchar) * share->bitmap_size, -#endif -#endif &tmp_cid, sizeof(char) * (SPIDER_SQL_HANDLER_CID_LEN + 1) * share->link_count, &spider->need_mons, sizeof(int) * share->link_count, @@ -5584,12 +5118,6 @@ SPIDER_SHARE *spider_get_share( &result_list->tmp_table_created, sizeof(uchar) * share->link_bitmap_size, #ifdef HA_CAN_BULK_ACCESS -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - &result_list->hs_r_bulk_open_index, - sizeof(uchar) * share->link_bitmap_size, - &result_list->hs_w_bulk_open_index, - sizeof(uchar) * share->link_bitmap_size, -#endif #endif &result_list->sql_kind_backup, sizeof(uint) * share->link_count, &result_list->casual_read, sizeof(int) * share->link_count, @@ -5601,12 +5129,6 @@ SPIDER_SHARE *spider_get_share( goto error_but_no_delete; } memcpy(tmp_name, share->conn_keys[0], share->conn_keys_charlen); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - memcpy(tmp_hs_r_name, share->hs_read_conn_keys[0], - share->hs_read_conn_keys_charlen); - memcpy(tmp_hs_w_name, share->hs_write_conn_keys[0], - share->hs_write_conn_keys_charlen); -#endif spider->conn_keys_first_ptr = tmp_name; for (roop_count = 0; roop_count < (int) share->link_count; roop_count++) @@ -5614,18 +5136,6 @@ SPIDER_SHARE *spider_get_share( spider->conn_keys[roop_count] = tmp_name; *tmp_name = first_byte; tmp_name += share->conn_keys_lengths[roop_count] + 1; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - spider->hs_r_conn_keys[roop_count] = tmp_hs_r_name; - tmp_hs_r_name += share->hs_read_conn_keys_lengths[roop_count] + 1; - spider->hs_w_conn_keys[roop_count] = tmp_hs_w_name; - tmp_hs_w_name += share->hs_write_conn_keys_lengths[roop_count] + 1; -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS - spider->hs_r_ret_fields[roop_count] = tmp_hs_r_ret_fields; - tmp_hs_r_ret_fields += table_share->fields; - spider->hs_w_ret_fields[roop_count] = tmp_hs_w_ret_fields; - tmp_hs_w_ret_fields += table_share->fields; -#endif -#endif spider->m_handler_cid[roop_count] = tmp_cid; tmp_cid += SPIDER_SQL_HANDLER_CID_LEN + 1; result_list->upd_tmp_tbl_prms[roop_count].init(); @@ -6715,32 +6225,6 @@ int spider_db_done( } pthread_mutex_unlock(&spider_allocated_thds_mutex); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - pthread_mutex_lock(&spider_hs_w_conn_mutex); - while ((conn = (SPIDER_CONN*) my_hash_element(&spider_hs_w_conn_hash, 0))) - { -#ifdef HASH_UPDATE_WITH_HASH_VALUE - my_hash_delete_with_hash_value(&spider_hs_w_conn_hash, - conn->conn_key_hash_value, (uchar*) conn); -#else - my_hash_delete(&spider_hs_w_conn_hash, (uchar*) conn); -#endif - spider_free_conn(conn); - } - pthread_mutex_unlock(&spider_hs_w_conn_mutex); - pthread_mutex_lock(&spider_hs_r_conn_mutex); - while ((conn = (SPIDER_CONN*) my_hash_element(&spider_hs_r_conn_hash, 0))) - { -#ifdef HASH_UPDATE_WITH_HASH_VALUE - my_hash_delete_with_hash_value(&spider_hs_r_conn_hash, - conn->conn_key_hash_value, (uchar*) conn); -#else - my_hash_delete(&spider_hs_r_conn_hash, (uchar*) conn); -#endif - spider_free_conn(conn); - } - pthread_mutex_unlock(&spider_hs_r_conn_mutex); -#endif pthread_mutex_lock(&spider_conn_mutex); while ((conn = (SPIDER_CONN*) my_hash_element(&spider_open_connections, 0))) { @@ -6770,18 +6254,6 @@ int spider_db_done( spider_allocated_thds.array.max_element * spider_allocated_thds.array.size_of_element); my_hash_free(&spider_allocated_thds); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - spider_free_mem_calc(spider_current_trx, - spider_hs_w_conn_hash_id, - spider_hs_w_conn_hash.array.max_element * - spider_hs_w_conn_hash.array.size_of_element); - my_hash_free(&spider_hs_w_conn_hash); - spider_free_mem_calc(spider_current_trx, - spider_hs_r_conn_hash_id, - spider_hs_r_conn_hash.array.max_element * - spider_hs_r_conn_hash.array.size_of_element); - my_hash_free(&spider_hs_r_conn_hash); -#endif spider_free_mem_calc(spider_current_trx, spider_open_connections_id, spider_open_connections.array.max_element * @@ -6829,10 +6301,6 @@ int spider_db_done( pthread_mutex_destroy(&spider_mon_table_cache_mutex); pthread_mutex_destroy(&spider_allocated_thds_mutex); pthread_mutex_destroy(&spider_open_conn_mutex); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - pthread_mutex_destroy(&spider_hs_w_conn_mutex); - pthread_mutex_destroy(&spider_hs_r_conn_mutex); -#endif pthread_mutex_destroy(&spider_conn_mutex); pthread_mutex_destroy(&spider_lgtm_tblhnd_share_mutex); #ifdef WITH_PARTITION_STORAGE_ENGINE @@ -7056,16 +6524,6 @@ int spider_db_init( &spider_open_conn_mutex, MY_MUTEX_INIT_FAST)) goto error_open_conn_mutex_init; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (mysql_mutex_init(spd_key_mutex_hs_r_conn, - &spider_hs_r_conn_mutex, MY_MUTEX_INIT_FAST)) - goto error_hs_r_conn_mutex_init; - - if (mysql_mutex_init(spd_key_mutex_hs_w_conn, - &spider_hs_w_conn_mutex, MY_MUTEX_INIT_FAST)) - goto error_hs_w_conn_mutex_init; - -#endif if (mysql_mutex_init(spd_key_mutex_allocated_thds, &spider_allocated_thds_mutex, MY_MUTEX_INIT_FAST)) goto error_allocated_thds_mutex_init; @@ -7133,26 +6591,6 @@ int spider_db_init( spider_open_connections, spider_open_connections.array.max_element * spider_open_connections.array.size_of_element); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (my_hash_init(PSI_INSTRUMENT_ME, &spider_hs_r_conn_hash, spd_charset_utf8mb3_bin, 32, 0, 0, - (my_hash_get_key) spider_conn_get_key, 0, 0)) - goto error_hs_r_conn_hash_init; - - spider_alloc_calc_mem_init(spider_hs_r_conn_hash, SPD_MID_DB_INIT_6); - spider_alloc_calc_mem(NULL, - spider_hs_r_conn_hash, - spider_hs_r_conn_hash.array.max_element * - spider_hs_r_conn_hash.array.size_of_element); - if (my_hash_init(PSI_INSTRUMENT_ME, &spider_hs_w_conn_hash, spd_charset_utf8mb3_bin, 32, 0, 0, - (my_hash_get_key) spider_conn_get_key, 0, 0)) - goto error_hs_w_conn_hash_init; - - spider_alloc_calc_mem_init(spider_hs_w_conn_hash, SPD_MID_DB_INIT_7); - spider_alloc_calc_mem(NULL, - spider_hs_w_conn_hash, - spider_hs_w_conn_hash.array.max_element * - spider_hs_w_conn_hash.array.size_of_element); -#endif if (my_hash_init(PSI_INSTRUMENT_ME, &spider_allocated_thds, spd_charset_utf8mb3_bin, 32, 0, 0, (my_hash_get_key) spider_allocated_thds_get_key, 0, 0)) goto error_allocated_thds_hash_init; @@ -7261,12 +6699,6 @@ int spider_db_init( spider_dbton_mariadb.db_util->dbton_id = dbton_id; spider_dbton[dbton_id] = spider_dbton_mariadb; ++dbton_id; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - spider_dbton_handlersocket.dbton_id = dbton_id; - spider_dbton_handlersocket.db_util->dbton_id = dbton_id; - spider_dbton[dbton_id] = spider_dbton_handlersocket; - ++dbton_id; -#endif #ifdef HAVE_ORACLE_OCI spider_dbton_oracle.dbton_id = dbton_id; spider_dbton_oracle.db_util->dbton_id = dbton_id; @@ -7344,20 +6776,6 @@ error_mon_table_cache_array_init: error_allocated_thds_hash_init: my_hash_free(&spider_ipport_conns); error_ipport_conn__hash_init: -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - spider_free_mem_calc(NULL, - spider_hs_w_conn_hash_id, - spider_hs_w_conn_hash.array.max_element * - spider_hs_w_conn_hash.array.size_of_element); - my_hash_free(&spider_hs_w_conn_hash); -error_hs_w_conn_hash_init: - spider_free_mem_calc(NULL, - spider_hs_r_conn_hash_id, - spider_hs_r_conn_hash.array.max_element * - spider_hs_r_conn_hash.array.size_of_element); - my_hash_free(&spider_hs_r_conn_hash); -error_hs_r_conn_hash_init: -#endif spider_free_mem_calc(NULL, spider_open_connections_id, spider_open_connections.array.max_element * @@ -7396,12 +6814,6 @@ error_mem_calc_mutex_init: error_mon_table_cache_mutex_init: pthread_mutex_destroy(&spider_allocated_thds_mutex); error_allocated_thds_mutex_init: -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - pthread_mutex_destroy(&spider_hs_w_conn_mutex); -error_hs_w_conn_mutex_init: - pthread_mutex_destroy(&spider_hs_r_conn_mutex); -error_hs_r_conn_mutex_init: -#endif pthread_mutex_destroy(&spider_open_conn_mutex); error_open_conn_mutex_init: pthread_mutex_destroy(&spider_conn_mutex); @@ -7980,112 +7392,6 @@ bool spider_check_pk_update( DBUG_RETURN(FALSE); } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS -bool spider_check_hs_pk_update( - ha_spider *spider, - key_range *key -) { - uint roop_count, field_index, set_count = 0; - TABLE *table = spider->get_table(); - TABLE_SHARE *table_share = table->s; - SPIDER_SHARE *share = spider->share; - KEY *key_info; - KEY_PART_INFO *key_part; - char buf[MAX_FIELD_WIDTH], buf2[MAX_FIELD_WIDTH]; - spider_string tmp_str(buf, MAX_FIELD_WIDTH, &my_charset_bin), - tmp_str2(buf2, MAX_FIELD_WIDTH, &my_charset_bin); - String *str, *str2; - DBUG_ENTER("spider_check_hs_pk_update"); - tmp_str.init_calc_mem(SPD_MID_CHECK_HS_PK_UPDATE_1); - - if (table_share->primary_key == MAX_KEY) - DBUG_RETURN(FALSE); - memset(spider->tmp_column_bitmap, 0, sizeof(uchar) * share->bitmap_size); - key_info = &table->key_info[table_share->primary_key]; - key_part = key_info->key_part; - for (roop_count = 0; roop_count < spider_user_defined_key_parts(key_info); - roop_count++) - { - field_index = key_part[roop_count].field->field_index; - if (bitmap_is_set(table->write_set, field_index)) - { - DBUG_PRINT("info", ("spider set key_part=%u field_index=%u", - roop_count, field_index)); - spider_set_bit(spider->tmp_column_bitmap, field_index); - set_count++; - } - } - DBUG_PRINT("info", ("spider set_count=%u", set_count)); - - Field *field; - uint store_length, length, var_len; - const uchar *ptr; - bool key_eq; - key_part_map tgt_key_part_map = key->keypart_map; - key_info = &table->key_info[spider->active_index]; - for ( - key_part = key_info->key_part, - length = 0; - tgt_key_part_map; - length += store_length, - tgt_key_part_map >>= 1, - key_part++ - ) { - store_length = key_part->store_length; - field = key_part->field; - field_index = field->field_index; - if (spider_bit_is_set(spider->tmp_column_bitmap, field_index)) - { - ptr = key->key + length; - key_eq = (tgt_key_part_map > 1); - if (key_part->null_bit && *ptr++) - { - if (key->flag != HA_READ_KEY_EXACT || !field->is_null()) - { - DBUG_PRINT("info", ("spider flag=%u is_null=%s", - key->flag, field->is_null() ? "TRUE" : "FALSE")); - DBUG_RETURN(TRUE); - } - } else { - if ( - field->type() == MYSQL_TYPE_BLOB || - field->real_type() == MYSQL_TYPE_VARCHAR || - field->type() == MYSQL_TYPE_GEOMETRY - ) { - var_len = uint2korr(ptr); - tmp_str.set_quick((char *) ptr + HA_KEY_BLOB_LENGTH, var_len, - &my_charset_bin); - str = tmp_str.get_str(); - } else { - str = field->val_str(tmp_str.get_str(), ptr); - tmp_str.mem_calc(); - } - str2 = field->val_str(tmp_str2.get_str()); - tmp_str2.mem_calc(); - if ( - str->length() != str2->length() || - memcmp(str->ptr(), str2->ptr(), str->length()) - ) { - DBUG_PRINT("info", ("spider length=%u %u", - str->length(), str2->length())); - DBUG_PRINT("info", ("spider length=%s %s", - str->c_ptr_safe(), str2->c_ptr_safe())); - DBUG_RETURN(TRUE); - } - } - set_count--; - } - } - DBUG_PRINT("info", ("spider set_count=%u", set_count)); - if (set_count) - { - DBUG_RETURN(TRUE); - } - DBUG_RETURN(FALSE); -} -#endif -#endif void spider_set_tmp_share_pointer( SPIDER_SHARE *tmp_share, @@ -8116,10 +7422,6 @@ void spider_set_tmp_share_pointer( tmp_share->tgt_pk_names = &tmp_connect_info[16]; tmp_share->tgt_sequence_names = &tmp_connect_info[17]; tmp_share->static_link_ids = &tmp_connect_info[18]; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - tmp_share->hs_read_socks = &tmp_connect_info[19]; - tmp_share->hs_write_socks = &tmp_connect_info[20]; -#endif tmp_share->tgt_ports = &tmp_long[0]; tmp_share->tgt_ssl_vscs = &tmp_long[1]; tmp_share->link_statuses = &tmp_long[2]; @@ -8129,13 +7431,6 @@ void spider_set_tmp_share_pointer( #ifndef WITHOUT_SPIDER_BG_SEARCH tmp_share->monitoring_bg_flag = &tmp_long[6]; tmp_share->monitoring_bg_kind = &tmp_long[7]; -#endif -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - tmp_share->use_hs_reads = &tmp_long[8]; - tmp_share->use_hs_writes = &tmp_long[9]; - tmp_share->hs_read_ports = &tmp_long[10]; - tmp_share->hs_write_ports = &tmp_long[11]; - tmp_share->hs_write_to_reads = &tmp_long[12]; #endif tmp_share->use_handlers = &tmp_long[13]; tmp_share->connect_timeouts = &tmp_long[14]; @@ -8171,10 +7466,6 @@ void spider_set_tmp_share_pointer( tmp_share->tgt_pk_names_lengths = &tmp_connect_info_length[16]; tmp_share->tgt_sequence_names_lengths = &tmp_connect_info_length[17]; tmp_share->static_link_ids_lengths = &tmp_connect_info_length[18]; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - tmp_share->hs_read_socks_lengths = &tmp_connect_info_length[19]; - tmp_share->hs_write_socks_lengths = &tmp_connect_info_length[20]; -#endif tmp_share->server_names_length = 1; tmp_share->tgt_table_names_length = 1; tmp_share->tgt_dbs_length = 1; @@ -8208,15 +7499,6 @@ void spider_set_tmp_share_pointer( tmp_share->monitoring_sid_length = 1; #ifndef WITHOUT_SPIDER_BG_SEARCH tmp_share->monitoring_bg_interval_length = 1; -#endif -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - tmp_share->hs_read_socks_length = 1; - tmp_share->hs_write_socks_length = 1; - tmp_share->use_hs_reads_length = 1; - tmp_share->use_hs_writes_length = 1; - tmp_share->hs_read_ports_length = 1; - tmp_share->hs_write_ports_length = 1; - tmp_share->hs_write_to_reads_length = 1; #endif tmp_share->use_handlers_length = 1; tmp_share->connect_timeouts_length = 1; @@ -8240,9 +7522,6 @@ void spider_set_tmp_share_pointer( tmp_share->monitoring_sid[0] = -1; tmp_share->bka_engine = NULL; tmp_share->use_dbton_count = 0; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - tmp_share->use_hs_dbton_count = 0; -#endif DBUG_VOID_RETURN; } @@ -8425,26 +7704,17 @@ longlong spider_split_read_param( #ifdef SPIDER_HAS_GROUP_BY_HANDLER bool inserting = ( -#ifdef HS_HAS_SQLCOM - spider->wide_handler->sql_command == SQLCOM_HS_INSERT || -#endif spider->wide_handler->sql_command == SQLCOM_INSERT || spider->wide_handler->sql_command == SQLCOM_INSERT_SELECT ); #endif bool updating = ( -#ifdef HS_HAS_SQLCOM - spider->wide_handler->sql_command == SQLCOM_HS_UPDATE || -#endif spider->wide_handler->sql_command == SQLCOM_UPDATE || spider->wide_handler->sql_command == SQLCOM_UPDATE_MULTI ); bool deleting = ( -#ifdef HS_HAS_SQLCOM - spider->wide_handler->sql_command == SQLCOM_HS_DELETE || -#endif spider->wide_handler->sql_command == SQLCOM_DELETE || spider->wide_handler->sql_command == SQLCOM_DELETE_MULTI ); @@ -9512,10 +8782,6 @@ int spider_create_spider_object_for_share( uint *conn_link_idx; uchar *conn_can_fo; char **conn_keys; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - char **hs_r_conn_keys; - char **hs_w_conn_keys; -#endif spider_db_handler **dbton_hdl; SPIDER_WIDE_HANDLER *wide_handler; DBUG_ENTER("spider_create_spider_object_for_share"); @@ -9536,21 +8802,6 @@ int spider_create_spider_object_for_share( goto error_spider_alloc; } DBUG_PRINT("info",("spider spider=%p", (*spider))); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (!(need_mons = (int *) - spider_bulk_malloc(spider_current_trx, SPD_MID_CREATE_SPIDER_OBJECT_FOR_SHARE_1, MYF(MY_WME | MY_ZEROFILL), - &need_mons, (uint) (sizeof(int) * share->link_count), - &conns, (uint) (sizeof(SPIDER_CONN *) * share->link_count), - &conn_link_idx, (uint) (sizeof(uint) * share->link_count), - &conn_can_fo, (uint) (sizeof(uchar) * share->link_bitmap_size), - &conn_keys, (uint) (sizeof(char *) * share->link_count), - &hs_r_conn_keys, (uint) (sizeof(char *) * share->link_count), - &hs_w_conn_keys, (uint) (sizeof(char *) * share->link_count), - &dbton_hdl, (uint) (sizeof(spider_db_handler *) * SPIDER_DBTON_SIZE), - &wide_handler, (uint) sizeof(SPIDER_WIDE_HANDLER), - NullS)) - ) -#else if (!(need_mons = (int *) spider_bulk_malloc(spider_current_trx, SPD_MID_CREATE_SPIDER_OBJECT_FOR_SHARE_2, MYF(MY_WME | MY_ZEROFILL), &need_mons, (uint) (sizeof(int) * share->link_count), @@ -9562,7 +8813,6 @@ int spider_create_spider_object_for_share( &wide_handler, (uint) sizeof(SPIDER_WIDE_HANDLER), NullS)) ) -#endif { error_num = HA_ERR_OUT_OF_MEM; goto error_need_mons_alloc; @@ -9578,10 +8828,6 @@ int spider_create_spider_object_for_share( (*spider)->need_mons = need_mons; (*spider)->conn_keys_first_ptr = share->conn_keys[0]; (*spider)->conn_keys = conn_keys; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - (*spider)->hs_r_conn_keys = hs_r_conn_keys; - (*spider)->hs_w_conn_keys = hs_w_conn_keys; -#endif (*spider)->dbton_handler = dbton_hdl; (*spider)->search_link_idx = -1; for (roop_count = 0; roop_count < SPIDER_DBTON_SIZE; roop_count++) diff --git a/storage/spider/spd_table.h b/storage/spider/spd_table.h index c87f91ac08b..8ab00212091 100644 --- a/storage/spider/spd_table.h +++ b/storage/spider/spd_table.h @@ -372,14 +372,6 @@ bool spider_check_pk_update( TABLE *table ); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS -bool spider_check_hs_pk_update( - ha_spider *spider, - key_range *key -); -#endif -#endif void spider_set_tmp_share_pointer( SPIDER_SHARE *tmp_share, diff --git a/storage/spider/spd_trx.cc b/storage/spider/spd_trx.cc index d96567e426c..65bd6fc2120 100644 --- a/storage/spider/spd_trx.cc +++ b/storage/spider/spd_trx.cc @@ -1078,30 +1078,6 @@ int spider_free_trx_alloc( trx->trx_another_conn_hash.array.max_element * trx->trx_another_conn_hash.array.size_of_element); my_hash_free(&trx->trx_another_conn_hash); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - spider_free_mem_calc(spider_current_trx, - trx->trx_direct_hs_r_conn_hash_id, - trx->trx_direct_hs_r_conn_hash.array.max_element * - trx->trx_direct_hs_r_conn_hash.array.size_of_element); - my_hash_free(&trx->trx_direct_hs_r_conn_hash); - spider_free_mem_calc(spider_current_trx, - trx->trx_direct_hs_w_conn_hash_id, - trx->trx_direct_hs_w_conn_hash.array.max_element * - trx->trx_direct_hs_w_conn_hash.array.size_of_element); - my_hash_free(&trx->trx_direct_hs_w_conn_hash); -#endif -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - spider_free_mem_calc(spider_current_trx, - trx->trx_hs_r_conn_hash_id, - trx->trx_hs_r_conn_hash.array.max_element * - trx->trx_hs_r_conn_hash.array.size_of_element); - my_hash_free(&trx->trx_hs_r_conn_hash); - spider_free_mem_calc(spider_current_trx, - trx->trx_hs_w_conn_hash_id, - trx->trx_hs_w_conn_hash.array.max_element * - trx->trx_hs_w_conn_hash.array.size_of_element); - my_hash_free(&trx->trx_hs_w_conn_hash); -#endif spider_free_mem_calc(spider_current_trx, trx->trx_ha_hash_id, trx->trx_ha_hash.array.max_element * @@ -1183,57 +1159,7 @@ SPIDER_TRX *spider_get_trx( trx->trx_another_conn_hash.array.max_element * trx->trx_another_conn_hash.array.size_of_element); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if ( - my_hash_init(&trx->trx_hs_r_conn_hash, spd_charset_utf8mb3_bin, 32, 0, 0, - (my_hash_get_key) spider_conn_get_key, 0, 0) - ) - goto error_hs_r_init_hash; - spider_alloc_calc_mem_init(trx->trx_hs_r_conn_hash, SPD_MID_GET_TRX_4); - spider_alloc_calc_mem( - thd ? ((SPIDER_TRX *) thd_get_ha_data(thd, spider_hton_ptr)) : NULL, - trx->trx_hs_r_conn_hash, - trx->trx_hs_r_conn_hash.array.max_element * - trx->trx_hs_r_conn_hash.array.size_of_element); - if ( - my_hash_init(&trx->trx_hs_w_conn_hash, spd_charset_utf8mb3_bin, 32, 0, 0, - (my_hash_get_key) spider_conn_get_key, 0, 0) - ) - goto error_hs_w_init_hash; - spider_alloc_calc_mem_init(trx->trx_hs_w_conn_hash, SPD_MID_GET_TRX_5); - spider_alloc_calc_mem( - thd ? ((SPIDER_TRX *) thd_get_ha_data(thd, spider_hton_ptr)) : NULL, - trx->trx_hs_w_conn_hash, - trx->trx_hs_w_conn_hash.array.max_element * - trx->trx_hs_w_conn_hash.array.size_of_element); -#endif - -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if ( - my_hash_init(&trx->trx_direct_hs_r_conn_hash, spd_charset_utf8mb3_bin, 32, - 0, 0, (my_hash_get_key) spider_conn_get_key, 0, 0) - ) - goto error_direct_hs_r_init_hash; - spider_alloc_calc_mem_init(trx->trx_direct_hs_r_conn_hash, SPD_MID_GET_TRX_6); - spider_alloc_calc_mem( - thd ? ((SPIDER_TRX *) thd_get_ha_data(thd, spider_hton_ptr)) : NULL, - trx->trx_direct_hs_r_conn_hash, - trx->trx_direct_hs_r_conn_hash.array.max_element * - trx->trx_direct_hs_r_conn_hash.array.size_of_element); - - if ( - my_hash_init(&trx->trx_direct_hs_w_conn_hash, spd_charset_utf8mb3_bin, 32, - 0, 0, (my_hash_get_key) spider_conn_get_key, 0, 0) - ) - goto error_direct_hs_w_init_hash; - spider_alloc_calc_mem_init(trx->trx_direct_hs_w_conn_hash, SPD_MID_GET_TRX_7); - spider_alloc_calc_mem( - thd ? ((SPIDER_TRX *) thd_get_ha_data(thd, spider_hton_ptr)) : NULL, - trx->trx_direct_hs_w_conn_hash, - trx->trx_direct_hs_w_conn_hash.array.max_element * - trx->trx_direct_hs_w_conn_hash.array.size_of_element); -#endif if ( my_hash_init(PSI_INSTRUMENT_ME, &trx->trx_alter_table_hash, @@ -1274,10 +1200,6 @@ SPIDER_TRX *spider_get_trx( ++spider_thread_id; pthread_mutex_unlock(&spider_thread_id_mutex); trx->trx_conn_adjustment = 1; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - trx->trx_hs_r_conn_adjustment = 1; - trx->trx_hs_w_conn_adjustment = 1; -#endif if (thd) { @@ -1431,38 +1353,6 @@ error_init_trx_ha_hash: trx->trx_alter_table_hash.array.size_of_element); my_hash_free(&trx->trx_alter_table_hash); error_init_alter_hash: -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - spider_free_mem_calc( - thd ? ((SPIDER_TRX *) thd_get_ha_data(thd, spider_hton_ptr)) : NULL, - trx->trx_direct_hs_w_conn_hash_id, - trx->trx_direct_hs_w_conn_hash.array.max_element * - trx->trx_direct_hs_w_conn_hash.array.size_of_element); - my_hash_free(&trx->trx_direct_hs_w_conn_hash); -error_direct_hs_w_init_hash: - spider_free_mem_calc( - thd ? ((SPIDER_TRX *) thd_get_ha_data(thd, spider_hton_ptr)) : NULL, - trx->trx_direct_hs_r_conn_hash_id, - trx->trx_direct_hs_r_conn_hash.array.max_element * - trx->trx_direct_hs_r_conn_hash.array.size_of_element); - my_hash_free(&trx->trx_direct_hs_r_conn_hash); -error_direct_hs_r_init_hash: -#endif -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - spider_free_mem_calc( - thd ? ((SPIDER_TRX *) thd_get_ha_data(thd, spider_hton_ptr)) : NULL, - trx->trx_hs_w_conn_hash_id, - trx->trx_hs_w_conn_hash.array.max_element * - trx->trx_hs_w_conn_hash.array.size_of_element); - my_hash_free(&trx->trx_hs_w_conn_hash); -error_hs_w_init_hash: - spider_free_mem_calc( - thd ? ((SPIDER_TRX *) thd_get_ha_data(thd, spider_hton_ptr)) : NULL, - trx->trx_hs_r_conn_hash_id, - trx->trx_hs_r_conn_hash.array.max_element * - trx->trx_hs_r_conn_hash.array.size_of_element); - my_hash_free(&trx->trx_hs_r_conn_hash); -error_hs_r_init_hash: -#endif spider_free_mem_calc( thd ? ((SPIDER_TRX *) thd_get_ha_data(thd, spider_hton_ptr)) : NULL, trx->trx_another_conn_hash_id, @@ -3618,24 +3508,6 @@ int spider_check_trx_and_get_conn( if (!trx_ha || trx_ha->wait_for_reusing) spider_trx_set_link_idx_for_all(spider); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS - if (use_conn_kind) - { - for (roop_count = 0; roop_count < (int) share->link_count; roop_count++) - { - if ( - share->hs_dbton_ids[spider->conn_link_idx[roop_count]] == - SPIDER_DBTON_SIZE - ) { - /* can't use hs interface */ - spider->conn_kind[roop_count] = SPIDER_CONN_KIND_MYSQL; - spider_clear_bit(spider->do_hs_direct_update, roop_count); - } - } - } -#endif -#endif if (semi_table_lock_conn) first_byte = '0' + @@ -3652,14 +3524,6 @@ int spider_check_trx_and_get_conn( trx_ha->wait_for_reusing || trx->spider_thread_id != spider->spider_thread_id || trx->trx_conn_adjustment != spider->trx_conn_adjustment || -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - (use_conn_kind && - ( - trx->trx_hs_r_conn_adjustment != spider->trx_hs_r_conn_adjustment || - trx->trx_hs_w_conn_adjustment != spider->trx_hs_w_conn_adjustment - ) - ) || -#endif first_byte != *spider->conn_keys[0] || share->link_statuses[spider->conn_link_idx[spider->search_link_idx]] == SPIDER_LINK_STATUS_NG @@ -3669,13 +3533,6 @@ int spider_check_trx_and_get_conn( "spider change thd" : "spider next trx")); spider->wide_handler->trx = trx; spider->trx_conn_adjustment = trx->trx_conn_adjustment; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (use_conn_kind) - { - spider->trx_hs_r_conn_adjustment = trx->trx_hs_r_conn_adjustment; - spider->trx_hs_w_conn_adjustment = trx->trx_hs_w_conn_adjustment; - } -#endif if ( spider->spider_thread_id != trx->spider_thread_id || spider->search_link_query_id != thd->query_id @@ -3720,12 +3577,6 @@ int spider_check_trx_and_get_conn( { if (!spider->handler_opened(roop_count, SPIDER_CONN_KIND_MYSQL)) spider->conns[roop_count] = NULL; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (!spider->handler_opened(roop_count, SPIDER_CONN_KIND_HS_READ)) - spider->hs_r_conns[roop_count] = NULL; - if (!spider->handler_opened(roop_count, SPIDER_CONN_KIND_HS_WRITE)) - spider->hs_w_conns[roop_count] = NULL; -#endif } bool search_link_idx_is_checked = FALSE; for ( @@ -3742,18 +3593,8 @@ int spider_check_trx_and_get_conn( if (roop_count == spider->search_link_idx) search_link_idx_is_checked = TRUE; if ( -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - ( -#endif tgt_conn_kind == SPIDER_CONN_KIND_MYSQL && !spider->conns[roop_count] -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - ) || - (tgt_conn_kind == SPIDER_CONN_KIND_HS_READ && - !spider->hs_r_conns[roop_count]) || - (tgt_conn_kind == SPIDER_CONN_KIND_HS_WRITE && - !spider->hs_w_conns[roop_count]) -#endif ) { *spider->conn_keys[roop_count] = first_byte; if ( @@ -3793,51 +3634,6 @@ int spider_check_trx_and_get_conn( } conn->error_mode &= spider->error_mode; } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS - if ( - spider->do_direct_update && - spider_bit_is_set(spider->do_hs_direct_update, roop_count) && - !spider->hs_w_conns[roop_count] - ) { - if ( - !(conn = - spider_get_conn(share, roop_count, - spider->conn_keys[roop_count], trx, - spider, FALSE, TRUE, - SPIDER_CONN_KIND_HS_WRITE, - &error_num)) - ) { - if ( - share->monitoring_kind[roop_count] && - spider->need_mons[roop_count] - ) { - error_num = spider_ping_table_mon_from_table( - trx, - trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - spider->conn_link_idx[roop_count], - NULL, - 0, - share->monitoring_kind[roop_count], - share->monitoring_limit[roop_count], - share->monitoring_flag[roop_count], - TRUE - ); - } - DBUG_PRINT("info",("spider get conn error")); - *spider->conn_keys[0] = first_byte_bak; - spider->spider_thread_id = 0; - DBUG_RETURN(error_num); - } - conn->error_mode &= spider->error_mode; - } -#endif -#endif } if (!search_link_idx_is_checked) { @@ -3876,21 +3672,7 @@ int spider_check_trx_and_get_conn( ) { if (roop_count == spider->search_link_idx) search_link_idx_is_checked = TRUE; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if ( - !use_conn_kind || - spider->conn_kind[roop_count] == SPIDER_CONN_KIND_MYSQL - ) { -#endif - conn = spider->conns[roop_count]; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else if (spider->conn_kind[roop_count] == SPIDER_CONN_KIND_HS_READ) - { - conn = spider->hs_r_conns[roop_count]; - } else { - conn = spider->hs_w_conns[roop_count]; - } -#endif + conn = spider->conns[roop_count]; if (!conn) { @@ -3930,53 +3712,6 @@ int spider_check_trx_and_get_conn( } } conn->error_mode &= spider->error_mode; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS - if ( - spider->do_direct_update && - spider_bit_is_set(spider->do_hs_direct_update, roop_count) - ) { - conn = spider->hs_w_conns[roop_count]; - if (!conn) - { - DBUG_PRINT("info",("spider get hs_w_conn %d", roop_count)); - if ( - !(conn = - spider_get_conn(share, roop_count, - spider->conn_keys[roop_count], trx, - spider, FALSE, TRUE, - SPIDER_CONN_KIND_HS_WRITE, - &error_num)) - ) { - if ( - share->monitoring_kind[roop_count] && - spider->need_mons[roop_count] - ) { - error_num = spider_ping_table_mon_from_table( - trx, - trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - spider->conn_link_idx[roop_count], - NULL, - 0, - share->monitoring_kind[roop_count], - share->monitoring_limit[roop_count], - share->monitoring_flag[roop_count], - TRUE - ); - } - DBUG_PRINT("info",("spider get conn error")); - DBUG_RETURN(error_num); - } - } - } - conn->error_mode &= spider->error_mode; -#endif -#endif } if (!search_link_idx_is_checked) { @@ -4217,20 +3952,6 @@ void spider_trx_set_link_idx_for_all( share->conn_keys[0]), char*); DBUG_PRINT("info",("spider conn_keys[%d]=%s", roop_count, spider->conn_keys[roop_count])); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - spider->hs_r_conn_keys[roop_count] = - ADD_TO_PTR(spider->conn_keys_first_ptr, - PTR_BYTE_DIFF(share->hs_read_conn_keys[conn_link_idx[roop_count]], - share->conn_keys[0]), char*); - DBUG_PRINT("info",("spider hs_r_conn_keys[%d]=%s", - roop_count, spider->hs_r_conn_keys[roop_count])); - spider->hs_w_conn_keys[roop_count] = - ADD_TO_PTR(spider->conn_keys_first_ptr, - PTR_BYTE_DIFF(share->hs_write_conn_keys[conn_link_idx[roop_count]], - share->conn_keys[0]), char*); - DBUG_PRINT("info",("spider hs_w_conn_keys[%d]=%s", - roop_count, spider->hs_w_conn_keys[roop_count])); -#endif } DBUG_VOID_RETURN; } From 6d0c9872d9579cd6315418275508974f5bbaabf7 Mon Sep 17 00:00:00 2001 From: Nayuta Yanagisawa Date: Fri, 27 May 2022 08:55:42 +0900 Subject: [PATCH 41/42] MDEV-28522 Delete constant SPIDER_SQL_TYPE_*_HS The HandlerSocket support of Spider has been deleted by MDEV-26858. Thus, the constants, SPIDER_SQL_TYPE_*_HS, are no longer necessary. --- storage/spider/spd_db_include.h | 5 -- storage/spider/spd_db_mysql.cc | 138 +++++++++----------------------- storage/spider/spd_db_mysql.h | 38 ++------- 3 files changed, 44 insertions(+), 137 deletions(-) diff --git a/storage/spider/spd_db_include.h b/storage/spider/spd_db_include.h index eef5ea0927a..4f25b0a2fe1 100644 --- a/storage/spider/spd_db_include.h +++ b/storage/spider/spd_db_include.h @@ -192,11 +192,6 @@ typedef st_spider_result SPIDER_RESULT; #define SPIDER_SQL_TYPE_DROP_TMP_TABLE_SQL (1 << 6) #define SPIDER_SQL_TYPE_OTHER_SQL (1 << 7) #define SPIDER_SQL_TYPE_HANDLER (1 << 8) -#define SPIDER_SQL_TYPE_SELECT_HS (1 << 9) -#define SPIDER_SQL_TYPE_INSERT_HS (1 << 10) -#define SPIDER_SQL_TYPE_UPDATE_HS (1 << 11) -#define SPIDER_SQL_TYPE_DELETE_HS (1 << 12) -#define SPIDER_SQL_TYPE_OTHER_HS (1 << 13) enum spider_bulk_upd_start { SPD_BU_NOT_START, diff --git a/storage/spider/spd_db_mysql.cc b/storage/spider/spd_db_mysql.cc index 847e9413f3b..d5f693c2cde 100644 --- a/storage/spider/spd_db_mysql.cc +++ b/storage/spider/spd_db_mysql.cc @@ -12407,23 +12407,14 @@ int spider_mbase_handler::append_from( DBUG_RETURN(0); } -int spider_mbase_handler::append_flush_tables_part( - ulong sql_type, - int link_idx, - bool lock -) { +int spider_mbase_handler::append_flush_tables_part(int link_idx, bool lock) +{ int error_num; spider_string *str; DBUG_ENTER("spider_mbase_handler::append_flush_tables_part"); DBUG_PRINT("info",("spider this=%p", this)); - switch (sql_type) - { - case SPIDER_SQL_TYPE_OTHER_SQL: - str = &spider->result_list.sqls[link_idx]; - break; - default: - DBUG_RETURN(0); - } + + str= &spider->result_list.sqls[link_idx]; error_num = append_flush_tables(str, link_idx, lock); DBUG_RETURN(error_num); } @@ -12451,22 +12442,14 @@ int spider_mbase_handler::append_flush_tables( DBUG_RETURN(0); } -int spider_mbase_handler::append_optimize_table_part( - ulong sql_type, - int link_idx -) { +int spider_mbase_handler::append_optimize_table_part(int link_idx) +{ int error_num; spider_string *str; DBUG_ENTER("spider_mbase_handler::append_optimize_table_part"); DBUG_PRINT("info",("spider this=%p", this)); - switch (sql_type) - { - case SPIDER_SQL_TYPE_OTHER_SQL: - str = &spider->result_list.sqls[link_idx]; - break; - default: - DBUG_RETURN(0); - } + + str= &spider->result_list.sqls[link_idx]; error_num = append_optimize_table(str, link_idx); DBUG_RETURN(error_num); } @@ -12497,22 +12480,14 @@ int spider_mbase_handler::append_optimize_table( DBUG_RETURN(0); } -int spider_mbase_handler::append_analyze_table_part( - ulong sql_type, - int link_idx -) { +int spider_mbase_handler::append_analyze_table_part(int link_idx) +{ int error_num; spider_string *str; DBUG_ENTER("spider_mbase_handler::append_analyze_table_part"); DBUG_PRINT("info",("spider this=%p", this)); - switch (sql_type) - { - case SPIDER_SQL_TYPE_OTHER_SQL: - str = &spider->result_list.sqls[link_idx]; - break; - default: - DBUG_RETURN(0); - } + + str= &spider->result_list.sqls[link_idx]; error_num = append_analyze_table(str, link_idx); DBUG_RETURN(error_num); } @@ -12543,23 +12518,15 @@ int spider_mbase_handler::append_analyze_table( DBUG_RETURN(0); } -int spider_mbase_handler::append_repair_table_part( - ulong sql_type, - int link_idx, - HA_CHECK_OPT* check_opt -) { +int spider_mbase_handler::append_repair_table_part(int link_idx, + HA_CHECK_OPT *check_opt) +{ int error_num; spider_string *str; DBUG_ENTER("spider_mbase_handler::append_repair_table_part"); DBUG_PRINT("info",("spider this=%p", this)); - switch (sql_type) - { - case SPIDER_SQL_TYPE_OTHER_SQL: - str = &spider->result_list.sqls[link_idx]; - break; - default: - DBUG_RETURN(0); - } + + str= &spider->result_list.sqls[link_idx]; error_num = append_repair_table(str, link_idx, check_opt); DBUG_RETURN(error_num); } @@ -12609,23 +12576,15 @@ int spider_mbase_handler::append_repair_table( DBUG_RETURN(0); } -int spider_mbase_handler::append_check_table_part( - ulong sql_type, - int link_idx, - HA_CHECK_OPT* check_opt -) { +int spider_mbase_handler::append_check_table_part(int link_idx, + HA_CHECK_OPT *check_opt) +{ int error_num; spider_string *str; DBUG_ENTER("spider_mbase_handler::append_check_table_part"); DBUG_PRINT("info",("spider this=%p", this)); - switch (sql_type) - { - case SPIDER_SQL_TYPE_OTHER_SQL: - str = &spider->result_list.sqls[link_idx]; - break; - default: - DBUG_RETURN(0); - } + + str= &spider->result_list.sqls[link_idx]; error_num = append_check_table(str, link_idx, check_opt); DBUG_RETURN(error_num); } @@ -12674,22 +12633,14 @@ int spider_mbase_handler::append_check_table( DBUG_RETURN(0); } -int spider_mbase_handler::append_enable_keys_part( - ulong sql_type, - int link_idx -) { +int spider_mbase_handler::append_enable_keys_part(int link_idx) +{ int error_num; spider_string *str; DBUG_ENTER("spider_mbase_handler::append_enable_keys_part"); DBUG_PRINT("info",("spider this=%p", this)); - switch (sql_type) - { - case SPIDER_SQL_TYPE_OTHER_SQL: - str = &spider->result_list.sqls[link_idx]; - break; - default: - DBUG_RETURN(0); - } + + str= &spider->result_list.sqls[link_idx]; error_num = append_enable_keys(str, link_idx); DBUG_RETURN(error_num); } @@ -12715,22 +12666,14 @@ int spider_mbase_handler::append_enable_keys( DBUG_RETURN(0); } -int spider_mbase_handler::append_disable_keys_part( - ulong sql_type, - int link_idx -) { +int spider_mbase_handler::append_disable_keys_part(int link_idx) +{ int error_num; spider_string *str; DBUG_ENTER("spider_mbase_handler::append_disable_keys_part"); DBUG_PRINT("info",("spider this=%p", this)); - switch (sql_type) - { - case SPIDER_SQL_TYPE_OTHER_SQL: - str = &spider->result_list.sqls[link_idx]; - break; - default: - DBUG_RETURN(0); - } + + str= &spider->result_list.sqls[link_idx]; error_num = append_disable_keys(str, link_idx); DBUG_RETURN(error_num); } @@ -14806,8 +14749,7 @@ int spider_mbase_handler::disable_keys( DBUG_ENTER("spider_mbase_handler::disable_keys"); DBUG_PRINT("info",("spider this=%p", this)); str->length(0); - if ((error_num = append_disable_keys_part(SPIDER_SQL_TYPE_OTHER_HS, - link_idx))) + if ((error_num= append_disable_keys_part(link_idx))) { DBUG_RETURN(error_num); } @@ -14865,8 +14807,7 @@ int spider_mbase_handler::enable_keys( DBUG_ENTER("spider_mbase_handler::enable_keys"); DBUG_PRINT("info",("spider this=%p", this)); str->length(0); - if ((error_num = append_enable_keys_part(SPIDER_SQL_TYPE_OTHER_HS, - link_idx))) + if ((error_num= append_enable_keys_part(link_idx))) { DBUG_RETURN(error_num); } @@ -14925,8 +14866,7 @@ int spider_mbase_handler::check_table( DBUG_ENTER("spider_mbase_handler::check_table"); DBUG_PRINT("info",("spider this=%p", this)); str->length(0); - if ((error_num = append_check_table_part(SPIDER_SQL_TYPE_OTHER_HS, - link_idx, check_opt))) + if ((error_num= append_check_table_part(link_idx, check_opt))) { DBUG_RETURN(error_num); } @@ -14985,8 +14925,7 @@ int spider_mbase_handler::repair_table( DBUG_ENTER("spider_mbase_handler::repair_table"); DBUG_PRINT("info",("spider this=%p", this)); str->length(0); - if ((error_num = append_repair_table_part(SPIDER_SQL_TYPE_OTHER_HS, - link_idx, check_opt))) + if ((error_num= append_repair_table_part(link_idx, check_opt))) { DBUG_RETURN(error_num); } @@ -15044,8 +14983,7 @@ int spider_mbase_handler::analyze_table( DBUG_ENTER("spider_mbase_handler::analyze_table"); DBUG_PRINT("info",("spider this=%p", this)); str->length(0); - if ((error_num = append_analyze_table_part(SPIDER_SQL_TYPE_OTHER_HS, - link_idx))) + if ((error_num= append_analyze_table_part(link_idx))) { DBUG_RETURN(error_num); } @@ -15103,8 +15041,7 @@ int spider_mbase_handler::optimize_table( DBUG_ENTER("spider_mbase_handler::optimize_table"); DBUG_PRINT("info",("spider this=%p", this)); str->length(0); - if ((error_num = append_optimize_table_part(SPIDER_SQL_TYPE_OTHER_HS, - link_idx))) + if ((error_num= append_optimize_table_part(link_idx))) { DBUG_RETURN(error_num); } @@ -15163,8 +15100,7 @@ int spider_mbase_handler::flush_tables( DBUG_ENTER("spider_mbase_handler::flush_tables"); DBUG_PRINT("info",("spider this=%p", this)); str->length(0); - if ((error_num = append_flush_tables_part(SPIDER_SQL_TYPE_OTHER_HS, - link_idx, lock))) + if ((error_num= append_flush_tables_part(link_idx, lock))) { DBUG_RETURN(error_num); } diff --git a/storage/spider/spd_db_mysql.h b/storage/spider/spd_db_mysql.h index 846289f54e7..231e7374b81 100644 --- a/storage/spider/spd_db_mysql.h +++ b/storage/spider/spd_db_mysql.h @@ -1248,64 +1248,40 @@ public: ulong sql_type, int link_idx ); - int append_flush_tables_part( - ulong sql_type, - int link_idx, - bool lock - ); + int append_flush_tables_part(int link_idx, bool lock); int append_flush_tables( spider_string *str, int link_idx, bool lock ); - int append_optimize_table_part( - ulong sql_type, - int link_idx - ); + int append_optimize_table_part(int link_idx); int append_optimize_table( spider_string *str, int link_idx ); - int append_analyze_table_part( - ulong sql_type, - int link_idx - ); + int append_analyze_table_part(int link_idx); int append_analyze_table( spider_string *str, int link_idx ); - int append_repair_table_part( - ulong sql_type, - int link_idx, - HA_CHECK_OPT* check_opt - ); + int append_repair_table_part(int link_idx, HA_CHECK_OPT *check_opt); int append_repair_table( spider_string *str, int link_idx, HA_CHECK_OPT* check_opt ); - int append_check_table_part( - ulong sql_type, - int link_idx, - HA_CHECK_OPT* check_opt - ); + int append_check_table_part(int link_idx, HA_CHECK_OPT *check_opt); int append_check_table( spider_string *str, int link_idx, HA_CHECK_OPT* check_opt ); - int append_enable_keys_part( - ulong sql_type, - int link_idx - ); + int append_enable_keys_part(int link_idx); int append_enable_keys( spider_string *str, int link_idx ); - int append_disable_keys_part( - ulong sql_type, - int link_idx - ); + int append_disable_keys_part(int link_idx); int append_disable_keys( spider_string *str, int link_idx From 25476ba1ae18728bec2956f6ff274f38a925d56d Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Thu, 9 May 2024 11:08:14 +1000 Subject: [PATCH 42/42] MDEV-29027 ASAN errors in spider_db_free_result after partition DDL Spider calls ha_spider::close() at least twice on ALTER TABLE ... ADD PARTITION. The first call frees wide_handler and the second call accesses wide_handler->trx->thd (heap-use-after-free). In general, there seems to be no problem with using THD obtained by the macro current_thd() except in background threads. Thus, we simply replace wide_handler->trx->thd with current_thd(). Original author: Nayuta Yanagasawa --- .../spider/bugfix/r/mdev_29027.result | 24 ++++++++++++++++ .../bugfix/r/mdev_29027_original.result | 15 ++++++++++ .../mysql-test/spider/bugfix/t/mdev_29027.cnf | 3 ++ .../spider/bugfix/t/mdev_29027.test | 28 +++++++++++++++++++ .../spider/bugfix/t/mdev_29027_original.test | 22 +++++++++++++++ storage/spider/spd_db_conn.cc | 8 +++--- 6 files changed, 96 insertions(+), 4 deletions(-) create mode 100644 storage/spider/mysql-test/spider/bugfix/r/mdev_29027.result create mode 100644 storage/spider/mysql-test/spider/bugfix/r/mdev_29027_original.result create mode 100644 storage/spider/mysql-test/spider/bugfix/t/mdev_29027.cnf create mode 100644 storage/spider/mysql-test/spider/bugfix/t/mdev_29027.test create mode 100644 storage/spider/mysql-test/spider/bugfix/t/mdev_29027_original.test diff --git a/storage/spider/mysql-test/spider/bugfix/r/mdev_29027.result b/storage/spider/mysql-test/spider/bugfix/r/mdev_29027.result new file mode 100644 index 00000000000..1d9bc01fdb2 --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/r/mdev_29027.result @@ -0,0 +1,24 @@ +# +# MDEV-29027 ASAN errors in spider_db_free_result after partition DDL +# +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +CREATE DATABASE auto_test_local; +USE auto_test_local; +CREATE TABLE tbl_a ( +c INT +) ENGINE=Spider DEFAULT CHARSET=utf8 PARTITION BY HASH(c) ( +PARTITION pt1 +); +ALTER TABLE tbl_a ADD PARTITION (PARTITION pt2); +DROP DATABASE auto_test_local; +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 diff --git a/storage/spider/mysql-test/spider/bugfix/r/mdev_29027_original.result b/storage/spider/mysql-test/spider/bugfix/r/mdev_29027_original.result new file mode 100644 index 00000000000..56391bd5212 --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/r/mdev_29027_original.result @@ -0,0 +1,15 @@ +for master_1 +for child2 +for child3 +set spider_same_server_link= 1; +CREATE SERVER srv FOREIGN DATA WRAPPER mysql +OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); +CREATE TABLE t1 (a INT); +CREATE TABLE t_spider (a INT) ENGINE=SPIDER PARTITION BY HASH(a) (PARTITION p1 COMMENT = "wrapper 'mysql', srv 'srv', table 't1'"); +CREATE TABLE t2 (a INT); +ALTER TABLE t_spider ADD PARTITION (PARTITION p2 COMMENT = "wrapper 'mysql', srv 'srv', table 't2'"); +DROP TABLE t_spider, t1, t2; +drop server srv; +for master_1 +for child2 +for child3 diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_29027.cnf b/storage/spider/mysql-test/spider/bugfix/t/mdev_29027.cnf new file mode 100644 index 00000000000..05dfd8a0bce --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_29027.cnf @@ -0,0 +1,3 @@ +!include include/default_mysqld.cnf +!include ../my_1_1.cnf +!include ../my_2_1.cnf diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_29027.test b/storage/spider/mysql-test/spider/bugfix/t/mdev_29027.test new file mode 100644 index 00000000000..f18154a1d28 --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_29027.test @@ -0,0 +1,28 @@ +--echo # +--echo # MDEV-29027 ASAN errors in spider_db_free_result after partition DDL +--echo # + +--disable_query_log +--disable_result_log +--source ../../t/test_init.inc +--enable_result_log +--enable_query_log + +CREATE DATABASE auto_test_local; +USE auto_test_local; + +eval CREATE TABLE tbl_a ( + c INT +) $MASTER_1_ENGINE $MASTER_1_CHARSET PARTITION BY HASH(c) ( + PARTITION pt1 +); + +ALTER TABLE tbl_a ADD PARTITION (PARTITION pt2); + +DROP DATABASE auto_test_local; + +--disable_query_log +--disable_result_log +--source ../../t/test_deinit.inc +--enable_result_log +--enable_query_log diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_29027_original.test b/storage/spider/mysql-test/spider/bugfix/t/mdev_29027_original.test new file mode 100644 index 00000000000..3a52c11c834 --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_29027_original.test @@ -0,0 +1,22 @@ +--disable_query_log +--disable_result_log +--source ../../t/test_init.inc +--enable_result_log +--enable_query_log +--source include/have_partition.inc +set spider_same_server_link= 1; +evalp CREATE SERVER srv FOREIGN DATA WRAPPER mysql +OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); + +CREATE TABLE t1 (a INT); +CREATE TABLE t_spider (a INT) ENGINE=SPIDER PARTITION BY HASH(a) (PARTITION p1 COMMENT = "wrapper 'mysql', srv 'srv', table 't1'"); +CREATE TABLE t2 (a INT); +ALTER TABLE t_spider ADD PARTITION (PARTITION p2 COMMENT = "wrapper 'mysql', srv 'srv', table 't2'"); + +DROP TABLE t_spider, t1, t2; +drop server srv; +--disable_query_log +--disable_result_log +--source ../../t/test_deinit.inc +--enable_result_log +--enable_query_log diff --git a/storage/spider/spd_db_conn.cc b/storage/spider/spd_db_conn.cc index 2498804ac06..22989bf88b9 100644 --- a/storage/spider/spd_db_conn.cc +++ b/storage/spider/spd_db_conn.cc @@ -3406,7 +3406,7 @@ int spider_db_free_result( SPIDER_RESULT *result; SPIDER_RESULT *prev; SPIDER_SHARE *share = spider->share; - SPIDER_TRX *trx = spider->wide_handler->trx; + THD *thd= current_thd; SPIDER_POSITION *position; int roop_count, error_num; DBUG_ENTER("spider_db_free_result"); @@ -3423,10 +3423,10 @@ int spider_db_free_result( if ( final || - spider_param_reset_sql_alloc(trx->thd, share->reset_sql_alloc) == 1 + spider_param_reset_sql_alloc(thd, share->reset_sql_alloc) == 1 ) { int alloc_size = final ? 0 : - (spider_param_init_sql_alloc_size(trx->thd, share->init_sql_alloc_size)); + (spider_param_init_sql_alloc_size(thd, share->init_sql_alloc_size)); while (result) { position = result->first_position; @@ -3469,7 +3469,7 @@ int spider_db_free_result( { ulong realloced = 0; int init_sql_alloc_size = - spider_param_init_sql_alloc_size(trx->thd, share->init_sql_alloc_size); + spider_param_init_sql_alloc_size(thd, share->init_sql_alloc_size); for (roop_count = 0; roop_count < (int) share->use_dbton_count; roop_count++) {