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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
8dafd2b9
Commit
8dafd2b9
authored
Apr 28, 2009
by
Alexey Botchkov
Browse files
Options
Browse Files
Download
Plain Diff
merging
parents
d1968ad4
52989c44
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
167 additions
and
133 deletions
+167
-133
myisam/mi_delete.c
myisam/mi_delete.c
+5
-1
myisam/mi_write.c
myisam/mi_write.c
+8
-1
server-tools/instance-manager/instance_options.cc
server-tools/instance-manager/instance_options.cc
+1
-2
sql/slave.cc
sql/slave.cc
+1
-2
sql/sp_head.cc
sql/sp_head.cc
+14
-13
sql/sp_head.h
sql/sp_head.h
+4
-4
sql/sp_pcontext.cc
sql/sp_pcontext.cc
+11
-11
sql/sp_pcontext.h
sql/sp_pcontext.h
+2
-2
sql/sql_select.cc
sql/sql_select.cc
+31
-15
sql/sql_yacc.yy
sql/sql_yacc.yy
+90
-82
No files found.
myisam/mi_delete.c
View file @
8dafd2b9
...
@@ -250,7 +250,11 @@ static int d_search(register MI_INFO *info, register MI_KEYDEF *keyinfo,
...
@@ -250,7 +250,11 @@ static int d_search(register MI_INFO *info, register MI_KEYDEF *keyinfo,
if
(
info
->
ft1_to_ft2
)
if
(
info
->
ft1_to_ft2
)
{
{
/* we're in ft1->ft2 conversion mode. Saving key data */
/* we're in ft1->ft2 conversion mode. Saving key data */
insert_dynamic
(
info
->
ft1_to_ft2
,
(
char
*
)
(
lastkey
+
off
));
if
(
insert_dynamic
(
info
->
ft1_to_ft2
,
(
char
*
)
(
lastkey
+
off
)))
{
DBUG_PRINT
(
"error"
,(
"Out of memory"
));
DBUG_RETURN
(
-
1
);
}
}
}
else
else
{
{
...
...
myisam/mi_write.c
View file @
8dafd2b9
...
@@ -550,7 +550,14 @@ int _mi_insert(register MI_INFO *info, register MI_KEYDEF *keyinfo,
...
@@ -550,7 +550,14 @@ int _mi_insert(register MI_INFO *info, register MI_KEYDEF *keyinfo,
we cannot easily dispatch an empty page here */
we cannot easily dispatch an empty page here */
b
+=
blen
+
ft2len
+
2
;
b
+=
blen
+
ft2len
+
2
;
for
(
a
=
anc_buff
+
a_length
;
b
<
a
;
b
+=
ft2len
+
2
)
for
(
a
=
anc_buff
+
a_length
;
b
<
a
;
b
+=
ft2len
+
2
)
insert_dynamic
(
info
->
ft1_to_ft2
,
(
char
*
)
b
);
{
if
(
insert_dynamic
(
info
->
ft1_to_ft2
,
(
char
*
)
b
))
{
mi_print_error
(
info
->
s
,
HA_ERR_OUT_OF_MEM
);
my_errno
=
HA_ERR_OUT_OF_MEM
;
DBUG_RETURN
(
-
1
);
}
}
/* fixing the page's length - it contains only one key now */
/* fixing the page's length - it contains only one key now */
mi_putint
(
anc_buff
,
2
+
blen
+
ft2len
+
2
,
0
);
mi_putint
(
anc_buff
,
2
+
blen
+
ft2len
+
2
,
0
);
...
...
server-tools/instance-manager/instance_options.cc
View file @
8dafd2b9
...
@@ -522,8 +522,7 @@ int Instance_options::add_option(const char* option)
...
@@ -522,8 +522,7 @@ int Instance_options::add_option(const char* option)
switch
(
selected_options
->
type
)
{
switch
(
selected_options
->
type
)
{
case
SAVE_WHOLE_AND_ADD
:
case
SAVE_WHOLE_AND_ADD
:
*
(
selected_options
->
value
)
=
tmp
;
*
(
selected_options
->
value
)
=
tmp
;
insert_dynamic
(
&
options_array
,(
gptr
)
&
tmp
);
return
insert_dynamic
(
&
options_array
,(
gptr
)
&
tmp
);
return
0
;
case
SAVE_VALUE
:
case
SAVE_VALUE
:
*
(
selected_options
->
value
)
=
strchr
(
tmp
,
'='
)
+
1
;
*
(
selected_options
->
value
)
=
strchr
(
tmp
,
'='
)
+
1
;
return
0
;
return
0
;
...
...
sql/slave.cc
View file @
8dafd2b9
...
@@ -1053,8 +1053,7 @@ int add_wild_table_rule(DYNAMIC_ARRAY* a, const char* table_spec)
...
@@ -1053,8 +1053,7 @@ int add_wild_table_rule(DYNAMIC_ARRAY* a, const char* table_spec)
e
->
tbl_name
=
e
->
db
+
(
dot
-
table_spec
)
+
1
;
e
->
tbl_name
=
e
->
db
+
(
dot
-
table_spec
)
+
1
;
e
->
key_len
=
len
;
e
->
key_len
=
len
;
memcpy
(
e
->
db
,
table_spec
,
len
);
memcpy
(
e
->
db
,
table_spec
,
len
);
insert_dynamic
(
a
,
(
gptr
)
&
e
);
return
insert_dynamic
(
a
,
(
gptr
)
&
e
);
return
0
;
}
}
...
...
sql/sp_head.cc
View file @
8dafd2b9
...
@@ -1929,17 +1929,16 @@ sp_head::restore_lex(THD *thd)
...
@@ -1929,17 +1929,16 @@ sp_head::restore_lex(THD *thd)
DBUG_VOID_RETURN
;
DBUG_VOID_RETURN
;
}
}
void
int
sp_head
::
push_backpatch
(
sp_instr
*
i
,
sp_label_t
*
lab
)
sp_head
::
push_backpatch
(
sp_instr
*
i
,
sp_label_t
*
lab
)
{
{
bp_t
*
bp
=
(
bp_t
*
)
sql_alloc
(
sizeof
(
bp_t
));
bp_t
*
bp
=
(
bp_t
*
)
sql_alloc
(
sizeof
(
bp_t
));
if
(
bp
)
if
(
!
bp
)
{
return
1
;
bp
->
lab
=
lab
;
bp
->
lab
=
lab
;
bp
->
instr
=
i
;
bp
->
instr
=
i
;
(
void
)
m_backpatch
.
push_front
(
bp
);
return
m_backpatch
.
push_front
(
bp
);
}
}
}
void
void
...
@@ -2014,7 +2013,7 @@ sp_head::fill_field_definition(THD *thd, LEX *lex,
...
@@ -2014,7 +2013,7 @@ sp_head::fill_field_definition(THD *thd, LEX *lex,
}
}
void
int
sp_head
::
new_cont_backpatch
(
sp_instr_opt_meta
*
i
)
sp_head
::
new_cont_backpatch
(
sp_instr_opt_meta
*
i
)
{
{
m_cont_level
+=
1
;
m_cont_level
+=
1
;
...
@@ -2022,15 +2021,17 @@ sp_head::new_cont_backpatch(sp_instr_opt_meta *i)
...
@@ -2022,15 +2021,17 @@ sp_head::new_cont_backpatch(sp_instr_opt_meta *i)
{
{
/* Use the cont. destination slot to store the level */
/* Use the cont. destination slot to store the level */
i
->
m_cont_dest
=
m_cont_level
;
i
->
m_cont_dest
=
m_cont_level
;
(
void
)
m_cont_backpatch
.
push_front
(
i
);
if
(
m_cont_backpatch
.
push_front
(
i
))
return
1
;
}
}
return
0
;
}
}
void
int
sp_head
::
add_cont_backpatch
(
sp_instr_opt_meta
*
i
)
sp_head
::
add_cont_backpatch
(
sp_instr_opt_meta
*
i
)
{
{
i
->
m_cont_dest
=
m_cont_level
;
i
->
m_cont_dest
=
m_cont_level
;
(
void
)
m_cont_backpatch
.
push_front
(
i
);
return
m_cont_backpatch
.
push_front
(
i
);
}
}
void
void
...
@@ -2212,7 +2213,7 @@ sp_head::show_create_procedure(THD *thd)
...
@@ -2212,7 +2213,7 @@ sp_head::show_create_procedure(THD *thd)
instr Instruction
instr Instruction
*/
*/
void
sp_head
::
add_instr
(
sp_instr
*
instr
)
int
sp_head
::
add_instr
(
sp_instr
*
instr
)
{
{
instr
->
free_list
=
m_thd
->
free_list
;
instr
->
free_list
=
m_thd
->
free_list
;
m_thd
->
free_list
=
0
;
m_thd
->
free_list
=
0
;
...
@@ -2223,7 +2224,7 @@ void sp_head::add_instr(sp_instr *instr)
...
@@ -2223,7 +2224,7 @@ void sp_head::add_instr(sp_instr *instr)
entire stored procedure, as their life span is equal.
entire stored procedure, as their life span is equal.
*/
*/
instr
->
mem_root
=
&
main_mem_root
;
instr
->
mem_root
=
&
main_mem_root
;
insert_dynamic
(
&
m_instr
,
(
gptr
)
&
instr
);
return
insert_dynamic
(
&
m_instr
,
(
gptr
)
&
instr
);
}
}
...
...
sql/sp_head.h
View file @
8dafd2b9
...
@@ -226,7 +226,7 @@ public:
...
@@ -226,7 +226,7 @@ public:
int
int
show_create_function
(
THD
*
thd
);
show_create_function
(
THD
*
thd
);
void
int
add_instr
(
sp_instr
*
instr
);
add_instr
(
sp_instr
*
instr
);
inline
uint
inline
uint
...
@@ -254,7 +254,7 @@ public:
...
@@ -254,7 +254,7 @@ public:
restore_lex
(
THD
*
thd
);
restore_lex
(
THD
*
thd
);
// Put the instruction on the backpatch list, associated with the label.
// Put the instruction on the backpatch list, associated with the label.
void
int
push_backpatch
(
sp_instr
*
,
struct
sp_label
*
);
push_backpatch
(
sp_instr
*
,
struct
sp_label
*
);
// Update all instruction with this label in the backpatch list to
// Update all instruction with this label in the backpatch list to
...
@@ -263,11 +263,11 @@ public:
...
@@ -263,11 +263,11 @@ public:
backpatch
(
struct
sp_label
*
);
backpatch
(
struct
sp_label
*
);
// Start a new cont. backpatch level. If 'i' is NULL, the level is just incr.
// Start a new cont. backpatch level. If 'i' is NULL, the level is just incr.
void
int
new_cont_backpatch
(
sp_instr_opt_meta
*
i
);
new_cont_backpatch
(
sp_instr_opt_meta
*
i
);
// Add an instruction to the current level
// Add an instruction to the current level
void
int
add_cont_backpatch
(
sp_instr_opt_meta
*
i
);
add_cont_backpatch
(
sp_instr_opt_meta
*
i
);
// Backpatch (and pop) the current level to the current position.
// Backpatch (and pop) the current level to the current position.
...
...
sql/sp_pcontext.cc
View file @
8dafd2b9
...
@@ -263,7 +263,8 @@ sp_pcontext::push_variable(LEX_STRING *name, enum enum_field_types type,
...
@@ -263,7 +263,8 @@ sp_pcontext::push_variable(LEX_STRING *name, enum enum_field_types type,
p
->
mode
=
mode
;
p
->
mode
=
mode
;
p
->
offset
=
current_var_count
();
p
->
offset
=
current_var_count
();
p
->
dflt
=
NULL
;
p
->
dflt
=
NULL
;
insert_dynamic
(
&
m_vars
,
(
gptr
)
&
p
);
if
(
insert_dynamic
(
&
m_vars
,
(
gptr
)
&
p
))
return
NULL
;
return
p
;
return
p
;
}
}
...
@@ -308,18 +309,17 @@ sp_pcontext::find_label(char *name)
...
@@ -308,18 +309,17 @@ sp_pcontext::find_label(char *name)
return
NULL
;
return
NULL
;
}
}
void
int
sp_pcontext
::
push_cond
(
LEX_STRING
*
name
,
sp_cond_type_t
*
val
)
sp_pcontext
::
push_cond
(
LEX_STRING
*
name
,
sp_cond_type_t
*
val
)
{
{
sp_cond_t
*
p
=
(
sp_cond_t
*
)
sql_alloc
(
sizeof
(
sp_cond_t
));
sp_cond_t
*
p
=
(
sp_cond_t
*
)
sql_alloc
(
sizeof
(
sp_cond_t
));
if
(
p
)
if
(
p
==
NULL
)
{
return
1
;
p
->
name
.
str
=
name
->
str
;
p
->
name
.
str
=
name
->
str
;
p
->
name
.
length
=
name
->
length
;
p
->
name
.
length
=
name
->
length
;
p
->
val
=
val
;
p
->
val
=
val
;
insert_dynamic
(
&
m_conds
,
(
gptr
)
&
p
);
return
insert_dynamic
(
&
m_conds
,
(
gptr
)
&
p
);
}
}
}
/*
/*
...
@@ -382,7 +382,7 @@ sp_pcontext::find_handler(sp_cond_type_t *cond)
...
@@ -382,7 +382,7 @@ sp_pcontext::find_handler(sp_cond_type_t *cond)
return
FALSE
;
return
FALSE
;
}
}
void
int
sp_pcontext
::
push_cursor
(
LEX_STRING
*
name
)
sp_pcontext
::
push_cursor
(
LEX_STRING
*
name
)
{
{
LEX_STRING
n
;
LEX_STRING
n
;
...
@@ -391,7 +391,7 @@ sp_pcontext::push_cursor(LEX_STRING *name)
...
@@ -391,7 +391,7 @@ sp_pcontext::push_cursor(LEX_STRING *name)
m_max_cursor_index
+=
1
;
m_max_cursor_index
+=
1
;
n
.
str
=
name
->
str
;
n
.
str
=
name
->
str
;
n
.
length
=
name
->
length
;
n
.
length
=
name
->
length
;
insert_dynamic
(
&
m_cursors
,
(
gptr
)
&
n
);
return
insert_dynamic
(
&
m_cursors
,
(
gptr
)
&
n
);
}
}
/*
/*
...
...
sql/sp_pcontext.h
View file @
8dafd2b9
...
@@ -323,7 +323,7 @@ public:
...
@@ -323,7 +323,7 @@ public:
// Conditions
// Conditions
//
//
void
int
push_cond
(
LEX_STRING
*
name
,
sp_cond_type_t
*
val
);
push_cond
(
LEX_STRING
*
name
,
sp_cond_type_t
*
val
);
inline
void
inline
void
...
@@ -365,7 +365,7 @@ public:
...
@@ -365,7 +365,7 @@ public:
// Cursors
// Cursors
//
//
void
int
push_cursor
(
LEX_STRING
*
name
);
push_cursor
(
LEX_STRING
*
name
);
my_bool
my_bool
...
...
sql/sql_select.cc
View file @
8dafd2b9
...
@@ -3371,10 +3371,6 @@ add_key_fields(JOIN *join, KEY_FIELD **key_fields, uint *and_level,
...
@@ -3371,10 +3371,6 @@ add_key_fields(JOIN *join, KEY_FIELD **key_fields, uint *and_level,
}
}
}
}
/*
Add all keys with uses 'field' for some keypart
If field->and_level != and_level then only mark key_part as const_part
*/
static
uint
static
uint
max_part_bit
(
key_part_map
bits
)
max_part_bit
(
key_part_map
bits
)
...
@@ -3384,7 +3380,16 @@ max_part_bit(key_part_map bits)
...
@@ -3384,7 +3380,16 @@ max_part_bit(key_part_map bits)
return
found
;
return
found
;
}
}
static
void
/*
Add all keys with uses 'field' for some keypart
If field->and_level != and_level then only mark key_part as const_part
RETURN
0 - OK
1 - Out of memory.
*/
static
bool
add_key_part
(
DYNAMIC_ARRAY
*
keyuse_array
,
KEY_FIELD
*
key_field
)
add_key_part
(
DYNAMIC_ARRAY
*
keyuse_array
,
KEY_FIELD
*
key_field
)
{
{
Field
*
field
=
key_field
->
field
;
Field
*
field
=
key_field
->
field
;
...
@@ -3414,24 +3419,26 @@ add_key_part(DYNAMIC_ARRAY *keyuse_array,KEY_FIELD *key_field)
...
@@ -3414,24 +3419,26 @@ add_key_part(DYNAMIC_ARRAY *keyuse_array,KEY_FIELD *key_field)
keyuse
.
optimize
=
key_field
->
optimize
&
KEY_OPTIMIZE_REF_OR_NULL
;
keyuse
.
optimize
=
key_field
->
optimize
&
KEY_OPTIMIZE_REF_OR_NULL
;
keyuse
.
null_rejecting
=
key_field
->
null_rejecting
;
keyuse
.
null_rejecting
=
key_field
->
null_rejecting
;
keyuse
.
cond_guard
=
key_field
->
cond_guard
;
keyuse
.
cond_guard
=
key_field
->
cond_guard
;
VOID
(
insert_dynamic
(
keyuse_array
,(
gptr
)
&
keyuse
));
if
(
insert_dynamic
(
keyuse_array
,(
gptr
)
&
keyuse
))
return
TRUE
;
}
}
}
}
}
}
}
}
return
FALSE
;
}
}
#define FT_KEYPART (MAX_REF_PARTS+10)
#define FT_KEYPART (MAX_REF_PARTS+10)
static
void
static
bool
add_ft_keys
(
DYNAMIC_ARRAY
*
keyuse_array
,
add_ft_keys
(
DYNAMIC_ARRAY
*
keyuse_array
,
JOIN_TAB
*
stat
,
COND
*
cond
,
table_map
usable_tables
)
JOIN_TAB
*
stat
,
COND
*
cond
,
table_map
usable_tables
)
{
{
Item_func_match
*
cond_func
=
NULL
;
Item_func_match
*
cond_func
=
NULL
;
if
(
!
cond
)
if
(
!
cond
)
return
;
return
FALSE
;
if
(
cond
->
type
()
==
Item
::
FUNC_ITEM
)
if
(
cond
->
type
()
==
Item
::
FUNC_ITEM
)
{
{
...
@@ -3465,13 +3472,16 @@ add_ft_keys(DYNAMIC_ARRAY *keyuse_array,
...
@@ -3465,13 +3472,16 @@ add_ft_keys(DYNAMIC_ARRAY *keyuse_array,
{
{
Item
*
item
;
Item
*
item
;
while
((
item
=
li
++
))
while
((
item
=
li
++
))
add_ft_keys
(
keyuse_array
,
stat
,
item
,
usable_tables
);
{
if
(
add_ft_keys
(
keyuse_array
,
stat
,
item
,
usable_tables
))
return
TRUE
;
}
}
}
}
}
if
(
!
cond_func
||
cond_func
->
key
==
NO_SUCH_KEY
||
if
(
!
cond_func
||
cond_func
->
key
==
NO_SUCH_KEY
||
!
(
usable_tables
&
cond_func
->
table
->
map
))
!
(
usable_tables
&
cond_func
->
table
->
map
))
return
;
return
FALSE
;
KEYUSE
keyuse
;
KEYUSE
keyuse
;
keyuse
.
table
=
cond_func
->
table
;
keyuse
.
table
=
cond_func
->
table
;
...
@@ -3481,7 +3491,7 @@ add_ft_keys(DYNAMIC_ARRAY *keyuse_array,
...
@@ -3481,7 +3491,7 @@ add_ft_keys(DYNAMIC_ARRAY *keyuse_array,
keyuse
.
used_tables
=
cond_func
->
key_item
()
->
used_tables
();
keyuse
.
used_tables
=
cond_func
->
key_item
()
->
used_tables
();
keyuse
.
optimize
=
0
;
keyuse
.
optimize
=
0
;
keyuse
.
keypart_map
=
0
;
keyuse
.
keypart_map
=
0
;
VOID
(
insert_dynamic
(
keyuse_array
,(
gptr
)
&
keyuse
)
);
return
insert_dynamic
(
keyuse_array
,(
gptr
)
&
keyuse
);
}
}
...
@@ -3631,7 +3641,8 @@ update_ref_and_keys(THD *thd, DYNAMIC_ARRAY *keyuse,JOIN_TAB *join_tab,
...
@@ -3631,7 +3641,8 @@ update_ref_and_keys(THD *thd, DYNAMIC_ARRAY *keyuse,JOIN_TAB *join_tab,
sargables
);
sargables
);
for
(;
field
!=
end
;
field
++
)
for
(;
field
!=
end
;
field
++
)
{
{
add_key_part
(
keyuse
,
field
);
if
(
add_key_part
(
keyuse
,
field
))
return
TRUE
;
/* Mark that we can optimize LEFT JOIN */
/* Mark that we can optimize LEFT JOIN */
if
(
field
->
val
->
type
()
==
Item
::
NULL_ITEM
&&
if
(
field
->
val
->
type
()
==
Item
::
NULL_ITEM
&&
!
field
->
field
->
real_maybe_null
())
!
field
->
field
->
real_maybe_null
())
...
@@ -3669,11 +3680,15 @@ update_ref_and_keys(THD *thd, DYNAMIC_ARRAY *keyuse,JOIN_TAB *join_tab,
...
@@ -3669,11 +3680,15 @@ update_ref_and_keys(THD *thd, DYNAMIC_ARRAY *keyuse,JOIN_TAB *join_tab,
/* fill keyuse with found key parts */
/* fill keyuse with found key parts */
for
(
;
field
!=
end
;
field
++
)
for
(
;
field
!=
end
;
field
++
)
add_key_part
(
keyuse
,
field
);
{
if
(
add_key_part
(
keyuse
,
field
))
return
TRUE
;
}
if
(
select_lex
->
ftfunc_list
->
elements
)
if
(
select_lex
->
ftfunc_list
->
elements
)
{
{
add_ft_keys
(
keyuse
,
join_tab
,
cond
,
normal_tables
);
if
(
add_ft_keys
(
keyuse
,
join_tab
,
cond
,
normal_tables
))
return
TRUE
;
}
}
/*
/*
...
@@ -3694,7 +3709,8 @@ update_ref_and_keys(THD *thd, DYNAMIC_ARRAY *keyuse,JOIN_TAB *join_tab,
...
@@ -3694,7 +3709,8 @@ update_ref_and_keys(THD *thd, DYNAMIC_ARRAY *keyuse,JOIN_TAB *join_tab,
(
qsort_cmp
)
sort_keyuse
);
(
qsort_cmp
)
sort_keyuse
);
bzero
((
char
*
)
&
key_end
,
sizeof
(
key_end
));
/* Add for easy testing */
bzero
((
char
*
)
&
key_end
,
sizeof
(
key_end
));
/* Add for easy testing */
VOID
(
insert_dynamic
(
keyuse
,(
gptr
)
&
key_end
));
if
(
insert_dynamic
(
keyuse
,(
gptr
)
&
key_end
))
return
TRUE
;
use
=
save_pos
=
dynamic_element
(
keyuse
,
0
,
KEYUSE
*
);
use
=
save_pos
=
dynamic_element
(
keyuse
,
0
,
KEYUSE
*
);
prev
=
&
key_end
;
prev
=
&
key_end
;
...
...
sql/sql_yacc.yy
View file @
8dafd2b9
...
@@ -234,9 +234,7 @@ int case_stmt_action_expr(LEX *lex, Item* expr)
...
@@ -234,9 +234,7 @@ int case_stmt_action_expr(LEX *lex, Item* expr)
parsing_ctx, case_expr_id, expr, lex);
parsing_ctx, case_expr_id, expr, lex);
sp->add_cont_backpatch(i);
sp->add_cont_backpatch(i);
sp->add_instr(i);
return sp->add_instr(i);
return 0;
}
}
/**
/**
...
@@ -247,7 +245,7 @@ int case_stmt_action_expr(LEX *lex, Item* expr)
...
@@ -247,7 +245,7 @@ int case_stmt_action_expr(LEX *lex, Item* expr)
@param simple true for simple cases, false for searched cases
@param simple true for simple cases, false for searched cases
*/
*/
void
case_stmt_action_when(LEX *lex, Item *when, bool simple)
int
case_stmt_action_when(LEX *lex, Item *when, bool simple)
{
{
sp_head *sp= lex->sphead;
sp_head *sp= lex->sphead;
sp_pcontext *ctx= lex->spcont;
sp_pcontext *ctx= lex->spcont;
...
@@ -279,8 +277,9 @@ void case_stmt_action_when(LEX *lex, Item *when, bool simple)
...
@@ -279,8 +277,9 @@ void case_stmt_action_when(LEX *lex, Item *when, bool simple)
(jump_if_not from instruction 2 to 5, 5 to 8 ... in the example)
(jump_if_not from instruction 2 to 5, 5 to 8 ... in the example)
*/
*/
sp->push_backpatch(i, ctx->push_label((char *)"", 0));
return !test(i) ||
sp->add_cont_backpatch(i);
sp->push_backpatch(i, ctx->push_label((char *)"", 0)) ||
sp->add_cont_backpatch(i) ||
sp->add_instr(i);
sp->add_instr(i);
}
}
...
@@ -290,13 +289,14 @@ void case_stmt_action_when(LEX *lex, Item *when, bool simple)
...
@@ -290,13 +289,14 @@ void case_stmt_action_when(LEX *lex, Item *when, bool simple)
@param lex the parser lex context
@param lex the parser lex context
*/
*/
void
case_stmt_action_then(LEX *lex)
int
case_stmt_action_then(LEX *lex)
{
{
sp_head *sp= lex->sphead;
sp_head *sp= lex->sphead;
sp_pcontext *ctx= lex->spcont;
sp_pcontext *ctx= lex->spcont;
uint ip= sp->instructions();
uint ip= sp->instructions();
sp_instr_jump *i = new sp_instr_jump(ip, ctx);
sp_instr_jump *i = new sp_instr_jump(ip, ctx);
sp->add_instr(i);
if (!test(i) || sp->add_instr(i))
return 1;
/*
/*
BACKPATCH: Resolving forward jump from
BACKPATCH: Resolving forward jump from
...
@@ -312,7 +312,7 @@ void case_stmt_action_then(LEX *lex)
...
@@ -312,7 +312,7 @@ void case_stmt_action_then(LEX *lex)
(jump from instruction 4 to 12, 7 to 12 ... in the example)
(jump from instruction 4 to 12, 7 to 12 ... in the example)
*/
*/
sp->push_backpatch(i, ctx->last_label());
return
sp->push_backpatch(i, ctx->last_label());
}
}
/**
/**
...
@@ -1905,10 +1905,9 @@ sp_decl:
...
@@ -1905,10 +1905,9 @@ sp_decl:
var_type,
var_type,
lex,
lex,
(i == num_vars - 1));
(i == num_vars - 1));
if (is == NULL)
if (is == NULL ||
lex->sphead->add_instr(is))
MYSQL_YYABORT;
MYSQL_YYABORT;
lex->sphead->add_instr(is);
}
}
pctx->declare_var_boundary(0);
pctx->declare_var_boundary(0);
...
@@ -1927,7 +1926,8 @@ sp_decl:
...
@@ -1927,7 +1926,8 @@ sp_decl:
my_error(ER_SP_DUP_COND, MYF(0), $2.str);
my_error(ER_SP_DUP_COND, MYF(0), $2.str);
MYSQL_YYABORT;
MYSQL_YYABORT;
}
}
YYTHD->lex->spcont->push_cond(&$2, $5);
if(YYTHD->lex->spcont->push_cond(&$2, $5))
MYSQL_YYABORT;
$$.vars= $$.hndlrs= $$.curs= 0;
$$.vars= $$.hndlrs= $$.curs= 0;
$$.conds= 1;
$$.conds= 1;
}
}
...
@@ -1942,10 +1942,10 @@ sp_decl:
...
@@ -1942,10 +1942,10 @@ sp_decl:
sp_instr_hpush_jump *i=
sp_instr_hpush_jump *i=
new sp_instr_hpush_jump(sp->instructions(), ctx, $2,
new sp_instr_hpush_jump(sp->instructions(), ctx, $2,
ctx->current_var_count());
ctx->current_var_count());
if (i == NULL)
if (i == NULL ||
sp->add_instr(i))
MYSQL_YYABORT;
MYSQL_YYABORT;
sp->add_instr(i);
sp->push_backpatch(i, ctx->push_label((char *)"", 0));
sp->push_backpatch(i, ctx->push_label((char *)"", 0));
}
}
sp_hcond_list sp_proc_stmt
sp_hcond_list sp_proc_stmt
...
@@ -1960,17 +1960,17 @@ sp_decl:
...
@@ -1960,17 +1960,17 @@ sp_decl:
{
{
i= new sp_instr_hreturn(sp->instructions(), ctx,
i= new sp_instr_hreturn(sp->instructions(), ctx,
ctx->current_var_count());
ctx->current_var_count());
if (i == NULL )
if (i == NULL ||
sp->add_instr(i))
MYSQL_YYABORT;
MYSQL_YYABORT;
sp->add_instr(i);
}
}
else
else
{ /* EXIT or UNDO handler, just jump to the end of the block */
{ /* EXIT or UNDO handler, just jump to the end of the block */
i= new sp_instr_hreturn(sp->instructions(), ctx, 0);
i= new sp_instr_hreturn(sp->instructions(), ctx, 0);
if (i == NULL)
if (i == NULL ||
sp->add_instr(i) ||
sp->push_backpatch(i, lex->spcont->last_label())) /* Block end */
MYSQL_YYABORT;
MYSQL_YYABORT;
sp->add_instr(i);
sp->push_backpatch(i, lex->spcont->last_label()); /* Block end */
}
}
lex->sphead->backpatch(hlab);
lex->sphead->backpatch(hlab);
...
@@ -1996,10 +1996,10 @@ sp_decl:
...
@@ -1996,10 +1996,10 @@ sp_decl:
}
}
i= new sp_instr_cpush(sp->instructions(), ctx, $5,
i= new sp_instr_cpush(sp->instructions(), ctx, $5,
ctx->current_cursor_count());
ctx->current_cursor_count());
if (i == NULL)
if (i == NULL ||
sp->add_instr(i) ||
ctx->push_cursor(&$2))
MYSQL_YYABORT;
MYSQL_YYABORT;
sp->add_instr(i);
ctx->push_cursor(&$2);
$$.vars= $$.conds= $$.hndlrs= 0;
$$.vars= $$.conds= $$.hndlrs= 0;
$$.curs= 1;
$$.curs= 1;
}
}
...
@@ -2223,10 +2223,11 @@ sp_proc_stmt:
...
@@ -2223,10 +2223,11 @@ sp_proc_stmt:
i->m_query.length= lip->ptr - sp->m_tmp_query;
i->m_query.length= lip->ptr - sp->m_tmp_query;
else
else
i->m_query.length= lip->tok_end - sp->m_tmp_query;
i->m_query.length= lip->tok_end - sp->m_tmp_query;
i->m_query.str= strmake_root(thd->mem_root,
i
f (!(i
->m_query.str= strmake_root(thd->mem_root,
sp->m_tmp_query,
sp->m_tmp_query,
i->m_query.length);
i->m_query.length)) ||
sp->add_instr(i);
sp->add_instr(i))
MYSQL_YYABORT;
}
}
sp->restore_lex(thd);
sp->restore_lex(thd);
}
}
...
@@ -2251,9 +2252,9 @@ sp_proc_stmt:
...
@@ -2251,9 +2252,9 @@ sp_proc_stmt:
i= new sp_instr_freturn(sp->instructions(), lex->spcont, $3,
i= new sp_instr_freturn(sp->instructions(), lex->spcont, $3,
sp->m_return_field_def.sql_type, lex);
sp->m_return_field_def.sql_type, lex);
if (i == NULL)
if (i == NULL ||
sp->add_instr(i))
MYSQL_YYABORT;
MYSQL_YYABORT;
sp->add_instr(i);
sp->m_flags|= sp_head::HAS_RETURN;
sp->m_flags|= sp_head::HAS_RETURN;
}
}
sp->restore_lex(YYTHD);
sp->restore_lex(YYTHD);
...
@@ -2311,23 +2312,23 @@ sp_proc_stmt:
...
@@ -2311,23 +2312,23 @@ sp_proc_stmt:
if (n)
if (n)
{
{
sp_instr_hpop *hpop= new sp_instr_hpop(ip++, ctx, n);
sp_instr_hpop *hpop= new sp_instr_hpop(ip++, ctx, n);
if (hpop == NULL)
if (hpop == NULL ||
sp->add_instr(hpop))
MYSQL_YYABORT;
MYSQL_YYABORT;
sp->add_instr(hpop);
}
}
n= ctx->diff_cursors(lab->ctx, exclusive);
n= ctx->diff_cursors(lab->ctx, exclusive);
if (n)
if (n)
{
{
sp_instr_cpop *cpop= new sp_instr_cpop(ip++, ctx, n);
sp_instr_cpop *cpop= new sp_instr_cpop(ip++, ctx, n);
if (cpop == NULL)
if (cpop == NULL ||
sp->add_instr(cpop))
MYSQL_YYABORT;
MYSQL_YYABORT;
sp->add_instr(cpop);
}
}
i= new sp_instr_jump(ip, ctx);
i= new sp_instr_jump(ip, ctx);
if (i == NULL)
if (i == NULL ||
sp->push_backpatch(i, lab) || /* Jumping forward */
sp->add_instr(i))
MYSQL_YYABORT;
MYSQL_YYABORT;
sp->push_backpatch(i, lab); /* Jumping forward */
sp->add_instr(i);
}
}
}
}
| ITERATE_SYM label_ident
| ITERATE_SYM label_ident
...
@@ -2352,22 +2353,22 @@ sp_proc_stmt:
...
@@ -2352,22 +2353,22 @@ sp_proc_stmt:
if (n)
if (n)
{
{
sp_instr_hpop *hpop= new sp_instr_hpop(ip++, ctx, n);
sp_instr_hpop *hpop= new sp_instr_hpop(ip++, ctx, n);
if (hpop == NULL)
if (hpop == NULL ||
sp->add_instr(hpop))
MYSQL_YYABORT;
MYSQL_YYABORT;
sp->add_instr(hpop);
}
}
n= ctx->diff_cursors(lab->ctx, FALSE); /* Inclusive the dest. */
n= ctx->diff_cursors(lab->ctx, FALSE); /* Inclusive the dest. */
if (n)
if (n)
{
{
sp_instr_cpop *cpop= new sp_instr_cpop(ip++, ctx, n);
sp_instr_cpop *cpop= new sp_instr_cpop(ip++, ctx, n);
if (cpop == NULL)
if (cpop == NULL ||
sp->add_instr(cpop))
MYSQL_YYABORT;
MYSQL_YYABORT;
sp->add_instr(cpop);
}
}
i= new sp_instr_jump(ip, ctx, lab->ip); /* Jump back */
i= new sp_instr_jump(ip, ctx, lab->ip); /* Jump back */
if (i == NULL)
if (i == NULL ||
sp->add_instr(i))
MYSQL_YYABORT;
MYSQL_YYABORT;
sp->add_instr(i);
}
}
}
}
| OPEN_SYM ident
| OPEN_SYM ident
...
@@ -2383,9 +2384,9 @@ sp_proc_stmt:
...
@@ -2383,9 +2384,9 @@ sp_proc_stmt:
MYSQL_YYABORT;
MYSQL_YYABORT;
}
}
i= new sp_instr_copen(sp->instructions(), lex->spcont, offset);
i= new sp_instr_copen(sp->instructions(), lex->spcont, offset);
if (i == NULL)
if (i == NULL ||
sp->add_instr(i))
MYSQL_YYABORT;
MYSQL_YYABORT;
sp->add_instr(i);
}
}
| FETCH_SYM sp_opt_fetch_noise ident INTO
| FETCH_SYM sp_opt_fetch_noise ident INTO
{
{
...
@@ -2400,9 +2401,9 @@ sp_proc_stmt:
...
@@ -2400,9 +2401,9 @@ sp_proc_stmt:
MYSQL_YYABORT;
MYSQL_YYABORT;
}
}
i= new sp_instr_cfetch(sp->instructions(), lex->spcont, offset);
i= new sp_instr_cfetch(sp->instructions(), lex->spcont, offset);
if (i == NULL)
if (i == NULL ||
sp->add_instr(i))
MYSQL_YYABORT;
MYSQL_YYABORT;
sp->add_instr(i);
}
}
sp_fetch_list
sp_fetch_list
{ }
{ }
...
@@ -2419,9 +2420,9 @@ sp_proc_stmt:
...
@@ -2419,9 +2420,9 @@ sp_proc_stmt:
MYSQL_YYABORT;
MYSQL_YYABORT;
}
}
i= new sp_instr_cclose(sp->instructions(), lex->spcont, offset);
i= new sp_instr_cclose(sp->instructions(), lex->spcont, offset);
if (i == NULL)
if (i == NULL ||
sp->add_instr(i))
MYSQL_YYABORT;
MYSQL_YYABORT;
sp->add_instr(i);
}
}
;
;
...
@@ -2488,11 +2489,11 @@ sp_if:
...
@@ -2488,11 +2489,11 @@ sp_if:
uint ip= sp->instructions();
uint ip= sp->instructions();
sp_instr_jump_if_not *i = new sp_instr_jump_if_not(ip, ctx,
sp_instr_jump_if_not *i = new sp_instr_jump_if_not(ip, ctx,
$2, lex);
$2, lex);
if (i == NULL)
if (i == NULL ||
sp->push_backpatch(i, ctx->push_label((char *)"", 0)) ||
sp->add_cont_backpatch(i) ||
sp->add_instr(i))
MYSQL_YYABORT;
MYSQL_YYABORT;
sp->push_backpatch(i, ctx->push_label((char *)"", 0));
sp->add_cont_backpatch(i);
sp->add_instr(i);
sp->restore_lex(YYTHD);
sp->restore_lex(YYTHD);
}
}
sp_proc_stmts1
sp_proc_stmts1
...
@@ -2501,9 +2502,9 @@ sp_if:
...
@@ -2501,9 +2502,9 @@ sp_if:
sp_pcontext *ctx= Lex->spcont;
sp_pcontext *ctx= Lex->spcont;
uint ip= sp->instructions();
uint ip= sp->instructions();
sp_instr_jump *i = new sp_instr_jump(ip, ctx);
sp_instr_jump *i = new sp_instr_jump(ip, ctx);
if (i == NULL)
if (i == NULL ||
sp->add_instr(i))
MYSQL_YYABORT;
MYSQL_YYABORT;
sp->add_instr(i);
sp->backpatch(ctx->pop_label());
sp->backpatch(ctx->pop_label());
sp->push_backpatch(i, ctx->push_label((char *)"", 0));
sp->push_backpatch(i, ctx->push_label((char *)"", 0));
}
}
...
@@ -2589,14 +2590,16 @@ simple_when_clause:
...
@@ -2589,14 +2590,16 @@ simple_when_clause:
/* Simple case: <caseval> = <whenval> */
/* Simple case: <caseval> = <whenval> */
LEX *lex= Lex;
LEX *lex= Lex;
case_stmt_action_when(lex, $3, true);
if (case_stmt_action_when(lex, $3, true))
MYSQL_YYABORT;
lex->sphead->restore_lex(YYTHD); /* For expr $3 */
lex->sphead->restore_lex(YYTHD); /* For expr $3 */
}
}
THEN_SYM
THEN_SYM
sp_proc_stmts1
sp_proc_stmts1
{
{
LEX *lex= Lex;
LEX *lex= Lex;
case_stmt_action_then(lex);
if (case_stmt_action_then(lex))
MYSQL_YYABORT;
}
}
;
;
...
@@ -2609,14 +2612,16 @@ searched_when_clause:
...
@@ -2609,14 +2612,16 @@ searched_when_clause:
expr
expr
{
{
LEX *lex= Lex;
LEX *lex= Lex;
case_stmt_action_when(lex, $3, false);
if (case_stmt_action_when(lex, $3, false))
MYSQL_YYABORT;
lex->sphead->restore_lex(YYTHD); /* For expr $3 */
lex->sphead->restore_lex(YYTHD); /* For expr $3 */
}
}
THEN_SYM
THEN_SYM
sp_proc_stmts1
sp_proc_stmts1
{
{
LEX *lex= Lex;
LEX *lex= Lex;
case_stmt_action_then(lex);
if (case_stmt_action_then(lex))
MYSQL_YYABORT;
}
}
;
;
...
@@ -2628,9 +2633,9 @@ else_clause_opt:
...
@@ -2628,9 +2633,9 @@ else_clause_opt:
uint ip= sp->instructions();
uint ip= sp->instructions();
sp_instr_error *i= new sp_instr_error(ip, lex->spcont,
sp_instr_error *i= new sp_instr_error(ip, lex->spcont,
ER_SP_CASE_NOT_FOUND);
ER_SP_CASE_NOT_FOUND);
if (i == NULL)
if (i == NULL ||
sp->add_instr(i))
MYSQL_YYABORT;
MYSQL_YYABORT;
sp->add_instr(i);
}
}
| ELSE sp_proc_stmts1
| ELSE sp_proc_stmts1
;
;
...
@@ -2744,17 +2749,17 @@ sp_block_content:
...
@@ -2744,17 +2749,17 @@ sp_block_content:
{
{
sp_instr_hpop *hpop= new sp_instr_hpop(sp->instructions(), ctx,
sp_instr_hpop *hpop= new sp_instr_hpop(sp->instructions(), ctx,
$3.hndlrs);
$3.hndlrs);
if (hpop == NULL)
if (hpop == NULL ||
sp->add_instr(hpop))
MYSQL_YYABORT;
MYSQL_YYABORT;
sp->add_instr(hpop);
}
}
if ($3.curs)
if ($3.curs)
{
{
sp_instr_cpop *cpop= new sp_instr_cpop(sp->instructions(), ctx,
sp_instr_cpop *cpop= new sp_instr_cpop(sp->instructions(), ctx,
$3.curs);
$3.curs);
if (cpop == NULL)
if (cpop == NULL ||
sp->add_instr(cpop))
MYSQL_YYABORT;
MYSQL_YYABORT;
sp->add_instr(cpop);
}
}
lex->spcont= ctx->pop_context();
lex->spcont= ctx->pop_context();
}
}
...
@@ -2768,9 +2773,9 @@ sp_unlabeled_control:
...
@@ -2768,9 +2773,9 @@ sp_unlabeled_control:
uint ip= lex->sphead->instructions();
uint ip= lex->sphead->instructions();
sp_label_t *lab= lex->spcont->last_label(); /* Jumping back */
sp_label_t *lab= lex->spcont->last_label(); /* Jumping back */
sp_instr_jump *i = new sp_instr_jump(ip, lex->spcont, lab->ip);
sp_instr_jump *i = new sp_instr_jump(ip, lex->spcont, lab->ip);
if (i == NULL)
if (i == NULL ||
lex->sphead->add_instr(i))
MYSQL_YYABORT;
MYSQL_YYABORT;
lex->sphead->add_instr(i);
}
}
| WHILE_SYM
| WHILE_SYM
{
{
...
@@ -2784,12 +2789,12 @@ sp_unlabeled_control:
...
@@ -2784,12 +2789,12 @@ sp_unlabeled_control:
uint ip= sp->instructions();
uint ip= sp->instructions();
sp_instr_jump_if_not *i = new sp_instr_jump_if_not(ip, lex->spcont,
sp_instr_jump_if_not *i = new sp_instr_jump_if_not(ip, lex->spcont,
$3, lex);
$3, lex);
if (i == NULL)
if (i == NULL ||
MYSQL_YYABORT;
/* Jumping forward */
/* Jumping forward */
sp->push_backpatch(i, lex->spcont->last_label());
sp->push_backpatch(i, lex->spcont->last_label()) ||
sp->new_cont_backpatch(i);
sp->new_cont_backpatch(i) ||
sp->add_instr(i);
sp->add_instr(i))
MYSQL_YYABORT;
sp->restore_lex(YYTHD);
sp->restore_lex(YYTHD);
}
}
sp_proc_stmts1 END WHILE_SYM
sp_proc_stmts1 END WHILE_SYM
...
@@ -2798,9 +2803,9 @@ sp_unlabeled_control:
...
@@ -2798,9 +2803,9 @@ sp_unlabeled_control:
uint ip= lex->sphead->instructions();
uint ip= lex->sphead->instructions();
sp_label_t *lab= lex->spcont->last_label(); /* Jumping back */
sp_label_t *lab= lex->spcont->last_label(); /* Jumping back */
sp_instr_jump *i = new sp_instr_jump(ip, lex->spcont, lab->ip);
sp_instr_jump *i = new sp_instr_jump(ip, lex->spcont, lab->ip);
if (i == NULL)
if (i == NULL ||
lex->sphead->add_instr(i))
MYSQL_YYABORT;
MYSQL_YYABORT;
lex->sphead->add_instr(i);
lex->sphead->do_cont_backpatch();
lex->sphead->do_cont_backpatch();
}
}
| REPEAT_SYM sp_proc_stmts1 UNTIL_SYM
| REPEAT_SYM sp_proc_stmts1 UNTIL_SYM
...
@@ -2816,9 +2821,9 @@ sp_unlabeled_control:
...
@@ -2816,9 +2821,9 @@ sp_unlabeled_control:
sp_instr_jump_if_not *i = new sp_instr_jump_if_not(ip, lex->spcont,
sp_instr_jump_if_not *i = new sp_instr_jump_if_not(ip, lex->spcont,
$5, lab->ip,
$5, lab->ip,
lex);
lex);
if (i == NULL)
if (i == NULL ||
lex->sphead->add_instr(i))
MYSQL_YYABORT;
MYSQL_YYABORT;
lex->sphead->add_instr(i);
lex->sphead->restore_lex(YYTHD);
lex->sphead->restore_lex(YYTHD);
/* We can shortcut the cont_backpatch here */
/* We can shortcut the cont_backpatch here */
i->m_cont_dest= ip+1;
i->m_cont_dest= ip+1;
...
@@ -9649,7 +9654,8 @@ option_type_value:
...
@@ -9649,7 +9654,8 @@ option_type_value:
qbuff.length);
qbuff.length);
qbuff.length+= 4;
qbuff.length+= 4;
i->m_query= qbuff;
i->m_query= qbuff;
sp->add_instr(i);
if (sp->add_instr(i))
MYSQL_YYABORT;
}
}
lex->sphead->restore_lex(thd);
lex->sphead->restore_lex(thd);
}
}
...
@@ -9731,7 +9737,8 @@ sys_option_value:
...
@@ -9731,7 +9737,8 @@ sys_option_value:
lex->trg_table_fields.link_in_list((byte *)trg_fld,
lex->trg_table_fields.link_in_list((byte *)trg_fld,
(byte **)&trg_fld->next_trg_field);
(byte **)&trg_fld->next_trg_field);
lex->sphead->add_instr(sp_fld);
if (lex->sphead->add_instr(sp_fld))
MYSQL_YYABORT;
}
}
else if ($2.var)
else if ($2.var)
{ /* System variable */
{ /* System variable */
...
@@ -9761,11 +9768,12 @@ sys_option_value:
...
@@ -9761,11 +9768,12 @@ sys_option_value:
it= spv->dflt;
it= spv->dflt;
else
else
it= new Item_null();
it= new Item_null();
if (it == NULL)
if (it == NULL ||
(sp_set= new sp_instr_set(lex->sphead->instructions(), ctx,
spv->offset, it, spv->type, lex,
TRUE)) == NULL ||
lex->sphead->add_instr(sp_set))
MYSQL_YYABORT;
MYSQL_YYABORT;
sp_set= new sp_instr_set(lex->sphead->instructions(), ctx,
spv->offset, it, spv->type, lex, TRUE);
lex->sphead->add_instr(sp_set);
}
}
}
}
| option_type TRANSACTION_SYM ISOLATION LEVEL_SYM isolation_types
| option_type TRANSACTION_SYM ISOLATION LEVEL_SYM isolation_types
...
...
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