oceanbase

Форк
0
/
pl_non_reserved_keywords_mysql_mode.c 
201 строка · 5.3 Кб
1
/**
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.
11
 */
12

13
#include <stdio.h>
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"
17

18
static t_node *mysql_pl_none_reserved_keywords_root = NULL;
19

20
/* List of non-reserved keywords */
21
/*一开始会对这些word建立一颗trie树,对于每次的查找来言,树是固定的
22
 *若新添加的keyword含有除大小写字母、'_'和数字以外的其它字符,请联系@叶提修改这颗树。
23
 *实现不需要保证字典序,但是原则上还是保证字典序,方便维护和查找*/
24
static const NonReservedKeyword Mysql_pl_none_reserved_keywords[] =
25
{
26
  {"after", AFTER},
27
  {"begin", BEGIN_KEY},
28
  {"before", BEFORE},
29
  {"binary_integer", BINARY_INTEGER},
30
  {"body", BODY},
31
  {"by", BY},
32
  {"case", CASE},
33
  {"catalog_name", CATALOG_NAME},
34
  {"class_origin", CLASS_ORIGIN},
35
  {"close", CLOSE},
36
  {"column_name", COLUMN_NAME},
37
  {"comment", COMMENT},
38
  {"commit", COMMIT},
39
  {"condition", CONDITION},
40
  {"constraint_catalog", CONSTRAINT_CATALOG},
41
  {"constraint_name", CONSTRAINT_NAME},
42
  {"constraint_schema", CONSTRAINT_SCHEMA},
43
  {"continue", CONTINUE},
44
  //{"count", COUNT},
45
  {"current_user", CURRENT_USER},
46
  {"cursor", CURSOR},
47
  {"cursor_name", CURSOR_NAME},
48
  {"declare", DECLARE},
49
  {"default", DEFAULT},
50
  {"definer", DEFINER},
51
  {"delete", DELETE},
52
  {"deterministic", DETERMINISTIC},
53
  {"each", EACH},
54
  {"else", ELSE},
55
  {"elseif", ELSEIF},
56
  {"end", END_KEY},
57
  {"exists", EXISTS},
58
  {"exit", EXIT},
59
  {"extend", EXTEND},
60
  {"for", FOR},
61
  {"found", FOUND},
62
  {"from", FROM},
63
  {"handler", HANDLER},
64
  {"if", IF},
65
  {"in", IN},
66
  {"insert", INSERT},
67
  {"is", IS},
68
  {"inout", INOUT},
69
  {"iterate", ITERATE},
70
  {"leave", LEAVE},
71
  {"limit", LIMIT},
72
  {"long", LONG},
73
  {"loop", LOOP},
74
  {"message_text", MESSAGE_TEXT},
75
  {"mysql_errno", MYSQL_ERRNO},
76
  {"national", NATIONAL},
77
  {"nchar", NCHAR},
78
  {"next", NEXT},
79
  {"not", NOT},
80
  {"nvarchar", NVARCHAR},
81
  {"of", OF},
82
  {"on", ON},
83
  {"open", OPEN},
84
  {"out", OUT},
85
  {"package", PACKAGE},
86
  {"precedes", PRECEDES},
87
  {"table_name", TABLE_NAME},
88
  {"then", THEN},
89
  {"type", TYPE},
90
  {"record", RECORD},
91
  {"repeat", REPEAT},
92
  {"resignal", RESIGNAL},
93
  {"return", RETURN},
94
  {"returns", RETURNS},
95
  {"rollback", ROLLBACK},
96
  {"row", ROW},
97
  {"rowtype", ROWTYPE},
98
  {"schema_name", SCHEMA_NAME},
99
  {"signal", SIGNAL},
100
  {"sqlexception", SQLEXCEPTION},
101
  {"sqlstate", SQLSTATE},
102
  {"sqlwarning", SQLWARNING},
103
  {"subclass_origin", SUBCLASS_ORIGIN},
104
  {"until", UNTIL},
105
  {"update", UPDATE},
106
  {"using", USING},
107
  {"when", WHEN},
108
  {"while", WHILE},
109
  {"language", LANGUAGE},
110
  {"sql", SQL},
111
  {"no", NO},
112
  {"contains", CONTAINS},
113
  {"reads", READS},
114
  {"modifies", MODIFIES},
115
  {"data", DATA},
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},
124
  {"int", INTEGER},
125
  {"int1", TINYINT},
126
  {"int2", SMALLINT},
127
  {"int3", MEDIUMINT},
128
  {"int4", INTEGER},
129
  {"int8", BIGINT},
130
  {"bigint", BIGINT},
131
  {"fetch", FETCH},
132
  {"float", FLOAT},
133
  {"float4", FLOAT},
134
  {"float8", DOUBLE},
135
  {"follows", FOLLOWS},
136
  {"double", DOUBLE},
137
  {"precision", PRECISION},
138
  {"dec", NUMBER},
139
  {"decimal", NUMBER},
140
  {"numeric", NUMBER},
141
  {"real", DOUBLE},
142
  {"bit", BIT},
143
  {"datetime", DATETIME},
144
  {"timestamp", TIMESTAMP},
145
  {"time", TIME},
146
  {"date", DATE},
147
  {"year", YEAR},
148
  {"character", CHARACTER},
149
  {"char", CHARACTER},
150
  {"text", TEXT},
151
  {"value", VALUE},
152
  {"varchar", VARCHAR},
153
  {"varcharacter", VARCHAR},
154
  {"varying", VARYING},
155
  {"varbinary", VARBINARY},
156
  {"unsigned", UNSIGNED},
157
  {"signed", SIGNED},
158
  {"zerofill", ZEROFILL},
159
  {"collate", COLLATE},
160
  {"charset", CHARSET},
161
  {"bool", BOOL},
162
  {"boolean", BOOLEAN},
163
  {"enum", ENUM},
164
  {"tinytext", TINYTEXT},
165
  {"mediumtext", MEDIUMTEXT},
166
  {"longtext", LONGTEXT},
167
  {"blob", BLOB},
168
  {"tinyblob", TINYBLOB},
169
  {"mediumblob", MEDIUMBLOB},
170
  {"longblob", LONGBLOB},
171
  {"fixed", NUMBER},
172
  {"authid", AUTHID},
173
  {"or", OR},
174
  {"replace", REPLACE},
175
  {"pragma", PRAGMA},
176
  {"interface", INTERFACE},
177
  {"c", C},
178
};
179

180
const NonReservedKeyword *mysql_pl_non_reserved_keyword_lookup(const char *word)
181
{
182
  return find_word(word, mysql_pl_none_reserved_keywords_root, Mysql_pl_none_reserved_keywords);
183
}
184

185
//return 0 if succ, return 1 if fail
186
int create_mysql_pl_trie_tree()
187
{
188
  int ret = 0;
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");
191
  }
192
  return ret;
193
}
194

195
void  __attribute__((constructor)) init_mysql_pl_non_reserved_keywords_tree()
196
{
197
  int ret = 0;
198
  if (0 != (ret = create_mysql_pl_trie_tree())) {
199
    (void)printf("ERROR build mysql_pl_non_reserved_keywords tree failed=>%d", ret);
200
  }
201
}
202

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.