Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
892af780
Commit
892af780
authored
Aug 08, 2016
by
Alexander Barkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-10411 Providing compatibility for basic PL/SQL constructs
Part6: assignment operator var:= 10;
parent
7e10e388
Changes
8
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
609 additions
and
192 deletions
+609
-192
mysql-test/suite/compat/oracle/r/sp.result
mysql-test/suite/compat/oracle/r/sp.result
+172
-0
mysql-test/suite/compat/oracle/t/sp.test
mysql-test/suite/compat/oracle/t/sp.test
+178
-0
sql/set_var.cc
sql/set_var.cc
+11
-0
sql/set_var.h
sql/set_var.h
+1
-0
sql/sql_lex.cc
sql/sql_lex.cc
+96
-0
sql/sql_lex.h
sql/sql_lex.h
+7
-0
sql/sql_yacc.yy
sql/sql_yacc.yy
+6
-83
sql/sql_yacc_ora.yy
sql/sql_yacc_ora.yy
+138
-109
No files found.
mysql-test/suite/compat/oracle/r/sp.result
View file @
892af780
...
...
@@ -80,3 +80,175 @@ SELECT @p1, @p2;
@p1 @p2
p1 p2new
DROP PROCEDURE p1;
# Testing Oracle-style assigment
CREATE PROCEDURE p1 (p1 OUT VARCHAR2(10))
BEGIN
p1:= 'p1new';
END;
/
SET @p1='p1';
CALL p1(@p1);
SELECT @p1;
@p1
p1new
DROP PROCEDURE p1;
# Testing that (some) keyword_sp are allowed in Oracle-style assignments
CREATE PROCEDURE p1 (action OUT INT) action:=10;
DROP PROCEDURE p1;
CREATE PROCEDURE p1 (clob OUT INT) clob:=10;
DROP PROCEDURE p1;
CREATE PROCEDURE p1 (enum OUT INT) enum:=10;
DROP PROCEDURE p1;
CREATE PROCEDURE p1 (via OUT INT) via:=10;
DROP PROCEDURE p1;
# Testing keyword_directly_assignable
CREATE PROCEDURE p1 (ascii OUT INT) ascii:=10;
DROP PROCEDURE p1;
CREATE PROCEDURE p1 (backup OUT INT) backup:=10;
DROP PROCEDURE p1;
CREATE PROCEDURE p1 (binlog OUT INT) binlog:=10;
DROP PROCEDURE p1;
CREATE PROCEDURE p1 (byte OUT INT) byte:=10;
DROP PROCEDURE p1;
CREATE PROCEDURE p1 (cache OUT INT) cache:=10;
DROP PROCEDURE p1;
CREATE PROCEDURE p1 (checksum OUT INT) checksum:=10;
DROP PROCEDURE p1;
CREATE PROCEDURE p1 (checkpoint OUT INT) checkpoint:=10;
DROP PROCEDURE p1;
CREATE PROCEDURE p1 (column_add OUT INT) column_add:=10;
DROP PROCEDURE p1;
CREATE PROCEDURE p1 (column_check OUT INT) column_check:=10;
DROP PROCEDURE p1;
CREATE PROCEDURE p1 (column_create OUT INT) column_create:=10;
DROP PROCEDURE p1;
CREATE PROCEDURE p1 (column_delete OUT INT) column_delete:=10;
DROP PROCEDURE p1;
CREATE PROCEDURE p1 (column_get OUT INT) column_get:=10;
DROP PROCEDURE p1;
CREATE PROCEDURE p1 (commit OUT INT) commit:=10;
DROP PROCEDURE p1;
CREATE PROCEDURE p1 (deallocate OUT INT) deallocate:=10;
DROP PROCEDURE p1;
CREATE PROCEDURE p1 (examined OUT INT) examined:=10;
DROP PROCEDURE p1;
CREATE PROCEDURE p1 (execute OUT INT) execute:=10;
DROP PROCEDURE p1;
CREATE PROCEDURE p1 (flush OUT INT) flush:=10;
DROP PROCEDURE p1;
CREATE PROCEDURE p1 (format OUT INT) format:=10;
DROP PROCEDURE p1;
CREATE PROCEDURE p1 (get OUT INT) get:=10;
DROP PROCEDURE p1;
CREATE PROCEDURE p1 (help OUT INT) help:=10;
DROP PROCEDURE p1;
CREATE PROCEDURE p1 (host OUT INT) host:=10;
DROP PROCEDURE p1;
CREATE PROCEDURE p1 (install OUT INT) install:=10;
DROP PROCEDURE p1;
CREATE PROCEDURE p1 (option OUT INT) option:=10;
DROP PROCEDURE p1;
CREATE PROCEDURE p1 (options OUT INT) options:=10;
DROP PROCEDURE p1;
CREATE PROCEDURE p1 (owner OUT INT) owner:=10;
DROP PROCEDURE p1;
CREATE PROCEDURE p1 (parser OUT INT) parser:=10;
DROP PROCEDURE p1;
CREATE PROCEDURE p1 (port OUT INT) port:=10;
DROP PROCEDURE p1;
CREATE PROCEDURE p1 (prepare OUT INT) prepare:=10;
DROP PROCEDURE p1;
CREATE PROCEDURE p1 (remove OUT INT) remove:=10;
DROP PROCEDURE p1;
CREATE PROCEDURE p1 (reset OUT INT) reset:=10;
DROP PROCEDURE p1;
CREATE PROCEDURE p1 (restore OUT INT) restore:=10;
DROP PROCEDURE p1;
CREATE PROCEDURE p1 (rollback OUT INT) rollback:=10;
DROP PROCEDURE p1;
CREATE PROCEDURE p1 (security OUT INT) security:=10;
DROP PROCEDURE p1;
CREATE PROCEDURE p1 (server OUT INT) server:=10;
DROP PROCEDURE p1;
CREATE PROCEDURE p1 (shutdown OUT INT) shutdown:=10;
DROP PROCEDURE p1;
CREATE PROCEDURE p1 (signed OUT INT) signed:=10;
DROP PROCEDURE p1;
CREATE PROCEDURE p1 (socket OUT INT) socket:=10;
DROP PROCEDURE p1;
CREATE PROCEDURE p1 (slave OUT INT) slave:=10;
DROP PROCEDURE p1;
CREATE PROCEDURE p1 (slaves OUT INT) slaves:=10;
DROP PROCEDURE p1;
CREATE PROCEDURE p1 (soname OUT INT) soname:=10;
DROP PROCEDURE p1;
CREATE PROCEDURE p1 (start OUT INT) start:=10;
DROP PROCEDURE p1;
CREATE PROCEDURE p1 (stop OUT INT) stop:=10;
DROP PROCEDURE p1;
CREATE PROCEDURE p1 (stored OUT INT) stored:=10;
DROP PROCEDURE p1;
CREATE PROCEDURE p1 (unicode OUT INT) unicode:=10;
DROP PROCEDURE p1;
CREATE PROCEDURE p1 (uninstall OUT INT) uninstall:=10;
DROP PROCEDURE p1;
CREATE PROCEDURE p1 (upgrade OUT INT) upgrade:=10;
DROP PROCEDURE p1;
CREATE PROCEDURE p1 (wrapper OUT INT) wrapper:=10;
DROP PROCEDURE p1;
CREATE PROCEDURE p1 (xa OUT INT) xa:=10;
DROP PROCEDURE p1;
# Testing that keyword_directly_not_assignable works in SET statements.
CREATE PROCEDURE p1 (contains OUT INT) SET contains=10;
DROP PROCEDURE p1;
CREATE PROCEDURE p1 (language OUT INT) SET language=10;
DROP PROCEDURE p1;
CREATE PROCEDURE p1 (no OUT INT) SET no=10;
DROP PROCEDURE p1;
CREATE PROCEDURE p1 (charset OUT INT) SET charset=10;
DROP PROCEDURE p1;
CREATE PROCEDURE p1 (do OUT INT) SET do=10;
DROP PROCEDURE p1;
CREATE PROCEDURE p1 (repair OUT INT) SET repair=10;
DROP PROCEDURE p1;
CREATE PROCEDURE p1 (handler OUT INT) SET handler=10;
DROP PROCEDURE p1;
CREATE PROCEDURE p1 (open OUT INT) SET open=10;
DROP PROCEDURE p1;
CREATE PROCEDURE p1 (close OUT INT) SET close=10;
DROP PROCEDURE p1;
CREATE PROCEDURE p1 (savepoint OUT INT) SET savepoint=10;
DROP PROCEDURE p1;
CREATE PROCEDURE p1 (truncate OUT INT) SET truncate=10;
DROP PROCEDURE p1;
CREATE PROCEDURE p1 (begin OUT INT) SET begin=10;
DROP PROCEDURE p1;
CREATE PROCEDURE p1 (end OUT INT) SET end=10;
DROP PROCEDURE p1;
# Testing that keyword_directly_not_assignable works in table/column names
CREATE TABLE contains (contains INT);
DROP TABLE contains;
CREATE TABLE language (language INT);
DROP TABLE language;
CREATE TABLE no (no INT);
DROP TABLE no;
CREATE TABLE charset (charset INT);
DROP TABLE charset;
CREATE TABLE do (do INT);
DROP TABLE do;
CREATE TABLE repair (repair INT);
DROP TABLE repair;
CREATE TABLE handler (handler INT);
DROP TABLE handler;
CREATE TABLE open (open INT);
DROP TABLE open;
CREATE TABLE close (close INT);
DROP TABLE close;
CREATE TABLE savepoint (savepoint INT);
DROP TABLE savepoint;
CREATE TABLE truncate (truncate INT);
DROP TABLE truncate;
CREATE TABLE begin (begin INT);
DROP TABLE begin;
CREATE TABLE end (end INT);
DROP TABLE end;
mysql-test/suite/compat/oracle/t/sp.test
View file @
892af780
...
...
@@ -88,3 +88,181 @@ SET @p1='p1', @p2='p2';
CALL
p1
(
@
p1
,
@
p2
);
SELECT
@
p1
,
@
p2
;
DROP
PROCEDURE
p1
;
--
echo
# Testing Oracle-style assigment
DELIMITER
/
;
CREATE
PROCEDURE
p1
(
p1
OUT
VARCHAR2
(
10
))
BEGIN
p1
:=
'p1new'
;
END
;
/
DELIMITER
;
/
SET
@
p1
=
'p1'
;
CALL
p1
(
@
p1
);
SELECT
@
p1
;
DROP
PROCEDURE
p1
;
--
echo
# Testing that (some) keyword_sp are allowed in Oracle-style assignments
CREATE
PROCEDURE
p1
(
action
OUT
INT
)
action
:=
10
;
DROP
PROCEDURE
p1
;
CREATE
PROCEDURE
p1
(
clob
OUT
INT
)
clob
:=
10
;
DROP
PROCEDURE
p1
;
CREATE
PROCEDURE
p1
(
enum
OUT
INT
)
enum
:=
10
;
DROP
PROCEDURE
p1
;
CREATE
PROCEDURE
p1
(
via
OUT
INT
)
via
:=
10
;
DROP
PROCEDURE
p1
;
--
echo
# Testing keyword_directly_assignable
CREATE
PROCEDURE
p1
(
ascii
OUT
INT
)
ascii
:=
10
;
DROP
PROCEDURE
p1
;
CREATE
PROCEDURE
p1
(
backup
OUT
INT
)
backup
:=
10
;
DROP
PROCEDURE
p1
;
CREATE
PROCEDURE
p1
(
binlog
OUT
INT
)
binlog
:=
10
;
DROP
PROCEDURE
p1
;
CREATE
PROCEDURE
p1
(
byte
OUT
INT
)
byte
:=
10
;
DROP
PROCEDURE
p1
;
CREATE
PROCEDURE
p1
(
cache
OUT
INT
)
cache
:=
10
;
DROP
PROCEDURE
p1
;
CREATE
PROCEDURE
p1
(
checksum
OUT
INT
)
checksum
:=
10
;
DROP
PROCEDURE
p1
;
CREATE
PROCEDURE
p1
(
checkpoint
OUT
INT
)
checkpoint
:=
10
;
DROP
PROCEDURE
p1
;
CREATE
PROCEDURE
p1
(
column_add
OUT
INT
)
column_add
:=
10
;
DROP
PROCEDURE
p1
;
CREATE
PROCEDURE
p1
(
column_check
OUT
INT
)
column_check
:=
10
;
DROP
PROCEDURE
p1
;
CREATE
PROCEDURE
p1
(
column_create
OUT
INT
)
column_create
:=
10
;
DROP
PROCEDURE
p1
;
CREATE
PROCEDURE
p1
(
column_delete
OUT
INT
)
column_delete
:=
10
;
DROP
PROCEDURE
p1
;
CREATE
PROCEDURE
p1
(
column_get
OUT
INT
)
column_get
:=
10
;
DROP
PROCEDURE
p1
;
CREATE
PROCEDURE
p1
(
commit
OUT
INT
)
commit
:=
10
;
DROP
PROCEDURE
p1
;
CREATE
PROCEDURE
p1
(
deallocate
OUT
INT
)
deallocate
:=
10
;
DROP
PROCEDURE
p1
;
CREATE
PROCEDURE
p1
(
examined
OUT
INT
)
examined
:=
10
;
DROP
PROCEDURE
p1
;
CREATE
PROCEDURE
p1
(
execute
OUT
INT
)
execute
:=
10
;
DROP
PROCEDURE
p1
;
CREATE
PROCEDURE
p1
(
flush
OUT
INT
)
flush
:=
10
;
DROP
PROCEDURE
p1
;
CREATE
PROCEDURE
p1
(
format
OUT
INT
)
format
:=
10
;
DROP
PROCEDURE
p1
;
CREATE
PROCEDURE
p1
(
get
OUT
INT
)
get
:=
10
;
DROP
PROCEDURE
p1
;
CREATE
PROCEDURE
p1
(
help
OUT
INT
)
help
:=
10
;
DROP
PROCEDURE
p1
;
CREATE
PROCEDURE
p1
(
host
OUT
INT
)
host
:=
10
;
DROP
PROCEDURE
p1
;
CREATE
PROCEDURE
p1
(
install
OUT
INT
)
install
:=
10
;
DROP
PROCEDURE
p1
;
CREATE
PROCEDURE
p1
(
option
OUT
INT
)
option
:=
10
;
DROP
PROCEDURE
p1
;
CREATE
PROCEDURE
p1
(
options
OUT
INT
)
options
:=
10
;
DROP
PROCEDURE
p1
;
CREATE
PROCEDURE
p1
(
owner
OUT
INT
)
owner
:=
10
;
DROP
PROCEDURE
p1
;
CREATE
PROCEDURE
p1
(
parser
OUT
INT
)
parser
:=
10
;
DROP
PROCEDURE
p1
;
CREATE
PROCEDURE
p1
(
port
OUT
INT
)
port
:=
10
;
DROP
PROCEDURE
p1
;
CREATE
PROCEDURE
p1
(
prepare
OUT
INT
)
prepare
:=
10
;
DROP
PROCEDURE
p1
;
CREATE
PROCEDURE
p1
(
remove
OUT
INT
)
remove
:=
10
;
DROP
PROCEDURE
p1
;
CREATE
PROCEDURE
p1
(
reset
OUT
INT
)
reset
:=
10
;
DROP
PROCEDURE
p1
;
CREATE
PROCEDURE
p1
(
restore
OUT
INT
)
restore
:=
10
;
DROP
PROCEDURE
p1
;
CREATE
PROCEDURE
p1
(
rollback
OUT
INT
)
rollback
:=
10
;
DROP
PROCEDURE
p1
;
CREATE
PROCEDURE
p1
(
security
OUT
INT
)
security
:=
10
;
DROP
PROCEDURE
p1
;
CREATE
PROCEDURE
p1
(
server
OUT
INT
)
server
:=
10
;
DROP
PROCEDURE
p1
;
CREATE
PROCEDURE
p1
(
shutdown
OUT
INT
)
shutdown
:=
10
;
DROP
PROCEDURE
p1
;
CREATE
PROCEDURE
p1
(
signed
OUT
INT
)
signed
:=
10
;
DROP
PROCEDURE
p1
;
CREATE
PROCEDURE
p1
(
socket
OUT
INT
)
socket
:=
10
;
DROP
PROCEDURE
p1
;
CREATE
PROCEDURE
p1
(
slave
OUT
INT
)
slave
:=
10
;
DROP
PROCEDURE
p1
;
CREATE
PROCEDURE
p1
(
slaves
OUT
INT
)
slaves
:=
10
;
DROP
PROCEDURE
p1
;
CREATE
PROCEDURE
p1
(
soname
OUT
INT
)
soname
:=
10
;
DROP
PROCEDURE
p1
;
CREATE
PROCEDURE
p1
(
start
OUT
INT
)
start
:=
10
;
DROP
PROCEDURE
p1
;
CREATE
PROCEDURE
p1
(
stop
OUT
INT
)
stop
:=
10
;
DROP
PROCEDURE
p1
;
CREATE
PROCEDURE
p1
(
stored
OUT
INT
)
stored
:=
10
;
DROP
PROCEDURE
p1
;
CREATE
PROCEDURE
p1
(
unicode
OUT
INT
)
unicode
:=
10
;
DROP
PROCEDURE
p1
;
CREATE
PROCEDURE
p1
(
uninstall
OUT
INT
)
uninstall
:=
10
;
DROP
PROCEDURE
p1
;
CREATE
PROCEDURE
p1
(
upgrade
OUT
INT
)
upgrade
:=
10
;
DROP
PROCEDURE
p1
;
CREATE
PROCEDURE
p1
(
wrapper
OUT
INT
)
wrapper
:=
10
;
DROP
PROCEDURE
p1
;
CREATE
PROCEDURE
p1
(
xa
OUT
INT
)
xa
:=
10
;
DROP
PROCEDURE
p1
;
--
echo
# Testing that keyword_directly_not_assignable works in SET statements.
CREATE
PROCEDURE
p1
(
contains
OUT
INT
)
SET
contains
=
10
;
DROP
PROCEDURE
p1
;
CREATE
PROCEDURE
p1
(
language
OUT
INT
)
SET
language
=
10
;
DROP
PROCEDURE
p1
;
CREATE
PROCEDURE
p1
(
no
OUT
INT
)
SET
no
=
10
;
DROP
PROCEDURE
p1
;
CREATE
PROCEDURE
p1
(
charset
OUT
INT
)
SET
charset
=
10
;
DROP
PROCEDURE
p1
;
CREATE
PROCEDURE
p1
(
do
OUT
INT
)
SET
do
=
10
;
DROP
PROCEDURE
p1
;
CREATE
PROCEDURE
p1
(
repair
OUT
INT
)
SET
repair
=
10
;
DROP
PROCEDURE
p1
;
CREATE
PROCEDURE
p1
(
handler
OUT
INT
)
SET
handler
=
10
;
DROP
PROCEDURE
p1
;
CREATE
PROCEDURE
p1
(
open
OUT
INT
)
SET
open
=
10
;
DROP
PROCEDURE
p1
;
CREATE
PROCEDURE
p1
(
close
OUT
INT
)
SET
close
=
10
;
DROP
PROCEDURE
p1
;
CREATE
PROCEDURE
p1
(
savepoint
OUT
INT
)
SET
savepoint
=
10
;
DROP
PROCEDURE
p1
;
CREATE
PROCEDURE
p1
(
truncate
OUT
INT
)
SET
truncate
=
10
;
DROP
PROCEDURE
p1
;
CREATE
PROCEDURE
p1
(
begin
OUT
INT
)
SET
begin
=
10
;
DROP
PROCEDURE
p1
;
CREATE
PROCEDURE
p1
(
end
OUT
INT
)
SET
end
=
10
;
DROP
PROCEDURE
p1
;
--
echo
# Testing that keyword_directly_not_assignable works in table/column names
CREATE
TABLE
contains
(
contains
INT
);
DROP
TABLE
contains
;
CREATE
TABLE
language
(
language
INT
);
DROP
TABLE
language
;
CREATE
TABLE
no
(
no
INT
);
DROP
TABLE
no
;
CREATE
TABLE
charset
(
charset
INT
);
DROP
TABLE
charset
;
CREATE
TABLE
do
(
do
INT
);
DROP
TABLE
do
;
CREATE
TABLE
repair
(
repair
INT
);
DROP
TABLE
repair
;
CREATE
TABLE
handler
(
handler
INT
);
DROP
TABLE
handler
;
CREATE
TABLE
open
(
open
INT
);
DROP
TABLE
open
;
CREATE
TABLE
close
(
close
INT
);
DROP
TABLE
close
;
CREATE
TABLE
savepoint
(
savepoint
INT
);
DROP
TABLE
savepoint
;
CREATE
TABLE
truncate
(
truncate
INT
);
DROP
TABLE
truncate
;
CREATE
TABLE
begin
(
begin
INT
);
DROP
TABLE
begin
;
CREATE
TABLE
end
(
end
INT
);
DROP
TABLE
end
;
sql/set_var.cc
View file @
892af780
...
...
@@ -686,6 +686,17 @@ sys_var *intern_find_sys_var(const char *str, uint length)
}
bool
find_sys_var_null_base
(
THD
*
thd
,
struct
sys_var_with_base
*
tmp
)
{
tmp
->
var
=
find_sys_var
(
thd
,
tmp
->
base_name
.
str
,
tmp
->
base_name
.
length
);
if
(
tmp
->
var
!=
NULL
)
tmp
->
base_name
=
null_lex_str
;
return
thd
->
is_error
();
}
/**
Execute update of all variables.
...
...
sql/set_var.h
View file @
892af780
...
...
@@ -391,6 +391,7 @@ SHOW_VAR* enumerate_sys_vars(THD *thd, bool sorted, enum enum_var_type type);
int
fill_sysvars
(
THD
*
thd
,
TABLE_LIST
*
tables
,
COND
*
cond
);
sys_var
*
find_sys_var
(
THD
*
thd
,
const
char
*
str
,
size_t
length
=
0
);
bool
find_sys_var_null_base
(
THD
*
thd
,
struct
sys_var_with_base
*
tmp
);
int
sql_set_variables
(
THD
*
thd
,
List
<
set_var_base
>
*
var_list
,
bool
free
);
#define SYSVAR_AUTOSIZE(VAR,VAL) \
...
...
sql/sql_lex.cc
View file @
892af780
...
...
@@ -5090,6 +5090,102 @@ bool LEX::sp_param_fill_definition(sp_variable *spvar)
}
void
LEX
::
set_stmt_init
()
{
sql_command
=
SQLCOM_SET_OPTION
;
mysql_init_select
(
this
);
option_type
=
OPT_SESSION
;
autocommit
=
0
;
};
bool
LEX
::
init_internal_variable
(
struct
sys_var_with_base
*
variable
,
LEX_STRING
name
)
{
sp_variable
*
spv
;
/* Best effort lookup for system variable. */
if
(
!
spcont
||
!
(
spv
=
spcont
->
find_variable
(
name
,
false
)))
{
struct
sys_var_with_base
tmp
=
{
NULL
,
name
};
/* Not an SP local variable */
if
(
find_sys_var_null_base
(
thd
,
&
tmp
))
return
true
;
*
variable
=
tmp
;
return
false
;
}
/*
Possibly an SP local variable (or a shadowed sysvar).
Will depend on the context of the SET statement.
*/
variable
->
var
=
NULL
;
variable
->
base_name
=
name
;
return
false
;
}
bool
LEX
::
init_internal_variable
(
struct
sys_var_with_base
*
variable
,
LEX_STRING
dbname
,
LEX_STRING
name
)
{
if
(
check_reserved_words
(
&
dbname
))
{
thd
->
parse_error
();
return
true
;
}
if
(
sphead
&&
sphead
->
m_type
==
TYPE_ENUM_TRIGGER
&&
(
!
my_strcasecmp
(
system_charset_info
,
dbname
.
str
,
"NEW"
)
||
!
my_strcasecmp
(
system_charset_info
,
dbname
.
str
,
"OLD"
)))
{
if
(
dbname
.
str
[
0
]
==
'O'
||
dbname
.
str
[
0
]
==
'o'
)
{
my_error
(
ER_TRG_CANT_CHANGE_ROW
,
MYF
(
0
),
"OLD"
,
""
);
return
true
;
}
if
(
trg_chistics
.
event
==
TRG_EVENT_DELETE
)
{
my_error
(
ER_TRG_NO_SUCH_ROW_IN_TRG
,
MYF
(
0
),
"NEW"
,
"on DELETE"
);
return
true
;
}
if
(
trg_chistics
.
action_time
==
TRG_ACTION_AFTER
)
{
my_error
(
ER_TRG_CANT_CHANGE_ROW
,
MYF
(
0
),
"NEW"
,
"after "
);
return
true
;
}
/* This special combination will denote field of NEW row */
variable
->
var
=
trg_new_row_fake_var
;
variable
->
base_name
=
name
;
return
false
;
}
sys_var
*
tmp
=
find_sys_var
(
thd
,
name
.
str
,
name
.
length
);
if
(
!
tmp
)
return
true
;
if
(
!
tmp
->
is_struct
())
my_error
(
ER_VARIABLE_IS_NOT_STRUCT
,
MYF
(
0
),
name
.
str
);
variable
->
var
=
tmp
;
variable
->
base_name
=
dbname
;
return
false
;
}
bool
LEX
::
init_default_internal_variable
(
struct
sys_var_with_base
*
variable
,
LEX_STRING
name
)
{
sys_var
*
tmp
=
find_sys_var
(
thd
,
name
.
str
,
name
.
length
);
if
(
!
tmp
)
return
true
;
if
(
!
tmp
->
is_struct
())
my_error
(
ER_VARIABLE_IS_NOT_STRUCT
,
MYF
(
0
),
name
.
str
);
variable
->
var
=
tmp
;
variable
->
base_name
.
str
=
(
char
*
)
"default"
;
variable
->
base_name
.
length
=
7
;
return
false
;
}
#ifdef MYSQL_SERVER
uint
binlog_unsafe_map
[
256
];
...
...
sql/sql_lex.h
View file @
892af780
...
...
@@ -3064,6 +3064,13 @@ struct LEX: public Query_tables_list
bool
set_trigger_new_row
(
LEX_STRING
*
name
,
Item
*
val
);
bool
set_system_variable
(
struct
sys_var_with_base
*
tmp
,
enum
enum_var_type
var_type
,
Item
*
val
);
void
set_stmt_init
();
bool
init_internal_variable
(
struct
sys_var_with_base
*
variable
,
LEX_STRING
name
);
bool
init_internal_variable
(
struct
sys_var_with_base
*
variable
,
LEX_STRING
dbname
,
LEX_STRING
name
);
bool
init_default_internal_variable
(
struct
sys_var_with_base
*
variable
,
LEX_STRING
name
);
bool
set_local_variable
(
sp_variable
*
spv
,
Item
*
val
);
Item_splocal
*
create_item_for_sp_var
(
LEX_STRING
name
,
sp_variable
*
spvar
,
const
char
*
start_in_q
,
...
...
sql/sql_yacc.yy
View file @
892af780
...
...
@@ -335,17 +335,6 @@ int LEX::case_stmt_action_then()
return sphead->push_backpatch(thd, i, spcont->last_label());
}
static bool
find_sys_var_null_base(THD *thd, struct sys_var_with_base *tmp)
{
tmp->var= find_sys_var(thd, tmp->base_name.str, tmp->base_name.length);
if (tmp->var != NULL)
tmp->base_name= null_lex_str;
return thd->is_error();
}
/**
Helper action for a SET statement.
...
...
@@ -14880,22 +14869,15 @@ set:
SET
{
LEX *lex=Lex;
lex->sql_command= SQLCOM_SET_OPTION;
mysql_init_select(lex);
lex->option_type=OPT_SESSION;
lex->set_stmt_init();
lex->var_list.empty();
lex->autocommit= 0;
sp_create_assignment_lex(thd, yychar == YYEMPTY);
}
start_option_value_list
{}
| SET STATEMENT_SYM
{
LEX *lex= Lex;
mysql_init_select(lex);
lex->option_type= OPT_SESSION;
lex->sql_command= SQLCOM_SET_OPTION;
lex->autocommit= 0;
Lex->set_stmt_init();
}
set_stmt_option_value_following_option_type_list
{
...
...
@@ -15193,77 +15175,18 @@ option_value_no_option_type:
internal_variable_name:
ident
{
sp_pcontext *spc= thd->lex->spcont;
sp_variable *spv;
/* Best effort lookup for system variable. */
if (!spc || !(spv = spc->find_variable($1, false)))
{
struct sys_var_with_base tmp= {NULL, $1};
/* Not an SP local variable */
if (find_sys_var_null_base(thd, &tmp))
if (Lex->init_internal_variable(&$$, $1))
MYSQL_YYABORT;
$$= tmp;
}
else
{
/*
Possibly an SP local variable (or a shadowed sysvar).
Will depend on the context of the SET statement.
*/
$$.var= NULL;
$$.base_name= $1;
}
}
| ident '.' ident
{
LEX *lex= Lex;
if (check_reserved_words(&$1))
{
thd->parse_error();
MYSQL_YYABORT;
}
if (lex->sphead && lex->sphead->m_type == TYPE_ENUM_TRIGGER &&
(!my_strcasecmp(system_charset_info, $1.str, "NEW") ||
!my_strcasecmp(system_charset_info, $1.str, "OLD")))
{
if ($1.str[0]=='O' || $1.str[0]=='o')
my_yyabort_error((ER_TRG_CANT_CHANGE_ROW, MYF(0), "OLD", ""));
if (lex->trg_chistics.event == TRG_EVENT_DELETE)
{
my_error(ER_TRG_NO_SUCH_ROW_IN_TRG, MYF(0),
"NEW", "on DELETE");
MYSQL_YYABORT;
}
if (lex->trg_chistics.action_time == TRG_ACTION_AFTER)
my_yyabort_error((ER_TRG_CANT_CHANGE_ROW, MYF(0), "NEW", "after "));
/* This special combination will denote field of NEW row */
$$.var= trg_new_row_fake_var;
$$.base_name= $3;
}
else
{
sys_var *tmp=find_sys_var(thd, $3.str, $3.length);
if (!tmp)
if (Lex->init_internal_variable(&$$, $1, $3))
MYSQL_YYABORT;
if (!tmp->is_struct())
my_error(ER_VARIABLE_IS_NOT_STRUCT, MYF(0), $3.str);
$$.var= tmp;
$$.base_name= $1;
}
}
| DEFAULT '.' ident
{
sys_var *tmp=find_sys_var(thd, $3.str, $3.length);
if (!tmp)
if (Lex->init_default_internal_variable(&$$, $3))
MYSQL_YYABORT;
if (!tmp->is_struct())
my_error(ER_VARIABLE_IS_NOT_STRUCT, MYF(0), $3.str);
$$.var= tmp;
$$.base_name.str= (char*) "default";
$$.base_name.length= 7;
}
;
...
...
sql/sql_yacc_ora.yy
View file @
892af780
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment