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
a6fa724b
Commit
a6fa724b
authored
Apr 07, 2013
by
Sergei Golubchik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
split THD::make_lex_string() in two
parent
e56cad4b
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
48 additions
and
67 deletions
+48
-67
sql/sql_acl.cc
sql/sql_acl.cc
+4
-6
sql/sql_class.cc
sql/sql_class.cc
+3
-27
sql/sql_class.h
sql/sql_class.h
+15
-3
sql/sql_show.cc
sql/sql_show.cc
+23
-28
sql/sql_view.cc
sql/sql_view.cc
+3
-3
No files found.
sql/sql_acl.cc
View file @
a6fa724b
...
...
@@ -7034,10 +7034,8 @@ bool sp_grant_privileges(THD *thd, const char *sp_db, const char *sp_name,
tables
->
db
=
(
char
*
)
sp_db
;
tables
->
table_name
=
tables
->
alias
=
(
char
*
)
sp_name
;
thd
->
make_lex_string
(
&
combo
->
user
,
combo
->
user
.
str
,
strlen
(
combo
->
user
.
str
),
0
);
thd
->
make_lex_string
(
&
combo
->
host
,
combo
->
host
.
str
,
strlen
(
combo
->
host
.
str
),
0
);
thd
->
make_lex_string
(
&
combo
->
user
,
combo
->
user
.
str
,
strlen
(
combo
->
user
.
str
));
thd
->
make_lex_string
(
&
combo
->
host
,
combo
->
host
.
str
,
strlen
(
combo
->
host
.
str
));
combo
->
password
=
empty_lex_str
;
combo
->
plugin
=
empty_lex_str
;
...
...
@@ -8263,7 +8261,7 @@ static bool parse_com_change_user_packet(MPVIO_EXT *mpvio, uint packet_length)
thd
->
user_connect
=
0
;
strmake
(
sctx
->
priv_user
,
sctx
->
user
,
USERNAME_LENGTH
);
if
(
thd
->
make_lex_string
(
&
mpvio
->
db
,
db_buff
,
db_len
,
0
)
==
0
)
if
(
thd
->
make_lex_string
(
&
mpvio
->
db
,
db_buff
,
db_len
)
==
0
)
DBUG_RETURN
(
1
);
/* The error is set by make_lex_string(). */
/*
...
...
@@ -8489,7 +8487,7 @@ static ulong parse_client_handshake_packet(MPVIO_EXT *mpvio,
Security_context
*
sctx
=
thd
->
security_ctx
;
if
(
thd
->
make_lex_string
(
&
mpvio
->
db
,
db
,
db_len
,
0
)
==
0
)
if
(
thd
->
make_lex_string
(
&
mpvio
->
db
,
db
,
db_len
)
==
0
)
return
packet_error
;
/* The error is set by make_lex_string(). */
my_free
(
sctx
->
user
);
if
(
!
(
sctx
->
user
=
my_strndup
(
user
,
user_len
,
MYF
(
MY_WME
))))
...
...
sql/sql_class.cc
View file @
a6fa724b
/*
Copyright (c) 2000, 2012, Oracle and/or its affiliates.
Copyright (c) 2008, 201
2
, Monty Program Ab
Copyright (c) 2008, 201
3
, Monty Program Ab
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
...
...
@@ -1186,8 +1186,8 @@ LEX_STRING *thd_make_lex_string(THD *thd, LEX_STRING *lex_str,
const
char
*
str
,
unsigned
int
size
,
int
allocate_lex_string
)
{
return
thd
->
make_lex_string
(
lex_str
,
str
,
size
,
(
bool
)
allocate_lex_string
);
return
allocate_lex_string
?
thd
->
make_lex_string
(
str
,
size
)
:
thd
->
make_lex_string
(
lex_str
,
str
,
size
);
}
extern
"C"
...
...
@@ -1900,30 +1900,6 @@ void THD::cleanup_after_query()
}
/**
Create a LEX_STRING in this connection.
@param lex_str pointer to LEX_STRING object to be initialized
@param str initializer to be copied into lex_str
@param length length of str, in bytes
@param allocate_lex_string if TRUE, allocate new LEX_STRING object,
instead of using lex_str value
@return NULL on failure, or pointer to the LEX_STRING object
*/
LEX_STRING
*
THD
::
make_lex_string
(
LEX_STRING
*
lex_str
,
const
char
*
str
,
uint
length
,
bool
allocate_lex_string
)
{
if
(
allocate_lex_string
)
if
(
!
(
lex_str
=
(
LEX_STRING
*
)
alloc_root
(
mem_root
,
sizeof
(
LEX_STRING
))))
return
0
;
if
(
!
(
lex_str
->
str
=
strmake_root
(
mem_root
,
str
,
length
)))
return
0
;
lex_str
->
length
=
length
;
return
lex_str
;
}
/*
Convert a string to another character set
...
...
sql/sql_class.h
View file @
a6fa724b
...
...
@@ -2622,9 +2622,21 @@ public:
return
alloc_root
(
&
transaction
.
mem_root
,
size
);
}
LEX_STRING
*
make_lex_string
(
LEX_STRING
*
lex_str
,
const
char
*
str
,
uint
length
,
bool
allocate_lex_string
);
LEX_STRING
*
make_lex_string
(
LEX_STRING
*
lex_str
,
const
char
*
str
,
uint
length
)
{
if
(
!
(
lex_str
->
str
=
strmake_root
(
mem_root
,
str
,
length
)))
return
0
;
lex_str
->
length
=
length
;
return
lex_str
;
}
LEX_STRING
*
make_lex_string
(
const
char
*
str
,
uint
length
)
{
LEX_STRING
*
lex_str
;
if
(
!
(
lex_str
=
(
LEX_STRING
*
)
alloc_root
(
mem_root
,
sizeof
(
LEX_STRING
))))
return
0
;
return
make_lex_string
(
lex_str
,
str
,
length
);
}
bool
convert_string
(
LEX_STRING
*
to
,
CHARSET_INFO
*
to_cs
,
const
char
*
from
,
uint
from_length
,
...
...
sql/sql_show.cc
View file @
a6fa724b
/* Copyright (c) 2000, 2012, Oracle and/or its affiliates.
Copyright (c) 2009, 201
2
, Monty Program Ab
Copyright (c) 2009, 201
3
, Monty Program Ab
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
...
...
@@ -829,8 +829,7 @@ find_files(THD *thd, List<LEX_STRING> *files, const char *db,
continue
;
}
#endif
if
(
!
(
file_name
=
thd
->
make_lex_string
(
file_name
,
uname
,
file_name_len
,
TRUE
))
||
if
(
!
(
file_name
=
thd
->
make_lex_string
(
uname
,
file_name_len
))
||
files
->
push_back
(
file_name
))
{
my_dirend
(
dirp
);
...
...
@@ -3443,8 +3442,8 @@ bool get_lookup_value(THD *thd, Item_func *item_func,
(
uchar
*
)
item_field
->
field_name
,
strlen
(
item_field
->
field_name
),
0
))
{
thd
->
make_lex_string
(
&
lookup_field_vals
->
db_value
,
tmp_str
->
ptr
(),
tmp_str
->
length
(),
FALSE
);
thd
->
make_lex_string
(
&
lookup_field_vals
->
db_value
,
tmp_str
->
ptr
(),
tmp_str
->
length
()
);
}
/* Lookup value is table name */
else
if
(
!
cs
->
coll
->
strnncollsp
(
cs
,
(
uchar
*
)
field_name2
,
...
...
@@ -3452,8 +3451,8 @@ bool get_lookup_value(THD *thd, Item_func *item_func,
(
uchar
*
)
item_field
->
field_name
,
strlen
(
item_field
->
field_name
),
0
))
{
thd
->
make_lex_string
(
&
lookup_field_vals
->
table_value
,
tmp_str
->
ptr
(),
tmp_str
->
length
(),
FALSE
);
thd
->
make_lex_string
(
&
lookup_field_vals
->
table_value
,
tmp_str
->
ptr
(),
tmp_str
->
length
()
);
}
}
return
0
;
...
...
@@ -3638,8 +3637,7 @@ bool get_lookup_field_values(THD *thd, COND *cond, TABLE_LIST *tables,
case
SQLCOM_SHOW_DATABASES
:
if
(
wild
)
{
thd
->
make_lex_string
(
&
lookup_field_values
->
db_value
,
wild
,
strlen
(
wild
),
0
);
thd
->
make_lex_string
(
&
lookup_field_values
->
db_value
,
wild
,
strlen
(
wild
));
lookup_field_values
->
wild_db_value
=
1
;
}
break
;
...
...
@@ -3648,11 +3646,11 @@ bool get_lookup_field_values(THD *thd, COND *cond, TABLE_LIST *tables,
case
SQLCOM_SHOW_TRIGGERS
:
case
SQLCOM_SHOW_EVENTS
:
thd
->
make_lex_string
(
&
lookup_field_values
->
db_value
,
lex
->
select_lex
.
db
,
strlen
(
lex
->
select_lex
.
db
)
,
0
);
lex
->
select_lex
.
db
,
strlen
(
lex
->
select_lex
.
db
));
if
(
wild
)
{
thd
->
make_lex_string
(
&
lookup_field_values
->
table_value
,
wild
,
strlen
(
wild
)
,
0
);
wild
,
strlen
(
wild
));
lookup_field_values
->
wild_table_value
=
1
;
}
break
;
...
...
@@ -3711,9 +3709,8 @@ int make_db_list(THD *thd, List<LEX_STRING> *files,
bool
*
with_i_schema
)
{
LEX_STRING
*
i_s_name_copy
=
0
;
i_s_name_copy
=
thd
->
make_lex_string
(
i_s_name_copy
,
INFORMATION_SCHEMA_NAME
.
str
,
INFORMATION_SCHEMA_NAME
.
length
,
TRUE
);
i_s_name_copy
=
thd
->
make_lex_string
(
INFORMATION_SCHEMA_NAME
.
str
,
INFORMATION_SCHEMA_NAME
.
length
);
*
with_i_schema
=
0
;
if
(
lookup_field_vals
->
wild_db_value
)
{
...
...
@@ -3802,9 +3799,8 @@ static my_bool add_schema_table(THD *thd, plugin_ref plugin,
DBUG_RETURN
(
0
);
}
if
((
file_name
=
thd
->
make_lex_string
(
file_name
,
schema_table
->
table_name
,
strlen
(
schema_table
->
table_name
),
TRUE
))
&&
if
((
file_name
=
thd
->
make_lex_string
(
schema_table
->
table_name
,
strlen
(
schema_table
->
table_name
)))
&&
!
file_list
->
push_back
(
file_name
))
DBUG_RETURN
(
0
);
DBUG_RETURN
(
1
);
...
...
@@ -3835,8 +3831,8 @@ int schema_tables_add(THD *thd, List<LEX_STRING> *files, const char *wild)
continue
;
}
if
((
file_name
=
thd
->
make_lex_string
(
file_name
,
tmp_schema_table
->
table_name
,
strlen
(
tmp_schema_table
->
table_name
)
,
TRUE
))
&&
thd
->
make_lex_string
(
tmp_schema_table
->
table_name
,
strlen
(
tmp_schema_table
->
table_name
)))
&&
!
files
->
push_back
(
file_name
))
continue
;
DBUG_RETURN
(
1
);
...
...
@@ -3888,9 +3884,8 @@ make_table_name_list(THD *thd, List<LEX_STRING> *table_names, LEX *lex,
find_schema_table
(
thd
,
lookup_field_vals
->
table_value
.
str
);
if
(
schema_table
&&
!
schema_table
->
hidden
)
{
if
(
!
(
name
=
thd
->
make_lex_string
(
NULL
,
schema_table
->
table_name
,
strlen
(
schema_table
->
table_name
),
TRUE
))
||
if
(
!
(
name
=
thd
->
make_lex_string
(
schema_table
->
table_name
,
strlen
(
schema_table
->
table_name
)))
||
table_names
->
push_back
(
name
))
return
1
;
}
...
...
@@ -4015,10 +4010,10 @@ fill_schema_table_by_open(THD *thd, bool is_show_fields_or_keys,
These copies are used for make_table_list() while unaltered values
are passed to process_table() functions.
*/
if
(
!
thd
->
make_lex_string
(
&
db_name
,
orig_db_name
->
str
,
orig_db_name
->
length
,
FALSE
)
||
!
thd
->
make_lex_string
(
&
table_name
,
orig_table_name
->
str
,
orig_table_name
->
length
,
FALSE
))
if
(
!
thd
->
make_lex_string
(
&
db_name
,
orig_db_name
->
str
,
orig_db_name
->
length
)
||
!
thd
->
make_lex_string
(
&
table_name
,
orig_table_name
->
str
,
orig_table_name
->
length
))
goto
end
;
/*
...
...
@@ -7860,9 +7855,9 @@ int make_schema_select(THD *thd, SELECT_LEX *sel,
because of lower_case_table_names
*/
thd
->
make_lex_string
(
&
db
,
INFORMATION_SCHEMA_NAME
.
str
,
INFORMATION_SCHEMA_NAME
.
length
,
0
);
INFORMATION_SCHEMA_NAME
.
length
);
thd
->
make_lex_string
(
&
table
,
schema_table
->
table_name
,
strlen
(
schema_table
->
table_name
)
,
0
);
strlen
(
schema_table
->
table_name
));
if
(
schema_table
->
old_format
(
thd
,
schema_table
)
||
/* Handle old syntax */
!
sel
->
add_table_to_list
(
thd
,
new
Table_ident
(
thd
,
db
,
table
,
0
),
0
,
0
,
TL_READ
,
MDL_SHARED_READ
))
...
...
sql/sql_view.cc
View file @
a6fa724b
/* Copyright (c) 2004, 2011, Oracle and/or its affiliates.
Copyright (c) 2011 Monty Program Ab
Copyright (c) 2011
, 2013,
Monty Program Ab
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
...
...
@@ -871,7 +871,7 @@ static int mysql_register_view(THD *thd, TABLE_LIST *view,
view
->
source
=
thd
->
lex
->
create_view_select
;
if
(
!
thd
->
make_lex_string
(
&
view
->
select_stmt
,
view_query
.
ptr
(),
view_query
.
length
()
,
false
))
view_query
.
length
()))
{
my_error
(
ER_OUT_OF_RESOURCES
,
MYF
(
0
));
error
=
-
1
;
...
...
@@ -1004,7 +1004,7 @@ loop_out:
view
->
view_creation_ctx
->
get_connection_cl
()
->
name
);
if
(
!
thd
->
make_lex_string
(
&
view
->
view_body_utf8
,
is_query
.
ptr
(),
is_query
.
length
()
,
false
))
is_query
.
length
()))
{
my_error
(
ER_OUT_OF_RESOURCES
,
MYF
(
0
));
error
=
-
1
;
...
...
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