*** a/sql/item_strfunc.h Fri Mar 2 10:14:49 2007 --- b/sql/item_strfunc.h Fri Mar 30 20:26:11 2007 *************** *** 792,798 **** public: Item_func_crc32(Item *a) :Item_int_func(a) {} const char *func_name() const { return "crc32"; } ! void fix_length_and_dec() { max_length=10; } longlong val_int(); }; --- 792,798 ---- public: Item_func_crc32(Item *a) :Item_int_func(a) {} const char *func_name() const { return "crc32"; } ! void fix_length_and_dec() { max_length=10; unsigned_flag= 1; } longlong val_int(); }; *** a/mysql-test/t/func_str.test Sat Mar 10 16:57:17 2007 --- b/mysql-test/t/func_str.test Fri Mar 30 20:39:12 2007 *************** *** 1055,1057 **** --- 1055,1119 ---- SELECT INSERT('abc', 6, 3, '1234'); --echo End of 5.0 tests + + # + # Bug #27530: Grouping on crc32, or create table select crc32 + # + + --disable_warnings + DROP TABLE IF EXISTS t1, t2; + drop view if exists v1; + --enable_warnings + + + create table t1 (col int primary key not null); + create view v1 as select crc32(col) as c from t1; + + insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); + select crc32(col), count(*) from t1 group by 1; + select crc32(col), count(*) from t1 group by 1 order by 2; + select * from (select crc32(col) from t1) t2; + create table t2 select crc32(col) from t1; + desc t2; + select * from v1; + select * from (select * from v1) x; + DROP TABLE t1; + DROP TABLE t2; + + create table t1 (col int unsigned not null); + insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); + select crc32(col), count(*) from t1 group by 1; + select crc32(col), count(*) from t1 group by 1 order by 2; + select * from (select crc32(col) from t1) t2; + create table t2 select crc32(col) from t1; + desc t2; + select * from v1; + select * from (select * from v1) x; + DROP TABLE t1; + DROP TABLE t2; + + create table t1 (col int signed null); + insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); + select crc32(col), count(*) from t1 group by 1; + select crc32(col), count(*) from t1 group by 1 order by 2; + select * from (select crc32(col) from t1) t2; + create table t2 select crc32(col) from t1; + desc t2; + select * from v1; + select * from (select * from v1) x; + DROP TABLE t1; + DROP TABLE t2; + + create table t1 (col varchar(3) not null); + insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); + select crc32(col), count(*) from t1 group by 1; + select crc32(col), count(*) from t1 group by 1 order by 2; + select * from (select crc32(col) from t1) t2; + create table t2 select crc32(col) from t1; + desc t2; + select * from v1; + select * from (select * from v1) x; + DROP TABLE t1; + DROP TABLE t2; + + drop view if exists v1; *** a/mysql-test/r/func_str.result Sat Mar 10 16:57:17 2007 --- b/mysql-test/r/func_str.result Fri Mar 30 20:39:15 2007 *************** *** 1984,1986 **** --- 1984,2262 ---- INSERT('abc', 6, 3, '1234') abc End of 5.0 tests + DROP TABLE IF EXISTS t1, t2; + drop view if exists v1; + create table t1 (col int primary key not null); + create view v1 as select crc32(col) as c from t1; + insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); + select crc32(col), count(*) from t1 group by 1; + crc32(col) count(*) + 450215437 1 + 498629140 1 + 1790921346 1 + 1842515611 1 + 2212294583 1 + 2226203566 1 + 2366072709 1 + 2707236321 1 + 4088798008 1 + 4194326291 1 + select crc32(col), count(*) from t1 group by 1 order by 2; + crc32(col) count(*) + 2212294583 1 + 450215437 1 + 1842515611 1 + 4088798008 1 + 2226203566 1 + 498629140 1 + 1790921346 1 + 4194326291 1 + 2366072709 1 + 2707236321 1 + select * from (select crc32(col) from t1) t2; + crc32(col) + 2212294583 + 450215437 + 1842515611 + 4088798008 + 2226203566 + 498629140 + 1790921346 + 4194326291 + 2366072709 + 2707236321 + create table t2 select crc32(col) from t1; + desc t2; + Field Type Null Key Default Extra + crc32(col) int(10) unsigned NO 0 + 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; + DROP TABLE t2; + create table t1 (col int unsigned not null); + insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); + select crc32(col), count(*) from t1 group by 1; + crc32(col) count(*) + 450215437 1 + 498629140 1 + 1790921346 1 + 1842515611 1 + 2212294583 1 + 2226203566 1 + 2366072709 1 + 2707236321 1 + 4088798008 1 + 4194326291 1 + select crc32(col), count(*) from t1 group by 1 order by 2; + crc32(col) count(*) + 2212294583 1 + 450215437 1 + 1842515611 1 + 4088798008 1 + 2226203566 1 + 498629140 1 + 1790921346 1 + 4194326291 1 + 2366072709 1 + 2707236321 1 + select * from (select crc32(col) from t1) t2; + crc32(col) + 2212294583 + 450215437 + 1842515611 + 4088798008 + 2226203566 + 498629140 + 1790921346 + 4194326291 + 2366072709 + 2707236321 + create table t2 select crc32(col) from t1; + desc t2; + Field Type Null Key Default Extra + crc32(col) int(10) unsigned NO 0 + 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; + DROP TABLE t2; + create table t1 (col int signed null); + insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); + select crc32(col), count(*) from t1 group by 1; + crc32(col) count(*) + 450215437 1 + 498629140 1 + 1790921346 1 + 1842515611 1 + 2212294583 1 + 2226203566 1 + 2366072709 1 + 2707236321 1 + 4088798008 1 + 4194326291 1 + select crc32(col), count(*) from t1 group by 1 order by 2; + crc32(col) count(*) + 2212294583 1 + 450215437 1 + 1842515611 1 + 4088798008 1 + 2226203566 1 + 498629140 1 + 1790921346 1 + 4194326291 1 + 2366072709 1 + 2707236321 1 + select * from (select crc32(col) from t1) t2; + crc32(col) + 2212294583 + 450215437 + 1842515611 + 4088798008 + 2226203566 + 498629140 + 1790921346 + 4194326291 + 2366072709 + 2707236321 + create table t2 select crc32(col) from t1; + desc t2; + Field Type Null Key Default Extra + crc32(col) 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; + DROP TABLE t2; + create table t1 (col varchar(3) not null); + insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); + select crc32(col), count(*) from t1 group by 1; + crc32(col) count(*) + 450215437 1 + 498629140 1 + 1790921346 1 + 1842515611 1 + 2212294583 1 + 2226203566 1 + 2366072709 1 + 2707236321 1 + 4088798008 1 + 4194326291 1 + select crc32(col), count(*) from t1 group by 1 order by 2; + crc32(col) count(*) + 2212294583 1 + 450215437 1 + 1842515611 1 + 4088798008 1 + 2226203566 1 + 498629140 1 + 1790921346 1 + 4194326291 1 + 2366072709 1 + 2707236321 1 + select * from (select crc32(col) from t1) t2; + crc32(col) + 2212294583 + 450215437 + 1842515611 + 4088798008 + 2226203566 + 498629140 + 1790921346 + 4194326291 + 2366072709 + 2707236321 + create table t2 select crc32(col) from t1; + desc t2; + Field Type Null Key Default Extra + crc32(col) int(10) unsigned NO 0 + 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; + DROP TABLE t2; + drop view if exists v1;