~drizzle-trunk/drizzle/development

1 by brian
clean slate
1
#
2
# This test gave a core dump
3
#
4
5
--disable_warnings
6
DROP TABLE IF EXISTS t1,t2,t3,t4;
7
--enable_warnings
8
9
CREATE TABLE t1 (
10
  project_id int(11) NOT NULL auto_increment,
11
  project_row_lock int(11) NOT NULL default '0',
12
  project_name varchar(80) NOT NULL default '',
13
  client_ptr int(11) NOT NULL default '0',
14
  project_contact_ptr int(11) default NULL,
15
  client_contact_ptr int(11) default NULL,
16
  billing_contact_ptr int(11) default NULL,
17
  comments mediumtext,
18
  PRIMARY KEY  (project_id),
19
  UNIQUE KEY project (client_ptr,project_name)
20
) ENGINE=MyISAM PACK_KEYS=1;
21
22
INSERT INTO t1 VALUES (1,0,'Rejected Time',1,NULL,NULL,NULL,NULL);
23
INSERT INTO t1 VALUES (209,0,'MDGRAD Proposal/Investigation',97,NULL,NULL,NULL,'');
24
INSERT INTO t1 VALUES (208,0,'Font 9 Design',84,NULL,NULL,NULL,'');
25
INSERT INTO t1 VALUES (207,0,'Web Based Order Processing',95,NULL,NULL,NULL,'');
26
INSERT INTO t1 VALUES (205,0,'Mac Screen Saver',95,NULL,NULL,NULL,'');
27
INSERT INTO t1 VALUES (206,0,'Web Site',96,NULL,NULL,NULL,'');
28
INSERT INTO t1 VALUES (204,0,'Magnafire Glue',94,NULL,NULL,NULL,'');
29
INSERT INTO t1 VALUES (203,0,'Print Bid',93,NULL,NULL,NULL,'');
30
INSERT INTO t1 VALUES (202,0,'EPOC Port',92,NULL,NULL,NULL,'');
31
INSERT INTO t1 VALUES (201,0,'TravelMate',88,NULL,NULL,NULL,'');
32
33
CREATE TABLE t2 (
34
  period_id int(11) NOT NULL auto_increment,
35
  period_type enum('user_table','client_table','role_table','member_table','project_table') default NULL,
36
  period_key int(11) default NULL,
37
  start_date datetime default NULL,
38
  end_date datetime default NULL,
39
  work_load int(11) default NULL,
40
  PRIMARY KEY  (period_id),
41
  KEY period_index (period_type,period_key),
42
  KEY date_index (start_date,end_date)
43
) ENGINE=MyISAM PACK_KEYS=1;
44
45
INSERT INTO t2 VALUES (1,'user_table',98,'2000-01-01 00:00:00',NULL,NULL);
46
INSERT INTO t2 VALUES (2,'user_table',99,'2000-01-01 00:00:00',NULL,NULL);
47
INSERT INTO t2 VALUES (3,'user_table',100,'2000-01-01 00:00:00',NULL,NULL);
48
INSERT INTO t2 VALUES (49,'project_table',148,'2000-01-01 00:00:00',NULL,NULL);
49
INSERT INTO t2 VALUES (50,'client_table',68,'2000-01-01 00:00:00',NULL,NULL);
50
INSERT INTO t2 VALUES (51,'project_table',149,'2000-01-01 00:00:00',NULL,NULL);
51
INSERT INTO t2 VALUES (52,'project_table',150,'2000-01-01 00:00:00',NULL,NULL);
52
INSERT INTO t2 VALUES (53,'client_table',69,'2000-01-01 00:00:00',NULL,NULL);
53
INSERT INTO t2 VALUES (54,'project_table',151,'2000-01-01 00:00:00',NULL,NULL);
54
INSERT INTO t2 VALUES (55,'client_table',70,'2000-01-01 00:00:00',NULL,NULL);
55
INSERT INTO t2 VALUES (155,'role_table',1,'2000-01-01 00:00:00',NULL,NULL);
56
INSERT INTO t2 VALUES (156,'role_table',2,'2000-01-01 00:00:00',NULL,NULL);
57
INSERT INTO t2 VALUES (160,'member_table',1,'2000-01-01 00:00:00',NULL,1);
58
INSERT INTO t2 VALUES (161,'member_table',2,'2000-01-01 00:00:00',NULL,1);
59
INSERT INTO t2 VALUES (162,'member_table',3,'2000-01-01 00:00:00',NULL,1);
60
61
CREATE TABLE t3 (
62
  budget_id int(11) NOT NULL auto_increment,
63
  project_ptr int(11) NOT NULL default '0',
64
  po_number varchar(20) NOT NULL default '',
65
  status enum('open','closed') default NULL,
66
  date_received datetime default NULL,
67
  amount_received float(10,2) default NULL,
68
  adjustment float(10,2) default NULL,
69
  PRIMARY KEY  (budget_id),
70
  UNIQUE KEY po (project_ptr,po_number)
71
) ENGINE=MyISAM PACK_KEYS=1;
72
73
CREATE TABLE t4 (
74
  client_id int(11) NOT NULL auto_increment,
75
  client_row_lock int(11) NOT NULL default '0',
76
  client_name varchar(80) NOT NULL default '',
77
  contact_ptr int(11) default NULL,
78
  comments mediumtext,
79
  PRIMARY KEY  (client_id),
80
  UNIQUE KEY client_name (client_name)
81
) ENGINE=MyISAM PACK_KEYS=1;
82
83
INSERT INTO t4 VALUES (1,0,'CPS',NULL,NULL);
84
85
#
86
#	The query that fails...
87
#
88
select distinct
89
    t1.project_id as project_id,
90
    t1.project_name as project_name,
91
    t1.client_ptr as client_ptr,
92
    t1.comments as comments,
93
    sum( t3.amount_received ) + sum( t3.adjustment ) as total_budget
94
from
95
    t2 as client_period ,
96
    t2 as project_period,
97
    t3 left join t1 on (t3.project_ptr = t1.project_id and
98
                        t3.date_received <= '2001-03-22 14:15:09')
99
       left join t4 on t4.client_id = t1.client_ptr
100
   where
101
        1
102
        and ( client_period.period_type = 'client_table'
103
            and client_period.period_key = t4.client_id
104
            and ( client_period.start_date <= '2001-03-22 14:15:09' or isnull( client_period.start_date ))
105
            and ( client_period.end_date > '2001-03-21 14:15:09' or isnull( client_period.end_date ))
106
            )
107
        and ( project_period.period_type = 'project_table'
108
        and project_period.period_key = t1.project_id
109
        and ( project_period.start_date <= '2001-03-22 14:15:09' or isnull( project_period.start_date ))
110
        and ( project_period.end_date > '2001-03-21 14:15:09' or isnull( project_period.end_date )) )
111
    group by
112
        client_id,
113
        project_id ,
114
        client_period.period_id ,
115
        project_period.period_id
116
    order by
117
        client_name asc,
118
        project_name asc;
119
DROP TABLE t1,t2,t3,t4;
120
121
# End of 4.1 tests