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
cae6bf2b
Commit
cae6bf2b
authored
Apr 03, 2017
by
Alexander Barkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleanup for MDEV-10581 sql_mode=ORACLE: Explicit cursor FOR LOOP
Addressing Monty's review suggestions.
parent
ce4b291b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
11 deletions
+18
-11
sql/sql_lex.cc
sql/sql_lex.cc
+11
-6
sql/sql_lex.h
sql/sql_lex.h
+2
-2
sql/sql_yacc_ora.yy
sql/sql_yacc_ora.yy
+5
-3
No files found.
sql/sql_lex.cc
View file @
cae6bf2b
...
...
@@ -5428,9 +5428,12 @@ LEX::sp_add_for_loop_cursor_variable(THD *thd,
Item_args
*
parameters
)
{
sp_variable
*
spvar
=
spcont
->
add_variable
(
thd
,
name
);
if
(
!
spvar
)
return
NULL
;
spcont
->
declare_var_boundary
(
1
);
sphead
->
fill_spvar_definition
(
thd
,
&
spvar
->
field_def
,
spvar
->
name
.
str
);
spvar
->
default_value
=
new
(
thd
->
mem_root
)
Item_null
(
thd
);
if
(
!
(
spvar
->
default_value
=
new
(
thd
->
mem_root
)
Item_null
(
thd
)))
return
NULL
;
spvar
->
field_def
.
set_cursor_rowtype_ref
(
true
);
...
...
@@ -5488,11 +5491,15 @@ bool LEX::sp_for_loop_intrange_condition_test(THD *thd,
bool
LEX
::
sp_for_loop_cursor_condition_test
(
THD
*
thd
,
const
Lex_for_loop_st
&
loop
)
{
const
LEX_STRING
*
cursor_name
;
Item
*
expr
;
spcont
->
set_for_loop
(
loop
);
sphead
->
reset_lex
(
thd
);
const
LEX_STRING
*
cursor_name
=
spcont
->
find_cursor
(
loop
.
m_cursor_offset
);
Item
*
expr
=
new
(
thd
->
mem_root
)
Item_func_cursor_found
(
thd
,
*
cursor_name
,
loop
.
m_cursor_offset
);
cursor_name
=
spcont
->
find_cursor
(
loop
.
m_cursor_offset
);
DBUG_ASSERT
(
cursor_name
);
if
(
!
(
expr
=
new
(
thd
->
mem_root
)
Item_func_cursor_found
(
thd
,
*
cursor_name
,
loop
.
m_cursor_offset
)))
return
true
;
if
(
thd
->
lex
->
sp_while_loop_expression
(
thd
,
expr
))
return
true
;
return
thd
->
lex
->
sphead
->
restore_lex
(
thd
);
...
...
@@ -5531,9 +5538,7 @@ bool LEX::sp_for_loop_cursor_declarations(THD *thd,
const
sp_pcursor
*
pcursor
;
if
((
item_splocal
=
item
->
get_item_splocal
()))
{
name
=
item_splocal
->
m_name
;
}
else
if
((
item_field
=
item
->
type
()
==
Item
::
FIELD_ITEM
?
static_cast
<
Item_field
*>
(
item
)
:
NULL
)
&&
item_field
->
table_name
==
NULL
)
...
...
sql/sql_lex.h
View file @
cae6bf2b
...
...
@@ -3400,10 +3400,10 @@ struct LEX: public Query_tables_list
This methods adds declarations:
- An explicit integer or cursor%ROWTYPE "index" variable
- An implicit in
g
eger upper bound variable, in case of integer range loops
- An implicit in
t
eger upper bound variable, in case of integer range loops
- A CURSOR, in case of an implicit CURSOR loops
The generated variables are stored into "loop".
Additional loop characteristics are copie
s
from "bounds" to "loop".
Additional loop characteristics are copie
d
from "bounds" to "loop".
*/
bool
sp_for_loop_declarations
(
THD
*
thd
,
Lex_for_loop_st
*
loop
,
const
LEX_STRING
&
index
,
...
...
sql/sql_yacc_ora.yy
View file @
cae6bf2b
...
...
@@ -3888,21 +3888,23 @@ sp_for_loop_bounds:
}
| IN_SYM opt_sp_for_loop_direction '(' sp_cursor_stmt ')'
{
Item *item;
DBUG_ASSERT(Lex->sphead);
LEX_STRING name= {C_STRING_WITH_LEN("[implicit_cursor]") };
if (Lex->sp_declare_cursor(thd, name, $4, NULL, true))
MYSQL_YYABORT;
$$.m_direction= 1;
if (!($$.m_index= new (thd->mem_root) sp_assignment_lex(thd, thd->lex)))
MYSQL_YYABORT;
$$.m_index->sp_lex_in_use= true;
Lex->sphead->reset_lex(thd, $$.m_index);
Item *
item= new (thd->mem_root) Item_field(thd,
if (!(
item= new (thd->mem_root) Item_field(thd,
Lex->current_context(),
NullS, NullS, name.str);
NullS, NullS, name.str)))
MYSQL_YYABORT;
$$.m_index->set_item_and_free_list(item, NULL);
if (Lex->sphead->restore_lex(thd))
MYSQL_YYABORT;
$$.m_direction= 1;
$$.m_upper_bound= NULL;
$$.m_implicit_cursor= true;
}
...
...
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