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
1e668717
Commit
1e668717
authored
Sep 03, 2014
by
Alexander Barkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding Item_string_sys and Item_string_ascii to reduce duplicate code
parent
e42f4e31
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
57 additions
and
50 deletions
+57
-50
sql/item.h
sql/item.h
+26
-0
sql/sql_acl.cc
sql/sql_acl.cc
+1
-1
sql/sql_explain.cc
sql/sql_explain.cc
+7
-13
sql/sql_help.cc
sql/sql_help.cc
+1
-1
sql/sql_select.cc
sql/sql_select.cc
+17
-30
sql/sql_yacc.yy
sql/sql_yacc.yy
+5
-5
No files found.
sql/item.h
View file @
1e668717
...
...
@@ -2929,6 +2929,32 @@ class Item_string_with_introducer :public Item_string
};
class
Item_string_sys
:
public
Item_string
{
public:
Item_string_sys
(
const
char
*
str
,
uint
length
)
:
Item_string
(
str
,
length
,
system_charset_info
)
{
}
Item_string_sys
(
const
char
*
str
)
:
Item_string
(
str
,
strlen
(
str
),
system_charset_info
)
{
}
};
class
Item_string_ascii
:
public
Item_string
{
public:
Item_string_ascii
(
const
char
*
str
,
uint
length
)
:
Item_string
(
str
,
length
,
&
my_charset_latin1
,
DERIVATION_COERCIBLE
,
MY_REPERTOIRE_ASCII
)
{
}
Item_string_ascii
(
const
char
*
str
)
:
Item_string
(
str
,
strlen
(
str
),
&
my_charset_latin1
,
DERIVATION_COERCIBLE
,
MY_REPERTOIRE_ASCII
)
{
}
};
longlong
longlong_from_string_with_check
(
CHARSET_INFO
*
cs
,
const
char
*
cptr
,
const
char
*
end
);
...
...
sql/sql_acl.cc
View file @
1e668717
...
...
@@ -7551,7 +7551,7 @@ bool mysql_show_grants(THD *thd, LEX_USER *lex_user)
}
DBUG_ASSERT
(
rolename
||
username
);
Item_string
*
field
=
new
Item_string
(
""
,
0
,
&
my_charset_latin1
);
Item_string
*
field
=
new
Item_string
_ascii
(
""
,
0
);
List
<
Item
>
field_list
;
field
->
name
=
buff
;
field
->
max_length
=
1024
;
...
...
sql/sql_explain.cc
View file @
1e668717
...
...
@@ -203,15 +203,13 @@ bool Explain_query::print_explain_str(THD *thd, String *out_str)
static
void
push_str
(
List
<
Item
>
*
item_list
,
const
char
*
str
)
{
item_list
->
push_back
(
new
Item_string
(
str
,
strlen
(
str
),
system_charset_info
));
item_list
->
push_back
(
new
Item_string_sys
(
str
));
}
static
void
push_string
(
List
<
Item
>
*
item_list
,
String
*
str
)
{
item_list
->
push_back
(
new
Item_string
(
str
->
ptr
(),
str
->
length
(),
system_charset_info
));
item_list
->
push_back
(
new
Item_string_sys
(
str
->
ptr
(),
str
->
length
()));
}
...
...
@@ -262,8 +260,7 @@ int Explain_union::print_explain(Explain_query *query,
len
+=
lastop
;
table_name_buffer
[
len
-
1
]
=
'>'
;
// change ',' to '>'
}
const
CHARSET_INFO
*
cs
=
system_charset_info
;
item_list
.
push_back
(
new
Item_string
(
table_name_buffer
,
len
,
cs
));
item_list
.
push_back
(
new
Item_string_sys
(
table_name_buffer
,
len
));
}
/* `partitions` column */
...
...
@@ -298,8 +295,7 @@ int Explain_union::print_explain(Explain_query *query,
{
extra_buf
.
append
(
STRING_WITH_LEN
(
"Using filesort"
));
}
const
CHARSET_INFO
*
cs
=
system_charset_info
;
item_list
.
push_back
(
new
Item_string
(
extra_buf
.
ptr
(),
extra_buf
.
length
(),
cs
));
item_list
.
push_back
(
new
Item_string_sys
(
extra_buf
.
ptr
(),
extra_buf
.
length
()));
//output->unit.offset_limit_cnt= 0;
if
(
output
->
send_data
(
item_list
))
...
...
@@ -349,12 +345,10 @@ int Explain_select::print_explain(Explain_query *query,
if
(
message
)
{
List
<
Item
>
item_list
;
const
CHARSET_INFO
*
cs
=
system_charset_info
;
Item
*
item_null
=
new
Item_null
();
item_list
.
push_back
(
new
Item_int
((
int32
)
select_id
));
item_list
.
push_back
(
new
Item_string
(
select_type
,
strlen
(
select_type
),
cs
));
item_list
.
push_back
(
new
Item_string_sys
(
select_type
));
for
(
uint
i
=
0
;
i
<
7
;
i
++
)
item_list
.
push_back
(
item_null
);
if
(
explain_flags
&
DESCRIBE_PARTITIONS
)
...
...
@@ -362,7 +356,7 @@ int Explain_select::print_explain(Explain_query *query,
if
(
explain_flags
&
DESCRIBE_EXTENDED
)
item_list
.
push_back
(
item_null
);
item_list
.
push_back
(
new
Item_string
(
message
,
strlen
(
message
),
cs
));
item_list
.
push_back
(
new
Item_string
_sys
(
message
));
if
(
output
->
send_data
(
item_list
))
return
1
;
...
...
@@ -560,7 +554,7 @@ int Explain_table_access::print_explain(select_result_sink *output, uint8 explai
extra_buf
.
append
(
STRING_WITH_LEN
(
"Using filesort"
));
}
item_list
.
push_back
(
new
Item_string
(
extra_buf
.
ptr
(),
extra_buf
.
length
(),
cs
));
item_list
.
push_back
(
new
Item_string
_sys
(
extra_buf
.
ptr
(),
extra_buf
.
length
()
));
if
(
output
->
send_data
(
item_list
))
return
1
;
...
...
sql/sql_help.cc
View file @
1e668717
...
...
@@ -626,7 +626,7 @@ SQL_SELECT *prepare_select_for_name(THD *thd, const char *mask, uint mlen,
{
Item
*
cond
=
new
Item_func_like
(
new
Item_field
(
pfname
),
new
Item_string
(
mask
,
mlen
,
pfname
->
charset
()),
new
Item_string
(
"
\\
"
,
1
,
&
my_charset_latin1
),
new
Item_string
_ascii
(
"
\\
"
),
FALSE
);
if
(
thd
->
is_fatal_error
)
return
0
;
// OOM
...
...
sql/sql_select.cc
View file @
1e668717
...
...
@@ -22950,13 +22950,11 @@ int print_explain_message_line(select_result_sink *result,
ha_rows
*
rows
,
const
char
*
message
)
{
const
CHARSET_INFO
*
cs
=
system_charset_info
;
Item
*
item_null
=
new
Item_null
();
List
<
Item
>
item_list
;
item_list
.
push_back
(
new
Item_int
((
int32
)
select_number
));
item_list
.
push_back
(
new
Item_string
(
select_type
,
strlen
(
select_type
),
cs
));
item_list
.
push_back
(
new
Item_string_sys
(
select_type
));
/* `table` */
item_list
.
push_back
(
item_null
);
...
...
@@ -22983,7 +22981,7 @@ int print_explain_message_line(select_result_sink *result,
/* `Extra` */
if
(
message
)
item_list
.
push_back
(
new
Item_string
(
message
,
strlen
(
message
),
cs
));
item_list
.
push_back
(
new
Item_string
_sys
(
message
));
else
item_list
.
push_back
(
item_null
);
...
...
@@ -23042,45 +23040,39 @@ int print_explain_row(select_result_sink *result,
ha_rows
*
rows
,
const
char
*
extra
)
{
const
CHARSET_INFO
*
cs
=
system_charset_info
;
Item
*
item_null
=
new
Item_null
();
List
<
Item
>
item_list
;
Item
*
item
;
item_list
.
push_back
(
new
Item_int
((
int32
)
select_number
));
item_list
.
push_back
(
new
Item_string
(
select_type
,
strlen
(
select_type
),
cs
));
item_list
.
push_back
(
new
Item_string
(
table_name
,
strlen
(
table_name
),
cs
));
item_list
.
push_back
(
new
Item_string_sys
(
select_type
));
item_list
.
push_back
(
new
Item_string_sys
(
table_name
));
if
(
options
&
DESCRIBE_PARTITIONS
)
{
if
(
partitions
)
{
item_list
.
push_back
(
new
Item_string
(
partitions
,
strlen
(
partitions
),
cs
));
item_list
.
push_back
(
new
Item_string_sys
(
partitions
));
}
else
item_list
.
push_back
(
item_null
);
}
const
char
*
jtype_str
=
join_type_str
[
jtype
];
item_list
.
push_back
(
new
Item_string
(
jtype_str
,
strlen
(
jtype_str
),
cs
));
item_list
.
push_back
(
new
Item_string_sys
(
jtype_str
));
item
=
possible_keys
?
new
Item_string
(
possible_keys
,
strlen
(
possible_keys
),
cs
)
:
item_null
;
item
=
possible_keys
?
new
Item_string_sys
(
possible_keys
)
:
item_null
;
item_list
.
push_back
(
item
);
/* 'index */
item
=
index
?
new
Item_string
(
index
,
strlen
(
index
),
cs
)
:
item_null
;
item
=
index
?
new
Item_string
_sys
(
index
)
:
item_null
;
item_list
.
push_back
(
item
);
/* 'key_len */
item
=
key_len
?
new
Item_string
(
key_len
,
strlen
(
key_len
),
cs
)
:
item_null
;
item
=
key_len
?
new
Item_string
_sys
(
key_len
)
:
item_null
;
item_list
.
push_back
(
item
);
/* 'ref' */
item
=
ref
?
new
Item_string
(
ref
,
strlen
(
ref
),
cs
)
:
item_null
;
item
=
ref
?
new
Item_string
_sys
(
ref
)
:
item_null
;
item_list
.
push_back
(
item
);
/* 'rows' */
...
...
@@ -23099,7 +23091,7 @@ int print_explain_row(select_result_sink *result,
/* 'Extra' */
if
(
extra
)
item_list
.
push_back
(
new
Item_string
(
extra
,
strlen
(
extra
),
cs
));
item_list
.
push_back
(
new
Item_string
_sys
(
extra
));
else
item_list
.
push_back
(
item_null
);
...
...
@@ -23112,7 +23104,6 @@ int print_explain_row(select_result_sink *result,
int
print_fake_select_lex_join
(
select_result_sink
*
result
,
bool
on_the_fly
,
SELECT_LEX
*
select_lex
,
uint8
explain_flags
)
{
const
CHARSET_INFO
*
cs
=
system_charset_info
;
Item
*
item_null
=
new
Item_null
();
List
<
Item
>
item_list
;
if
(
on_the_fly
)
...
...
@@ -23129,9 +23120,7 @@ int print_fake_select_lex_join(select_result_sink *result, bool on_the_fly,
/* id */
item_list
.
push_back
(
new
Item_null
);
/* select_type */
item_list
.
push_back
(
new
Item_string
(
select_lex
->
type
,
strlen
(
select_lex
->
type
),
cs
));
item_list
.
push_back
(
new
Item_string_sys
(
select_lex
->
type
));
/* table */
{
SELECT_LEX
*
sl
=
select_lex
->
master_unit
()
->
first_select
();
...
...
@@ -23153,15 +23142,14 @@ int print_fake_select_lex_join(select_result_sink *result, bool on_the_fly,
len
+=
lastop
;
table_name_buffer
[
len
-
1
]
=
'>'
;
// change ',' to '>'
}
item_list
.
push_back
(
new
Item_string
(
table_name_buffer
,
len
,
cs
));
item_list
.
push_back
(
new
Item_string
_sys
(
table_name_buffer
,
len
));
}
/* partitions */
if
(
explain_flags
&
DESCRIBE_PARTITIONS
)
item_list
.
push_back
(
item_null
);
/* type */
item_list
.
push_back
(
new
Item_string
(
join_type_str
[
JT_ALL
],
strlen
(
join_type_str
[
JT_ALL
]),
cs
));
item_list
.
push_back
(
new
Item_string_sys
(
join_type_str
[
JT_ALL
]));
/* possible_keys */
item_list
.
push_back
(
item_null
);
/* key*/
...
...
@@ -23177,10 +23165,9 @@ int print_fake_select_lex_join(select_result_sink *result, bool on_the_fly,
item_list
.
push_back
(
item_null
);
/* extra */
if
(
select_lex
->
master_unit
()
->
global_parameters
->
order_list
.
first
)
item_list
.
push_back
(
new
Item_string
(
"Using filesort"
,
14
,
cs
));
item_list
.
push_back
(
new
Item_string_sys
(
"Using filesort"
,
14
));
else
item_list
.
push_back
(
new
Item_string
(
""
,
0
,
cs
));
item_list
.
push_back
(
new
Item_string
_sys
(
""
,
0
));
if
(
result
->
send_data
(
item_list
))
return
1
;
...
...
sql/sql_yacc.yy
View file @
1e668717
...
...
@@ -11124,8 +11124,8 @@ opt_escape:
{
Lex->escape_used= FALSE;
$$= ((thd->variables.sql_mode & MODE_NO_BACKSLASH_ESCAPES) ?
new (thd->mem_root) Item_string
("", 0, &my_charset_latin1
) :
new (thd->mem_root) Item_string
("\\", 1, &my_charset_latin
1));
new (thd->mem_root) Item_string
_ascii("", 0
) :
new (thd->mem_root) Item_string
_ascii("\\",
1));
if ($$ == NULL)
MYSQL_YYABORT;
}
...
...
@@ -14792,19 +14792,19 @@ set_expr_or_default:
| DEFAULT { $$=0; }
| ON
{
$$=new (thd->mem_root) Item_string
("ON", 2, system_charset_info
);
$$=new (thd->mem_root) Item_string
_sys("ON", 2
);
if ($$ == NULL)
MYSQL_YYABORT;
}
| ALL
{
$$=new (thd->mem_root) Item_string
("ALL", 3, system_charset_info
);
$$=new (thd->mem_root) Item_string
_sys("ALL", 3
);
if ($$ == NULL)
MYSQL_YYABORT;
}
| BINARY
{
$$=new (thd->mem_root) Item_string
("binary", 6, system_charset_info
);
$$=new (thd->mem_root) Item_string
_sys("binary", 6
);
if ($$ == NULL)
MYSQL_YYABORT;
}
...
...
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