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
d53fc319
Commit
d53fc319
authored
Feb 12, 2003
by
pem@mysql.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed some DBUGing, and optimized SET slightly.
parent
f2d6ec93
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
50 additions
and
23 deletions
+50
-23
sql/sp.cc
sql/sp.cc
+11
-5
sql/sp_head.cc
sql/sp_head.cc
+21
-8
sql/sql_parse.cc
sql/sql_parse.cc
+6
-6
sql/sql_yacc.yy
sql/sql_yacc.yy
+12
-4
No files found.
sql/sp.cc
View file @
d53fc319
...
@@ -26,6 +26,7 @@
...
@@ -26,6 +26,7 @@
sp_head
*
sp_head
*
sp_find_procedure
(
THD
*
thd
,
Item_string
*
iname
)
sp_find_procedure
(
THD
*
thd
,
Item_string
*
iname
)
{
{
DBUG_ENTER
(
"sp_find_procedure"
);
extern
int
yyparse
(
void
*
thd
);
extern
int
yyparse
(
void
*
thd
);
LEX
*
tmplex
;
LEX
*
tmplex
;
TABLE
*
table
;
TABLE
*
table
;
...
@@ -35,11 +36,12 @@ sp_find_procedure(THD *thd, Item_string *iname)
...
@@ -35,11 +36,12 @@ sp_find_procedure(THD *thd, Item_string *iname)
sp_head
*
sp
=
NULL
;
sp_head
*
sp
=
NULL
;
name
=
iname
->
const_string
();
name
=
iname
->
const_string
();
DBUG_PRINT
(
"enter"
,
(
"name: %*s"
,
name
->
length
(),
name
->
c_ptr
()));
memset
(
&
tables
,
0
,
sizeof
(
tables
));
memset
(
&
tables
,
0
,
sizeof
(
tables
));
tables
.
db
=
(
char
*
)
"mysql"
;
tables
.
db
=
(
char
*
)
"mysql"
;
tables
.
real_name
=
tables
.
alias
=
(
char
*
)
"proc"
;
tables
.
real_name
=
tables
.
alias
=
(
char
*
)
"proc"
;
if
(
!
(
table
=
open_ltable
(
thd
,
&
tables
,
TL_READ
)))
if
(
!
(
table
=
open_ltable
(
thd
,
&
tables
,
TL_READ
)))
return
NULL
;
DBUG_RETURN
(
NULL
)
;
if
(
table
->
file
->
index_read_idx
(
table
->
record
[
0
],
0
,
if
(
table
->
file
->
index_read_idx
(
table
->
record
[
0
],
0
,
(
byte
*
)
name
->
c_ptr
(),
name
->
length
(),
(
byte
*
)
name
->
c_ptr
(),
name
->
length
(),
...
@@ -59,12 +61,14 @@ sp_find_procedure(THD *thd, Item_string *iname)
...
@@ -59,12 +61,14 @@ sp_find_procedure(THD *thd, Item_string *iname)
done:
done:
if
(
table
)
if
(
table
)
close_thread_tables
(
thd
);
close_thread_tables
(
thd
);
return
sp
;
DBUG_RETURN
(
sp
)
;
}
}
int
int
sp_create_procedure
(
THD
*
thd
,
char
*
name
,
uint
namelen
,
char
*
def
,
uint
deflen
)
sp_create_procedure
(
THD
*
thd
,
char
*
name
,
uint
namelen
,
char
*
def
,
uint
deflen
)
{
{
DBUG_ENTER
(
"sp_create_procedure"
);
DBUG_PRINT
(
"enter"
,
(
"name: %*s def: %*s"
,
namelen
,
name
,
deflen
,
def
));
int
ret
=
0
;
int
ret
=
0
;
TABLE
*
table
;
TABLE
*
table
;
TABLE_LIST
tables
;
TABLE_LIST
tables
;
...
@@ -88,12 +92,14 @@ sp_create_procedure(THD *thd, char *name, uint namelen, char *def, uint deflen)
...
@@ -88,12 +92,14 @@ sp_create_procedure(THD *thd, char *name, uint namelen, char *def, uint deflen)
done:
done:
close_thread_tables
(
thd
);
close_thread_tables
(
thd
);
return
ret
;
DBUG_RETURN
(
ret
)
;
}
}
int
int
sp_drop_procedure
(
THD
*
thd
,
char
*
name
,
uint
namelen
)
sp_drop_procedure
(
THD
*
thd
,
char
*
name
,
uint
namelen
)
{
{
DBUG_ENTER
(
"sp_drop_procedure"
);
DBUG_PRINT
(
"enter"
,
(
"name: %*s"
,
namelen
,
name
));
TABLE
*
table
;
TABLE
*
table
;
TABLE_LIST
tables
;
TABLE_LIST
tables
;
...
@@ -111,9 +117,9 @@ sp_drop_procedure(THD *thd, char *name, uint namelen)
...
@@ -111,9 +117,9 @@ sp_drop_procedure(THD *thd, char *name, uint namelen)
table
->
file
->
print_error
(
error
,
MYF
(
0
));
table
->
file
->
print_error
(
error
,
MYF
(
0
));
}
}
close_thread_tables
(
thd
);
close_thread_tables
(
thd
);
return
0
;
DBUG_RETURN
(
0
)
;
err:
err:
close_thread_tables
(
thd
);
close_thread_tables
(
thd
);
return
-
1
;
DBUG_RETURN
(
-
1
)
;
}
}
sql/sp_head.cc
View file @
d53fc319
...
@@ -99,17 +99,21 @@ sp_head::sp_head(LEX_STRING *name, LEX *lex)
...
@@ -99,17 +99,21 @@ sp_head::sp_head(LEX_STRING *name, LEX *lex)
int
int
sp_head
::
create
(
THD
*
thd
)
sp_head
::
create
(
THD
*
thd
)
{
{
DBUG_ENTER
(
"sp_head::create"
);
String
*
name
=
m_name
->
const_string
();
String
*
name
=
m_name
->
const_string
();
String
*
def
=
m_defstr
->
const_string
();
String
*
def
=
m_defstr
->
const_string
();
return
sp_create_procedure
(
thd
,
DBUG_PRINT
(
"info"
,
(
"name: %s def: %s"
,
name
->
c_ptr
(),
def
->
c_ptr
()));
name
->
c_ptr
(),
name
->
length
(),
DBUG_RETURN
(
sp_create_procedure
(
thd
,
def
->
c_ptr
(),
def
->
length
());
name
->
c_ptr
(),
name
->
length
(),
def
->
c_ptr
(),
def
->
length
()));
}
}
int
int
sp_head
::
execute
(
THD
*
thd
)
sp_head
::
execute
(
THD
*
thd
)
{
{
DBUG_ENTER
(
"sp_head::execute"
);
DBUG_PRINT
(
"executing"
,
(
"procedure %s"
,
((
String
*
)
m_name
->
const_string
())
->
c_ptr
()));
int
ret
=
0
;
int
ret
=
0
;
sp_instr
*
p
;
sp_instr
*
p
;
sp_pcontext
*
pctx
=
m_call_lex
->
spcont
;
sp_pcontext
*
pctx
=
m_call_lex
->
spcont
;
...
@@ -171,6 +175,7 @@ sp_head::execute(THD *thd)
...
@@ -171,6 +175,7 @@ sp_head::execute(THD *thd)
i
=
get_instr
(
ip
);
// Returns NULL when we're done.
i
=
get_instr
(
ip
);
// Returns NULL when we're done.
if
(
i
==
NULL
)
if
(
i
==
NULL
)
break
;
break
;
DBUG_PRINT
(
"execute"
,
(
"Instruction %u"
,
ip
));
ret
=
i
->
execute
(
thd
,
&
ip
);
ret
=
i
->
execute
(
thd
,
&
ip
);
}
}
}
}
...
@@ -218,7 +223,7 @@ sp_head::execute(THD *thd)
...
@@ -218,7 +223,7 @@ sp_head::execute(THD *thd)
thd
->
spcont
=
octx
;
thd
->
spcont
=
octx
;
}
}
return
ret
;
DBUG_RETURN
(
ret
)
;
}
}
...
@@ -351,6 +356,8 @@ sp_head::backpatch(sp_label_t *lab)
...
@@ -351,6 +356,8 @@ sp_head::backpatch(sp_label_t *lab)
int
int
sp_instr_stmt
::
execute
(
THD
*
thd
,
uint
*
nextp
)
sp_instr_stmt
::
execute
(
THD
*
thd
,
uint
*
nextp
)
{
{
DBUG_ENTER
(
"sp_instr_stmt::execute"
);
DBUG_PRINT
(
"info"
,
(
"command: %d"
,
m_lex
.
sql_command
));
LEX
olex
;
// The other lex
LEX
olex
;
// The other lex
int
res
;
int
res
;
...
@@ -364,7 +371,7 @@ sp_instr_stmt::execute(THD *thd, uint *nextp)
...
@@ -364,7 +371,7 @@ sp_instr_stmt::execute(THD *thd, uint *nextp)
memcpy
(
&
thd
->
lex
,
&
olex
,
sizeof
(
LEX
));
// Restore the other lex
memcpy
(
&
thd
->
lex
,
&
olex
,
sizeof
(
LEX
));
// Restore the other lex
*
nextp
=
m_ip
+
1
;
*
nextp
=
m_ip
+
1
;
return
res
;
DBUG_RETURN
(
res
)
;
}
}
//
//
...
@@ -373,9 +380,11 @@ sp_instr_stmt::execute(THD *thd, uint *nextp)
...
@@ -373,9 +380,11 @@ sp_instr_stmt::execute(THD *thd, uint *nextp)
int
int
sp_instr_set
::
execute
(
THD
*
thd
,
uint
*
nextp
)
sp_instr_set
::
execute
(
THD
*
thd
,
uint
*
nextp
)
{
{
DBUG_ENTER
(
"sp_instr_set::execute"
);
DBUG_PRINT
(
"info"
,
(
"offset: %u"
,
m_offset
));
thd
->
spcont
->
set_item
(
m_offset
,
eval_func_item
(
thd
,
m_value
,
m_type
));
thd
->
spcont
->
set_item
(
m_offset
,
eval_func_item
(
thd
,
m_value
,
m_type
));
*
nextp
=
m_ip
+
1
;
*
nextp
=
m_ip
+
1
;
return
0
;
DBUG_RETURN
(
0
)
;
}
}
//
//
...
@@ -384,13 +393,15 @@ sp_instr_set::execute(THD *thd, uint *nextp)
...
@@ -384,13 +393,15 @@ sp_instr_set::execute(THD *thd, uint *nextp)
int
int
sp_instr_jump_if
::
execute
(
THD
*
thd
,
uint
*
nextp
)
sp_instr_jump_if
::
execute
(
THD
*
thd
,
uint
*
nextp
)
{
{
DBUG_ENTER
(
"sp_instr_jump_if::execute"
);
DBUG_PRINT
(
"info"
,
(
"destination: %u"
,
m_dest
));
Item
*
it
=
eval_func_item
(
thd
,
m_expr
,
MYSQL_TYPE_TINY
);
Item
*
it
=
eval_func_item
(
thd
,
m_expr
,
MYSQL_TYPE_TINY
);
if
(
it
->
val_int
())
if
(
it
->
val_int
())
*
nextp
=
m_dest
;
*
nextp
=
m_dest
;
else
else
*
nextp
=
m_ip
+
1
;
*
nextp
=
m_ip
+
1
;
return
0
;
DBUG_RETURN
(
0
)
;
}
}
//
//
...
@@ -399,11 +410,13 @@ sp_instr_jump_if::execute(THD *thd, uint *nextp)
...
@@ -399,11 +410,13 @@ sp_instr_jump_if::execute(THD *thd, uint *nextp)
int
int
sp_instr_jump_if_not
::
execute
(
THD
*
thd
,
uint
*
nextp
)
sp_instr_jump_if_not
::
execute
(
THD
*
thd
,
uint
*
nextp
)
{
{
DBUG_ENTER
(
"sp_instr_jump_if_not::execute"
);
DBUG_PRINT
(
"info"
,
(
"destination: %u"
,
m_dest
));
Item
*
it
=
eval_func_item
(
thd
,
m_expr
,
MYSQL_TYPE_TINY
);
Item
*
it
=
eval_func_item
(
thd
,
m_expr
,
MYSQL_TYPE_TINY
);
if
(
!
it
->
val_int
())
if
(
!
it
->
val_int
())
*
nextp
=
m_dest
;
*
nextp
=
m_dest
;
else
else
*
nextp
=
m_ip
+
1
;
*
nextp
=
m_ip
+
1
;
return
0
;
DBUG_RETURN
(
0
)
;
}
}
sql/sql_parse.cc
View file @
d53fc319
...
@@ -1513,7 +1513,7 @@ mysql_execute_command(THD *thd)
...
@@ -1513,7 +1513,7 @@ mysql_execute_command(THD *thd)
given and the table list says the query should not be replicated
given and the table list says the query should not be replicated
*/
*/
if
(
table_rules_on
&&
tables
&&
!
tables_ok
(
thd
,
tables
))
if
(
table_rules_on
&&
tables
&&
!
tables_ok
(
thd
,
tables
))
return
0
;
DBUG_RETURN
(
0
)
;
#ifndef TO_BE_DELETED
#ifndef TO_BE_DELETED
/*
/*
This is a workaround to deal with the shortcoming in 3.23.44-3.23.46
This is a workaround to deal with the shortcoming in 3.23.44-3.23.46
...
@@ -1549,7 +1549,7 @@ mysql_execute_command(THD *thd)
...
@@ -1549,7 +1549,7 @@ mysql_execute_command(THD *thd)
{
{
if
(
res
<
0
||
thd
->
net
.
report_error
)
if
(
res
<
0
||
thd
->
net
.
report_error
)
send_error
(
thd
,
thd
->
killed
?
ER_SERVER_SHUTDOWN
:
0
);
send_error
(
thd
,
thd
->
killed
?
ER_SERVER_SHUTDOWN
:
0
);
return
res
;
DBUG_RETURN
(
res
)
;
}
}
}
}
}
}
...
@@ -1558,7 +1558,7 @@ mysql_execute_command(THD *thd)
...
@@ -1558,7 +1558,7 @@ mysql_execute_command(THD *thd)
lex
->
unit
.
create_total_list
(
thd
,
lex
,
&
tables
))
||
lex
->
unit
.
create_total_list
(
thd
,
lex
,
&
tables
))
||
(
table_rules_on
&&
tables
&&
thd
->
slave_thread
&&
(
table_rules_on
&&
tables
&&
thd
->
slave_thread
&&
!
tables_ok
(
thd
,
tables
)))
!
tables_ok
(
thd
,
tables
)))
return
0
;
DBUG_RETURN
(
0
)
;
statistic_increment
(
com_stat
[
lex
->
sql_command
],
&
LOCK_status
);
statistic_increment
(
com_stat
[
lex
->
sql_command
],
&
LOCK_status
);
switch
(
lex
->
sql_command
)
{
switch
(
lex
->
sql_command
)
{
...
@@ -1838,7 +1838,7 @@ mysql_execute_command(THD *thd)
...
@@ -1838,7 +1838,7 @@ mysql_execute_command(THD *thd)
find_real_table_in_list
(
tables
->
next
,
tables
->
db
,
tables
->
real_name
))
find_real_table_in_list
(
tables
->
next
,
tables
->
db
,
tables
->
real_name
))
{
{
net_printf
(
thd
,
ER_UPDATE_TABLE_USED
,
tables
->
real_name
);
net_printf
(
thd
,
ER_UPDATE_TABLE_USED
,
tables
->
real_name
);
return
-
1
;
DBUG_RETURN
(
-
1
)
;
}
}
if
(
tables
->
next
)
if
(
tables
->
next
)
{
{
...
@@ -2912,11 +2912,11 @@ mysql_execute_command(THD *thd)
...
@@ -2912,11 +2912,11 @@ mysql_execute_command(THD *thd)
// or res != 0 and no send_error() has yet been done.
// or res != 0 and no send_error() has yet been done.
if
(
res
<
0
)
if
(
res
<
0
)
send_error
(
thd
,
thd
->
killed
?
ER_SERVER_SHUTDOWN
:
0
);
send_error
(
thd
,
thd
->
killed
?
ER_SERVER_SHUTDOWN
:
0
);
return
res
;
DBUG_RETURN
(
res
)
;
error:
error:
// We end up here if send_error() has already been done.
// We end up here if send_error() has already been done.
return
-
1
;
DBUG_RETURN
(
-
1
)
;
}
}
...
...
sql/sql_yacc.yy
View file @
d53fc319
...
@@ -1049,10 +1049,18 @@ sp_proc_stmt:
...
@@ -1049,10 +1049,18 @@ sp_proc_stmt:
}
}
else
else
{
{
sp_instr_stmt *i= new sp_instr_stmt(lex->sphead->instructions());
/* Don't add an instruction for empty SET statements.
** (This happens if the SET only contained local variables,
i->set_lex(lex);
** which get their set instructions generated separately.)
lex->sphead->add_instr(i);
*/
if (lex->sql_command != SQLCOM_SET_OPTION ||
!lex->var_list.is_empty())
{
sp_instr_stmt *i= new sp_instr_stmt(lex->sphead->instructions());
i->set_lex(lex);
lex->sphead->add_instr(i);
}
lex->sphead->restore_lex(YYTHD);
lex->sphead->restore_lex(YYTHD);
}
}
}
}
...
...
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