Commit 9f6aca19 authored by Alexander Barkov's avatar Alexander Barkov

Adding an alternative grammar file sql_yacc_ora.yy for sql_mode=ORACLE

- Adding a new grammar file sql_yacc_ora.yy, which is currently
  almost a full copy of sql_yacc.yy.

  Note, it's now assumed that sql_yacc.yy and sql_yacc_ora.yy
  use the same set of %token directives and exactly the same
  %union directive.
  These declarations should eventually be moved into a shared
  included file, to make sure that sql_yacc.h and sql_yacc_ora.h
  are compatible.

- Removing the "-p MYSQL" flag from cmake/bison.cmake, using
  the %name-prefix directive inside sql_yacc.yy and sql_yacc_ora.yy instead

- Adding other CMake related changes to build sql_yacc_ora.o
  form sql_yacc_ora.yy

- Adding NUMBER(M,N) as a synonym to DECIMAL(M,N) as the first
  Oracle compatibility syntax understood in sql_mode=ORACLE.

- Adding prototypes to functions add_virtual_expression()
  and handle_sql2003_note184_exception(), so they can be used
  in both sql_yacc.yy and sql_yacc_ora.yy.

- Adding a new test suite compat/oracle, with the first test "type_number".
  Use this:
   ./mtr compat/oracle.type_number   # to run a single test
   ./mtr --suite=compat/oracle       # to run the entire new suite

- Adding compat/oracle into the list of default suites,
  so BuildBot can run it automatically on pushes.
parent e34acc83
......@@ -161,6 +161,8 @@ sql/mysqld
sql/sql_builtin.cc
sql/sql_yacc.cc
sql/sql_yacc.h
sql/sql_yacc_ora.cc
sql/sql_yacc_ora.h
storage/heap/hp_test1
storage/heap/hp_test2
storage/maria/aria_chk
......
......@@ -50,7 +50,7 @@ MACRO (RUN_BISON input_yy output_cc output_h)
ADD_CUSTOM_COMMAND(
OUTPUT ${output_cc}
${output_h}
COMMAND ${BISON_EXECUTABLE} -y -p MYSQL
COMMAND ${BISON_EXECUTABLE} -y
--output=${output_cc}
--defines=${output_h}
${input_yy}
......
......@@ -30,6 +30,8 @@ ${SSL_INTERNAL_INCLUDE_DIRS}
SET(GEN_SOURCES
${CMAKE_BINARY_DIR}/sql/sql_yacc.h
${CMAKE_BINARY_DIR}/sql/sql_yacc.cc
${CMAKE_BINARY_DIR}/sql/sql_yacc_ora.h
${CMAKE_BINARY_DIR}/sql/sql_yacc_ora.cc
${CMAKE_BINARY_DIR}/sql/lex_hash.h
)
......
......@@ -171,6 +171,7 @@ my @DEFAULT_SUITES= qw(
binlog-
binlog_encryption-
csv-
compat/oracle-
encryption-
federated-
funcs_1-
......
SET sql_mode=ORACLE;
CREATE TABLE t1 (a NUMBER(10,2));
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE "t1" (
"a" decimal(10,2) DEFAULT NULL
)
DROP TABLE t1;
SET sql_mode=ORACLE;
CREATE TABLE t1 (a NUMBER(10,2));
SHOW CREATE TABLE t1;
DROP TABLE t1;
......@@ -48,6 +48,8 @@ ${WSREP_INCLUDES}
SET(GEN_SOURCES
${CMAKE_CURRENT_BINARY_DIR}/sql_yacc.h
${CMAKE_CURRENT_BINARY_DIR}/sql_yacc.cc
${CMAKE_CURRENT_BINARY_DIR}/sql_yacc_ora.h
${CMAKE_CURRENT_BINARY_DIR}/sql_yacc_ora.cc
${CMAKE_CURRENT_BINARY_DIR}/lex_hash.h
)
SET(GEN_DIGEST_SOURCES
......@@ -279,6 +281,12 @@ RUN_BISON(
${CMAKE_CURRENT_BINARY_DIR}/sql_yacc.h
)
RUN_BISON(
${CMAKE_CURRENT_SOURCE_DIR}/sql_yacc_ora.yy
${CMAKE_CURRENT_BINARY_DIR}/sql_yacc_ora.cc
${CMAKE_CURRENT_BINARY_DIR}/sql_yacc_ora.h
)
# Gen_lex_hash
IF(NOT CMAKE_CROSSCOMPILING)
ADD_EXECUTABLE(gen_lex_hash gen_lex_hash.cc)
......@@ -329,6 +337,7 @@ CONFIGURE_FILE(
ADD_CUSTOM_TARGET(dist
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/make_dist.cmake
DEPENDS ${CMAKE_BINARY_DIR}/sql/sql_yacc.cc ${CMAKE_BINARY_DIR}/sql/sql_yacc.h
DEPENDS ${CMAKE_BINARY_DIR}/sql/sql_yacc_ora.cc ${CMAKE_BINARY_DIR}/sql/sql_yacc_ora.h
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
......
......@@ -1336,6 +1336,11 @@ int MYSQLlex(YYSTYPE *yylval, THD *thd)
return token;
}
int ORAlex(YYSTYPE *yylval, THD *thd)
{
return MYSQLlex(yylval, thd);
}
static int lex_one_token(YYSTYPE *yylval, THD *thd)
{
reg1 uchar UNINIT_VAR(c);
......
......@@ -3367,6 +3367,7 @@ extern void lex_end_stage2(LEX *lex);
void end_lex_with_single_table(THD *thd, TABLE *table, LEX *old_lex);
int init_lex_with_single_table(THD *thd, TABLE *table, LEX *lex);
extern int MYSQLlex(union YYSTYPE *yylval, THD *thd);
extern int ORAlex(union YYSTYPE *yylval, THD *thd);
extern void trim_whitespace(CHARSET_INFO *cs, LEX_STRING *str,
uint *prefix_removed);
......@@ -3382,5 +3383,8 @@ extern bool is_native_function_with_warn(THD *thd, const LEX_STRING *name);
void my_missing_function_error(const LEX_STRING &token, const char *name);
bool is_keyword(const char *name, uint len);
Virtual_column_info *add_virtual_expression(THD *thd, Item *expr);
Item* handle_sql2003_note184_exception(THD *thd, Item* left, bool equal,
Item *expr);
#endif /* MYSQL_SERVER */
#endif /* SQL_LEX_INCLUDED */
......@@ -9849,6 +9849,7 @@ bool check_host_name(LEX_STRING *str)
extern int MYSQLparse(THD *thd); // from sql_yacc.cc
extern int ORAparse(THD *thd); // from sql_yacc_ora.cc
/**
......@@ -9908,7 +9909,10 @@ bool parse_sql(THD *thd, Parser_state *parser_state,
/* Parse the query. */
bool mysql_parse_status= MYSQLparse(thd) != 0;
bool mysql_parse_status=
((thd->variables.sql_mode & MODE_ORACLE) ?
ORAparse(thd) :
MYSQLparse(thd)) != 0;
/*
Check that if MYSQLparse() failed either thd->is_error() is set, or an
......
......@@ -993,6 +993,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
%}
%pure-parser /* We have threads */
%name-prefix "MYSQL"
%parse-param { THD *thd }
%lex-param { THD *thd }
/*
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment