Flawed SQL statement warning when enabling the module

px - July 31, 2008 - 17:38
Project:Comment Subscribe
Version:6.x-1.2
Component:Code
Category:bug report
Priority:normal
Assigned:zyxware
Status:closed
Description

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 'left join z_commentsubscribe cs on c1.cid = cs.cid where cs.subscribe is null' at line 2 query: insert into z_commentsubscribe (cid, parents, subscribe, subscribenode) left join z_commentsubscribe cs on c1.cid = cs.cid where cs.subscribe is null in ###Sorry, nonofficial project, can't disclose the path in my filesystem here###/htdocs/sites/all/modules/comment_subscribe/comment_subscribe.module on line 443.

#1

marcus0263 - August 14, 2008 - 10:18

Yep, same error with both Drupal 6.3 and with 6.4

* user warning: Table 'xxxxxxxx.comments' doesn't exist query: select c1.cid, concat('0,', if(c1.pid <> 0, concat(c1.pid, ','),'') ) as parents from comments c1 in /####/####/####/sites/all/modules/comment_subscribe/comment_subscribe.module on line 428.
* 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 'left join z_commentsubscribe cs on c1.cid = cs.cid where cs.subscribe is null' at line 2 query: insert into z_commentsubscribe (cid, parents, subscribe, subscribenode) left join z_commentsubscribe cs on c1.cid = cs.cid where cs.subscribe is null in /###/###/######/sites/all/modules/comment_subscribe/comment_subscribe.module on line 443.

#2

abarmot - August 23, 2008 - 07:08

I have the same problem:

* user warning: Table 'wwwfood_db.comments' doesn't exist query: select c1.cid, concat('0,', if(c1.pid <> 0, concat(c1.pid, ','),'') ) as parents from comments c1 in /arc/www/food/sites/all/modules/comment_subscribe/comment_subscribe.module on line 428.
* 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 'left join z_commentsubscribe cs on c1.cid = cs.cid where cs.subscribe is null' at line 2 query: insert into z_commentsubscribe (cid, parents, subscribe, subscribenode) left join z_commentsubscribe cs on c1.cid = cs.cid where cs.subscribe is null in /arc/www/food/sites/all/modules/comment_subscribe/comment_subscribe.module on line 443.

#3

jason.schoeman - August 26, 2008 - 11:59
Version:6.x-1.1» 5.x-1.2
Component:User interface» Code

Yes same in V5. I do not know if it will still work though...

#4

sidharth_k - August 27, 2008 - 22:59

Hi I too have the same error! Any ideas? I want to use comment subscribe in a production server so am worried about data corruption with these SQL errors. Are they any substitutes to comment subscribe?

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 'left join z_commentsubscribe cs on c1.cid = cs.cid where cs.subscribe is null' at line 2 query: insert into z_commentsubscribe (cid, parents, subscribe, subscribenode) left join z_commentsubscribe cs on c1.cid = cs.cid where cs.subscribe is null in /home/sidk/public_html/change/public/includes/database.mysqli.inc on line 154.

#5

Alex_Tutubalin - October 10, 2008 - 06:53

Fixed in my Postgresql patch (in MySQL mode too) http://drupal.org/node/319441

#6

rares - December 12, 2008 - 05:33
Status:active» needs review

The issue here is that the table names weren't bracketed and thus is doesn't work if the database setup has table prefixes:
i.e.
$sql = "select c1.cid, concat('0,', ".$ifcondition." ) as parents from comments c1 ".$join;
should be
$sql = "select c1.cid, concat('0,', ".$ifcondition." ) as parents from {comments} c1 ".$join;
(line 427 of version 6.x-1.1)

and
$join .= " join comments c".$level." on c".$prvlevel.".pid=c".$level.".cid";
should be
$join .= " join {comments} c".$level." on c".$prvlevel.".pid=c".$level.".cid";
(line 425 of version 6.x-1.1)

#7

zyxware - December 15, 2008 - 11:31
Assigned to:Anonymous» zyxware
Status:needs review» active

Hi all,
The problem will be fixed in the next commit.

Thanks
zyxware

#8

zyxware - December 22, 2008 - 11:38
Status:active» needs review

Hi All,

The problem fixed in the latest dev release. Do check and inform us any bugs there?

Regards
zyxware

#9

zyxware - December 24, 2008 - 15:21
Status:needs review» fixed

The issue has been fixed in the latest release

#10

milianw - December 24, 2008 - 23:46

There's still an error left:

In comment_subscribe.isntall the line:
db_query("INSERT INTO z_nodesubscribe (nid, uid) select nid,uid from node");

should instead be:
db_query("INSERT INTO {z_nodesubscribe} (nid, uid) select nid,uid from {node}");

I think (i.e. my tables have prefixes and thus should be prefixed accordingly. I'm not sure that's the right syntax but afair it should.

#11

anoopjohn - December 25, 2008 - 19:28
Status:fixed» active

Changing status to active

#12

zyxware - December 27, 2008 - 05:46
Status:active» fixed

Fixed the issue in the latest commit

Regards
zyxware

#13

System Message - January 10, 2009 - 05:50
Status:fixed» closed

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

#14

ap - February 19, 2009 - 09:56
Version:5.x-1.2» 6.x-1.2

I just downloaded version 6.x-1.2 and the bug still seems to be there.

 
 

Drupal is a registered trademark of Dries Buytaert.