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
8c8553af
Commit
8c8553af
authored
Feb 04, 2005
by
jimw@mysql.com
Browse files
Options
Browse Files
Download
Plain Diff
Merge changes
parents
d017a604
bd9239d4
Changes
21
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
21 changed files
with
334 additions
and
188 deletions
+334
-188
client/mysqlcheck.c
client/mysqlcheck.c
+1
-1
include/ft_global.h
include/ft_global.h
+1
-1
myisam/ft_boolean_search.c
myisam/ft_boolean_search.c
+4
-3
myisam/ft_static.c
myisam/ft_static.c
+3
-2
myisam/ftdefs.h
myisam/ftdefs.h
+1
-1
mysql-test/r/func_group.result
mysql-test/r/func_group.result
+12
-0
mysql-test/r/insert_select.result.es
mysql-test/r/insert_select.result.es
+12
-0
mysql-test/r/type_date.result
mysql-test/r/type_date.result
+8
-0
mysql-test/r/union.result
mysql-test/r/union.result
+36
-0
mysql-test/t/func_group.test
mysql-test/t/func_group.test
+14
-0
mysql-test/t/type_date.test
mysql-test/t/type_date.test
+7
-0
mysql-test/t/union.test
mysql-test/t/union.test
+35
-0
scripts/make_binary_distribution.sh
scripts/make_binary_distribution.sh
+1
-1
sql/field.cc
sql/field.cc
+35
-0
sql/field.h
sql/field.h
+87
-154
sql/ha_myisam.h
sql/ha_myisam.h
+6
-2
sql/handler.h
sql/handler.h
+1
-2
sql/item.cc
sql/item.cc
+53
-12
sql/item.h
sql/item.h
+2
-2
sql/item_func.cc
sql/item_func.cc
+3
-5
sql/sql_union.cc
sql/sql_union.cc
+12
-2
No files found.
client/mysqlcheck.c
View file @
8c8553af
...
@@ -195,7 +195,7 @@ static void usage(void)
...
@@ -195,7 +195,7 @@ static void usage(void)
puts
(
"and you are welcome to modify and redistribute it under the GPL license.
\n
"
);
puts
(
"and you are welcome to modify and redistribute it under the GPL license.
\n
"
);
puts
(
"This program can be used to CHECK (-c,-m,-C), REPAIR (-r), ANALYZE (-a)"
);
puts
(
"This program can be used to CHECK (-c,-m,-C), REPAIR (-r), ANALYZE (-a)"
);
puts
(
"or OPTIMIZE (-o) tables. Some of the options (like -e or -q) can be"
);
puts
(
"or OPTIMIZE (-o) tables. Some of the options (like -e or -q) can be"
);
puts
(
"used at the same time.
It works on MyISAM and in some cases on BDB tabl
es."
);
puts
(
"used at the same time.
Not all options are supported by all storage engin
es."
);
puts
(
"Please consult the MySQL manual for latest information about the"
);
puts
(
"Please consult the MySQL manual for latest information about the"
);
puts
(
"above. The options -c,-r,-a and -o are exclusive to each other, which"
);
puts
(
"above. The options -c,-r,-a and -o are exclusive to each other, which"
);
puts
(
"means that the last option will be used, if several was specified.
\n
"
);
puts
(
"means that the last option will be used, if several was specified.
\n
"
);
...
...
include/ft_global.h
View file @
8c8553af
...
@@ -62,7 +62,7 @@ void ft_free_stopwords(void);
...
@@ -62,7 +62,7 @@ void ft_free_stopwords(void);
#define FT_SORTED 2
#define FT_SORTED 2
#define FT_EXPAND 4
/* query expansion */
#define FT_EXPAND 4
/* query expansion */
FT_INFO
*
ft_init_search
(
uint
,
void
*
,
uint
,
byte
*
,
uint
,
byte
*
);
FT_INFO
*
ft_init_search
(
uint
,
void
*
,
uint
,
byte
*
,
uint
,
CHARSET_INFO
*
,
byte
*
);
my_bool
ft_boolean_check_syntax_string
(
const
byte
*
);
my_bool
ft_boolean_check_syntax_string
(
const
byte
*
);
#ifdef __cplusplus
#ifdef __cplusplus
...
...
myisam/ft_boolean_search.c
View file @
8c8553af
...
@@ -366,6 +366,7 @@ static void _ftb_init_index_search(FT_INFO *ftb)
...
@@ -366,6 +366,7 @@ static void _ftb_init_index_search(FT_INFO *ftb)
reset_tree
(
&
ftb
->
no_dupes
);
reset_tree
(
&
ftb
->
no_dupes
);
}
}
ftbw
->
off
=
0
;
/* in case of reinit */
if
(
_ft2_search
(
ftb
,
ftbw
,
1
))
if
(
_ft2_search
(
ftb
,
ftbw
,
1
))
return
;
return
;
}
}
...
@@ -374,7 +375,7 @@ static void _ftb_init_index_search(FT_INFO *ftb)
...
@@ -374,7 +375,7 @@ static void _ftb_init_index_search(FT_INFO *ftb)
FT_INFO
*
ft_init_boolean_search
(
MI_INFO
*
info
,
uint
keynr
,
byte
*
query
,
FT_INFO
*
ft_init_boolean_search
(
MI_INFO
*
info
,
uint
keynr
,
byte
*
query
,
uint
query_len
)
uint
query_len
,
CHARSET_INFO
*
cs
)
{
{
FTB
*
ftb
;
FTB
*
ftb
;
FTB_EXPR
*
ftbe
;
FTB_EXPR
*
ftbe
;
...
@@ -386,8 +387,8 @@ FT_INFO * ft_init_boolean_search(MI_INFO *info, uint keynr, byte *query,
...
@@ -386,8 +387,8 @@ FT_INFO * ft_init_boolean_search(MI_INFO *info, uint keynr, byte *query,
ftb
->
state
=
UNINITIALIZED
;
ftb
->
state
=
UNINITIALIZED
;
ftb
->
info
=
info
;
ftb
->
info
=
info
;
ftb
->
keynr
=
keynr
;
ftb
->
keynr
=
keynr
;
ftb
->
charset
=
((
keynr
==
NO_SUCH_KEY
)
?
ftb
->
charset
=
cs
;
default_charset_info
:
info
->
s
->
keyinfo
[
keynr
].
seg
->
charset
);
DBUG_ASSERT
(
keynr
==
NO_SUCH_KEY
||
cs
==
info
->
s
->
keyinfo
[
keynr
].
seg
->
charset
);
ftb
->
with_scan
=
0
;
ftb
->
with_scan
=
0
;
ftb
->
lastpos
=
HA_OFFSET_ERROR
;
ftb
->
lastpos
=
HA_OFFSET_ERROR
;
bzero
(
&
ftb
->
no_dupes
,
sizeof
(
TREE
));
bzero
(
&
ftb
->
no_dupes
,
sizeof
(
TREE
));
...
...
myisam/ft_static.c
View file @
8c8553af
...
@@ -57,11 +57,12 @@ const struct _ft_vft _ft_vft_boolean = {
...
@@ -57,11 +57,12 @@ const struct _ft_vft _ft_vft_boolean = {
FT_INFO
*
ft_init_search
(
uint
flags
,
void
*
info
,
uint
keynr
,
FT_INFO
*
ft_init_search
(
uint
flags
,
void
*
info
,
uint
keynr
,
byte
*
query
,
uint
query_len
,
byte
*
record
)
byte
*
query
,
uint
query_len
,
CHARSET_INFO
*
cs
,
byte
*
record
)
{
{
FT_INFO
*
res
;
FT_INFO
*
res
;
if
(
flags
&
FT_BOOL
)
if
(
flags
&
FT_BOOL
)
res
=
ft_init_boolean_search
((
MI_INFO
*
)
info
,
keynr
,
query
,
query_len
);
res
=
ft_init_boolean_search
((
MI_INFO
*
)
info
,
keynr
,
query
,
query_len
,
cs
);
else
else
res
=
ft_init_nlq_search
((
MI_INFO
*
)
info
,
keynr
,
query
,
query_len
,
flags
,
res
=
ft_init_nlq_search
((
MI_INFO
*
)
info
,
keynr
,
query
,
query_len
,
flags
,
record
);
record
);
...
...
myisam/ftdefs.h
View file @
8c8553af
...
@@ -131,7 +131,7 @@ FT_WORD * _mi_ft_parserecord(MI_INFO *, uint, const byte *);
...
@@ -131,7 +131,7 @@ FT_WORD * _mi_ft_parserecord(MI_INFO *, uint, const byte *);
uint
_mi_ft_parse
(
TREE
*
,
MI_INFO
*
,
uint
,
const
byte
*
,
my_bool
);
uint
_mi_ft_parse
(
TREE
*
,
MI_INFO
*
,
uint
,
const
byte
*
,
my_bool
);
FT_INFO
*
ft_init_nlq_search
(
MI_INFO
*
,
uint
,
byte
*
,
uint
,
uint
,
byte
*
);
FT_INFO
*
ft_init_nlq_search
(
MI_INFO
*
,
uint
,
byte
*
,
uint
,
uint
,
byte
*
);
FT_INFO
*
ft_init_boolean_search
(
MI_INFO
*
,
uint
,
byte
*
,
uint
);
FT_INFO
*
ft_init_boolean_search
(
MI_INFO
*
,
uint
,
byte
*
,
uint
,
CHARSET_INFO
*
);
extern
const
struct
_ft_vft
_ft_vft_nlq
;
extern
const
struct
_ft_vft
_ft_vft_nlq
;
int
ft_nlq_read_next
(
FT_INFO
*
,
char
*
);
int
ft_nlq_read_next
(
FT_INFO
*
,
char
*
);
...
...
mysql-test/r/func_group.result
View file @
8c8553af
...
@@ -737,3 +737,15 @@ one 2
...
@@ -737,3 +737,15 @@ one 2
two 2
two 2
three 1
three 1
drop table t1;
drop table t1;
create table t1(f1 datetime);
insert into t1 values (now());
create table t2 select f2 from (select max(now()) f2 from t1) a;
show columns from t2;
Field Type Null Key Default Extra
f2 datetime 0000-00-00 00:00:00
drop table t2;
create table t2 select f2 from (select now() f2 from t1) a;
show columns from t2;
Field Type Null Key Default Extra
f2 datetime 0000-00-00 00:00:00
drop table t2, t1;
mysql-test/r/insert_select.result.es
View file @
8c8553af
...
@@ -633,3 +633,15 @@ No Field Count
...
@@ -633,3 +633,15 @@ No Field Count
0 1 100
0 1 100
0 2 100
0 2 100
drop table t1, t2;
drop table t1, t2;
CREATE TABLE t1 (
ID int(11) NOT NULL auto_increment,
NO int(11) NOT NULL default '0',
SEQ int(11) NOT NULL default '0',
PRIMARY KEY (ID),
KEY t1$NO (SEQ,NO)
) ENGINE=MyISAM;
INSERT INTO t1 (SEQ, NO) SELECT "1" AS SEQ, IF(MAX(NO) IS NULL, 0, MAX(NO)) + 1 AS NO FROM t1 WHERE (SEQ = 1);
select SQL_BUFFER_RESULT * from t1 WHERE (SEQ = 1);
ID NO SEQ
1 1 1
drop table t1;
mysql-test/r/type_date.result
View file @
8c8553af
...
@@ -96,3 +96,11 @@ f2
...
@@ -96,3 +96,11 @@ f2
19781126
19781126
19781126
19781126
DROP TABLE t1, t2, t3;
DROP TABLE t1, t2, t3;
CREATE TABLE t1 (y YEAR);
INSERT INTO t1 VALUES ('abc');
Warnings:
Warning 1265 Data truncated for column 'y' at row 1
SELECT * FROM t1;
y
0000
DROP TABLE t1;
mysql-test/r/union.result
View file @
8c8553af
...
@@ -1137,3 +1137,39 @@ t1 CREATE TABLE `t1` (
...
@@ -1137,3 +1137,39 @@ t1 CREATE TABLE `t1` (
) ENGINE=MyISAM DEFAULT CHARSET=latin1
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
drop table t1;
drop table t2;
drop table t2;
create table t1(a1 int, f1 char(10));
create table t2
select f2,a1 from (select a1, CAST('2004-12-31' AS DATE) f2 from t1) a
union
select f2,a1 from (select a1, CAST('2004-12-31' AS DATE) f2 from t1) a
order by f2, a1;
show columns from t2;
Field Type Null Key Default Extra
f2 date YES NULL
a1 int(11) YES NULL
drop table t1, t2;
create table t1 (f1 int);
create table t2 (f1 int, f2 int ,f3 date);
create table t3 (f1 int, f2 char(10));
create table t4
(
select t2.f3 as sdate
from t1
left outer join t2 on (t1.f1 = t2.f1)
inner join t3 on (t2.f2 = t3.f1)
order by t1.f1, t3.f1, t2.f3
)
union
(
select cast('2004-12-31' as date) as sdate
from t1
left outer join t2 on (t1.f1 = t2.f1)
inner join t3 on (t2.f2 = t3.f1)
group by t1.f1
order by t1.f1, t3.f1, t2.f3
)
order by sdate;
show columns from t4;
Field Type Null Key Default Extra
sdate date YES NULL
drop table t1, t2, t3, t4;
mysql-test/t/func_group.test
View file @
8c8553af
...
@@ -473,3 +473,17 @@ INSERT INTO t1 VALUES
...
@@ -473,3 +473,17 @@ INSERT INTO t1 VALUES
select
val
,
count
(
*
)
from
t1
group
by
val
;
select
val
,
count
(
*
)
from
t1
group
by
val
;
drop
table
t1
;
drop
table
t1
;
#
# Bug 7833: Wrong datatype of aggregate column is returned
#
create
table
t1
(
f1
datetime
);
insert
into
t1
values
(
now
());
create
table
t2
select
f2
from
(
select
max
(
now
())
f2
from
t1
)
a
;
show
columns
from
t2
;
drop
table
t2
;
create
table
t2
select
f2
from
(
select
now
()
f2
from
t1
)
a
;
show
columns
from
t2
;
drop
table
t2
,
t1
;
mysql-test/t/type_date.test
View file @
8c8553af
...
@@ -107,3 +107,10 @@ SELECT * FROM t2;
...
@@ -107,3 +107,10 @@ SELECT * FROM t2;
SELECT
*
FROM
t3
;
SELECT
*
FROM
t3
;
DROP
TABLE
t1
,
t2
,
t3
;
DROP
TABLE
t1
,
t2
,
t3
;
# Test that setting YEAR to invalid string results in default value, not
# 2000. (Bug #6067)
CREATE
TABLE
t1
(
y
YEAR
);
INSERT
INTO
t1
VALUES
(
'abc'
);
SELECT
*
FROM
t1
;
DROP
TABLE
t1
;
mysql-test/t/union.test
View file @
8c8553af
...
@@ -682,3 +682,38 @@ show create table t1;
...
@@ -682,3 +682,38 @@ show create table t1;
drop
table
t1
;
drop
table
t1
;
drop
table
t2
;
drop
table
t2
;
#
# Bug 6931: Date Type column problem when using UNION-Table.
#
create
table
t1
(
a1
int
,
f1
char
(
10
));
create
table
t2
select
f2
,
a1
from
(
select
a1
,
CAST
(
'2004-12-31'
AS
DATE
)
f2
from
t1
)
a
union
select
f2
,
a1
from
(
select
a1
,
CAST
(
'2004-12-31'
AS
DATE
)
f2
from
t1
)
a
order
by
f2
,
a1
;
show
columns
from
t2
;
drop
table
t1
,
t2
;
create
table
t1
(
f1
int
);
create
table
t2
(
f1
int
,
f2
int
,
f3
date
);
create
table
t3
(
f1
int
,
f2
char
(
10
));
create
table
t4
(
select
t2
.
f3
as
sdate
from
t1
left
outer
join
t2
on
(
t1
.
f1
=
t2
.
f1
)
inner
join
t3
on
(
t2
.
f2
=
t3
.
f1
)
order
by
t1
.
f1
,
t3
.
f1
,
t2
.
f3
)
union
(
select
cast
(
'2004-12-31'
as
date
)
as
sdate
from
t1
left
outer
join
t2
on
(
t1
.
f1
=
t2
.
f1
)
inner
join
t3
on
(
t2
.
f2
=
t3
.
f1
)
group
by
t1
.
f1
order
by
t1
.
f1
,
t3
.
f1
,
t2
.
f3
)
order
by
sdate
;
show
columns
from
t4
;
drop
table
t1
,
t2
,
t3
,
t4
;
scripts/make_binary_distribution.sh
View file @
8c8553af
...
@@ -221,7 +221,7 @@ $CP mysql-test/std_data/*.dat mysql-test/std_data/*.frm \
...
@@ -221,7 +221,7 @@ $CP mysql-test/std_data/*.dat mysql-test/std_data/*.frm \
mysql-test/std_data/des_key_file mysql-test/std_data/
*
.
*
001
\
mysql-test/std_data/des_key_file mysql-test/std_data/
*
.
*
001
\
$BASE
/mysql-test/std_data
$BASE
/mysql-test/std_data
$CP
mysql-test/t/
*
test
mysql-test/t/
*
.opt mysql-test/t/
*
.slave-mi mysql-test/t/
*
.sh
$BASE
/mysql-test/t
$CP
mysql-test/t/
*
test
mysql-test/t/
*
.opt mysql-test/t/
*
.slave-mi mysql-test/t/
*
.sh
$BASE
/mysql-test/t
$CP
mysql-test/r/
*
result mysql-test/r/
*
.require
$BASE
/mysql-test/r
$CP
mysql-test/r/
*
result mysql-test/r/
*
result.es mysql-test/r/
*
.require
$BASE
/mysql-test/r
if
[
$BASE_SYSTEM
!=
"netware"
]
;
then
if
[
$BASE_SYSTEM
!=
"netware"
]
;
then
chmod
a+x
$BASE
/bin/
*
chmod
a+x
$BASE
/bin/
*
...
...
sql/field.cc
View file @
8c8553af
...
@@ -261,6 +261,7 @@ static Field::field_cast_enum field_cast_date[]=
...
@@ -261,6 +261,7 @@ static Field::field_cast_enum field_cast_date[]=
Field
::
FIELD_CAST_BLOB
,
Field
::
FIELD_CAST_STOP
};
Field
::
FIELD_CAST_BLOB
,
Field
::
FIELD_CAST_STOP
};
static
Field
::
field_cast_enum
field_cast_newdate
[]
=
static
Field
::
field_cast_enum
field_cast_newdate
[]
=
{
Field
::
FIELD_CAST_NEWDATE
,
{
Field
::
FIELD_CAST_NEWDATE
,
Field
::
FIELD_CAST_DATE
,
Field
::
FIELD_CAST_DATETIME
,
Field
::
FIELD_CAST_DATETIME
,
Field
::
FIELD_CAST_STRING
,
Field
::
FIELD_CAST_VARSTRING
,
Field
::
FIELD_CAST_STRING
,
Field
::
FIELD_CAST_VARSTRING
,
Field
::
FIELD_CAST_BLOB
,
Field
::
FIELD_CAST_STOP
};
Field
::
FIELD_CAST_BLOB
,
Field
::
FIELD_CAST_STOP
};
...
@@ -6834,6 +6835,40 @@ Field *make_field(char *ptr, uint32 field_length,
...
@@ -6834,6 +6835,40 @@ Field *make_field(char *ptr, uint32 field_length,
}
}
/*
Check if field_type is appropriate field type
to create field for tmp table using
item->tmp_table_field() method
SYNOPSIS
field_types_to_be_kept()
field_type - field type
NOTE
it is used in function get_holder_example_field()
from item.cc
RETURN
1 - can use item->tmp_table_field() method
0 - can not use item->tmp_table_field() method
*/
bool
field_types_to_be_kept
(
enum_field_types
field_type
)
{
switch
(
field_type
)
{
case
FIELD_TYPE_DATE
:
case
FIELD_TYPE_NEWDATE
:
case
FIELD_TYPE_TIME
:
case
FIELD_TYPE_DATETIME
:
return
1
;
default:
return
0
;
}
}
/* Create a field suitable for create of table */
/* Create a field suitable for create of table */
create_field
::
create_field
(
Field
*
old_field
,
Field
*
orig_field
)
create_field
::
create_field
(
Field
*
old_field
,
Field
*
orig_field
)
...
...
sql/field.h
View file @
8c8553af
This diff is collapsed.
Click to expand it.
sql/ha_myisam.h
View file @
8c8553af
...
@@ -88,8 +88,12 @@ class ha_myisam: public handler
...
@@ -88,8 +88,12 @@ class ha_myisam: public handler
ft_handler
->
please
->
reinit_search
(
ft_handler
);
ft_handler
->
please
->
reinit_search
(
ft_handler
);
return
0
;
return
0
;
}
}
FT_INFO
*
ft_init_ext
(
uint
flags
,
uint
inx
,
const
byte
*
key
,
uint
keylen
)
FT_INFO
*
ft_init_ext
(
uint
flags
,
uint
inx
,
String
*
key
)
{
return
ft_init_search
(
flags
,
file
,
inx
,(
byte
*
)
key
,
keylen
,
table
->
record
[
0
]);
}
{
return
ft_init_search
(
flags
,
file
,
inx
,
(
byte
*
)
key
->
ptr
(),
key
->
length
(),
key
->
charset
(),
table
->
record
[
0
]);
}
int
ft_read
(
byte
*
buf
);
int
ft_read
(
byte
*
buf
);
int
rnd_init
(
bool
scan
);
int
rnd_init
(
bool
scan
);
int
rnd_next
(
byte
*
buf
);
int
rnd_next
(
byte
*
buf
);
...
...
sql/handler.h
View file @
8c8553af
...
@@ -455,8 +455,7 @@ class handler :public Sql_alloc
...
@@ -455,8 +455,7 @@ class handler :public Sql_alloc
int
compare_key
(
key_range
*
range
);
int
compare_key
(
key_range
*
range
);
virtual
int
ft_init
()
{
return
HA_ERR_WRONG_COMMAND
;
}
virtual
int
ft_init
()
{
return
HA_ERR_WRONG_COMMAND
;
}
void
ft_end
()
{
ft_handler
=
NULL
;
}
void
ft_end
()
{
ft_handler
=
NULL
;
}
virtual
FT_INFO
*
ft_init_ext
(
uint
flags
,
uint
inx
,
const
byte
*
key
,
virtual
FT_INFO
*
ft_init_ext
(
uint
flags
,
uint
inx
,
String
*
key
)
uint
keylen
)
{
return
NULL
;
}
{
return
NULL
;
}
virtual
int
ft_read
(
byte
*
buf
)
{
return
HA_ERR_WRONG_COMMAND
;
}
virtual
int
ft_read
(
byte
*
buf
)
{
return
HA_ERR_WRONG_COMMAND
;
}
virtual
int
rnd_next
(
byte
*
buf
)
=
0
;
virtual
int
rnd_next
(
byte
*
buf
)
=
0
;
...
...
sql/item.cc
View file @
8c8553af
...
@@ -3633,7 +3633,53 @@ void Item_cache_row::bring_value()
...
@@ -3633,7 +3633,53 @@ void Item_cache_row::bring_value()
}
}
Item_type_holder
::
Item_type_holder
(
THD
*
thd
,
Item
*
item
)
/*
Returns field for temporary table dependind on item type
SYNOPSIS
get_holder_example_field()
thd - thread handler
item - pointer to item
table - empty table object
NOTE
It is possible to return field for Item_func
items only if field type of this item is
date or time or datetime type.
also see function field_types_to_be_kept() from
field.cc
RETURN
# - field
0 - no field
*/
Field
*
get_holder_example_field
(
THD
*
thd
,
Item
*
item
,
TABLE
*
table
)
{
DBUG_ASSERT
(
table
);
Item_func
*
tmp_item
=
0
;
if
(
item
->
type
()
==
Item
::
FIELD_ITEM
)
return
(((
Item_field
*
)
item
)
->
field
);
if
(
item
->
type
()
==
Item
::
FUNC_ITEM
)
tmp_item
=
(
Item_func
*
)
item
;
else
if
(
item
->
type
()
==
Item
::
SUM_FUNC_ITEM
)
{
Item_sum
*
item_sum
=
(
Item_sum
*
)
item
;
if
(
item_sum
->
keep_field_type
())
{
if
(
item_sum
->
args
[
0
]
->
type
()
==
Item
::
FIELD_ITEM
)
return
(((
Item_field
*
)
item_sum
->
args
[
0
])
->
field
);
if
(
item_sum
->
args
[
0
]
->
type
()
==
Item
::
FUNC_ITEM
)
tmp_item
=
(
Item_func
*
)
item_sum
->
args
[
0
];
}
}
return
(
tmp_item
&&
field_types_to_be_kept
(
tmp_item
->
field_type
())
?
tmp_item
->
tmp_table_field
(
table
)
:
0
);
}
Item_type_holder
::
Item_type_holder
(
THD
*
thd
,
Item
*
item
,
TABLE
*
table
)
:
Item
(
thd
,
item
),
item_type
(
item
->
result_type
()),
:
Item
(
thd
,
item
),
item_type
(
item
->
result_type
()),
orig_type
(
item_type
)
orig_type
(
item_type
)
{
{
...
@@ -3643,10 +3689,7 @@ Item_type_holder::Item_type_holder(THD *thd, Item *item)
...
@@ -3643,10 +3689,7 @@ Item_type_holder::Item_type_holder(THD *thd, Item *item)
It is safe assign pointer on field, because it will be used just after
It is safe assign pointer on field, because it will be used just after
all JOIN::prepare calls and before any SELECT execution
all JOIN::prepare calls and before any SELECT execution
*/
*/
if
(
item
->
type
()
==
Item
::
FIELD_ITEM
)
field_example
=
get_holder_example_field
(
thd
,
item
,
table
);
field_example
=
((
Item_field
*
)
item
)
->
field
;
else
field_example
=
0
;
max_length
=
real_length
(
item
);
max_length
=
real_length
(
item
);
maybe_null
=
item
->
maybe_null
;
maybe_null
=
item
->
maybe_null
;
collation
.
set
(
item
->
collation
);
collation
.
set
(
item
->
collation
);
...
@@ -3686,25 +3729,23 @@ inline bool is_attr_compatible(Item *from, Item *to)
...
@@ -3686,25 +3729,23 @@ inline bool is_attr_compatible(Item *from, Item *to)
(
to
->
maybe_null
||
!
from
->
maybe_null
)
&&
(
to
->
maybe_null
||
!
from
->
maybe_null
)
&&
(
to
->
result_type
()
!=
STRING_RESULT
||
(
to
->
result_type
()
!=
STRING_RESULT
||
from
->
result_type
()
!=
STRING_RESULT
||
from
->
result_type
()
!=
STRING_RESULT
||
my_charset_same
(
from
->
collation
.
collation
,
(
from
->
collation
.
collation
==
to
->
collation
.
collation
)));
to
->
collation
.
collation
)));
}
}
bool
Item_type_holder
::
join_types
(
THD
*
thd
,
Item
*
item
)
bool
Item_type_holder
::
join_types
(
THD
*
thd
,
Item
*
item
,
TABLE
*
table
)
{
{
uint32
new_length
=
real_length
(
item
);
uint32
new_length
=
real_length
(
item
);
bool
use_new_field
=
0
,
use_expression_type
=
0
;
bool
use_new_field
=
0
,
use_expression_type
=
0
;
Item_result
new_result_type
=
type_convertor
[
item_type
][
item
->
result_type
()];
Item_result
new_result_type
=
type_convertor
[
item_type
][
item
->
result_type
()];
bool
item_is_a_field
=
item
->
type
()
==
Item
::
FIELD_ITEM
;
Field
*
field
=
get_holder_example_field
(
thd
,
item
,
table
)
;
bool
item_is_a_field
=
field
;
/*
/*
Check if both items point to fields: in this case we
Check if both items point to fields: in this case we
can adjust column types of result table in the union smartly.
can adjust column types of result table in the union smartly.
*/
*/
if
(
field_example
&&
item_is_a_field
)
if
(
field_example
&&
item_is_a_field
)
{
{
Field
*
field
=
((
Item_field
*
)
item
)
->
field
;
/* Can 'field_example' field store data of the column? */
/* Can 'field_example' field store data of the column? */
if
((
use_new_field
=
if
((
use_new_field
=
(
!
field
->
field_cast_compatible
(
field_example
->
field_cast_type
())
||
(
!
field
->
field_cast_compatible
(
field_example
->
field_cast_type
())
||
...
@@ -3745,7 +3786,7 @@ bool Item_type_holder::join_types(THD *thd, Item *item)
...
@@ -3745,7 +3786,7 @@ bool Item_type_holder::join_types(THD *thd, Item *item)
It is safe to assign a pointer to field here, because it will be used
It is safe to assign a pointer to field here, because it will be used
before any table is closed.
before any table is closed.
*/
*/
field_example
=
((
Item_field
*
)
item
)
->
field
;
field_example
=
field
;
}
}
old_cs
=
collation
.
collation
->
name
;
old_cs
=
collation
.
collation
->
name
;
...
...
sql/item.h
View file @
8c8553af
...
@@ -1579,14 +1579,14 @@ class Item_type_holder: public Item
...
@@ -1579,14 +1579,14 @@ class Item_type_holder: public Item
Item_result
orig_type
;
Item_result
orig_type
;
Field
*
field_example
;
Field
*
field_example
;
public:
public:
Item_type_holder
(
THD
*
,
Item
*
);
Item_type_holder
(
THD
*
,
Item
*
,
TABLE
*
);
Item_result
result_type
()
const
{
return
item_type
;
}
Item_result
result_type
()
const
{
return
item_type
;
}
enum
Type
type
()
const
{
return
TYPE_HOLDER
;
}
enum
Type
type
()
const
{
return
TYPE_HOLDER
;
}
double
val_real
();
double
val_real
();
longlong
val_int
();
longlong
val_int
();
String
*
val_str
(
String
*
);
String
*
val_str
(
String
*
);
bool
join_types
(
THD
*
thd
,
Item
*
);
bool
join_types
(
THD
*
thd
,
Item
*
,
TABLE
*
);
Field
*
example
()
{
return
field_example
;
}
Field
*
example
()
{
return
field_example
;
}
static
uint32
real_length
(
Item
*
item
);
static
uint32
real_length
(
Item
*
item
);
void
cleanup
()
void
cleanup
()
...
...
sql/item_func.cc
View file @
8c8553af
...
@@ -3138,9 +3138,7 @@ void Item_func_match::init_search(bool no_order)
...
@@ -3138,9 +3138,7 @@ void Item_func_match::init_search(bool no_order)
if
(
join_key
&&
!
no_order
)
if
(
join_key
&&
!
no_order
)
flags
|=
FT_SORTED
;
flags
|=
FT_SORTED
;
ft_handler
=
table
->
file
->
ft_init_ext
(
flags
,
key
,
ft_handler
=
table
->
file
->
ft_init_ext
(
flags
,
key
,
ft_tmp
);
(
byte
*
)
ft_tmp
->
ptr
(),
ft_tmp
->
length
());
if
(
join_key
)
if
(
join_key
)
table
->
file
->
ft_handler
=
ft_handler
;
table
->
file
->
ft_handler
=
ft_handler
;
...
@@ -3182,12 +3180,12 @@ bool Item_func_match::fix_fields(THD *thd, TABLE_LIST *tlist, Item **ref)
...
@@ -3182,12 +3180,12 @@ bool Item_func_match::fix_fields(THD *thd, TABLE_LIST *tlist, Item **ref)
}
}
/*
/*
Check that all columns come from the same table.
Check that all columns come from the same table.
We've already checked that columns in MATCH are fields so
We've already checked that columns in MATCH are fields so
PARAM_TABLE_BIT can only appear from AGAINST argument.
PARAM_TABLE_BIT can only appear from AGAINST argument.
*/
*/
if
((
used_tables_cache
&
~
PARAM_TABLE_BIT
)
!=
item
->
used_tables
())
if
((
used_tables_cache
&
~
PARAM_TABLE_BIT
)
!=
item
->
used_tables
())
key
=
NO_SUCH_KEY
;
key
=
NO_SUCH_KEY
;
if
(
key
==
NO_SUCH_KEY
&&
!
(
flags
&
FT_BOOL
))
if
(
key
==
NO_SUCH_KEY
&&
!
(
flags
&
FT_BOOL
))
{
{
my_error
(
ER_WRONG_ARGUMENTS
,
MYF
(
0
),
"MATCH"
);
my_error
(
ER_WRONG_ARGUMENTS
,
MYF
(
0
),
"MATCH"
);
...
...
sql/sql_union.cc
View file @
8c8553af
...
@@ -153,6 +153,7 @@ bool st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result,
...
@@ -153,6 +153,7 @@ bool st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result,
SELECT_LEX
*
sl
,
*
first_select
;
SELECT_LEX
*
sl
,
*
first_select
;
select_result
*
tmp_result
;
select_result
*
tmp_result
;
bool
is_union
;
bool
is_union
;
TABLE
*
empty_table
=
0
;
DBUG_ENTER
(
"st_select_lex_unit::prepare"
);
DBUG_ENTER
(
"st_select_lex_unit::prepare"
);
describe
=
test
(
additional_options
&
SELECT_DESCRIBE
);
describe
=
test
(
additional_options
&
SELECT_DESCRIBE
);
...
@@ -249,13 +250,21 @@ bool st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result,
...
@@ -249,13 +250,21 @@ bool st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result,
goto
err
;
goto
err
;
if
(
sl
==
first_select
)
if
(
sl
==
first_select
)
{
{
/*
We need to create an empty table object. It is used
to create tmp_table fields in Item_type_holder.
The main reason of this is that we can't create
field object without table.
*/
DBUG_ASSERT
(
!
empty_table
);
empty_table
=
(
TABLE
*
)
thd
->
calloc
(
sizeof
(
TABLE
));
types
.
empty
();
types
.
empty
();
List_iterator_fast
<
Item
>
it
(
sl
->
item_list
);
List_iterator_fast
<
Item
>
it
(
sl
->
item_list
);
Item
*
item_tmp
;
Item
*
item_tmp
;
while
((
item_tmp
=
it
++
))
while
((
item_tmp
=
it
++
))
{
{
/* Error's in 'new' will be detected after loop */
/* Error's in 'new' will be detected after loop */
types
.
push_back
(
new
Item_type_holder
(
thd_arg
,
item_tmp
));
types
.
push_back
(
new
Item_type_holder
(
thd_arg
,
item_tmp
,
empty_table
));
}
}
if
(
thd_arg
->
is_fatal_error
)
if
(
thd_arg
->
is_fatal_error
)
...
@@ -274,7 +283,8 @@ bool st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result,
...
@@ -274,7 +283,8 @@ bool st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result,
Item
*
type
,
*
item_tmp
;
Item
*
type
,
*
item_tmp
;
while
((
type
=
tp
++
,
item_tmp
=
it
++
))
while
((
type
=
tp
++
,
item_tmp
=
it
++
))
{
{
if
(((
Item_type_holder
*
)
type
)
->
join_types
(
thd_arg
,
item_tmp
))
if
(((
Item_type_holder
*
)
type
)
->
join_types
(
thd_arg
,
item_tmp
,
empty_table
))
DBUG_RETURN
(
TRUE
);
DBUG_RETURN
(
TRUE
);
}
}
}
}
...
...
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