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
db9b5f33
Commit
db9b5f33
authored
Jul 15, 2003
by
unknown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ELT passes the first argument in args[0] instead of having a separate Item.
parent
4b3eecf4
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
14 additions
and
58 deletions
+14
-58
mysql-test/r/func_str.result
mysql-test/r/func_str.result
+2
-2
mysql-test/t/func_str.test
mysql-test/t/func_str.test
+2
-2
sql/item_strfunc.cc
sql/item_strfunc.cc
+8
-36
sql/item_strfunc.h
sql/item_strfunc.h
+1
-17
sql/sql_yacc.yy
sql/sql_yacc.yy
+1
-1
No files found.
mysql-test/r/func_str.result
View file @
db9b5f33
...
@@ -297,9 +297,9 @@ select FIELD('b','A' COLLATE latin1_bin,'B');
...
@@ -297,9 +297,9 @@ select FIELD('b','A' COLLATE latin1_bin,'B');
FIELD('b','A' COLLATE latin1_bin,'B')
FIELD('b','A' COLLATE latin1_bin,'B')
0
0
select FIELD(_latin2'b','A','B');
select FIELD(_latin2'b','A','B');
Illegal mix of collations (latin2_general_ci,COERCIBLE), (latin1_swedish_ci,COERCIBLE), (latin1_swedish_ci,COERCIBLE) for operation 'field'
ERROR HY000:
Illegal mix of collations (latin2_general_ci,COERCIBLE), (latin1_swedish_ci,COERCIBLE), (latin1_swedish_ci,COERCIBLE) for operation 'field'
select FIELD('b',_latin2'A','B');
select FIELD('b',_latin2'A','B');
Illegal mix of collations (latin1_swedish_ci,COERCIBLE), (latin2_general_ci,COERCIBLE), (latin1_swedish_ci,COERCIBLE) for operation 'field'
ERROR HY000:
Illegal mix of collations (latin1_swedish_ci,COERCIBLE), (latin2_general_ci,COERCIBLE), (latin1_swedish_ci,COERCIBLE) for operation 'field'
select FIELD('b',_latin2'A','B',1);
select FIELD('b',_latin2'A','B',1);
FIELD('b',_latin2'A','B',1)
FIELD('b',_latin2'A','B',1)
1
1
...
...
mysql-test/t/func_str.test
View file @
db9b5f33
...
@@ -167,9 +167,9 @@ select FIELD('b','A','B');
...
@@ -167,9 +167,9 @@ select FIELD('b','A','B');
select
FIELD
(
'B'
,
'A'
,
'B'
);
select
FIELD
(
'B'
,
'A'
,
'B'
);
select
FIELD
(
'b'
COLLATE
latin1_bin
,
'A'
,
'B'
);
select
FIELD
(
'b'
COLLATE
latin1_bin
,
'A'
,
'B'
);
select
FIELD
(
'b'
,
'A'
COLLATE
latin1_bin
,
'B'
);
select
FIELD
(
'b'
,
'A'
COLLATE
latin1_bin
,
'B'
);
--
error
126
5
--
error
126
8
select
FIELD
(
_latin2
'b'
,
'A'
,
'B'
);
select
FIELD
(
_latin2
'b'
,
'A'
,
'B'
);
--
error
126
5
--
error
126
8
select
FIELD
(
'b'
,
_latin2
'A'
,
'B'
);
select
FIELD
(
'b'
,
_latin2
'A'
,
'B'
);
select
FIELD
(
'b'
,
_latin2
'A'
,
'B'
,
1
);
select
FIELD
(
'b'
,
_latin2
'A'
,
'B'
,
1
);
...
...
sql/item_strfunc.cc
View file @
db9b5f33
...
@@ -1660,81 +1660,53 @@ void Item_func_elt::fix_length_and_dec()
...
@@ -1660,81 +1660,53 @@ void Item_func_elt::fix_length_and_dec()
max_length
=
0
;
max_length
=
0
;
decimals
=
0
;
decimals
=
0
;
if
(
agg_arg_collations
(
collation
,
args
,
arg_count
))
if
(
agg_arg_collations
(
collation
,
args
+
1
,
arg_count
-
1
))
return
;
return
;
for
(
uint
i
=
0
;
i
<
arg_count
;
i
++
)
for
(
uint
i
=
1
;
i
<
arg_count
;
i
++
)
{
{
set_if_bigger
(
max_length
,
args
[
i
]
->
max_length
);
set_if_bigger
(
max_length
,
args
[
i
]
->
max_length
);
set_if_bigger
(
decimals
,
args
[
i
]
->
decimals
);
set_if_bigger
(
decimals
,
args
[
i
]
->
decimals
);
}
}
maybe_null
=
1
;
// NULL if wrong first arg
maybe_null
=
1
;
// NULL if wrong first arg
with_sum_func
=
with_sum_func
||
item
->
with_sum_func
;
used_tables_cache
|=
item
->
used_tables
();
const_item_cache
&=
item
->
const_item
();
}
void
Item_func_elt
::
split_sum_func
(
Item
**
ref_pointer_array
,
List
<
Item
>
&
fields
)
{
if
(
item
->
with_sum_func
&&
item
->
type
()
!=
SUM_FUNC_ITEM
)
item
->
split_sum_func
(
ref_pointer_array
,
fields
);
else
if
(
item
->
used_tables
()
||
item
->
type
()
==
SUM_FUNC_ITEM
)
{
uint
el
=
fields
.
elements
;
fields
.
push_front
(
item
);
ref_pointer_array
[
el
]
=
item
;
item
=
new
Item_ref
(
ref_pointer_array
+
el
,
0
,
item
->
name
);
}
Item_str_func
::
split_sum_func
(
ref_pointer_array
,
fields
);
}
void
Item_func_elt
::
update_used_tables
()
{
Item_func
::
update_used_tables
();
item
->
update_used_tables
();
used_tables_cache
|=
item
->
used_tables
();
const_item_cache
&=
item
->
const_item
();
}
}
double
Item_func_elt
::
val
()
double
Item_func_elt
::
val
()
{
{
uint
tmp
;
uint
tmp
;
if
((
tmp
=
(
uint
)
item
->
val_int
())
==
0
||
tmp
>
arg_count
)
if
((
tmp
=
(
uint
)
args
[
0
]
->
val_int
())
==
0
||
tmp
>=
arg_count
)
{
{
null_value
=
1
;
null_value
=
1
;
return
0.0
;
return
0.0
;
}
}
null_value
=
0
;
null_value
=
0
;
return
args
[
tmp
-
1
]
->
val
();
return
args
[
tmp
]
->
val
();
}
}
longlong
Item_func_elt
::
val_int
()
longlong
Item_func_elt
::
val_int
()
{
{
uint
tmp
;
uint
tmp
;
if
((
tmp
=
(
uint
)
item
->
val_int
())
==
0
||
tmp
>
arg_count
)
if
((
tmp
=
(
uint
)
args
[
0
]
->
val_int
())
==
0
||
tmp
>=
arg_count
)
{
{
null_value
=
1
;
null_value
=
1
;
return
0
;
return
0
;
}
}
null_value
=
0
;
null_value
=
0
;
return
args
[
tmp
-
1
]
->
val_int
();
return
args
[
tmp
]
->
val_int
();
}
}
String
*
Item_func_elt
::
val_str
(
String
*
str
)
String
*
Item_func_elt
::
val_str
(
String
*
str
)
{
{
uint
tmp
;
uint
tmp
;
String
*
res
;
String
*
res
;
if
((
tmp
=
(
uint
)
item
->
val_int
())
==
0
||
tmp
>
arg_count
)
if
((
tmp
=
(
uint
)
args
[
0
]
->
val_int
())
==
0
||
tmp
>=
arg_count
)
{
{
null_value
=
1
;
null_value
=
1
;
return
NULL
;
return
NULL
;
}
}
null_value
=
0
;
null_value
=
0
;
res
=
args
[
tmp
-
1
]
->
val_str
(
str
);
res
=
args
[
tmp
]
->
val_str
(
str
);
res
->
set_charset
(
charset
());
res
->
set_charset
(
charset
());
return
res
;
return
res
;
}
}
...
...
sql/item_strfunc.h
View file @
db9b5f33
...
@@ -372,29 +372,13 @@ class Item_func_soundex :public Item_str_func
...
@@ -372,29 +372,13 @@ class Item_func_soundex :public Item_str_func
class
Item_func_elt
:
public
Item_str_func
class
Item_func_elt
:
public
Item_str_func
{
{
Item
*
item
;
public:
public:
Item_func_elt
(
Item
*
a
,
List
<
Item
>
&
list
)
:
Item_str_func
(
list
),
item
(
a
)
{}
Item_func_elt
(
List
<
Item
>
&
list
)
:
Item_str_func
(
list
)
{}
~
Item_func_elt
()
{
delete
item
;
}
double
val
();
double
val
();
longlong
val_int
();
longlong
val_int
();
String
*
val_str
(
String
*
str
);
String
*
val_str
(
String
*
str
);
bool
fix_fields
(
THD
*
thd
,
TABLE_LIST
*
tlist
,
Item
**
ref
)
{
return
(
item
->
fix_fields
(
thd
,
tlist
,
&
item
)
||
item
->
check_cols
(
1
)
||
Item_func
::
fix_fields
(
thd
,
tlist
,
ref
));
}
void
split_sum_func
(
Item
**
ref_pointer_array
,
List
<
Item
>
&
fields
);
void
fix_length_and_dec
();
void
fix_length_and_dec
();
void
update_used_tables
();
const
char
*
func_name
()
const
{
return
"elt"
;
}
const
char
*
func_name
()
const
{
return
"elt"
;
}
void
set_outer_resolving
()
{
item
->
set_outer_resolving
();
Item_str_func
::
set_outer_resolving
();
}
};
};
...
...
sql/sql_yacc.yy
View file @
db9b5f33
...
@@ -2389,7 +2389,7 @@ simple_expr:
...
@@ -2389,7 +2389,7 @@ simple_expr:
| DAY_SYM '(' expr ')'
| DAY_SYM '(' expr ')'
{ $$= new Item_func_dayofmonth($3); }
{ $$= new Item_func_dayofmonth($3); }
| ELT_FUNC '(' expr ',' expr_list ')'
| ELT_FUNC '(' expr ',' expr_list ')'
{ $
$= new Item_func_elt($3,
*$5); }
{ $
5->push_front($3); $$= new Item_func_elt(
*$5); }
| MAKE_SET_SYM '(' expr ',' expr_list ')'
| MAKE_SET_SYM '(' expr ',' expr_list ')'
{ $$= new Item_func_make_set($3, *$5); }
{ $$= new Item_func_make_set($3, *$5); }
| ENCRYPT '(' expr ')'
| ENCRYPT '(' expr ')'
...
...
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