mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 12:02:42 +01:00
Bug #27530:
The function CRC32() returns unsigned integer. But the metadata (the unsigned flag) for the function was set incorrectly. As a result type arithmetics based on the function's metadata (like finding the concise type of an temporary table column to hold the result) returned incorrect results. Fixed by returning correct type information. This fix is based on code contributed by Martin Friebe (martin@hybyte.com) on 2007-03-30. mysql-test/r/func_str.result: Bug #27530: test case mysql-test/t/func_str.test: Bug #27530: test case sql/item_strfunc.h: Bug #27530: Marked CRC32() as returning unsigned
This commit is contained in:
parent
b518d2a8bd
commit
8fe487beba
5 changed files with 161 additions and 1 deletions
35
mysql-test/r/bdb_notembedded.result
Normal file
35
mysql-test/r/bdb_notembedded.result
Normal file
|
@ -0,0 +1,35 @@
|
|||
set autocommit=1;
|
||||
reset master;
|
||||
create table bug16206 (a int);
|
||||
insert into bug16206 values(1);
|
||||
start transaction;
|
||||
insert into bug16206 values(2);
|
||||
commit;
|
||||
show binlog events;
|
||||
Log_name Pos Event_type Server_id End_log_pos Info
|
||||
f n Format_desc 1 n Server ver: VERSION, Binlog ver: 4
|
||||
f n Query 1 n use `test`; create table bug16206 (a int)
|
||||
f n Query 1 n use `test`; insert into bug16206 values(1)
|
||||
f n Query 1 n use `test`; insert into bug16206 values(2)
|
||||
drop table bug16206;
|
||||
reset master;
|
||||
create table bug16206 (a int) engine= bdb;
|
||||
insert into bug16206 values(0);
|
||||
insert into bug16206 values(1);
|
||||
start transaction;
|
||||
insert into bug16206 values(2);
|
||||
commit;
|
||||
insert into bug16206 values(3);
|
||||
show binlog events;
|
||||
Log_name Pos Event_type Server_id End_log_pos Info
|
||||
f n Format_desc 1 n Server ver: VERSION, Binlog ver: 4
|
||||
f n Query 1 n use `test`; create table bug16206 (a int) engine= bdb
|
||||
f n Query 1 n use `test`; insert into bug16206 values(0)
|
||||
f n Query 1 n use `test`; insert into bug16206 values(1)
|
||||
f n Query 1 n use `test`; BEGIN
|
||||
f n Query 1 n use `test`; insert into bug16206 values(2)
|
||||
f n Query 1 n use `test`; COMMIT
|
||||
f n Query 1 n use `test`; insert into bug16206 values(3)
|
||||
drop table bug16206;
|
||||
set autocommit=0;
|
||||
End of 5.0 tests
|
|
@ -1992,4 +1992,73 @@ abc
|
|||
SELECT INSERT('abc', 6, 3, '1234');
|
||||
INSERT('abc', 6, 3, '1234')
|
||||
abc
|
||||
CREATE TABLE t1 (a INT);
|
||||
CREATE VIEW v1 AS SELECT CRC32(a) AS C FROM t1;
|
||||
INSERT INTO t1 VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
|
||||
SELECT CRC32(a), COUNT(*) FROM t1 GROUP BY 1;
|
||||
CRC32(a) COUNT(*)
|
||||
450215437 1
|
||||
498629140 1
|
||||
1790921346 1
|
||||
1842515611 1
|
||||
2212294583 1
|
||||
2226203566 1
|
||||
2366072709 1
|
||||
2707236321 1
|
||||
4088798008 1
|
||||
4194326291 1
|
||||
SELECT CRC32(a), COUNT(*) FROM t1 GROUP BY 1 ORDER BY 1;
|
||||
CRC32(a) COUNT(*)
|
||||
450215437 1
|
||||
498629140 1
|
||||
1790921346 1
|
||||
1842515611 1
|
||||
2212294583 1
|
||||
2226203566 1
|
||||
2366072709 1
|
||||
2707236321 1
|
||||
4088798008 1
|
||||
4194326291 1
|
||||
SELECT * FROM (SELECT CRC32(a) FROM t1) t2;
|
||||
CRC32(a)
|
||||
2212294583
|
||||
450215437
|
||||
1842515611
|
||||
4088798008
|
||||
2226203566
|
||||
498629140
|
||||
1790921346
|
||||
4194326291
|
||||
2366072709
|
||||
2707236321
|
||||
CREATE TABLE t2 SELECT CRC32(a) FROM t1;
|
||||
desc t2;
|
||||
Field Type Null Key Default Extra
|
||||
CRC32(a) int(10) unsigned YES NULL
|
||||
SELECT * FROM v1;
|
||||
C
|
||||
2212294583
|
||||
450215437
|
||||
1842515611
|
||||
4088798008
|
||||
2226203566
|
||||
498629140
|
||||
1790921346
|
||||
4194326291
|
||||
2366072709
|
||||
2707236321
|
||||
SELECT * FROM (SELECT * FROM v1) x;
|
||||
C
|
||||
2212294583
|
||||
450215437
|
||||
1842515611
|
||||
4088798008
|
||||
2226203566
|
||||
498629140
|
||||
1790921346
|
||||
4194326291
|
||||
2366072709
|
||||
2707236321
|
||||
DROP TABLE t1, t2;
|
||||
DROP VIEW v1;
|
||||
End of 5.0 tests
|
||||
|
|
38
mysql-test/t/bdb_notembedded.test
Normal file
38
mysql-test/t/bdb_notembedded.test
Normal file
|
@ -0,0 +1,38 @@
|
|||
-- source include/not_embedded.inc
|
||||
-- source include/have_bdb.inc
|
||||
|
||||
#
|
||||
# Bug #16206: Superfluous COMMIT event in binlog when updating BDB in autocommit mode
|
||||
#
|
||||
set autocommit=1;
|
||||
|
||||
let $VERSION=`select version()`;
|
||||
|
||||
reset master;
|
||||
create table bug16206 (a int);
|
||||
insert into bug16206 values(1);
|
||||
start transaction;
|
||||
insert into bug16206 values(2);
|
||||
commit;
|
||||
--replace_result $VERSION VERSION
|
||||
--replace_column 1 f 2 n 5 n
|
||||
show binlog events;
|
||||
drop table bug16206;
|
||||
|
||||
reset master;
|
||||
create table bug16206 (a int) engine= bdb;
|
||||
insert into bug16206 values(0);
|
||||
insert into bug16206 values(1);
|
||||
start transaction;
|
||||
insert into bug16206 values(2);
|
||||
commit;
|
||||
insert into bug16206 values(3);
|
||||
--replace_result $VERSION VERSION
|
||||
--replace_column 1 f 2 n 5 n
|
||||
show binlog events;
|
||||
drop table bug16206;
|
||||
|
||||
set autocommit=0;
|
||||
|
||||
|
||||
--echo End of 5.0 tests
|
|
@ -1058,4 +1058,22 @@ SELECT INSERT('abc', 4, 3, '1234');
|
|||
SELECT INSERT('abc', 5, 3, '1234');
|
||||
SELECT INSERT('abc', 6, 3, '1234');
|
||||
|
||||
#
|
||||
# Bug #27530: Grouping on crc32, or create table select crc32
|
||||
#
|
||||
CREATE TABLE t1 (a INT);
|
||||
CREATE VIEW v1 AS SELECT CRC32(a) AS C FROM t1;
|
||||
|
||||
INSERT INTO t1 VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
|
||||
SELECT CRC32(a), COUNT(*) FROM t1 GROUP BY 1;
|
||||
SELECT CRC32(a), COUNT(*) FROM t1 GROUP BY 1 ORDER BY 1;
|
||||
SELECT * FROM (SELECT CRC32(a) FROM t1) t2;
|
||||
CREATE TABLE t2 SELECT CRC32(a) FROM t1;
|
||||
desc t2;
|
||||
SELECT * FROM v1;
|
||||
SELECT * FROM (SELECT * FROM v1) x;
|
||||
|
||||
DROP TABLE t1, t2;
|
||||
DROP VIEW v1;
|
||||
|
||||
--echo End of 5.0 tests
|
||||
|
|
|
@ -790,7 +790,7 @@ class Item_func_crc32 :public Item_int_func
|
|||
{
|
||||
String value;
|
||||
public:
|
||||
Item_func_crc32(Item *a) :Item_int_func(a) {}
|
||||
Item_func_crc32(Item *a) :Item_int_func(a) { unsigned_flag= 1; }
|
||||
const char *func_name() const { return "crc32"; }
|
||||
void fix_length_and_dec() { max_length=10; }
|
||||
longlong val_int();
|
||||
|
|
Loading…
Reference in a new issue