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
a1ab7860
Commit
a1ab7860
authored
Mar 21, 2005
by
monty@mysql.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleanups during review of code
Fixed newly introduced bug in rollup
parent
df12e299
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
86 additions
and
45 deletions
+86
-45
client/mysqldump.c
client/mysqldump.c
+2
-3
mysql-test/r/olap.result
mysql-test/r/olap.result
+45
-0
mysql-test/t/olap.test
mysql-test/t/olap.test
+7
-0
sql/handler.cc
sql/handler.cc
+9
-5
sql/item.cc
sql/item.cc
+2
-12
sql/item_sum.cc
sql/item_sum.cc
+7
-11
sql/mysqld.cc
sql/mysqld.cc
+4
-3
sql/sql_select.cc
sql/sql_select.cc
+9
-7
sql/sql_string.h
sql/sql_string.h
+1
-4
No files found.
client/mysqldump.c
View file @
a1ab7860
...
@@ -1093,7 +1093,7 @@ static void print_xml_row(FILE *xml_file, const char *row_name,
...
@@ -1093,7 +1093,7 @@ static void print_xml_row(FILE *xml_file, const char *row_name,
number of fields in table, 0 if error
number of fields in table, 0 if error
*/
*/
static
uint
getTableStructure
(
char
*
table
,
char
*
db
)
static
uint
getTableStructure
(
char
*
table
,
char
*
db
)
{
{
MYSQL_RES
*
tableRes
;
MYSQL_RES
*
tableRes
;
MYSQL_ROW
row
;
MYSQL_ROW
row
;
...
@@ -1396,10 +1396,9 @@ static uint getTableStructure(char *table, char* db)
...
@@ -1396,10 +1396,9 @@ static uint getTableStructure(char *table, char* db)
/* Get MySQL specific create options */
/* Get MySQL specific create options */
if
(
create_options
)
if
(
create_options
)
{
{
char
show_name_buff
[
FN_REFLEN
];
char
show_name_buff
[
NAME_LEN
*
2
+
2
+
24
];
/* Check memory for quote_for_like() */
/* Check memory for quote_for_like() */
DBUG_ASSERT
(
2
*
sizeof
(
table
)
<
sizeof
(
show_name_buff
));
my_snprintf
(
buff
,
sizeof
(
buff
),
"show table status like %s"
,
my_snprintf
(
buff
,
sizeof
(
buff
),
"show table status like %s"
,
quote_for_like
(
table
,
show_name_buff
));
quote_for_like
(
table
,
show_name_buff
));
...
...
mysql-test/r/olap.result
View file @
a1ab7860
...
@@ -378,6 +378,51 @@ a sum(b)
...
@@ -378,6 +378,51 @@ a sum(b)
2 6
2 6
4 4
4 4
NULL 14
NULL 14
SELECT b, a, sum(b) FROM t1 GROUP BY a,b WITH ROLLUP;
b a sum(b)
4 1 4
NULL 1 4
1 2 2
2 2 4
NULL 2 6
1 4 4
NULL 4 4
NULL NULL 14
SELECT DISTINCT b,a, sum(b) FROM t1 GROUP BY a,b WITH ROLLUP;
b a sum(b)
4 1 4
NULL 1 4
1 2 2
2 2 4
NULL 2 6
1 4 4
NULL 4 4
NULL NULL 14
ALTER TABLE t1 ADD COLUMN c INT;
SELECT a,b,sum(c) FROM t1 GROUP BY a,b,c WITH ROLLUP;
a b sum(c)
1 4 NULL
1 4 NULL
1 NULL NULL
2 1 NULL
2 1 NULL
2 2 NULL
2 2 NULL
2 NULL NULL
4 1 NULL
4 1 NULL
4 NULL NULL
NULL NULL NULL
SELECT distinct a,b,sum(c) FROM t1 GROUP BY a,b,c WITH ROLLUP;
a b sum(c)
1 4 NULL
1 NULL NULL
2 1 NULL
2 2 NULL
2 NULL NULL
4 1 NULL
4 NULL NULL
NULL NULL NULL
DROP TABLE t1;
DROP TABLE t1;
CREATE TABLE t1 (a int, b int);
CREATE TABLE t1 (a int, b int);
INSERT INTO t1 VALUES
INSERT INTO t1 VALUES
...
...
mysql-test/t/olap.test
View file @
a1ab7860
...
@@ -153,6 +153,13 @@ SELECT DISTINCT SUM(b), COUNT(DISTINCT b), COUNT(*) FROM t1
...
@@ -153,6 +153,13 @@ SELECT DISTINCT SUM(b), COUNT(DISTINCT b), COUNT(*) FROM t1
SELECT
a
,
sum
(
b
)
FROM
t1
GROUP
BY
a
,
b
WITH
ROLLUP
;
SELECT
a
,
sum
(
b
)
FROM
t1
GROUP
BY
a
,
b
WITH
ROLLUP
;
SELECT
DISTINCT
a
,
sum
(
b
)
FROM
t1
GROUP
BY
a
,
b
WITH
ROLLUP
;
SELECT
DISTINCT
a
,
sum
(
b
)
FROM
t1
GROUP
BY
a
,
b
WITH
ROLLUP
;
SELECT
b
,
a
,
sum
(
b
)
FROM
t1
GROUP
BY
a
,
b
WITH
ROLLUP
;
SELECT
DISTINCT
b
,
a
,
sum
(
b
)
FROM
t1
GROUP
BY
a
,
b
WITH
ROLLUP
;
ALTER
TABLE
t1
ADD
COLUMN
c
INT
;
SELECT
a
,
b
,
sum
(
c
)
FROM
t1
GROUP
BY
a
,
b
,
c
WITH
ROLLUP
;
SELECT
distinct
a
,
b
,
sum
(
c
)
FROM
t1
GROUP
BY
a
,
b
,
c
WITH
ROLLUP
;
DROP
TABLE
t1
;
DROP
TABLE
t1
;
#
#
...
...
sql/handler.cc
View file @
a1ab7860
...
@@ -762,14 +762,13 @@ static char* xid_to_str(char *buf, XID *xid)
...
@@ -762,14 +762,13 @@ static char* xid_to_str(char *buf, XID *xid)
for
(
i
=
0
;
i
<
xid
->
gtrid_length
+
xid
->
bqual_length
;
i
++
)
for
(
i
=
0
;
i
<
xid
->
gtrid_length
+
xid
->
bqual_length
;
i
++
)
{
{
uchar
c
=
(
uchar
)
xid
->
data
[
i
];
uchar
c
=
(
uchar
)
xid
->
data
[
i
];
bool
is_next_dig
;
/* is_next_dig is set if next character is a number */
bool
is_next_dig
=
FALSE
;
if
(
i
<
XIDDATASIZE
)
if
(
i
<
XIDDATASIZE
)
{
{
char
ch
=
xid
->
data
[
i
+
1
];
char
ch
=
xid
->
data
[
i
+
1
];
is_next_dig
=
(
c
>=
'0'
&&
c
<=
'9'
);
is_next_dig
=
(
ch
>=
'0'
&&
ch
<=
'9'
);
}
}
else
is_next_dig
=
FALSE
;
if
(
i
==
xid
->
gtrid_length
)
if
(
i
==
xid
->
gtrid_length
)
{
{
*
s
++=
'\''
;
*
s
++=
'\''
;
...
@@ -782,6 +781,11 @@ static char* xid_to_str(char *buf, XID *xid)
...
@@ -782,6 +781,11 @@ static char* xid_to_str(char *buf, XID *xid)
if
(
c
<
32
||
c
>
126
)
if
(
c
<
32
||
c
>
126
)
{
{
*
s
++=
'\\'
;
*
s
++=
'\\'
;
/*
If next character is a number, write current character with
3 octal numbers to ensure that the next number is not seen
as part of the octal number
*/
if
(
c
>
077
||
is_next_dig
)
if
(
c
>
077
||
is_next_dig
)
*
s
++=
_dig_vec_lower
[
c
>>
6
];
*
s
++=
_dig_vec_lower
[
c
>>
6
];
if
(
c
>
007
||
is_next_dig
)
if
(
c
>
007
||
is_next_dig
)
...
...
sql/item.cc
View file @
a1ab7860
...
@@ -586,18 +586,8 @@ Item *Item_string::safe_charset_converter(CHARSET_INFO *tocs)
...
@@ -586,18 +586,8 @@ Item *Item_string::safe_charset_converter(CHARSET_INFO *tocs)
return
NULL
;
return
NULL
;
}
}
conv
->
str_value
.
copy
();
conv
->
str_value
.
copy
();
/*
/* Ensure that no one is going to change the result string */
The above line executes str_value.realloc() internally,
conv
->
str_value
.
mark_as_const
();
which alligns Alloced_length using ALLIGN_SIZE.
In the case of Item_string::str_value we don't want
Alloced_length to be longer than str_length.
Otherwise, some functions like Item_func_concat::val_str()
try to reuse str_value as a buffer for concatenation result
for optimization purposes, so our string constant become
corrupted. See bug#8785 for more details.
Let's shrink Alloced_length to str_length to avoid this problem.
*/
conv
->
str_value
.
shrink_to_length
();
return
conv
;
return
conv
;
}
}
...
...
sql/item_sum.cc
View file @
a1ab7860
...
@@ -2671,11 +2671,11 @@ int dump_leaf_key(byte* key, uint32 count __attribute__((unused)),
...
@@ -2671,11 +2671,11 @@ int dump_leaf_key(byte* key, uint32 count __attribute__((unused)),
TABLE
*
table
=
item
->
table
;
TABLE
*
table
=
item
->
table
;
char
*
record
=
(
char
*
)
table
->
record
[
0
]
+
table
->
s
->
null_bytes
;
char
*
record
=
(
char
*
)
table
->
record
[
0
]
+
table
->
s
->
null_bytes
;
String
tmp
(
table
->
record
[
1
],
table
->
s
->
reclength
,
default_charset_info
),
tmp2
;
String
tmp
(
table
->
record
[
1
],
table
->
s
->
reclength
,
default_charset_info
),
tmp2
;
String
&
result
=
item
->
result
;
String
*
result
=
&
item
->
result
;
Item
**
arg
=
item
->
args
,
**
arg_end
=
item
->
args
+
item
->
arg_count_field
;
Item
**
arg
=
item
->
args
,
**
arg_end
=
item
->
args
+
item
->
arg_count_field
;
if
(
result
.
length
())
if
(
result
->
length
())
result
.
append
(
*
item
->
separator
);
result
->
append
(
*
item
->
separator
);
tmp
.
length
(
0
);
tmp
.
length
(
0
);
...
@@ -2702,14 +2702,14 @@ int dump_leaf_key(byte* key, uint32 count __attribute__((unused)),
...
@@ -2702,14 +2702,14 @@ int dump_leaf_key(byte* key, uint32 count __attribute__((unused)),
else
else
res
=
(
*
arg
)
->
val_str
(
&
tmp
);
res
=
(
*
arg
)
->
val_str
(
&
tmp
);
if
(
res
)
if
(
res
)
result
.
append
(
*
res
);
result
->
append
(
*
res
);
}
}
/* stop if length of result more than max_length */
/* stop if length of result more than max_length */
if
(
result
.
length
()
>
item
->
max_length
)
if
(
result
->
length
()
>
item
->
max_length
)
{
{
item
->
count_cut_values
++
;
item
->
count_cut_values
++
;
result
.
length
(
item
->
max_length
);
result
->
length
(
item
->
max_length
);
item
->
warning_for_row
=
TRUE
;
item
->
warning_for_row
=
TRUE
;
return
1
;
return
1
;
}
}
...
@@ -2910,8 +2910,6 @@ Item_func_group_concat::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
...
@@ -2910,8 +2910,6 @@ Item_func_group_concat::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
MYF
(
0
));
MYF
(
0
));
return
TRUE
;
return
TRUE
;
}
}
if
(
!
args
)
/* allocation in constructor may fail */
return
TRUE
;
thd
->
allow_sum_func
=
0
;
thd
->
allow_sum_func
=
0
;
maybe_null
=
0
;
maybe_null
=
0
;
...
@@ -2972,12 +2970,10 @@ bool Item_func_group_concat::setup(THD *thd)
...
@@ -2972,12 +2970,10 @@ bool Item_func_group_concat::setup(THD *thd)
if
(
item
->
null_value
)
if
(
item
->
null_value
)
{
{
always_null
=
1
;
always_null
=
1
;
break
;
DBUG_RETURN
(
FALSE
)
;
}
}
}
}
}
}
if
(
always_null
)
DBUG_RETURN
(
FALSE
);
List
<
Item
>
all_fields
(
list
);
List
<
Item
>
all_fields
(
list
);
/*
/*
...
...
sql/mysqld.cc
View file @
a1ab7860
...
@@ -3310,9 +3310,10 @@ default_service_handling(char **argv,
...
@@ -3310,9 +3310,10 @@ default_service_handling(char **argv,
int
main
(
int
argc
,
char
**
argv
)
int
main
(
int
argc
,
char
**
argv
)
{
{
/* When several instances are running on the same machine, we
/*
need to have an unique named hEventShudown through the
When several instances are running on the same machine, we
application PID e.g.: MySQLShutdown1890; MySQLShutdown2342
need to have an unique named hEventShudown through the
application PID e.g.: MySQLShutdown1890; MySQLShutdown2342
*/
*/
int10_to_str
((
int
)
GetCurrentProcessId
(),
strmov
(
shutdown_event_name
,
int10_to_str
((
int
)
GetCurrentProcessId
(),
strmov
(
shutdown_event_name
,
"MySQLShutdown"
),
10
);
"MySQLShutdown"
),
10
);
...
...
sql/sql_select.cc
View file @
a1ab7860
...
@@ -10145,20 +10145,18 @@ end_write_group(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)),
...
@@ -10145,20 +10145,18 @@ end_write_group(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)),
join
->
sum_funcs_end
[
send_group_parts
]);
join
->
sum_funcs_end
[
send_group_parts
]);
if
(
join
->
having
&&
join
->
having
->
val_int
()
==
0
)
if
(
join
->
having
&&
join
->
having
->
val_int
()
==
0
)
error
=
-
1
;
error
=
-
1
;
else
if
((
error
=
table
->
file
->
write_row
(
table
->
record
[
0
])))
else
if
((
error
=
table
->
file
->
write_row
(
table
->
record
[
0
])))
{
{
if
(
create_myisam_from_heap
(
join
->
thd
,
table
,
if
(
create_myisam_from_heap
(
join
->
thd
,
table
,
&
join
->
tmp_table_param
,
&
join
->
tmp_table_param
,
error
,
0
))
error
,
0
))
DBUG_RETURN
(
-
1
);
DBUG_RETURN
(
-
1
);
}
}
if
(
join
->
rollup
.
state
!=
ROLLUP
::
STATE_NONE
&&
error
<=
0
)
if
(
join
->
rollup
.
state
!=
ROLLUP
::
STATE_NONE
)
{
{
if
(
join
->
rollup_write_data
((
uint
)
(
idx
+
1
),
table
))
if
(
join
->
rollup_write_data
((
uint
)
(
idx
+
1
),
table
))
error
=
1
;
DBUG_RETURN
(
-
1
)
;
}
}
if
(
error
>
0
)
DBUG_RETURN
(
-
1
);
if
(
end_of_records
)
if
(
end_of_records
)
DBUG_RETURN
(
0
);
DBUG_RETURN
(
0
);
}
}
...
@@ -12685,17 +12683,21 @@ bool JOIN::rollup_make_fields(List<Item> &fields_arg, List<Item> &sel_fields,
...
@@ -12685,17 +12683,21 @@ bool JOIN::rollup_make_fields(List<Item> &fields_arg, List<Item> &sel_fields,
{
{
/* Check if this is something that is part of this group by */
/* Check if this is something that is part of this group by */
ORDER
*
group_tmp
;
ORDER
*
group_tmp
;
for
(
group_tmp
=
start_group
,
i
--
;
for
(
group_tmp
=
start_group
,
i
=
pos
;
group_tmp
;
group_tmp
=
group_tmp
->
next
,
i
++
)
group_tmp
;
group_tmp
=
group_tmp
->
next
,
i
++
)
{
{
if
(
*
group_tmp
->
item
==
item
)
if
(
*
group_tmp
->
item
==
item
)
{
{
Item_null_result
*
null_item
;
/*
/*
This is an element that is used by the GROUP BY and should be
This is an element that is used by the GROUP BY and should be
set to NULL in this level
set to NULL in this level
*/
*/
item
->
maybe_null
=
1
;
// Value will be null sometimes
item
->
maybe_null
=
1
;
// Value will be null sometimes
Item_null_result
*
null_item
=
rollup
.
null_items
[
i
];
null_item
=
rollup
.
null_items
[
i
];
DBUG_ASSERT
(
null_item
->
result_field
==
0
||
null_item
->
result_field
==
((
Item_field
*
)
item
)
->
result_field
);
null_item
->
result_field
=
((
Item_field
*
)
item
)
->
result_field
;
null_item
->
result_field
=
((
Item_field
*
)
item
)
->
result_field
;
item
=
null_item
;
item
=
null_item
;
break
;
break
;
...
...
sql/sql_string.h
View file @
a1ab7860
...
@@ -84,6 +84,7 @@ class String
...
@@ -84,6 +84,7 @@ class String
inline
char
&
operator
[]
(
uint32
i
)
const
{
return
Ptr
[
i
];
}
inline
char
&
operator
[]
(
uint32
i
)
const
{
return
Ptr
[
i
];
}
inline
void
length
(
uint32
len
)
{
str_length
=
len
;
}
inline
void
length
(
uint32
len
)
{
str_length
=
len
;
}
inline
bool
is_empty
()
{
return
(
str_length
==
0
);
}
inline
bool
is_empty
()
{
return
(
str_length
==
0
);
}
inline
void
mark_as_const
()
{
Alloced_length
=
0
;}
inline
const
char
*
ptr
()
const
{
return
Ptr
;
}
inline
const
char
*
ptr
()
const
{
return
Ptr
;
}
inline
char
*
c_ptr
()
inline
char
*
c_ptr
()
{
{
...
@@ -205,10 +206,6 @@ class String
...
@@ -205,10 +206,6 @@ class String
}
}
}
}
}
}
inline
void
shrink_to_length
()
{
Alloced_length
=
str_length
;
}
bool
is_alloced
()
{
return
alloced
;
}
bool
is_alloced
()
{
return
alloced
;
}
inline
String
&
operator
=
(
const
String
&
s
)
inline
String
&
operator
=
(
const
String
&
s
)
{
{
...
...
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