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
8b65423d
Commit
8b65423d
authored
Dec 21, 2007
by
mhansson/martin@linux-st28.site
Browse files
Options
Browse Files
Download
Plain Diff
Merge mhansson@bk-internal:/home/bk/mysql-5.1-opt
into linux-st28.site:/home/martin/mysql/src/bug32848/my51-bug32848
parents
1f5b0b39
fe93176c
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
64 additions
and
1 deletion
+64
-1
mysql-test/r/union.result
mysql-test/r/union.result
+24
-0
mysql-test/t/union.test
mysql-test/t/union.test
+22
-0
sql/field.cc
sql/field.cc
+2
-1
sql/field.h
sql/field.h
+10
-0
sql/item.cc
sql/item.cc
+4
-0
sql/sql_select.cc
sql/sql_select.cc
+2
-0
No files found.
mysql-test/r/union.result
View file @
8b65423d
...
@@ -1496,4 +1496,28 @@ UNION
...
@@ -1496,4 +1496,28 @@ UNION
SELECT 1,1;
SELECT 1,1;
ERROR HY000: Incorrect usage of UNION and ORDER BY
ERROR HY000: Incorrect usage of UNION and ORDER BY
DROP TABLE t1,t2;
DROP TABLE t1,t2;
CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (1), (2), (3);
CREATE TABLE t2 SELECT * FROM (SELECT NULL) a UNION SELECT a FROM t1;
DESC t2;
Field Type Null Key Default Extra
NULL int(11) YES NULL
CREATE TABLE t3 SELECT a FROM t1 UNION SELECT * FROM (SELECT NULL) a;
DESC t3;
Field Type Null Key Default Extra
a int(11) YES NULL
CREATE TABLE t4 SELECT NULL;
DESC t4;
Field Type Null Key Default Extra
NULL binary(0) YES NULL
CREATE TABLE t5 SELECT NULL UNION SELECT NULL;
DESC t5;
Field Type Null Key Default Extra
NULL binary(0) YES NULL
CREATE TABLE t6
SELECT * FROM (SELECT * FROM (SELECT NULL)a) b UNION SELECT a FROM t1;
DESC t6;
Field Type Null Key Default Extra
NULL int(11) YES NULL
DROP TABLE t1, t2, t3, t4, t5, t6;
End of 5.0 tests
End of 5.0 tests
mysql-test/t/union.test
View file @
8b65423d
...
@@ -966,4 +966,26 @@ SELECT 1,1;
...
@@ -966,4 +966,26 @@ SELECT 1,1;
DROP
TABLE
t1
,
t2
;
DROP
TABLE
t1
,
t2
;
# Bug#32848: Data type conversion bug in union subselects in MySQL 5.0.38
#
CREATE
TABLE
t1
(
a
INT
);
INSERT
INTO
t1
VALUES
(
1
),
(
2
),
(
3
);
CREATE
TABLE
t2
SELECT
*
FROM
(
SELECT
NULL
)
a
UNION
SELECT
a
FROM
t1
;
DESC
t2
;
CREATE
TABLE
t3
SELECT
a
FROM
t1
UNION
SELECT
*
FROM
(
SELECT
NULL
)
a
;
DESC
t3
;
CREATE
TABLE
t4
SELECT
NULL
;
DESC
t4
;
CREATE
TABLE
t5
SELECT
NULL
UNION
SELECT
NULL
;
DESC
t5
;
CREATE
TABLE
t6
SELECT
*
FROM
(
SELECT
*
FROM
(
SELECT
NULL
)
a
)
b
UNION
SELECT
a
FROM
t1
;
DESC
t6
;
DROP
TABLE
t1
,
t2
,
t3
,
t4
,
t5
,
t6
;
--
echo
End
of
5.0
tests
--
echo
End
of
5.0
tests
sql/field.cc
View file @
8b65423d
...
@@ -1307,7 +1307,8 @@ Field::Field(uchar *ptr_arg,uint32 length_arg,uchar *null_ptr_arg,
...
@@ -1307,7 +1307,8 @@ Field::Field(uchar *ptr_arg,uint32 length_arg,uchar *null_ptr_arg,
field_name
(
field_name_arg
),
field_name
(
field_name_arg
),
key_start
(
0
),
part_of_key
(
0
),
part_of_key_not_clustered
(
0
),
key_start
(
0
),
part_of_key
(
0
),
part_of_key_not_clustered
(
0
),
part_of_sortkey
(
0
),
unireg_check
(
unireg_check_arg
),
part_of_sortkey
(
0
),
unireg_check
(
unireg_check_arg
),
field_length
(
length_arg
),
null_bit
(
null_bit_arg
)
field_length
(
length_arg
),
null_bit
(
null_bit_arg
),
is_created_from_null_item
(
FALSE
)
{
{
flags
=
null_ptr
?
0
:
NOT_NULL_FLAG
;
flags
=
null_ptr
?
0
:
NOT_NULL_FLAG
;
comment
.
str
=
(
char
*
)
""
;
comment
.
str
=
(
char
*
)
""
;
...
...
sql/field.h
View file @
8b65423d
...
@@ -90,6 +90,16 @@ public:
...
@@ -90,6 +90,16 @@ public:
uint32
flags
;
uint32
flags
;
uint16
field_index
;
// field number in fields array
uint16
field_index
;
// field number in fields array
uchar
null_bit
;
// Bit used to test null bit
uchar
null_bit
;
// Bit used to test null bit
/**
If true, this field was created in create_tmp_field_from_item from a NULL
value. This means that the type of the field is just a guess, and the type
may be freely coerced to another type.
@see create_tmp_field_from_item
@see Item_type_holder::get_real_type
*/
bool
is_created_from_null_item
;
Field
(
uchar
*
ptr_arg
,
uint32
length_arg
,
uchar
*
null_ptr_arg
,
Field
(
uchar
*
ptr_arg
,
uint32
length_arg
,
uchar
*
null_ptr_arg
,
uchar
null_bit_arg
,
utype
unireg_check_arg
,
uchar
null_bit_arg
,
utype
unireg_check_arg
,
...
...
sql/item.cc
View file @
8b65423d
...
@@ -6707,6 +6707,8 @@ enum_field_types Item_type_holder::get_real_type(Item *item)
...
@@ -6707,6 +6707,8 @@ enum_field_types Item_type_holder::get_real_type(Item *item)
*/
*/
Field
*
field
=
((
Item_field
*
)
item
)
->
field
;
Field
*
field
=
((
Item_field
*
)
item
)
->
field
;
enum_field_types
type
=
field
->
real_type
();
enum_field_types
type
=
field
->
real_type
();
if
(
field
->
is_created_from_null_item
)
return
MYSQL_TYPE_NULL
;
/* work around about varchar type field detection */
/* work around about varchar type field detection */
if
(
type
==
MYSQL_TYPE_STRING
&&
field
->
type
()
==
MYSQL_TYPE_VAR_STRING
)
if
(
type
==
MYSQL_TYPE_STRING
&&
field
->
type
()
==
MYSQL_TYPE_VAR_STRING
)
return
MYSQL_TYPE_VAR_STRING
;
return
MYSQL_TYPE_VAR_STRING
;
...
@@ -6965,6 +6967,8 @@ Field *Item_type_holder::make_field_by_type(TABLE *table)
...
@@ -6965,6 +6967,8 @@ Field *Item_type_holder::make_field_by_type(TABLE *table)
if
(
field
)
if
(
field
)
field
->
init
(
table
);
field
->
init
(
table
);
return
field
;
return
field
;
case
MYSQL_TYPE_NULL
:
return
make_string_field
(
table
);
default:
default:
break
;
break
;
}
}
...
...
sql/sql_select.cc
View file @
8b65423d
...
@@ -9277,6 +9277,8 @@ static Field *create_tmp_field_from_item(THD *thd, Item *item, TABLE *table,
...
@@ -9277,6 +9277,8 @@ static Field *create_tmp_field_from_item(THD *thd, Item *item, TABLE *table,
*
((
*
copy_func
)
++
)
=
item
;
// Save for copy_funcs
*
((
*
copy_func
)
++
)
=
item
;
// Save for copy_funcs
if
(
modify_item
)
if
(
modify_item
)
item
->
set_result_field
(
new_field
);
item
->
set_result_field
(
new_field
);
if
(
item
->
type
()
==
Item
::
NULL_ITEM
)
new_field
->
is_created_from_null_item
=
TRUE
;
return
new_field
;
return
new_field
;
}
}
...
...
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