When accessing most any page as an anonymous user, I get the following warning:

user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'HAVING (event_start >= '2007-07-01 00:00:00' AND event_start <= query: event_get_events_event SELECT DISTINCT(n.nid), n.uid, n.title, n.type, e.event_start, e.event_start AS event_start_orig, e.event_end, e.event_end AS event_end_orig, e.timezone, tz.offset AS offset, tz.offset_dst AS offset_dst, tz.dst_region, tz.is_dst, e.event_start - INTERVAL IF(tz.is_dst, tz.offset_dst, tz.offset) HOUR_SECOND AS event_start_utc, e.event_end - INTERVAL IF(tz.is_dst, tz.offset_dst, tz.offset) HOUR_SECOND AS event_end_utc, e.event_start - INTERVAL IF(tz.is_dst, tz.offset_dst, tz.offset) HOUR_SECOND + INTERVAL 0 SECOND AS event_start_user, e.event_end - INTERVAL IF(tz.is_dst, tz.offset_dst, tz.offset) HOUR_SECOND + INTERVAL 0 SECOND AS event_end_user, e.event_start - INTERVAL IF(tz.is_dst, tz.offset_dst, tz.offset) HOUR_SECOND + INTERVAL -14400 SECOND AS event_start_si in E:\drupal\includes\database.mysql.inc on line 172.

This appears to be due to a bug in the SELECT statement. SQL states that the HAVING clause is to be used in conjunction with a GROUP BY clause or other aggregation functions. Additionally, the WHERE clause is preferable to HAVING since it may be analyzed by the optimizer.

Additionally, I'm having trouble understanding the intent of the HAVING clause. It appears that WHERE is attempting to select this month's events, but HAVING is wanting to further restrict the events to just today's. Therefore, they seem to be competing and I don't understand the need. Perhaps I'm missing something, but is it ok to eliminate the HAVING clause altogether???

Assuming that it is ok to remove HAVING, I have done so in this patch that has eliminated this warning and should improve performance a bit. It also adds aliases to avoid ambiguity. Note that I'm shooting a bit from the hip so please review this patch.

CommentFileSizeAuthor
event_database.patch.txt29.13 KBCheckeredFlag

Comments

killes@www.drop.org’s picture

Status: Active » Fixed

This was a bug which occurred when you used node_access modules with event 5.2 and Drupal up tp Drupal 5.1 Upgrade to Drupal 5.3 to fix this.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.