Skip to content

Commit

Permalink
fix(handler): fix the bug for create table #mysql50#q.q should return…
Browse files Browse the repository at this point in the history
… failure and actually return success (#487)

	[summary]
	1.When creating a table in the tianmu engine, add code to determine whether the table name is empty.
	2.Add issue corresponding to mtr test case.
  • Loading branch information
lylth authored and mergify[bot] committed Oct 9, 2022
1 parent 008cc77 commit c6c8f98
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
3 changes: 3 additions & 0 deletions mysql-test/suite/tianmu/r/issue487.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
use test;
create table `#mysql50#q.q` (f1 int primary key) engine=tianmu;
ERROR HY000: Got error 1103 from storage engine
4 changes: 4 additions & 0 deletions mysql-test/suite/tianmu/t/issue487.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
--source include/have_tianmu.inc
use test;
-- error 1030
create table `#mysql50#q.q` (f1 int primary key) engine=tianmu;
9 changes: 9 additions & 0 deletions storage/tianmu/handler/tianmu_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1219,6 +1219,15 @@ ha_rows TianmuHandler::records_in_range([[maybe_unused]] uint inx, [[maybe_unuse
int TianmuHandler::create(const char *name, TABLE *table_arg, [[maybe_unused]] HA_CREATE_INFO *create_info) {
DBUG_ENTER(__PRETTY_FUNCTION__);
try {

//fix issue 487: bug for create table #mysql50#q.q should return failure and actually return success
const size_t table_name_len = strlen(name);
if (name[table_name_len - 1] == '/')
{
TIANMU_LOG(LogCtl_Level::ERROR, "Table name is empty");
DBUG_RETURN(ER_WRONG_TABLE_NAME);
}

ha_rcengine_->CreateTable(name, table_arg);
DBUG_RETURN(0);
} catch (common::AutoIncException &e) {
Expand Down

0 comments on commit c6c8f98

Please sign in to comment.