Commit 0c9c4b84 authored by Alexander Barkov's avatar Alexander Barkov

MDEV-10411 Providing compatibility for basic PL/SQL constructs

Part 10: Default variable value: x INT := 10;
parent 8fdc1f01
SET sql_mode=ORACLE; SET sql_mode=ORACLE;
# Testing ":=" to set the default value of a variable
CREATE FUNCTION f1 () RETURNS NUMBER(10) AS
a NUMBER(10) := 10;
BEGIN
DECLARE
b NUMBER(10) DEFAULT 3;
BEGIN
RETURN a+b;
END;
END;
/
SELECT f1();
f1()
13
DROP FUNCTION f1;
# Testing labels # Testing labels
CREATE FUNCTION f1 (a INT) RETURNS CLOB AS CREATE FUNCTION f1 (a INT) RETURNS CLOB AS
BEGIN BEGIN
......
SET sql_mode=ORACLE; SET sql_mode=ORACLE;
--echo # Testing ":=" to set the default value of a variable
DELIMITER /;
CREATE FUNCTION f1 () RETURNS NUMBER(10) AS
a NUMBER(10) := 10;
BEGIN
DECLARE
b NUMBER(10) DEFAULT 3;
BEGIN
RETURN a+b;
END;
END;
/
DELIMITER ;/
SELECT f1();
DROP FUNCTION f1;
--echo # Testing labels --echo # Testing labels
DELIMITER /; DELIMITER /;
......
...@@ -2851,6 +2851,7 @@ sp_decl_idents: ...@@ -2851,6 +2851,7 @@ sp_decl_idents:
sp_opt_default: sp_opt_default:
/* Empty */ { $$ = NULL; } /* Empty */ { $$ = NULL; }
| DEFAULT expr { $$ = $2; } | DEFAULT expr { $$ = $2; }
| SET_VAR expr { $$ = $2; }
; ;
/* /*
......
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