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
962d2df6
Commit
962d2df6
authored
Nov 22, 2005
by
pem@mysql.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Some final cleanup of the sp_instr print methods.
parent
4513ffd1
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
23 deletions
+42
-23
sql/sp_head.cc
sql/sp_head.cc
+42
-23
No files found.
sql/sp_head.cc
View file @
962d2df6
...
@@ -2048,14 +2048,19 @@ sp_instr_stmt::execute(THD *thd, uint *nextp)
...
@@ -2048,14 +2048,19 @@ sp_instr_stmt::execute(THD *thd, uint *nextp)
DBUG_RETURN
(
res
);
DBUG_RETURN
(
res
);
}
}
#define STMT_PRINT_MAXLEN 40
/*
Sufficient max length of printed destinations and frame offsets (all uints).
*/
#define SP_INSTR_UINT_MAXLEN 8
#define SP_STMT_PRINT_MAXLEN 40
void
void
sp_instr_stmt
::
print
(
String
*
str
)
sp_instr_stmt
::
print
(
String
*
str
)
{
{
uint
i
,
len
;
uint
i
,
len
;
/*
Reserve enough space for 'stmt CMD "..."'; max+20 is more than enough.
*/
/*
stmt CMD "..."
*/
if
(
str
->
reserve
(
S
TMT_PRINT_MAXLEN
+
20
))
if
(
str
->
reserve
(
S
P_STMT_PRINT_MAXLEN
+
SP_INSTR_UINT_MAXLEN
+
8
))
return
;
return
;
str
->
qs_append
(
"stmt "
,
5
);
str
->
qs_append
(
"stmt "
,
5
);
str
->
qs_append
((
uint
)
m_lex_keeper
.
sql_command
());
str
->
qs_append
((
uint
)
m_lex_keeper
.
sql_command
());
...
@@ -2065,8 +2070,8 @@ sp_instr_stmt::print(String *str)
...
@@ -2065,8 +2070,8 @@ sp_instr_stmt::print(String *str)
Print the query string (but not too much of it), just to indicate which
Print the query string (but not too much of it), just to indicate which
statement it is.
statement it is.
*/
*/
if
(
len
>
STMT_PRINT_MAXLEN
)
if
(
len
>
S
P_S
TMT_PRINT_MAXLEN
)
len
=
STMT_PRINT_MAXLEN
-
3
;
len
=
S
P_S
TMT_PRINT_MAXLEN
-
3
;
/* Copy the query string and replace '\n' with ' ' in the process */
/* Copy the query string and replace '\n' with ' ' in the process */
for
(
i
=
0
;
i
<
len
;
i
++
)
for
(
i
=
0
;
i
<
len
;
i
++
)
{
{
...
@@ -2075,11 +2080,11 @@ sp_instr_stmt::print(String *str)
...
@@ -2075,11 +2080,11 @@ sp_instr_stmt::print(String *str)
else
else
str
->
qs_append
(
m_query
.
str
[
i
]);
str
->
qs_append
(
m_query
.
str
[
i
]);
}
}
if
(
m_query
.
length
>
STMT_PRINT_MAXLEN
)
if
(
m_query
.
length
>
S
P_S
TMT_PRINT_MAXLEN
)
str
->
qs_append
(
"..."
,
3
);
/* Indicate truncated string */
str
->
qs_append
(
"..."
,
3
);
/* Indicate truncated string */
str
->
qs_append
(
'"'
);
str
->
qs_append
(
'"'
);
}
}
#undef STMT_PRINT_MAXLEN
#undef S
P_S
TMT_PRINT_MAXLEN
int
int
sp_instr_stmt
::
exec_core
(
THD
*
thd
,
uint
*
nextp
)
sp_instr_stmt
::
exec_core
(
THD
*
thd
,
uint
*
nextp
)
...
@@ -2116,7 +2121,8 @@ sp_instr_set::exec_core(THD *thd, uint *nextp)
...
@@ -2116,7 +2121,8 @@ sp_instr_set::exec_core(THD *thd, uint *nextp)
void
void
sp_instr_set
::
print
(
String
*
str
)
sp_instr_set
::
print
(
String
*
str
)
{
{
int
rsrv
=
16
;
/* set name@offset ... */
int
rsrv
=
SP_INSTR_UINT_MAXLEN
+
6
;
sp_pvar_t
*
var
=
m_ctx
->
find_pvar
(
m_offset
);
sp_pvar_t
*
var
=
m_ctx
->
find_pvar
(
m_offset
);
/* 'var' should always be non-null, but just in case... */
/* 'var' should always be non-null, but just in case... */
...
@@ -2164,7 +2170,7 @@ sp_instr_set_trigger_field::exec_core(THD *thd, uint *nextp)
...
@@ -2164,7 +2170,7 @@ sp_instr_set_trigger_field::exec_core(THD *thd, uint *nextp)
void
void
sp_instr_set_trigger_field
::
print
(
String
*
str
)
sp_instr_set_trigger_field
::
print
(
String
*
str
)
{
{
str
->
append
(
"set
"
,
4
);
str
->
append
(
"set
_trigger_field "
,
18
);
trigger_field
->
print
(
str
);
trigger_field
->
print
(
str
);
str
->
append
(
":="
,
2
);
str
->
append
(
":="
,
2
);
value
->
print
(
str
);
value
->
print
(
str
);
...
@@ -2188,7 +2194,8 @@ sp_instr_jump::execute(THD *thd, uint *nextp)
...
@@ -2188,7 +2194,8 @@ sp_instr_jump::execute(THD *thd, uint *nextp)
void
void
sp_instr_jump
::
print
(
String
*
str
)
sp_instr_jump
::
print
(
String
*
str
)
{
{
if
(
str
->
reserve
(
12
))
/* jump dest */
if
(
str
->
reserve
(
SP_INSTR_UINT_MAXLEN
+
5
))
return
;
return
;
str
->
qs_append
(
"jump "
,
5
);
str
->
qs_append
(
"jump "
,
5
);
str
->
qs_append
(
m_dest
);
str
->
qs_append
(
m_dest
);
...
@@ -2271,7 +2278,8 @@ sp_instr_jump_if::exec_core(THD *thd, uint *nextp)
...
@@ -2271,7 +2278,8 @@ sp_instr_jump_if::exec_core(THD *thd, uint *nextp)
void
void
sp_instr_jump_if
::
print
(
String
*
str
)
sp_instr_jump_if
::
print
(
String
*
str
)
{
{
if
(
str
->
reserve
(
32
))
/* jump_if dest ... */
if
(
str
->
reserve
(
SP_INSTR_UINT_MAXLEN
+
8
+
32
))
// Add some for the expr. too
return
;
return
;
str
->
qs_append
(
"jump_if "
,
8
);
str
->
qs_append
(
"jump_if "
,
8
);
str
->
qs_append
(
m_dest
);
str
->
qs_append
(
m_dest
);
...
@@ -2333,7 +2341,8 @@ sp_instr_jump_if_not::exec_core(THD *thd, uint *nextp)
...
@@ -2333,7 +2341,8 @@ sp_instr_jump_if_not::exec_core(THD *thd, uint *nextp)
void
void
sp_instr_jump_if_not
::
print
(
String
*
str
)
sp_instr_jump_if_not
::
print
(
String
*
str
)
{
{
if
(
str
->
reserve
(
32
))
/* jump_if_not dest ... */
if
(
str
->
reserve
(
SP_INSTR_UINT_MAXLEN
+
12
+
32
))
// Add some for the expr. too
return
;
return
;
str
->
qs_append
(
"jump_if_not "
,
12
);
str
->
qs_append
(
"jump_if_not "
,
12
);
str
->
qs_append
(
m_dest
);
str
->
qs_append
(
m_dest
);
...
@@ -2392,7 +2401,8 @@ sp_instr_freturn::exec_core(THD *thd, uint *nextp)
...
@@ -2392,7 +2401,8 @@ sp_instr_freturn::exec_core(THD *thd, uint *nextp)
void
void
sp_instr_freturn
::
print
(
String
*
str
)
sp_instr_freturn
::
print
(
String
*
str
)
{
{
if
(
str
->
reserve
(
32
))
/* freturn type expr... */
if
(
str
->
reserve
(
UINT_MAX
+
8
+
32
))
// Add some for the expr. too
return
;
return
;
str
->
qs_append
(
"freturn "
,
8
);
str
->
qs_append
(
"freturn "
,
8
);
str
->
qs_append
((
uint
)
m_type
);
str
->
qs_append
((
uint
)
m_type
);
...
@@ -2421,7 +2431,8 @@ sp_instr_hpush_jump::execute(THD *thd, uint *nextp)
...
@@ -2421,7 +2431,8 @@ sp_instr_hpush_jump::execute(THD *thd, uint *nextp)
void
void
sp_instr_hpush_jump
::
print
(
String
*
str
)
sp_instr_hpush_jump
::
print
(
String
*
str
)
{
{
if
(
str
->
reserve
(
32
))
/* hpush_jump dest fsize type */
if
(
str
->
reserve
(
SP_INSTR_UINT_MAXLEN
*
2
+
21
))
return
;
return
;
str
->
qs_append
(
"hpush_jump "
,
11
);
str
->
qs_append
(
"hpush_jump "
,
11
);
str
->
qs_append
(
m_dest
);
str
->
qs_append
(
m_dest
);
...
@@ -2479,7 +2490,8 @@ sp_instr_hpop::execute(THD *thd, uint *nextp)
...
@@ -2479,7 +2490,8 @@ sp_instr_hpop::execute(THD *thd, uint *nextp)
void
void
sp_instr_hpop
::
print
(
String
*
str
)
sp_instr_hpop
::
print
(
String
*
str
)
{
{
if
(
str
->
reserve
(
12
))
/* hpop count */
if
(
str
->
reserve
(
SP_INSTR_UINT_MAXLEN
+
5
))
return
;
return
;
str
->
qs_append
(
"hpop "
,
5
);
str
->
qs_append
(
"hpop "
,
5
);
str
->
qs_append
(
m_count
);
str
->
qs_append
(
m_count
);
...
@@ -2515,7 +2527,8 @@ sp_instr_hreturn::execute(THD *thd, uint *nextp)
...
@@ -2515,7 +2527,8 @@ sp_instr_hreturn::execute(THD *thd, uint *nextp)
void
void
sp_instr_hreturn
::
print
(
String
*
str
)
sp_instr_hreturn
::
print
(
String
*
str
)
{
{
if
(
str
->
reserve
(
20
))
/* hreturn framesize dest */
if
(
str
->
reserve
(
SP_INSTR_UINT_MAXLEN
*
2
+
9
))
return
;
return
;
str
->
qs_append
(
"hreturn "
,
8
);
str
->
qs_append
(
"hreturn "
,
8
);
str
->
qs_append
(
m_frame
);
str
->
qs_append
(
m_frame
);
...
@@ -2570,8 +2583,9 @@ void
...
@@ -2570,8 +2583,9 @@ void
sp_instr_cpush
::
print
(
String
*
str
)
sp_instr_cpush
::
print
(
String
*
str
)
{
{
LEX_STRING
n
;
LEX_STRING
n
;
uint
rsrv
=
12
;
my_bool
found
=
m_ctx
->
find_cursor
(
m_cursor
,
&
n
);
my_bool
found
=
m_ctx
->
find_cursor
(
m_cursor
,
&
n
);
/* cpush name@offset */
uint
rsrv
=
SP_INSTR_UINT_MAXLEN
+
7
;
if
(
found
)
if
(
found
)
rsrv
+=
n
.
length
;
rsrv
+=
n
.
length
;
...
@@ -2604,7 +2618,8 @@ sp_instr_cpop::execute(THD *thd, uint *nextp)
...
@@ -2604,7 +2618,8 @@ sp_instr_cpop::execute(THD *thd, uint *nextp)
void
void
sp_instr_cpop
::
print
(
String
*
str
)
sp_instr_cpop
::
print
(
String
*
str
)
{
{
if
(
str
->
reserve
(
12
))
/* cpop count */
if
(
str
->
reserve
(
SP_INSTR_UINT_MAXLEN
+
5
))
return
;
return
;
str
->
qs_append
(
"cpop "
,
5
);
str
->
qs_append
(
"cpop "
,
5
);
str
->
qs_append
(
m_count
);
str
->
qs_append
(
m_count
);
...
@@ -2681,8 +2696,9 @@ void
...
@@ -2681,8 +2696,9 @@ void
sp_instr_copen
::
print
(
String
*
str
)
sp_instr_copen
::
print
(
String
*
str
)
{
{
LEX_STRING
n
;
LEX_STRING
n
;
uint
rsrv
=
16
;
my_bool
found
=
m_ctx
->
find_cursor
(
m_cursor
,
&
n
);
my_bool
found
=
m_ctx
->
find_cursor
(
m_cursor
,
&
n
);
/* copen name@offset */
uint
rsrv
=
SP_INSTR_UINT_MAXLEN
+
7
;
if
(
found
)
if
(
found
)
rsrv
+=
n
.
length
;
rsrv
+=
n
.
length
;
...
@@ -2722,8 +2738,9 @@ void
...
@@ -2722,8 +2738,9 @@ void
sp_instr_cclose
::
print
(
String
*
str
)
sp_instr_cclose
::
print
(
String
*
str
)
{
{
LEX_STRING
n
;
LEX_STRING
n
;
uint
rsrv
=
16
;
my_bool
found
=
m_ctx
->
find_cursor
(
m_cursor
,
&
n
);
my_bool
found
=
m_ctx
->
find_cursor
(
m_cursor
,
&
n
);
/* cclose name@offset */
uint
rsrv
=
SP_INSTR_UINT_MAXLEN
+
8
;
if
(
found
)
if
(
found
)
rsrv
+=
n
.
length
;
rsrv
+=
n
.
length
;
...
@@ -2764,8 +2781,9 @@ sp_instr_cfetch::print(String *str)
...
@@ -2764,8 +2781,9 @@ sp_instr_cfetch::print(String *str)
List_iterator_fast
<
struct
sp_pvar
>
li
(
m_varlist
);
List_iterator_fast
<
struct
sp_pvar
>
li
(
m_varlist
);
sp_pvar_t
*
pv
;
sp_pvar_t
*
pv
;
LEX_STRING
n
;
LEX_STRING
n
;
uint
rsrv
=
16
;
my_bool
found
=
m_ctx
->
find_cursor
(
m_cursor
,
&
n
);
my_bool
found
=
m_ctx
->
find_cursor
(
m_cursor
,
&
n
);
/* cfetch name@offset vars... */
uint
rsrv
=
SP_INSTR_UINT_MAXLEN
+
8
;
if
(
found
)
if
(
found
)
rsrv
+=
n
.
length
;
rsrv
+=
n
.
length
;
...
@@ -2780,7 +2798,7 @@ sp_instr_cfetch::print(String *str)
...
@@ -2780,7 +2798,7 @@ sp_instr_cfetch::print(String *str)
str
->
qs_append
(
m_cursor
);
str
->
qs_append
(
m_cursor
);
while
((
pv
=
li
++
))
while
((
pv
=
li
++
))
{
{
if
(
str
->
reserve
(
pv
->
name
.
length
+
10
))
if
(
str
->
reserve
(
pv
->
name
.
length
+
SP_INSTR_UINT_MAXLEN
+
2
))
return
;
return
;
str
->
qs_append
(
' '
);
str
->
qs_append
(
' '
);
str
->
qs_append
(
pv
->
name
.
str
,
pv
->
name
.
length
);
str
->
qs_append
(
pv
->
name
.
str
,
pv
->
name
.
length
);
...
@@ -2808,7 +2826,8 @@ sp_instr_error::execute(THD *thd, uint *nextp)
...
@@ -2808,7 +2826,8 @@ sp_instr_error::execute(THD *thd, uint *nextp)
void
void
sp_instr_error
::
print
(
String
*
str
)
sp_instr_error
::
print
(
String
*
str
)
{
{
if
(
str
->
reserve
(
12
))
/* error code */
if
(
str
->
reserve
(
SP_INSTR_UINT_MAXLEN
+
6
))
return
;
return
;
str
->
qs_append
(
"error "
,
6
);
str
->
qs_append
(
"error "
,
6
);
str
->
qs_append
(
m_errcode
);
str
->
qs_append
(
m_errcode
);
...
...
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