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
204aa972
Commit
204aa972
authored
Dec 19, 2002
by
pem@mysql.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed some of the data collection during parsing.
parent
58d3dda3
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
17 deletions
+43
-17
sql/sp_head.cc
sql/sp_head.cc
+40
-16
sql/sp_head.h
sql/sp_head.h
+3
-1
No files found.
sql/sp_head.cc
View file @
204aa972
...
...
@@ -88,7 +88,7 @@ sp_head::sp_head(LEX_STRING *name, LEX *lex)
{
const
char
*
dstr
=
(
const
char
*
)
lex
->
buf
;
m_
my
lex
=
lex
;
m_
call_
lex
=
lex
;
m_name
=
new
Item_string
(
name
->
str
,
name
->
length
,
default_charset_info
);
m_defstr
=
new
Item_string
(
dstr
,
lex
->
end_of_query
-
lex
->
buf
,
default_charset_info
);
...
...
@@ -112,7 +112,7 @@ sp_head::execute(THD *thd)
{
int
ret
=
0
;
sp_instr
*
p
;
sp_pcontext
*
pctx
=
m_
my
lex
->
spcont
;
sp_pcontext
*
pctx
=
m_
call_
lex
->
spcont
;
uint
csize
=
pctx
->
max_framesize
();
uint
params
=
pctx
->
params
();
sp_rcontext
*
octx
=
thd
->
spcont
;
...
...
@@ -121,7 +121,7 @@ sp_head::execute(THD *thd)
if
(
csize
>
0
)
{
uint
i
;
List_iterator_fast
<
Item
>
li
(
m_
my
lex
->
value_list
);
List_iterator_fast
<
Item
>
li
(
m_
call_
lex
->
value_list
);
Item
*
it
=
li
++
;
// Skip first one, it's the procedure name
nctx
=
new
sp_rcontext
(
csize
);
...
...
@@ -235,27 +235,51 @@ sp_head::restore_lex(THD *thd)
// Update some state in the old one first
m_lex
.
ptr
=
thd
->
lex
.
ptr
;
m_lex
.
next_state
=
thd
->
lex
.
next_state
;
// Collect some data from the sub statement lex.
// We reuse some lists in lex instead of adding new ones to this already
// quite large structure.
// CALL puts the proc. name and parameters in value_list, so we might as
// collect called procedures there.
// Collect some data from the sub statement lex.
if
(
thd
->
lex
.
sql_command
==
SQLCOM_CALL
)
{
// Assuming we will rarely have more than, say, 10 calls to other
// procedures, this is probably fastest.
Item
*
proc
=
thd
->
lex
.
value_list
.
head
();
List_iterator_fast
<
Item
>
li
(
m_lex
.
value_list
);
Item
*
it
;
// We know they are Item_strings (since we put them there ourselves)
// It would be slightly faster to keep the list sorted, but we need
// an "insert before" method to do that.
Item_string
*
proc
=
static_cast
<
Item_string
*>
(
thd
->
lex
.
value_list
.
head
());
String
*
snew
=
proc
->
val_str
(
NULL
);
List_iterator_fast
<
Item_string
>
li
(
m_calls
);
Item_string
*
it
;
while
((
it
=
li
++
))
if
(
proc
->
eq
(
it
,
FALSE
))
{
String
*
sold
=
it
->
val_str
(
NULL
);
if
(
stringcmp
(
snew
,
sold
)
==
0
)
break
;
}
if
(
!
it
)
m_lex
.
value_list
.
push_back
(
proc
);
// Got a new one.
m_calls
.
push_back
(
proc
);
}
// Merge used tables
// QQ ...or just open tables in thd->open_tables?
// This is not entirerly clear at the moment, but for now, we collect
// tables here.
for
(
SELECT_LEX
*
sl
=
thd
->
lex
.
all_selects_list
;
sl
;
sl
=
sl
->
next_select
())
{
for
(
TABLE_LIST
*
tables
=
sl
->
get_table_list
()
;
tables
;
tables
=
tables
->
next
)
{
List_iterator_fast
<
char
*>
li
(
m_tables
);
char
**
tb
;
while
((
tb
=
li
++
))
if
(
strcasecmp
(
tables
->
real_name
,
*
tb
)
==
0
)
break
;
if
(
!
tb
)
m_tables
.
push_back
(
&
tables
->
real_name
);
}
}
// QQ Copy select_lex.table_list.
memcpy
(
&
thd
->
lex
,
&
m_lex
,
sizeof
(
LEX
));
// Restore lex
}
...
...
sql/sp_head.h
View file @
204aa972
...
...
@@ -36,6 +36,8 @@ class sp_head : public Sql_alloc
public:
my_bool
m_simple_case
;
// TRUE if parsing simple case, FALSE otherwise
List
<
Item_string
>
m_calls
;
// Called procedures.
List
<
char
*>
m_tables
;
// Used tables.
static
void
*
operator
new
(
size_t
size
)
{
...
...
@@ -89,7 +91,7 @@ private:
Item_string
*
m_name
;
Item_string
*
m_defstr
;
LEX
*
m_
mylex
;
// My
own lex
LEX
*
m_
call_lex
;
// The CALL's
own lex
LEX
m_lex
;
// Temp. store for the other lex
DYNAMIC_ARRAY
m_instr
;
// The "instructions"
typedef
struct
...
...
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