未验证 提交 f3e18cf3 编写于 作者: L lylth 提交者: GitHub

fix(core): Fix the problem of inserting data with special character table name...

fix(core): Fix the problem of inserting data with special character table name failure.(#222)(#362) (#427)
Co-authored-by: Nmergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
上级 35d39da2
use test;
create table $tt (a$1 int, $b int, c$ int) engine=tianmu;
insert into $tt values (1,2,3);
select a$1, $b, c$ from $tt;
a$1 $b c$
1 2 3
drop table $tt;
use test;
CREATE TABLE `abcÿdef` (i int)engine=tianmu;
INSERT INTO `abcÿdef` VALUES (1);
INSERT INTO abcÿdef VALUES (2);
SELECT * FROM `abcÿdef`;
i
1
2
SELECT * FROM abcÿdef;
i
1
2
DROP TABLE `abcÿdef`;
use test;
create table $tt (a$1 int, $b int, c$ int) engine=tianmu;
insert into $tt values (1,2,3);
select a$1, $b, c$ from $tt;
drop table $tt;
use test;
CREATE TABLE `abcÿdef` (i int)engine=tianmu;
INSERT INTO `abcÿdef` VALUES (1);
INSERT INTO abcÿdef VALUES (2);
SELECT * FROM `abcÿdef`;
SELECT * FROM abcÿdef;
DROP TABLE `abcÿdef`;
......@@ -1091,8 +1091,12 @@ static void HandleDelayedLoad(int tid, std::vector<std::unique_ptr<char[]>> &vec
dbname.length=db_name.length();
loadquery.str=const_cast<char *>(load_data_query.c_str());
loadquery.length=load_data_query.length();
tabname.str=const_cast<char *>(tab_name.c_str());
tabname.length=tab_name.length();
// fix issue 362: bug for insert into a table which table name contains special characters
char t_tbname[MAX_TABLE_NAME_LEN + 1]={0};
tabname.length = filename_to_tablename( const_cast<char *>(tab_name.c_str()),t_tbname, sizeof(t_tbname));
tabname.str=t_tbname;
// END
//TIANMU UPGRADE
......
......@@ -38,6 +38,7 @@
#include "system/io_parameters.h"
#include "system/rc_system.h"
#include "log.h"
#include "sql_table.h"
#include "util/fs.h"
#include "util/mapped_circular_buffer.h"
#include "util/thread_pool.h"
......@@ -338,6 +339,15 @@ int get_parameter(THD *thd, enum tianmu_var_name vn, int64_t &value);
int get_parameter(THD *thd, enum tianmu_var_name vn, std::string &value);
bool parameter_equals(THD *thd, enum tianmu_var_name vn, longlong value);
/** The maximum length of an encode table name in bytes. The max
+table and database names are NAME_CHAR_LEN (64) characters. After the
+encoding, the max length would be NAME_CHAR_LEN (64) *
+FILENAME_CHARSET_MAXNAMLEN (5) = 320 bytes. The number does not include a
+terminating '\0'. InnoDB can handle longer names internally */
#define MAX_TABLE_NAME_LEN 320
} // namespace core
} // namespace Tianmu
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册