Description:
SELECT DISTINCT
bugs.bug_id, bugs.groupset, bugs.bug_severity, bugs.priority, bugs.rep_platform, map_assigned_to.login_name,
bugs.bug_status, bugs.resolution, bugs.short_desc FROM bugs, profiles map_assigned_to, profiles map_reporter
LEFT JOIN profiles map_qa_contact ON bugs.qa_contact = map_qa_contact.userid LEFT JOIN cc selectVisible_cc ON
bugs.bug_id = selectVisible_cc.bug_id AND
selectVisible_cc.who = 3 WHERE ((bugs.groupset & 127) = bugs.groupset OR (bugs.reporter_accessible = 1 AND
bugs.reporter = 3) OR (bugs.cclist_accessible = 1 AND selectVisible_cc.who = 3
AND not isnull(selectVisible_cc.who)) OR (bugs.assigned_to = 3)) AND bugs.assigned_to = map_assigned_to.userid
AND bugs.reporter = map_reporter.userid AND (bugs.bug_status = 'NEW' OR bugs.bug_status = 'ASSIGNED' OR
bugs.bug_status = 'REOPENED') AND (bugs.product = 'AstBill') ORDER BY bugs.bug_status, bugs.priority,
map_assigned_to.login_name, bugs.bug_id;
The above SQL works EXELENT in 5.10 and erarlier versions of mysql. It is part of standard bugzilla.org installation that have been using mysql for a very long time.
IT IS NOT WORKING IN 5.0.12-beta-standard
ERROR 1054 (42S22): Unknown column 'bugs.qa_contact' in 'on clause'
The column 'bugs.qa_contact' is in the table.
How to repeat:
CREATE TABLE `bugs` (
`bug_id` mediumint(9) NOT NULL auto_increment,
`groupset` bigint(20) NOT NULL,
`assigned_to` mediumint(9) NOT NULL,
`bug_file_loc` text,
`bug_severity` enum('blocker','critical','major','normal','minor','trivial','enhancement') NOT NULL,
`bug_status` enum('UNCONFIRMED','NEW','ASSIGNED','REOPENED','RESOLVED','VERIFIED','CLOSED') NOT NULL,
`creation_ts` datetime NOT NULL,
`delta_ts` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
`short_desc` mediumtext,
`op_sys` enum('All','Windows 3.1','Windows 95','Windows 98','Windows ME','Windows 2000','Windows NT','Mac System 7','Mac System 7.5','Mac System 7.6.1','Mac System 8.0','Mac System 8.5','Mac System 8.6','Mac System 9.x','MacOS X','Linux','BSDI','FreeBSD','NetBSD','OpenBSD','AIX','BeOS','HP-UX','IRIX','Neutrino','OpenVMS','OS/2','OSF/1','Solaris','SunOS','other') NOT NULL,
`priority` enum('P1','P2','P3','P4','P5') NOT NULL,
`product` varchar(64) NOT NULL,
`rep_platform` enum('All','DEC','HP','Macintosh','PC','SGI','Sun','Other') default NULL,
`reporter` mediumint(9) NOT NULL,
`version` varchar(64) NOT NULL,
`component` varchar(50) NOT NULL,
`resolution` enum('','FIXED','INVALID','WONTFIX','LATER','REMIND','DUPLICATE','WORKSFORME','MOVED') NOT NULL,
`target_milestone` varchar(20) NOT NULL default '---',
`qa_contact` mediumint(9) NOT NULL,
`status_whiteboard` mediumtext NOT NULL,
`votes` mediumint(9) NOT NULL,
`keywords` mediumtext NOT NULL,
`lastdiffed` datetime NOT NULL,
`everconfirmed` tinyint(4) NOT NULL,
`reporter_accessible` tinyint(4) NOT NULL default '1',
`cclist_accessible` tinyint(4) NOT NULL default '1',
PRIMARY KEY (`bug_id`),
KEY `assigned_to` (`assigned_to`),
KEY `creation_ts` (`creation_ts`),
KEY `delta_ts` (`delta_ts`),
KEY `bug_severity` (`bug_severity`),
KEY `bug_status` (`bug_status`),
KEY `op_sys` (`op_sys`),
KEY `priority` (`priority`),
KEY `product` (`product`),
KEY `reporter` (`reporter`),
KEY `version` (`version`),
KEY `component` (`component`),
KEY `resolution` (`resolution`),
KEY `target_milestone` (`target_milestone`),
KEY `qa_contact` (`qa_contact`),
KEY `votes` (`votes`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=36 ;
--
-- Dumping data for table `bugs`
--
INSERT INTO `bugs` VALUES (1, 0, 3, '', 'normal', 'RESOLVED', '2005-08-28 19:22:47', '2005-08-28 22:32:14', 'blablabla', 'All', 'P2', 'AstBill', 'PC', 1, '0.9.1', 'astentry', 'FIXED', '---', 0, '', 0, '', '2005-08-28 22:32:14', 1, 1, 1);
INSERT INTO `bugs` VALUES (27, 0, 1, '', 'critical', 'RESOLVED', '2005-08-31 23:03:38', '2005-08-31 23:31:52', 'BUGS: Friends & Incoming', 'All', 'P1', 'AstBill', 'PC', 3, '0.9.1', 'AstAdmin', 'FIXED', '---', 0, '', 0, '', '2005-08-31 23:31:52', 1, 1, 1);
INSERT INTO `bugs` VALUES (32, 0, 1, '', 'normal', 'NEW', '2005-09-01 12:43:26', '2005-09-01 13:15:52', 'Show CDR', 'All', 'P3', 'AstBill', 'PC', 3, '0.9.1', 'AstAdmin', '', '---', 0, '', 0, '', '2005-09-01 13:15:52', 1, 1, 1);
INSERT INTO `bugs` VALUES (34, 0, 3, '', 'normal', 'RESOLVED', '2005-09-01 15:17:48', '2005-09-02 13:02:24', 'Startup Script', 'All', 'P3', 'AstBill', 'PC', 3, '0.9.1', 'Server Scripts', 'FIXED', '---', 0, '', 0, '', '2005-09-02 13:02:24', 1, 1, 1);
INSERT INTO `bugs` VALUES (35, 0, 1, '', 'blocker', 'RESOLVED', '2005-09-02 13:47:11', '2005-09-02 15:45:22', 'Database: astdialplan.fri', 'All', 'P1', 'AstBill', 'PC', 3, '0.9.1', 'astentry', 'FIXED', '---', 0, '', 0, '', '2005-09-02 15:45:23', 1, 1, 1);
CREATE TABLE `cc` (
`bug_id` mediumint(9) NOT NULL,
`who` mediumint(9) NOT NULL,
UNIQUE KEY `bug_id` (`bug_id`,`who`),
KEY `who` (`who`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
CREATE TABLE `profiles` (
`userid` mediumint(9) NOT NULL auto_increment,
`login_name` varchar(255) NOT NULL,
`cryptpassword` varchar(34) default NULL,
`realname` varchar(255) default NULL,
`groupset` bigint(20) NOT NULL,
`disabledtext` mediumtext NOT NULL,
`mybugslink` tinyint(4) NOT NULL default '1',
`blessgroupset` bigint(20) NOT NULL default '0',
`emailflags` mediumtext,
PRIMARY KEY (`userid`),
UNIQUE KEY `login_name` (`login_name`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ;
--
-- Dumping data for table `profiles`
--
INSERT INTO `profiles` VALUES (1, 'testtest@gmail.com', 'dfsadf23rf43f34f34f4', 'User', 9223372036854775807, '', 1, 0, 'ExcludeSelf~on~emailOwnerRemoveme~on~emailOwnerComments~on~emailOwnerAttachments~on~emailOwnerStatus~on~emailOwnerResolved~on~emailOwnerKeywords~on~emailOwnerCC~on~emailOwnerOther~on~emailReporterRemoveme~on~emailReporterComments~on~emailReporterAttachments~on~emailReporterStatus~on~emailReporterResolved~on~emailReporterKeywords~on~emailReporterCC~on~emailReporterOther~on~emailQAcontactRemoveme~on~emailQAcontactComments~on~emailQAcontactAttachments~on~emailQAcontactStatus~on~emailQAcontactResolved~on~emailQAcontactKeywords~on~emailQAcontactCC~on~emailQAcontactOther~on~emailCClistRemoveme~on~emailCClistComments~on~emailCClistAttachments~on~emailCClistStatus~on~emailCClistResolved~on~emailCClistKeywords~on~emailCClistCC~on~emailCClistOther~on~emailVoterRemoveme~on~emailVoterComments~on~emailVoterAttachments~on~emailVoterStatus~on~emailVoterResolved~on~emailVoterKeywords~on~emailVoterCC~on~emailVoterOther~on');
SELECT DISTINCT
bugs.bug_id, bugs.groupset, bugs.bug_severity, bugs.priority, bugs.rep_platform, map_assigned_to.login_name,
bugs.bug_status, bugs.resolution, bugs.short_desc FROM bugs, profiles map_assigned_to, profiles map_reporter
LEFT JOIN profiles map_qa_contact ON bugs.qa_contact = map_qa_contact.userid LEFT JOIN cc selectVisible_cc ON
bugs.bug_id = selectVisible_cc.bug_id AND
selectVisible_cc.who = 3 WHERE ((bugs.groupset & 127) = bugs.groupset OR (bugs.reporter_accessible = 1 AND
bugs.reporter = 3) OR (bugs.cclist_accessible = 1 AND selectVisible_cc.who = 3
AND not isnull(selectVisible_cc.who)) OR (bugs.assigned_to = 3)) AND bugs.assigned_to = map_assigned_to.userid
AND bugs.reporter = map_reporter.userid AND (bugs.bug_status = 'NEW' OR bugs.bug_status = 'ASSIGNED' OR
bugs.bug_status = 'REOPENED') AND (bugs.product = 'AstBill') ORDER BY bugs.bug_status, bugs.priority,
map_assigned_to.login_name, bugs.bug_id;