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
53b43f30
Commit
53b43f30
authored
Aug 14, 2020
by
Monty
Committed by
Sergei Golubchik
May 19, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added full_name_cstring()
This returns a LEX_CSTRING and allows one to avoid strlen() calls.
parent
b6ff139a
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
32 additions
and
23 deletions
+32
-23
sql/item.cc
sql/item.cc
+20
-16
sql/item.h
sql/item.h
+10
-3
sql/item_subselect.cc
sql/item_subselect.cc
+1
-2
sql/sql_test.cc
sql/sql_test.cc
+1
-2
No files found.
sql/item.cc
View file @
53b43f30
...
@@ -501,8 +501,7 @@ void Item::print_parenthesised(String *str, enum_query_type query_type,
...
@@ -501,8 +501,7 @@ void Item::print_parenthesised(String *str, enum_query_type query_type,
void
Item
::
print
(
String
*
str
,
enum_query_type
query_type
)
void
Item
::
print
(
String
*
str
,
enum_query_type
query_type
)
{
{
const
char
*
name
=
full_name
();
str
->
append
(
full_name_cstring
());
str
->
append
(
name
,
strlen
(
name
));
}
}
...
@@ -3146,32 +3145,37 @@ bool Item_field::switch_to_nullable_fields_processor(void *arg)
...
@@ -3146,32 +3145,37 @@ bool Item_field::switch_to_nullable_fields_processor(void *arg)
return
0
;
return
0
;
}
}
const
char
*
Item_ident
::
full_name
()
const
LEX_CSTRING
Item_ident
::
full_name_cstring
()
const
{
{
char
*
tmp
;
char
*
tmp
;
size_t
length
;
if
(
!
table_name
.
str
||
!
field_name
.
str
)
if
(
!
table_name
.
str
||
!
field_name
.
str
)
return
field_name
.
str
?
field_name
.
str
:
name
.
str
?
name
.
str
:
"tmp_field"
;
{
if
(
field_name
.
str
)
return
field_name
;
if
(
name
.
str
)
return
name
;
return
{
STRING_WITH_LEN
(
"tmp_field"
)
};
}
if
(
db_name
.
str
&&
db_name
.
str
[
0
])
if
(
db_name
.
str
&&
db_name
.
str
[
0
])
{
{
THD
*
thd
=
current_thd
;
THD
*
thd
=
current_thd
;
tmp
=
(
char
*
)
thd
->
alloc
((
uint
)
db_name
.
length
+
(
uint
)
table_name
.
length
+
tmp
=
(
char
*
)
thd
->
alloc
((
uint
)
db_name
.
length
+
(
uint
)
table_name
.
length
+
(
uint
)
field_name
.
length
+
3
);
(
uint
)
field_name
.
length
+
3
);
strxmov
(
tmp
,
db_name
.
str
,
"."
,
table_name
.
str
,
"."
,
field_name
.
str
,
NullS
);
length
=
(
strxmov
(
tmp
,
db_name
.
str
,
"."
,
table_name
.
str
,
"."
,
field_name
.
str
,
NullS
)
-
tmp
);
}
}
else
else
{
{
if
(
table_name
.
str
[
0
])
if
(
!
table_name
.
str
[
0
])
{
return
field_name
;
THD
*
thd
=
current_thd
;
THD
*
thd
=
current_thd
;
tmp
=
(
char
*
)
thd
->
alloc
((
uint
)
table_name
.
length
+
tmp
=
(
char
*
)
thd
->
alloc
((
uint
)
table_name
.
length
+
field_name
.
length
+
2
);
field_name
.
length
+
2
);
strxmov
(
tmp
,
table_name
.
str
,
"."
,
field_name
.
str
,
NullS
);
length
=
(
strxmov
(
tmp
,
table_name
.
str
,
"."
,
field_name
.
str
,
NullS
)
-
tmp
);
}
}
else
return
{
tmp
,
length
};
return
field_name
.
str
;
}
return
tmp
;
}
}
void
Item_ident
::
print
(
String
*
str
,
enum_query_type
query_type
)
void
Item_ident
::
print
(
String
*
str
,
enum_query_type
query_type
)
...
...
sql/item.h
View file @
53b43f30
...
@@ -1697,7 +1697,13 @@ class Item :public Value_source,
...
@@ -1697,7 +1697,13 @@ class Item :public Value_source,
virtual
Field
*
get_tmp_table_field
()
{
return
0
;
}
virtual
Field
*
get_tmp_table_field
()
{
return
0
;
}
virtual
Field
*
create_field_for_create_select
(
MEM_ROOT
*
root
,
TABLE
*
table
);
virtual
Field
*
create_field_for_create_select
(
MEM_ROOT
*
root
,
TABLE
*
table
);
virtual
const
char
*
full_name
()
const
{
return
name
.
str
?
name
.
str
:
"???"
;
}
inline
const
char
*
full_name
()
const
{
return
full_name_cstring
().
str
;
}
virtual
LEX_CSTRING
full_name_cstring
()
const
{
if
(
name
.
str
)
return
name
;
return
{
STRING_WITH_LEN
(
"???"
)
};
}
const
char
*
field_name_or_null
()
const
char
*
field_name_or_null
()
{
return
real_item
()
->
type
()
==
Item
::
FIELD_ITEM
?
name
.
str
:
NULL
;
}
{
return
real_item
()
->
type
()
==
Item
::
FIELD_ITEM
?
name
.
str
:
NULL
;
}
const
TABLE_SHARE
*
field_table_or_null
();
const
TABLE_SHARE
*
field_table_or_null
();
...
@@ -3439,7 +3445,7 @@ class Item_ident :public Item_result_field
...
@@ -3439,7 +3445,7 @@ class Item_ident :public Item_result_field
const
LEX_CSTRING
&
field_name_arg
);
const
LEX_CSTRING
&
field_name_arg
);
Item_ident
(
THD
*
thd
,
Item_ident
*
item
);
Item_ident
(
THD
*
thd
,
Item_ident
*
item
);
Item_ident
(
THD
*
thd
,
TABLE_LIST
*
view_arg
,
const
LEX_CSTRING
&
field_name_arg
);
Item_ident
(
THD
*
thd
,
TABLE_LIST
*
view_arg
,
const
LEX_CSTRING
&
field_name_arg
);
const
char
*
full_name
()
const
override
;
LEX_CSTRING
full_name_cstring
()
const
override
;
void
cleanup
()
override
;
void
cleanup
()
override
;
st_select_lex
*
get_depended_from
()
const
;
st_select_lex
*
get_depended_from
()
const
;
bool
remove_dependence_processor
(
void
*
arg
)
override
;
bool
remove_dependence_processor
(
void
*
arg
)
override
;
...
@@ -5845,7 +5851,8 @@ class Item_cache_wrapper :public Item_result_field
...
@@ -5845,7 +5851,8 @@ class Item_cache_wrapper :public Item_result_field
/* Following methods make this item transparent as much as possible */
/* Following methods make this item transparent as much as possible */
void
print
(
String
*
str
,
enum_query_type
query_type
)
override
;
void
print
(
String
*
str
,
enum_query_type
query_type
)
override
;
const
char
*
full_name
()
const
override
{
return
orig_item
->
full_name
();
}
LEX_CSTRING
full_name_cstring
()
const
override
{
return
orig_item
->
full_name_cstring
();
}
void
make_send_field
(
THD
*
thd
,
Send_field
*
field
)
override
void
make_send_field
(
THD
*
thd
,
Send_field
*
field
)
override
{
orig_item
->
make_send_field
(
thd
,
field
);
}
{
orig_item
->
make_send_field
(
thd
,
field
);
}
bool
eq
(
const
Item
*
item
,
bool
binary_cmp
)
const
override
bool
eq
(
const
Item
*
item
,
bool
binary_cmp
)
const
override
...
...
sql/item_subselect.cc
View file @
53b43f30
...
@@ -2307,8 +2307,7 @@ Item_in_subselect::create_single_in_to_exists_cond(JOIN *join,
...
@@ -2307,8 +2307,7 @@ Item_in_subselect::create_single_in_to_exists_cond(JOIN *join,
if
(
join_having
||
select_lex
->
with_sum_func
||
if
(
join_having
||
select_lex
->
with_sum_func
||
select_lex
->
group_list
.
elements
)
select_lex
->
group_list
.
elements
)
{
{
const
char
*
tmp
=
this
->
full_name
();
LEX_CSTRING
field_name
=
this
->
full_name_cstring
();
LEX_CSTRING
field_name
=
{
tmp
,
safe_strlen
(
tmp
)};
Item
*
item
=
func
->
create
(
thd
,
expr
,
Item
*
item
=
func
->
create
(
thd
,
expr
,
new
(
thd
->
mem_root
)
Item_ref_null_helper
(
new
(
thd
->
mem_root
)
Item_ref_null_helper
(
thd
,
thd
,
...
...
sql/sql_test.cc
View file @
53b43f30
...
@@ -189,8 +189,7 @@ TEST_join(JOIN *join)
...
@@ -189,8 +189,7 @@ TEST_join(JOIN *join)
JOIN_TAB
*
tab
=
jt_range
->
start
+
i
;
JOIN_TAB
*
tab
=
jt_range
->
start
+
i
;
for
(
ref
=
0
;
ref
<
tab
->
ref
.
key_parts
;
ref
++
)
for
(
ref
=
0
;
ref
<
tab
->
ref
.
key_parts
;
ref
++
)
{
{
const
char
*
full_name
=
(
tab
->
ref
.
items
[
ref
]
->
full_name
());
ref_key_parts
[
i
].
append
(
tab
->
ref
.
items
[
ref
]
->
full_name_cstring
());
ref_key_parts
[
i
].
append
(
full_name
,
strlen
(
full_name
));
ref_key_parts
[
i
].
append
(
STRING_WITH_LEN
(
" "
));
ref_key_parts
[
i
].
append
(
STRING_WITH_LEN
(
" "
));
}
}
}
}
...
...
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