~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/r/join_crash.result

  • Committer: Stewart Smith
  • Date: 2008-07-13 06:56:15 UTC
  • mto: (210.1.1 drizzle)
  • mto: This revision was merged to the branch mainline in revision 211.
  • Revision ID: stewart@flamingspork.com-20080713065615-vzok75kgnnviokl9
Move MD5() into a UDF

Show diffs side-by-side

added added

removed removed

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