Skip to content

Commit 01a8bad

Browse files
kevgsmidenok
authored andcommitted
SQL: allow PERIOD as identifier [fixes #331]
1 parent 62470fc commit 01a8bad

18 files changed

+618
-617
lines changed

mysql-test/extra/binlog_tests/blackhole.test

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ drop table if exists t1,t2;
1717
--enable_warnings
1818

1919
CREATE TABLE t1 (
20-
Period_ smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL,
20+
Period smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL,
2121
Varor_period smallint(4) unsigned DEFAULT '0' NOT NULL
2222
) ENGINE=blackhole;
2323

2424
INSERT INTO t1 VALUES (9410,9412);
2525

26-
select period_ from t1;
26+
select period from t1;
2727
select * from t1;
2828
select t1.* from t1;
2929

mysql-test/include/common-tests.inc

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ drop table if exists t1,t2,t3,t4;
1414
--enable_warnings
1515

1616
CREATE TABLE t1 (
17-
Period_ smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL,
17+
Period smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL,
1818
Varor_period smallint(4) unsigned DEFAULT '0' NOT NULL
1919
);
2020

2121
INSERT INTO t1 VALUES (9410,9412);
2222

23-
select period_ from t1;
23+
select period from t1;
2424
select * from t1;
2525
select t1.* from t1;
2626

@@ -1349,7 +1349,7 @@ select fld1,fld3 from t2 where fld1 like "25050_";
13491349
select distinct companynr from t2;
13501350
select distinct companynr from t2 order by companynr;
13511351
select distinct companynr from t2 order by companynr desc;
1352-
select distinct t2.fld3,period_ from t2,t1 where companynr=37 and fld3 like "O%";
1352+
select distinct t2.fld3,period from t2,t1 where companynr=37 and fld3 like "O%";
13531353

13541354
select distinct fld3 from t2 where companynr = 34 order by fld3;
13551355
select distinct fld3 from t2 limit 10;
@@ -1362,26 +1362,26 @@ select distinct substring(fld3,1,3) as a from t2 having a like "A%" limit 10;
13621362
# make a big table.
13631363

13641364
create table t3 (
1365-
period_ int not null,
1365+
period int not null,
13661366
name char(32) not null,
13671367
companynr int not null,
13681368
price double(11,0),
13691369
price2 double(11,0),
1370-
key (period_),
1370+
key (period),
13711371
key (name)
13721372
);
13731373

13741374
--disable_query_log
1375-
INSERT INTO t3 (period_,name,companynr,price,price2) VALUES (1001,"Iranizes",37,5987435,234724);
1376-
INSERT INTO t3 (period_,name,companynr,price,price2) VALUES (1002,"violinist",37,28357832,8723648);
1377-
INSERT INTO t3 (period_,name,companynr,price,price2) VALUES (1003,"extramarital",37,39654943,235872);
1378-
INSERT INTO t3 (period_,name,companynr,price,price2) VALUES (1004,"spates",78,726498,72987523);
1379-
INSERT INTO t3 (period_,name,companynr,price,price2) VALUES (1005,"cloakroom",78,98439034,823742);
1380-
INSERT INTO t3 (period_,name,companynr,price,price2) VALUES (1006,"gazer",101,834598,27348324);
1381-
INSERT INTO t3 (period_,name,companynr,price,price2) VALUES (1007,"hand",154,983543950,29837423);
1382-
INSERT INTO t3 (period_,name,companynr,price,price2) VALUES (1008,"tucked",311,234298,3275892);
1383-
INSERT INTO t3 (period_,name,companynr,price,price2) VALUES (1009,"gems",447,2374834,9872392);
1384-
INSERT INTO t3 (period_,name,companynr,price,price2) VALUES (1010,"clinker",512,786542,76234234);
1375+
INSERT INTO t3 (period,name,companynr,price,price2) VALUES (1001,"Iranizes",37,5987435,234724);
1376+
INSERT INTO t3 (period,name,companynr,price,price2) VALUES (1002,"violinist",37,28357832,8723648);
1377+
INSERT INTO t3 (period,name,companynr,price,price2) VALUES (1003,"extramarital",37,39654943,235872);
1378+
INSERT INTO t3 (period,name,companynr,price,price2) VALUES (1004,"spates",78,726498,72987523);
1379+
INSERT INTO t3 (period,name,companynr,price,price2) VALUES (1005,"cloakroom",78,98439034,823742);
1380+
INSERT INTO t3 (period,name,companynr,price,price2) VALUES (1006,"gazer",101,834598,27348324);
1381+
INSERT INTO t3 (period,name,companynr,price,price2) VALUES (1007,"hand",154,983543950,29837423);
1382+
INSERT INTO t3 (period,name,companynr,price,price2) VALUES (1008,"tucked",311,234298,3275892);
1383+
INSERT INTO t3 (period,name,companynr,price,price2) VALUES (1009,"gems",447,2374834,9872392);
1384+
INSERT INTO t3 (period,name,companynr,price,price2) VALUES (1010,"clinker",512,786542,76234234);
13851385
--enable_query_log
13861386

13871387
create temporary table tmp engine = myisam select * from t3;
@@ -1450,47 +1450,47 @@ explain select t3.t2nr,fld3 from t2,t3 where t2.companynr = 34 and t2.fld1=t3.t2
14501450
# Some test with ORDER BY and limit
14511451
#
14521452

1453-
explain select * from t3 as t1,t3 where t1.period_=t3.period_ order by t3.period_;
1454-
explain select * from t3 as t1,t3 where t1.period_=t3.period_ order by t3.period_ limit 10;
1455-
explain select * from t3 as t1,t3 where t1.period_=t3.period_ order by t1.period_ limit 10;
1453+
explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period;
1454+
explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period limit 10;
1455+
explain select * from t3 as t1,t3 where t1.period=t3.period order by t1.period limit 10;
14561456

14571457
#
14581458
# Search with a constant table.
14591459
#
14601460

1461-
select period_ from t1;
1462-
select period_ from t1 where period_=1900;
1463-
select fld3,period_ from t1,t2 where fld1 = 011401 order by period_;
1461+
select period from t1;
1462+
select period from t1 where period=1900;
1463+
select fld3,period from t1,t2 where fld1 = 011401 order by period;
14641464

14651465
#
14661466
# Search with a constant table and several keyparts. (Rows are read only once
14671467
# in the beginning of the search)
14681468
#
14691469

1470-
select fld3,period_ from t2,t3 where t2.fld1 = 011401 and t2.fld1=t3.t2nr and t3.period_=1001;
1470+
select fld3,period from t2,t3 where t2.fld1 = 011401 and t2.fld1=t3.t2nr and t3.period=1001;
14711471

1472-
explain select fld3,period_ from t2,t3 where t2.fld1 = 011401 and t3.t2nr=t2.fld1 and 1001 = t3.period_;
1472+
explain select fld3,period from t2,t3 where t2.fld1 = 011401 and t3.t2nr=t2.fld1 and 1001 = t3.period;
14731473

14741474
#
14751475
# Search with a constant table and several rows from another table
14761476
#
14771477

1478-
select fld3,period_ from t2,t1 where companynr*10 = 37*10;
1478+
select fld3,period from t2,t1 where companynr*10 = 37*10;
14791479

14801480
#
14811481
# Search with a table reference and without a key.
14821482
# t3 will be the main table.
14831483
#
14841484

1485-
select fld3,period_,price,price2 from t2,t3 where t2.fld1=t3.t2nr and period_ >= 1001 and period_ <= 1002 and t2.companynr = 37 order by fld3,period_, price;
1485+
select fld3,period,price,price2 from t2,t3 where t2.fld1=t3.t2nr and period >= 1001 and period <= 1002 and t2.companynr = 37 order by fld3,period, price;
14861486

14871487
#
14881488
# Search with an interval on a table with full key on reference table.
14891489
# Here t2 will be the main table and only records matching the
14901490
# t2nr will be checked.
14911491
#
14921492

1493-
select t2.fld1,fld3,period_,price,price2 from t2,t3 where t2.fld1>= 18201 and t2.fld1 <= 18811 and t2.fld1=t3.t2nr and period_ = 1001 and t2.companynr = 37;
1493+
select t2.fld1,fld3,period,price,price2 from t2,t3 where t2.fld1>= 18201 and t2.fld1 <= 18811 and t2.fld1=t3.t2nr and period = 1001 and t2.companynr = 37;
14941494

14951495
#
14961496
# We need another table for join stuff..
@@ -1588,18 +1588,18 @@ explain select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=
15881588
# each record
15891589
#
15901590

1591-
select t2.fld1,t2.companynr,fld3,period_ from t3,t2 where t2.fld1 = 38208 and t2.fld1=t3.t2nr and period_ = 1008 or t2.fld1 = 38008 and t2.fld1 =t3.t2nr and period_ = 1008;
1591+
select t2.fld1,t2.companynr,fld3,period from t3,t2 where t2.fld1 = 38208 and t2.fld1=t3.t2nr and period = 1008 or t2.fld1 = 38008 and t2.fld1 =t3.t2nr and period = 1008;
15921592

1593-
select t2.fld1,t2.companynr,fld3,period_ from t3,t2 where (t2.fld1 = 38208 or t2.fld1 = 38008) and t2.fld1=t3.t2nr and period_>=1008 and period_<=1009;
1593+
select t2.fld1,t2.companynr,fld3,period from t3,t2 where (t2.fld1 = 38208 or t2.fld1 = 38008) and t2.fld1=t3.t2nr and period>=1008 and period<=1009;
15941594

1595-
select t2.fld1,t2.companynr,fld3,period_ from t3,t2 where (t3.t2nr = 38208 or t3.t2nr = 38008) and t2.fld1=t3.t2nr and period_>=1008 and period_<=1009;
1595+
select t2.fld1,t2.companynr,fld3,period from t3,t2 where (t3.t2nr = 38208 or t3.t2nr = 38008) and t2.fld1=t3.t2nr and period>=1008 and period<=1009;
15961596

15971597
#
15981598
# Test of many parenthesis levels
15991599
#
16001600

1601-
select period_ from t1 where (((period_ > 0) or period_ < 10000 or (period_ = 1900)) and (period_=1900 and period_ <= 1901) or (period_=1903 and (period_=1903)) and period_>=1902) or ((period_=1904 or period_=1905) or (period_=1906 or period_>1907)) or (period_=1908 and period_ = 1909);
1602-
select period_ from t1 where ((period_ > 0 and period_ < 1) or (((period_ > 0 and period_ < 100) and (period_ > 10)) or (period_ > 10)) or (period_ > 0 and (period_ > 5 or period_ > 6)));
1601+
select period from t1 where (((period > 0) or period < 10000 or (period = 1900)) and (period=1900 and period <= 1901) or (period=1903 and (period=1903)) and period>=1902) or ((period=1904 or period=1905) or (period=1906 or period>1907)) or (period=1908 and period = 1909);
1602+
select period from t1 where ((period > 0 and period < 1) or (((period > 0 and period < 100) and (period > 10)) or (period > 10)) or (period > 0 and (period > 5 or period > 6)));
16031603

16041604
select a.fld1 from t2 as a,t2 b where ((a.fld1 = 250501 and a.fld1=b.fld1) or a.fld1=250502 or a.fld1=250503 or (a.fld1=250505 and a.fld1<=b.fld1 and b.fld1>=a.fld1)) and a.fld1=b.fld1;
16051605

@@ -1657,7 +1657,7 @@ select t2.fld1,count(*) from t2,t3 where t2.fld1=158402 and t3.name=t2.fld3 grou
16571657
# Calculation with group functions
16581658
#
16591659

1660-
select sum(Period_)/count(*) from t1;
1660+
select sum(Period)/count(*) from t1;
16611661
select companynr,count(price) as "count",sum(price) as "sum" ,abs(sum(price)/count(price)-avg(price)) as "diff",(0+count(price))*companynr as func from t3 group by companynr;
16621662
select companynr,sum(price)/count(price) as avg from t3 group by companynr having avg > 70000000 order by avg;
16631663

@@ -1747,13 +1747,13 @@ select max(t2nr) from t3 where price=983543950;
17471747
# Test of alias
17481748
#
17491749

1750-
select t1.period_ from t3 = t1 limit 1;
1751-
select t1.period_ from t1 as t1 limit 1;
1752-
select t1.period_ as "Nuvarande period_" from t1 as t1 limit 1;
1753-
select period_ as ok_period from t1 limit 1;
1754-
select period_ as ok_period from t1 group by ok_period limit 1;
1750+
select t1.period from t3 = t1 limit 1;
1751+
select t1.period from t1 as t1 limit 1;
1752+
select t1.period as "Nuvarande period" from t1 as t1 limit 1;
1753+
select period as ok_period from t1 limit 1;
1754+
select period as ok_period from t1 group by ok_period limit 1;
17551755
select 1+1 as summa from t1 group by summa limit 1;
1756-
select period_ as "Nuvarande period_" from t1 group by "Nuvarande period_" limit 1;
1756+
select period as "Nuvarande period" from t1 group by "Nuvarande period" limit 1;
17571757

17581758
#
17591759
# Some simple show commands

0 commit comments

Comments
 (0)