2
* Copyright (c) 2021 OceanBase
3
* OceanBase CE is licensed under Mulan PubL v2.
4
* You can use this software according to the terms and conditions of the Mulan PubL v2.
5
* You may obtain a copy of Mulan PubL v2 at:
6
* http://license.coscl.org.cn/MulanPubL-2.0
7
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
8
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
9
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
10
* See the Mulan PubL v2 for more details.
14
#include "lib/alloc/alloc_assist.h"
15
#include "sql/parser/ob_non_reserved_keywords.h"
16
#include "pl/parser/pl_parser_mysql_mode_tab.h"
18
static t_node *mysql_pl_none_reserved_keywords_root = NULL;
20
/* List of non-reserved keywords */
21
/*一开始会对这些word建立一颗trie树,对于每次的查找来言,树是固定的
22
*若新添加的keyword含有除大小写字母、'_'和数字以外的其它字符,请联系@叶提修改这颗树。
23
*实现不需要保证字典序,但是原则上还是保证字典序,方便维护和查找*/
24
static const NonReservedKeyword Mysql_pl_none_reserved_keywords[] =
29
{"binary_integer", BINARY_INTEGER},
33
{"catalog_name", CATALOG_NAME},
34
{"class_origin", CLASS_ORIGIN},
36
{"column_name", COLUMN_NAME},
39
{"condition", CONDITION},
40
{"constraint_catalog", CONSTRAINT_CATALOG},
41
{"constraint_name", CONSTRAINT_NAME},
42
{"constraint_schema", CONSTRAINT_SCHEMA},
43
{"continue", CONTINUE},
45
{"current_user", CURRENT_USER},
47
{"cursor_name", CURSOR_NAME},
52
{"deterministic", DETERMINISTIC},
74
{"message_text", MESSAGE_TEXT},
75
{"mysql_errno", MYSQL_ERRNO},
76
{"national", NATIONAL},
80
{"nvarchar", NVARCHAR},
86
{"precedes", PRECEDES},
87
{"table_name", TABLE_NAME},
92
{"resignal", RESIGNAL},
95
{"rollback", ROLLBACK},
98
{"schema_name", SCHEMA_NAME},
100
{"sqlexception", SQLEXCEPTION},
101
{"sqlstate", SQLSTATE},
102
{"sqlwarning", SQLWARNING},
103
{"subclass_origin", SUBCLASS_ORIGIN},
109
{"language", LANGUAGE},
112
{"contains", CONTAINS},
114
{"modifies", MODIFIES},
116
{"constraint_origin", CONSTRAINT_ORIGIN},
117
{"invoker", INVOKER},
118
{"security", SECURITY},
119
{"tinyint", TINYINT},
120
{"smallint", SMALLINT},
121
{"mediumint", MEDIUMINT},
122
{"middleint", MEDIUMINT},
123
{"integer", INTEGER},
135
{"follows", FOLLOWS},
137
{"precision", PRECISION},
143
{"datetime", DATETIME},
144
{"timestamp", TIMESTAMP},
148
{"character", CHARACTER},
152
{"varchar", VARCHAR},
153
{"varcharacter", VARCHAR},
154
{"varying", VARYING},
155
{"varbinary", VARBINARY},
156
{"unsigned", UNSIGNED},
158
{"zerofill", ZEROFILL},
159
{"collate", COLLATE},
160
{"charset", CHARSET},
162
{"boolean", BOOLEAN},
164
{"tinytext", TINYTEXT},
165
{"mediumtext", MEDIUMTEXT},
166
{"longtext", LONGTEXT},
168
{"tinyblob", TINYBLOB},
169
{"mediumblob", MEDIUMBLOB},
170
{"longblob", LONGBLOB},
174
{"replace", REPLACE},
176
{"interface", INTERFACE},
180
const NonReservedKeyword *mysql_pl_non_reserved_keyword_lookup(const char *word)
182
return find_word(word, mysql_pl_none_reserved_keywords_root, Mysql_pl_none_reserved_keywords);
185
//return 0 if succ, return 1 if fail
186
int create_mysql_pl_trie_tree()
189
if (0 != (ret = create_trie_tree(Mysql_pl_none_reserved_keywords, LENGTH_OF(Mysql_pl_none_reserved_keywords), &mysql_pl_none_reserved_keywords_root))) {
190
(void)printf("ERROR create trie tree failed! \n");
195
void __attribute__((constructor)) init_mysql_pl_non_reserved_keywords_tree()
198
if (0 != (ret = create_mysql_pl_trie_tree())) {
199
(void)printf("ERROR build mysql_pl_non_reserved_keywords tree failed=>%d", ret);