Commit graph

379 commits

Author SHA1 Message Date
Alexander Barkov
30bec863cf MDEV-10342 Providing compatibility for basic SQL built-in functions
Adding functions NVL() and NVL2().
2017-04-05 15:02:48 +04:00
Alexander Barkov
7e7ba7cb94 Removing SHOW FUNCTION CODE from compat/oracle.sp,
as this type of SHOW is only available in debug builds.
A bug in b7af3e704dd7800638ef677e9d921ad3e467a9a6.
All SHOW FUNCTION CODE queries should be in compat/oracle.sp-code.
2017-04-05 15:02:47 +04:00
Alexander Barkov
5721ea6ab7 MDEV-10579 sql_mode=ORACLE: Triggers: Understand :NEW.c1 and :OLD.c1 instead of NEW.c1 and OLD.c1 2017-04-05 15:02:47 +04:00
Alexander Barkov
ca242117ce MDEV-10411 Providing compatibility for basic PL/SQL constructs
Part 19: CONTINUE statement
2017-04-05 15:02:47 +04:00
Alexander Barkov
442ea81ed3 MDEV-10411 Providing compatibility for basic PL/SQL constructs
Fixed that the ITERATE statement inside a FOR LOOP statement did not
increment the index variable before jumping to the beginning
of the loop, which caused the loop to repeat endlessly.
2017-04-05 15:02:47 +04:00
Alexander Barkov
2ea63492f7 MDEV-10580 sql_mode=ORACLE: FOR loop statement
Adding labeled FOR LOOP
2017-04-05 15:02:46 +04:00
Alexander Barkov
c570636ba2 MDEV-10580 sql_mode=ORACLE: FOR loop statement
Adding non-labeled FOR LOOP statement.
2017-04-05 15:02:46 +04:00
Alexander Barkov
28f2859136 MDEV-10411 Providing compatibility for basic PL/SQL constructs
Part 18: WHILE syntax
2017-04-05 15:02:45 +04:00
Alexander Barkov
4212039db7 MDEV-10411 Providing compatibility for basic PL/SQL constructs
Part 17: RETURN in stored procedures
2017-04-05 15:02:45 +04:00
Alexander Barkov
ed19ed6a4b MDEV-10411 Providing compatibility for basic PL/SQL constructs
Part 16: CURSOR declaration
2017-04-05 15:02:45 +04:00
Alexander Barkov
6cd24d124f MDEV-10411 Providing compatibility for basic PL/SQL constructs
Part 15: ELSIF vs ELSEIF

Also, moving tests for Oracle keywords in sql_mode=DEFAULT
from "parser.test" to a better place "keywords.test".
2017-04-05 15:02:44 +04:00
Alexander Barkov
a83d0aee96 MDEV-10411 Providing compatibility for basic PL/SQL constructs
Part 5: EXIT statement

Adding optional WHEN clause:

EXIT [label] [WHEN expr]
2017-04-05 15:02:44 +04:00
Alexander Barkov
8feb984211 MDEV-10411 Providing compatibility for basic PL/SQL constructs
Part 5: EXIT statement

Adding unconditional EXIT statement:

  EXIT [ label ]

Conditional EXIT statements with WHERE clause
will be added in a separate patch.
2017-04-05 15:02:44 +04:00
Alexander Barkov
4b61495576 MDEV-10411 Providing compatibility for basic PL/SQL constructs
Part 9: EXCEPTION handlers

EXCEPTION is now supported in inner blocks.
2017-04-05 15:02:43 +04:00
Alexander Barkov
d2b007d6bc Optimization for MDEV-10411 Providing compatibility for basic PL/SQL constructs
When processing an SP body:

CREATE PROCEDURE p1 (parameters)
AS [ declarations ]
BEGIN statements
[ EXCEPTION exceptions ]
END;

the parser generates two "jump" instructions:
- from the end of "declarations" to the beginning of EXCEPTION
- from the end of EXCEPTION to "statements"

