Commit graph

177119 commits

Author SHA1 Message Date
Alexander Barkov
c0576ba5ec MDEV-11275 sql_mode=ORACLE: CAST(..AS VARCHAR(N)) 2017-04-05 15:02:54 +04:00
Alexander Barkov
f8a714c848 MDEV-10597 Cursors with parameters 2017-04-05 15:02:53 +04:00
Alexander Barkov
4ed804aa4d MDEV-10587 sql_mode=ORACLE: User defined exceptions 2017-04-05 15:02:53 +04:00
Alexander Barkov
4d3818d30d MDEV-11037 Diagnostics_area refactoring for user defined exceptions
Part 2:

Moving the part of Sql_condition that contain condition items
(such as m_class_origin, m_cursor_name, etc) into a separate
class Sql_condition_items. This allows to remove duplicate code in
different Sql_condition constructors.

Also, introducing new Sql_condition constructors and removing the method
Sql_condition::set(). All code sequences that called an Sql_condition
constructor followed by Sql_condition::set() are now replaced to
the new constructor calls. This gives light performance improvement,
as the relevant members are now initialized only one time.
2017-04-05 15:02:53 +04:00
Alexander Barkov
6010662cb3 MDEV-11037 Diagnostics_area refactoring for user defined exceptions 2017-04-05 15:02:53 +04:00
Alexander Barkov
ffca1e4830 MDEV-10578 sql_mode=ORACLE: SP control functions SQLCODE, SQLERRM 2017-04-05 15:02:52 +04:00
Alexander Barkov
de6d40592c MDEV-10411 Providing compatibility for basic PL/SQL constructs
An additional change for "Part 9: EXCEPTION handlers"

This construct:
  EXCEPTION WHEN OTHERS THEN ...;
now catches warning-alike conditions, e.g. NO_DATA_FOUND.
2017-04-05 15:02:52 +04:00
Alexander Barkov
f7043858ba MDEV-10866 Extend PREPARE and EXECUTE IMMEDIATE to understand expressions
MDEV-10867 PREPARE..EXECUTE is not consistent about non-ASCII characters

Adding Oracle specific tests
2017-04-05 15:02:52 +04:00
Alexander Barkov
054d00a9a3 A fix for MDEV-10411 Providing compatibility for basic PL/SQL constructs (Part 6: Assignment operator)
Fixed that a crash in this script:

SET sql_mode=ORACLE;
max_sort_length:= 1024;
2017-04-05 15:02:52 +04:00
Alexander Barkov
7fa1ad14dc MDEV-10840 sql_mode=ORACLE: RAISE statement for predefined exceptions 2017-04-05 15:02:51 +04:00
Alexander Barkov
76714a5c9a MDEV-10582 sql_mode=ORACLE: explicit cursor attributes %ISOPEN, %ROWCOUNT, %FOUND, %NOTFOUND 2017-04-05 15:02:51 +04:00
Alexander Barkov
4bb87996b9 DEV-10583 sql_mode=ORACLE: SQL%ROWCOUNT
Fixed that EXPLAIN EXTENDED erroneously returned
"SQL%%ROWCOUNT" instead of "SQL%ROWCOUNT"
2017-04-05 15:02:51 +04:00
Alexander Barkov
a2a196c04c MDEV-10709 Expressions as parameters to Dynamic SQL
Adding Oracle-specific tests for stored functions as EXECUTE..USING parameters.
2017-04-05 15:02:50 +04:00
Alexander Barkov
417c8c9daf MDEV-10585 EXECUTE IMMEDIATE statement
Adding Oracle specific tests
2017-04-05 15:02:50 +04:00
Alexander Barkov
a699a5f967 MDEV-10583 sql_mode=ORACLE: SQL%ROWCOUNT 2017-04-05 15:02:50 +04:00
Alexander Barkov
ccb91eb3ce MDEV-10839 sql_mode=ORACLE: Predefined exceptions: TOO_MANY_ROWS, NO_DATA_FOUND, DUP_VAL_ON_INDEX 2017-04-05 15:02:50 +04:00
Alexander Barkov
c2c45c55ce MDEV-10709 Expressions as parameters to Dynamic SQL
Adding Oracle specific tests
2017-04-05 15:02:49 +04:00
Alexander Barkov
c8822d71ef MDEV-10342 Providing compatibility for basic SQL built-in functions
Adding the Oracle style DECODE function:

  DECODE(operand, search, result [, search, result ...] [, default_result])
2017-04-05 15:02:49 +04:00
Alexander Barkov
02a72cf87c MDEV-10596 Allow VARCHAR and VARCHAR2 without length as a data type of routine parameters and in RETURN clause 2017-04-05 15:02:49 +04:00
Alexander Barkov
ec527face3 MDEV-10801 sql_mode: dynamic SQL placeholders 2017-04-05 15:02:49 +04:00
Alexander Barkov
f564ceb473 Fixed a crash in a EXIT/CONTINUE with an unknown identifier in the WHEN clause
The crash happened because of a wrong reset_lex() .. restore_lex() sequence.
The Item in WHERE clause and the corresponding sp_instr_jump_if_not() were
erroneously created using different LEX.
2017-04-05 15:02:48 +04:00
Alexander Barkov
cfb6345982 Fixed that 'FOR i IN 1..10' with no spaces around '..' returned a syntax error.
This is a fix for "MDEV-10580 sql_mode=ORACLE: FOR loop statement"
The tokenizer now treats digits followed by two dots (e.g. '1..')
as an integer number '1' followed by DOT_DOT_SYM.
Previously this sequence was treated as a double number '1.' followed by '.'.
2017-04-05 15:02:48 +04:00
Alexander Barkov
bf573e21c7 MDEV-10580 sql_mode=ORACLE: FOR loop statement
Fixed a crash when trying to use a FOR loop as a compound statement
outside of an SP. A bug in 051e415d8a251bd70e9b73619dbcc40f3c65371d.
2017-04-05 15:02:48 +04:00
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
71a0a12e61 Changing a LEX::sp_variable_declarations_finalize() parameter
from "const Lex_field_type_st &" to "const Column_definition &".
2017-04-05 15:02:46 +04:00
Alexander Barkov
8ec4cf1f01 Refactoring for MDEV-10580 sql_mode=ORACLE: FOR loop statement
Adding methods:
- LEX::sp_while_loop_expression()
- LEX::sp_while_loop_finalize()

to reuse code between sql_yacc.yy and sql_yacc_ora.yy.
FOR loop will also reuse these methods.
2017-04-05 15:02:45 +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
765d9d6429 MDEV-10411 Providing compatibility for basic PL/SQL constructs
Moving similar code from sql_yacc.yy and sql_yacc_ora.yy to methods:
  LEX::maybe_start_compound_statement()
  LEX::sp_push_loop_label()
  LEX::sp_push_loop_empty_label()
  LEX::sp_pop_loop_label()
  LEX::sp_pop_loop_empty_label()

The EXIT statement will also reuse this code.
2017-04-05 15:02:44 +04:00
Alexander Barkov
f37a943f49 MDEV-10411 Providing compatibility for basic PL/SQL constructs
Moving the code from *.yy to methods:
LEX::sp_change_context()
LEX::sp_leave_statement()
LEX::sp_iterate_statement()
to reuse the same code between LEAVE and ITERATE statements.
EXIT statement will also reuse the same code.
2017-04-05 15:02:43 +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
f3a0df72f2 Reusing code: Adding LEX::make_sp_head() and LEX::make_sp_head_no_recursive() 2017-04-05 15:02:41 +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