bugzilla내의 mysql query...

ohdol의 이미지

버그 질라 2.16.3 + mysql 5.x를 사용하고 있습니다.

아래와 같은 에러가 발생하네요

Quote:
Software error:
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 = 1 WHERE ((bugs.groupset & 9223372036854775807) = bugs.groupset OR (bugs.reporter_accessible = 1 AND bugs.reporter = 1) OR (bugs.cclist_accessible = 1 AND selectVisible_cc.who = 1 AND not isnull(selectVisible_cc.who)) OR (bugs.assigned_to = 1)) AND bugs.assigned_to = map_assigned_to.userid AND bugs.reporter = map_reporter.userid 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 (map_assigned_to.login_name = 'ohsgx@onnet.co.kr' OR map_reporter.login_name = 'ohsgx@onnet.co.kr'): Unknown column 'bugs.qa_contact' in 'on clause' at globals.pl line 276.

bugs 테이블에 qa_contact 컬럼은 존재하고요...

앞부분만 잡아와서 처음 left join 만 해봐도 같은 에러메세지가 발생합니다

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);

mysql 버전과 충돌이 나는건지 잘 안되네요.

feanor의 이미지

MySQL 5.0.12 버전부터 MySQL이 natural join을 더 표준에 가깝게 처리하도록 바뀌었기 때문에 이전 코드가 안 되는 경우가 있습니다.

MySQL 5.0.12 Release Notes
http://dev.mysql.com/doc/refman/5.0/en/news-5-0-12.html

Incompatible change: Beginning with MySQL 5.0.12, natural joins and joins with USING, including outer join variants, are processed according to the SQL:2003 standard. The changes include elimination of redundant output columns for NATURAL joins and joins specified with a USING clause and proper ordering of output columns. The precedence of the comma operator also now is lower compared to JOIN.

쿼리에서 보시면,
SELECT bugs.bug_id, ... FROM bugs, profiles map_assigned_to LEFT JOIN

처럼 되어 있는 것을
SELECT bugs.bug_id, ... FROM (bugs, profiles map_assigned_to) LEFT JOIN

처럼 바꿔야 합니다. (여러 테이블을 FROM으로 선택할 때 테이블 나열을 괄호로 감싸지 않으면 FROM (a, b) JOIN ... 이 아니라 FROM (a, (b JOIN...)) 처럼 처리되기 때문인 듯 합니다.)

--feanor

keizie의 이미지

메인 스트림에 반영이 된다면 많은 사람들이 고생을 덜 수 있을 겁니다.