diff --git a/mysql-test/suite/compat/oracle/r/minus.result b/mysql-test/suite/compat/oracle/r/minus.result new file mode 100644 index 00000000000..67b7e5347c3 --- /dev/null +++ b/mysql-test/suite/compat/oracle/r/minus.result @@ -0,0 +1,48 @@ +CREATE TABLE tx1 (c1 int, c2 varchar(30)); +CREATE TABLE tx2 (c1 int, c2 varchar(30)); +CREATE TABLE tx3 (c1 int, c2 varchar(30)); +INSERT INTO tx1 VALUES (1, 'jim'); +INSERT INTO tx1 VALUES (2, 'menny'); +INSERT INTO tx1 VALUES (3, 'linda'); +INSERT INTO tx2 VALUES (1, 'jim'); +INSERT INTO tx2 VALUES (2, 'kris'); +INSERT INTO tx2 VALUES (3, 'shory'); +INSERT INTO tx3 VALUES (1, 'jim'); +INSERT INTO tx3 VALUES (2, 'kris'); +INSERT INTO tx3 VALUES (3, 'linda'); +# +# test when sql_mode is not oracle +# +SELECT c2 FROM tx1 EXCEPT SELECT c2 from tx2; +c2 +menny +linda +SELECT c2 FROM tx1 MINUS SELECT c2 from tx2; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'SELECT c2 from tx2' at line 1 +create table MINUS (a int); +drop table MINUS; +# +# test when sql_mode is oracle +# +SET sql_mode=ORACLE; +SELECT c2 FROM tx1 MINUS SELECT c2 from tx2; +c2 +menny +linda +SELECT c2 FROM tx1 MINUS SELECT c2 from tx2 MINUS SELECT c2 from tx3; +c2 +menny +SELECT c2 FROM tx1 MINUS SELECT c2 from tx2 EXCEPT SELECT c2 from tx3; +c2 +menny +SELECT c2 FROM tx1 MINUS SELECT c2 from tx2 UNION SELECT c2 from tx3; +c2 +jim +menny +linda +kris +create table MINUS (a int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'MINUS (a int)' at line 1 +DROP TABLE tx1; +DROP TABLE tx2; +DROP TABLE tx3; diff --git a/mysql-test/suite/compat/oracle/t/minus.test b/mysql-test/suite/compat/oracle/t/minus.test new file mode 100644 index 00000000000..cbaf422740b --- /dev/null +++ b/mysql-test/suite/compat/oracle/t/minus.test @@ -0,0 +1,44 @@ +CREATE TABLE tx1 (c1 int, c2 varchar(30)); +CREATE TABLE tx2 (c1 int, c2 varchar(30)); +CREATE TABLE tx3 (c1 int, c2 varchar(30)); +INSERT INTO tx1 VALUES (1, 'jim'); +INSERT INTO tx1 VALUES (2, 'menny'); +INSERT INTO tx1 VALUES (3, 'linda'); + +INSERT INTO tx2 VALUES (1, 'jim'); +INSERT INTO tx2 VALUES (2, 'kris'); +INSERT INTO tx2 VALUES (3, 'shory'); + +INSERT INTO tx3 VALUES (1, 'jim'); +INSERT INTO tx3 VALUES (2, 'kris'); +INSERT INTO tx3 VALUES (3, 'linda'); + +--echo # +--echo # test when sql_mode is not oracle +--echo # + +SELECT c2 FROM tx1 EXCEPT SELECT c2 from tx2; +--error 1064 +SELECT c2 FROM tx1 MINUS SELECT c2 from tx2; + +# MINUS should not be a reserved word +create table MINUS (a int); +drop table MINUS; + +--echo # +--echo # test when sql_mode is oracle +--echo # + +SET sql_mode=ORACLE; +SELECT c2 FROM tx1 MINUS SELECT c2 from tx2; +SELECT c2 FROM tx1 MINUS SELECT c2 from tx2 MINUS SELECT c2 from tx3; +SELECT c2 FROM tx1 MINUS SELECT c2 from tx2 EXCEPT SELECT c2 from tx3; +SELECT c2 FROM tx1 MINUS SELECT c2 from tx2 UNION SELECT c2 from tx3; + +# MINUS should be a reserved word +--error ER_PARSE_ERROR +create table MINUS (a int); + +DROP TABLE tx1; +DROP TABLE tx2; +DROP TABLE tx3; \ No newline at end of file diff --git a/mysql-test/suite/perfschema/r/start_server_low_digest_sql_length.result b/mysql-test/suite/perfschema/r/start_server_low_digest_sql_length.result index ba5c0baf79b..2f259ccae12 100644 --- a/mysql-test/suite/perfschema/r/start_server_low_digest_sql_length.result +++ b/mysql-test/suite/perfschema/r/start_server_low_digest_sql_length.result @@ -8,5 +8,5 @@ SELECT 1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1 #################################### SELECT event_name, digest, digest_text, sql_text FROM events_statements_history_long; event_name digest digest_text sql_text -statement/sql/select 62764f94ca18cf720c44d84579e05e60 SELECT ? + ? + SELECT ... -statement/sql/truncate 5947880b8ba439f0ed3ff0bfbb04eebf TRUNCATE TABLE truncat... +statement/sql/select bb82f2829bcdfd9ac1e53f7b27829d36 SELECT ? + ? + SELECT ... +statement/sql/truncate fd6a2d48e5fda6a3f990cb8810136546 TRUNCATE TABLE truncat... diff --git a/sql/lex.h b/sql/lex.h index 3357500454a..e945ec6a8d0 100644 --- a/sql/lex.h +++ b/sql/lex.h @@ -404,6 +404,7 @@ static SYMBOL symbols[] = { { "MICROSECOND", SYM(MICROSECOND_SYM)}, { "MIDDLEINT", SYM(MEDIUMINT)}, /* For powerbuilder */ { "MIGRATE", SYM(MIGRATE_SYM)}, + { "MINUS", SYM(MINUS_ORACLE_SYM)}, { "MINUTE", SYM(MINUTE_SYM)}, { "MINUTE_MICROSECOND", SYM(MINUTE_MICROSECOND_SYM)}, { "MINUTE_SECOND", SYM(MINUTE_SECOND_SYM)}, diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 2b013b8b88b..05574daf42b 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -1404,6 +1404,7 @@ int Lex_input_stream::find_keyword(Lex_ident_cli_st *kwd, case EXCEPTION_MARIADB_SYM: return EXCEPTION_ORACLE_SYM; case EXIT_MARIADB_SYM: return EXIT_ORACLE_SYM; case GOTO_MARIADB_SYM: return GOTO_ORACLE_SYM; + case MINUS_ORACLE_SYM: return EXCEPT_SYM; case NUMBER_MARIADB_SYM: return NUMBER_ORACLE_SYM; case OTHERS_MARIADB_SYM: return OTHERS_ORACLE_SYM; case PACKAGE_MARIADB_SYM: return PACKAGE_ORACLE_SYM; diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 780194c8b85..3471b99aec7 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -592,6 +592,7 @@ End SQL_MODE_ORACLE_SPECIFIC */ %token MEDIUMINT %token MEDIUMTEXT %token MIN_SYM /* SQL-2003-N */ +%token MINUS_ORACLE_SYM /* Oracle-R */ %token MINUTE_MICROSECOND_SYM %token MINUTE_SECOND_SYM %token MODIFIES_SYM /* SQL-2003-R */ @@ -16037,6 +16038,9 @@ keyword_sp_var_and_label: | MICROSECOND_SYM | MIGRATE_SYM | MINUTE_SYM +/* Start SQL_MODE_DEFAULT_SPECIFIC */ + | MINUS_ORACLE_SYM +/* End SQL_MODE_DEFAULT_SPECIFIC */ | MINVALUE_SYM | MIN_ROWS | MODIFY_SYM @@ -16329,6 +16333,9 @@ reserved_keyword_udt_not_param_type: | MINUTE_MICROSECOND_SYM | MINUTE_SECOND_SYM | MIN_SYM +/* Start SQL_MODE_ORACLE_SPECIFIC + | MINUS_ORACLE_SYM +End SQL_MODE_ORACLE_SPECIFIC */ | MODIFIES_SYM | MOD_SYM | NATURAL