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
6530f680
Commit
6530f680
authored
May 21, 2007
by
mhansson@dl145s.mysql.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bug#23856
parent
bb089cea
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
111 additions
and
6 deletions
+111
-6
mysql-test/r/func_gconcat.result
mysql-test/r/func_gconcat.result
+47
-0
mysql-test/t/func_gconcat.test
mysql-test/t/func_gconcat.test
+32
-0
sql/field.h
sql/field.h
+5
-0
sql/field_conv.cc
sql/field_conv.cc
+14
-0
sql/item_sum.cc
sql/item_sum.cc
+10
-4
sql/sql_select.cc
sql/sql_select.cc
+3
-2
No files found.
mysql-test/r/func_gconcat.result
View file @
6530f680
...
@@ -737,4 +737,51 @@ SELECT GROUP_CONCAT(DISTINCT UCASE(b)) FROM t1;
...
@@ -737,4 +737,51 @@ SELECT GROUP_CONCAT(DISTINCT UCASE(b)) FROM t1;
GROUP_CONCAT(DISTINCT UCASE(b))
GROUP_CONCAT(DISTINCT UCASE(b))
ONE.1,TWO.2,ONE.3
ONE.1,TWO.2,ONE.3
DROP TABLE t1;
DROP TABLE t1;
SET group_concat_max_len= 65535;
CREATE TABLE t1( a TEXT, b INTEGER );
INSERT INTO t1 VALUES ( 'a', 0 ), ( 'b', 1 );
SELECT GROUP_CONCAT( a ORDER BY b ) FROM t1;
GROUP_CONCAT( a ORDER BY b )
a,b
SELECT GROUP_CONCAT(DISTINCT a ORDER BY b) FROM t1;
GROUP_CONCAT(DISTINCT a ORDER BY b)
a,b
SELECT GROUP_CONCAT(DISTINCT a) FROM t1;
GROUP_CONCAT(DISTINCT a)
a,b
SET group_concat_max_len= 10;
SELECT GROUP_CONCAT(a ORDER BY b) FROM t1;
GROUP_CONCAT(a ORDER BY b)
a,b
SELECT GROUP_CONCAT(DISTINCT a ORDER BY b) FROM t1;
GROUP_CONCAT(DISTINCT a ORDER BY b)
a,b
SELECT GROUP_CONCAT(DISTINCT a) FROM t1;
GROUP_CONCAT(DISTINCT a)
a,b
SET group_concat_max_len= 65535;
CREATE TABLE t2( a TEXT );
INSERT INTO t2 VALUES( REPEAT( 'a', 5000 ) );
INSERT INTO t2 VALUES( REPEAT( 'b', 5000 ) );
INSERT INTO t2 VALUES( REPEAT( 'a', 5000 ) );
SELECT LENGTH( GROUP_CONCAT( DISTINCT a ) ) FROM t2;
LENGTH( GROUP_CONCAT( DISTINCT a ) )
10001
CREATE TABLE t3( a TEXT, b INT );
INSERT INTO t3 VALUES( REPEAT( 'a', 65534 ), 1 );
INSERT INTO t3 VALUES( REPEAT( 'a', 65535 ), 2 );
INSERT INTO t3 VALUES( REPEAT( 'a', 65536 ), 3 );
Warnings:
Warning 1265 Data truncated for column 'a' at row 1
SELECT LENGTH( GROUP_CONCAT( a ) ) FROM t3 WHERE b = 1;
LENGTH( GROUP_CONCAT( a ) )
65534
SELECT LENGTH( GROUP_CONCAT( a ) ) FROM t3 WHERE b = 2;
LENGTH( GROUP_CONCAT( a ) )
65535
SELECT LENGTH( GROUP_CONCAT( a ) ) FROM t3 WHERE b = 3;
LENGTH( GROUP_CONCAT( a ) )
65535
SET group_concat_max_len= DEFAULT;
DROP TABLE t1, t2, t3;
End of 5.0 tests
End of 5.0 tests
mysql-test/t/func_gconcat.test
View file @
6530f680
...
@@ -507,4 +507,36 @@ SELECT GROUP_CONCAT(DISTINCT UCASE(a)) FROM t1;
...
@@ -507,4 +507,36 @@ SELECT GROUP_CONCAT(DISTINCT UCASE(a)) FROM t1;
SELECT
GROUP_CONCAT
(
DISTINCT
UCASE
(
b
))
FROM
t1
;
SELECT
GROUP_CONCAT
(
DISTINCT
UCASE
(
b
))
FROM
t1
;
DROP
TABLE
t1
;
DROP
TABLE
t1
;
#
# Bug #23856:GROUP_CONCAT and ORDER BY: junk from previous rows for query on I_S
#
SET
group_concat_max_len
=
65535
;
CREATE
TABLE
t1
(
a
TEXT
,
b
INTEGER
);
INSERT
INTO
t1
VALUES
(
'a'
,
0
),
(
'b'
,
1
);
SELECT
GROUP_CONCAT
(
a
ORDER
BY
b
)
FROM
t1
;
SELECT
GROUP_CONCAT
(
DISTINCT
a
ORDER
BY
b
)
FROM
t1
;
SELECT
GROUP_CONCAT
(
DISTINCT
a
)
FROM
t1
;
SET
group_concat_max_len
=
10
;
SELECT
GROUP_CONCAT
(
a
ORDER
BY
b
)
FROM
t1
;
SELECT
GROUP_CONCAT
(
DISTINCT
a
ORDER
BY
b
)
FROM
t1
;
SELECT
GROUP_CONCAT
(
DISTINCT
a
)
FROM
t1
;
SET
group_concat_max_len
=
65535
;
CREATE
TABLE
t2
(
a
TEXT
);
INSERT
INTO
t2
VALUES
(
REPEAT
(
'a'
,
5000
)
);
INSERT
INTO
t2
VALUES
(
REPEAT
(
'b'
,
5000
)
);
INSERT
INTO
t2
VALUES
(
REPEAT
(
'a'
,
5000
)
);
SELECT
LENGTH
(
GROUP_CONCAT
(
DISTINCT
a
)
)
FROM
t2
;
CREATE
TABLE
t3
(
a
TEXT
,
b
INT
);
INSERT
INTO
t3
VALUES
(
REPEAT
(
'a'
,
65534
),
1
);
INSERT
INTO
t3
VALUES
(
REPEAT
(
'a'
,
65535
),
2
);
INSERT
INTO
t3
VALUES
(
REPEAT
(
'a'
,
65536
),
3
);
SELECT
LENGTH
(
GROUP_CONCAT
(
a
)
)
FROM
t3
WHERE
b
=
1
;
SELECT
LENGTH
(
GROUP_CONCAT
(
a
)
)
FROM
t3
WHERE
b
=
2
;
SELECT
LENGTH
(
GROUP_CONCAT
(
a
)
)
FROM
t3
WHERE
b
=
3
;
SET
group_concat_max_len
=
DEFAULT
;
DROP
TABLE
t1
,
t2
,
t3
;
--
echo
End
of
5.0
tests
--
echo
End
of
5.0
tests
sql/field.h
View file @
6530f680
...
@@ -1108,6 +1108,11 @@ public:
...
@@ -1108,6 +1108,11 @@ public:
class
Field_varstring
:
public
Field_longstr
{
class
Field_varstring
:
public
Field_longstr
{
public:
public:
/*
The maximum space available in a Field_varstring, in bytes. See
length_bytes.
*/
static
const
int
MAX_SIZE
=
UINT_MAX16
;
/* Store number of bytes used to store length (1 or 2) */
/* Store number of bytes used to store length (1 or 2) */
uint32
length_bytes
;
uint32
length_bytes
;
Field_varstring
(
char
*
ptr_arg
,
Field_varstring
(
char
*
ptr_arg
,
...
...
sql/field_conv.cc
View file @
6530f680
...
@@ -530,7 +530,21 @@ void Copy_field::set(char *to,Field *from)
...
@@ -530,7 +530,21 @@ void Copy_field::set(char *to,Field *from)
}
}
/*
To do:
If 'save\ is set to true and the 'from' is a blob field, do_copy is set to
do_save_blob rather than do_conv_blob. The only differences between them
appears to be:
- do_save_blob allocates and uses an intermediate buffer before calling
Field_blob::store. Is this in order to trigger the call to
well_formed_copy_nchars, by changing the pointer copy->tmp.ptr()?
That call will take place anyway in all known cases.
- The above causes a truncation to MAX_FIELD_WIDTH. Is this the intended
effect? Truncation is handled by well_formed_copy_nchars anyway.
*/
void
Copy_field
::
set
(
Field
*
to
,
Field
*
from
,
bool
save
)
void
Copy_field
::
set
(
Field
*
to
,
Field
*
from
,
bool
save
)
{
{
if
(
to
->
type
()
==
FIELD_TYPE_NULL
)
if
(
to
->
type
()
==
FIELD_TYPE_NULL
)
...
...
sql/item_sum.cc
View file @
6530f680
...
@@ -432,7 +432,7 @@ Field *Item_sum::create_tmp_field(bool group, TABLE *table,
...
@@ -432,7 +432,7 @@ Field *Item_sum::create_tmp_field(bool group, TABLE *table,
2-byte lenght.
2-byte lenght.
*/
*/
if
(
max_length
/
collation
.
collation
->
mbmaxlen
>
255
&&
if
(
max_length
/
collation
.
collation
->
mbmaxlen
>
255
&&
convert_blob_length
<
UINT_MAX16
&&
convert_blob_length
)
convert_blob_length
<
=
Field_varstring
::
MAX_SIZE
&&
convert_blob_length
)
return
new
Field_varstring
(
convert_blob_length
,
maybe_null
,
return
new
Field_varstring
(
convert_blob_length
,
maybe_null
,
name
,
table
,
name
,
table
,
collation
.
collation
);
collation
.
collation
);
...
@@ -3268,15 +3268,21 @@ bool Item_func_group_concat::setup(THD *thd)
...
@@ -3268,15 +3268,21 @@ bool Item_func_group_concat::setup(THD *thd)
count_field_types
(
tmp_table_param
,
all_fields
,
0
);
count_field_types
(
tmp_table_param
,
all_fields
,
0
);
tmp_table_param
->
force_copy_fields
=
force_copy_fields
;
tmp_table_param
->
force_copy_fields
=
force_copy_fields
;
DBUG_ASSERT
(
table
==
0
);
DBUG_ASSERT
(
table
==
0
);
/*
Currently we have to force conversion of BLOB values to VARCHAR's
if we are to store them in TREE objects used for ORDER BY and
DISTINCT. This leads to truncation if the BLOB's size exceeds
Field_varstring::MAX_SIZE.
*/
if
(
arg_count_order
>
0
||
distinct
)
set_if_smaller
(
tmp_table_param
->
convert_blob_length
,
Field_varstring
::
MAX_SIZE
);
/*
/*
We have to create a temporary table to get descriptions of fields
We have to create a temporary table to get descriptions of fields
(types, sizes and so on).
(types, sizes and so on).
Note that in the table, we first have the ORDER BY fields, then the
Note that in the table, we first have the ORDER BY fields, then the
field list.
field list.
We need to set set_sum_field in true for storing value of blob in buffer
of a record instead of a pointer of one.
*/
*/
if
(
!
(
table
=
create_tmp_table
(
thd
,
tmp_table_param
,
all_fields
,
if
(
!
(
table
=
create_tmp_table
(
thd
,
tmp_table_param
,
all_fields
,
(
ORDER
*
)
0
,
0
,
TRUE
,
(
ORDER
*
)
0
,
0
,
TRUE
,
...
...
sql/sql_select.cc
View file @
6530f680
...
@@ -8794,7 +8794,7 @@ Field* create_tmp_field_from_field(THD *thd, Field* org_field,
...
@@ -8794,7 +8794,7 @@ Field* create_tmp_field_from_field(THD *thd, Field* org_field,
Make sure that the blob fits into a Field_varstring which has
Make sure that the blob fits into a Field_varstring which has
2-byte lenght.
2-byte lenght.
*/
*/
if
(
convert_blob_length
&&
convert_blob_length
<
UINT_MAX16
&&
if
(
convert_blob_length
&&
convert_blob_length
<
=
Field_varstring
::
MAX_SIZE
&&
(
org_field
->
flags
&
BLOB_FLAG
))
(
org_field
->
flags
&
BLOB_FLAG
))
new_field
=
new
Field_varstring
(
convert_blob_length
,
new_field
=
new
Field_varstring
(
convert_blob_length
,
org_field
->
maybe_null
(),
org_field
->
maybe_null
(),
...
@@ -8885,7 +8885,8 @@ static Field *create_tmp_field_from_item(THD *thd, Item *item, TABLE *table,
...
@@ -8885,7 +8885,8 @@ static Field *create_tmp_field_from_item(THD *thd, Item *item, TABLE *table,
2-byte lenght.
2-byte lenght.
*/
*/
else
if
(
item
->
max_length
/
item
->
collation
.
collation
->
mbmaxlen
>
255
&&
else
if
(
item
->
max_length
/
item
->
collation
.
collation
->
mbmaxlen
>
255
&&
convert_blob_length
<
UINT_MAX16
&&
convert_blob_length
)
convert_blob_length
<=
Field_varstring
::
MAX_SIZE
&&
convert_blob_length
)
new_field
=
new
Field_varstring
(
convert_blob_length
,
maybe_null
,
new_field
=
new
Field_varstring
(
convert_blob_length
,
maybe_null
,
item
->
name
,
table
,
item
->
name
,
table
,
item
->
collation
.
collation
);
item
->
collation
.
collation
);
...
...
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