These jumps are useless if EXCEPTION does not exist.
This patch makes sure that these two "jump" instructions are
generated only if EXCEPTION really exists.
2017-04-05 15:02:43 +04:00
Alexander Barkov
4940a91a5f A test clean-up for 7c78b27a33b749656cbc28091eac32bbbeee9e42 2017-04-05 15:02:42 +04:00
Alexander Barkov
81ba971d03 MDEV-10411 Providing compatibility for basic PL/SQL constructs
- Part 9: EXCEPTION handlers

  The top-most stored routine blocks now support EXCEPTION clause
  in its correct place:
  AS [ declarations ]
  BEGIN statements
  [ EXCEPTION exceptions ]
  END

  Inner block will be done in a separate commit.

- Part 14: IN OUT instead of INOUT (in SP parameter declarations)
2017-04-05 15:02:42 +04:00
Alexander Barkov
0040b0f380 MDEV-10411 Providing compatibility for basic PL/SQL constructs
Part 13: RETURN vs RETURNS in function definition:

  CREATE FUNCTION f1(a INT) RETURN INT ...

Part 12:  No parentheses if no arguments:

  CREATE FUNCTION f1 RETURN INT ...
2017-04-05 15:02:42 +04:00
Alexander Barkov
bd76d44564 MDEV-10411 Providing compatibility for basic PL/SQL constructs
Part 12: No parentheses if no arguments
Now "CREATE PROCEDURE p1 AS" is supported with no parentheses after the name.
Note, "CREATE FUNCTION f1 AS" is not supported yet, due to grammar conflict
with UDFs. Functions will be done in a separate patch.
2017-04-05 15:02:42 +04:00
Alexander Barkov
dc292bc6eb MDEV-10411 Providing compatibility for basic PL/SQL constructs
Part 11: NULL as a statement
2017-04-05 15:02:41 +04:00
Alexander Barkov
0c9c4b84b7 MDEV-10411 Providing compatibility for basic PL/SQL constructs
Part 10: Default variable value: x INT := 10;
2017-04-05 15:02:41 +04:00
Alexander Barkov
8fdc1f0147 MDEV-10411 Providing compatibility for basic PL/SQL constructs
Part 9: EXCEPTION handlers

- Adding exception handler syntax:
  WHEN exception_name THEN statement
- Adding EXCEPTION section intoi the top BEGIN..END SP block.
  Note, currently EXCEPTION goes in the beginning of the top BEGIN..END
  SP block.

TODO:
- add EXCEPTION section into inner blocks
- move EXCEPTION to the end of the block
2017-04-05 15:02:41 +04:00
Alexander Barkov
a44e90ae05 MDEV-10411 Providing compatibility for basic PL/SQL constructs
Part 7: variable declarations
2017-04-05 15:02:40 +04:00
Alexander Barkov
f71a1f736d MDEV-10411 Providing compatibility for basic PL/SQL constructs
Part 4: AS/IS keyword before a function or a procedure body
2017-04-05 15:02:39 +04:00
Alexander Barkov
892af78085 MDEV-10411 Providing compatibility for basic PL/SQL constructs
Part6: assignment operator

  var:= 10;
2017-04-05 15:02:39 +04:00
Alexander Barkov
7e10e38825 MDEV-10411 Providing compatibility for basic PL/SQL constructs
Part2: Different order of IN, OUT, INOUT keywords in CREATE PROCEDURE params
2017-04-05 15:02:38 +04:00
Alexander Barkov
47a75ed7cb MDEV-10411 Providing compatibility for basic PL/SQL constructs
Changing label syntax from "label:" to "<<label>>".
2017-04-05 15:02:38 +04:00
Alexander Barkov
4de26a8e0e MDEV-10343 Providing compatibility for basic SQL data types
Based on the patch by Dmitry Tolpeko.
2017-04-05 15:02:38 +04:00
Alexander Barkov
9f6aca198c 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.
2017-04-05 15:01:59 +04:00