Problem with the creation of MySQL triggers

161 views
Skip to first unread message

Cédric Bonhomme

unread,
May 20, 2013, 5:03:58 PM5/20/13
to open...@googlegroups.com
Hello,

I just updated my instance on the master branch and the creation of the 4 MySQL triggers is always failing.
https://github.com/photo/frontend/blob/master/src/configs/upgrade/db/mysql/mysql-4.0.1.php

For example, with this code:
"""
CREATE TRIGGER update_album_counts_on_delete AFTER DELETE ON op_elementAlbum
FOR EACH ROW
BEGIN
  SET @countPublic=(SELECT COUNT(*) FROM op_photo AS p INNER JOIN op_elementAlbum AS ea ON p.id = ea.element WHERE ea.owner=OLD.owner AND ea.album=OLD.album AND p.owner=OLD.owner AND p.permission='1');
  SET @countPrivate=(SELECT COUNT(*) FROM op_photo AS p INNER JOIN op_elementAlbum AS ea ON p.id = ea.element WHERE ea.owner=OLD.owner AND ea.album=OLD.album AND p.owner=OLD.owner);
  UPDATE op_album SET countPublic=@countPublic, countPrivate=@countPrivate WHERE owner=OLD.owner AND id=OLD.album;
END
"""
MySQL returns:
"""
#1064 - 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 '' at line 4
"""

I tried by replacing p.permission='1' by p.permission=1. But this changes nothing. Isn't "p.permission" supposed to be an integer?

Any idea?


For the rest all is working fine except the fact that when I click the link (New Feature On This Page), nothing happens.

thanks,
Cédric

Jaisen Mathai

unread,
May 20, 2013, 5:33:37 PM5/20/13
to open...@googlegroups.com, James Walker
In our upgrade tests we were able to run them in the upgrade without problems (cc'ing James).

MySql lets you put quotes around integers, so that's not the problem.

The "New Feature On This Page" just means you're not loading the "Tutorial" plugin which we're now making mandatory. You can fix it by adding "Tutorial" to your list of activePlugins in your conf file.



--
You received this message because you are subscribed to the Google Groups "OpenPhoto" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openphoto+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Cédric Bonhomme

unread,
May 20, 2013, 5:50:12 PM5/20/13
to open...@googlegroups.com, James Walker
Thanks, the tutorial plugin is really nice!

There is still the problem as you can see with the herewith screen shot. I'll test with the other triggers from your gist.
sqlerror.png

James Walker

unread,
May 20, 2013, 5:52:02 PM5/20/13
to Cédric Bonhomme, open...@googlegroups.com
Hey there,

Can you please tell me what version of MySQL you are using?

Thanks!
James

Cédric Bonhomme

unread,
May 20, 2013, 5:56:10 PM5/20/13
to open...@googlegroups.com, Cédric Bonhomme
Hello,

This is the version 5.1.39-1.
And MySQL web server: 5.1.49

Cédric

Jaisen Mathai

unread,
May 20, 2013, 6:39:14 PM5/20/13
to open...@googlegroups.com, James Walker

You need the following (and associated) line(s)....
DELIMITER |
I suggest just pasting the entire gist in ...

Cédric Bonhomme

unread,
May 21, 2013, 1:45:06 AM5/21/13
to open...@googlegroups.com, James Walker
Thank you. I know have the following error message:
"""
#1235 - This version of MySQL doesn't yet support 'multiple triggers with the same action time and event for one table'
"""
With the entire gist.

Jaisen Mathai

unread,
May 21, 2013, 1:51:16 AM5/21/13
to open...@googlegroups.com
Run SHOW TRIGGERS and delete them all first?

Cédric Bonhomme

unread,
May 21, 2013, 2:12:49 AM5/21/13
to open...@googlegroups.com
It is now working, thanks!
I'll compare the structure of my database with this version: https://github.com/photo/frontend/blob/master/src/configs/upgrade/db/mysql/mysql-base.php. Since I always have the same kind of problems.
I suppose that this php file creates the database for a first installation.

Jaisen Mathai

unread,
May 21, 2013, 2:14:56 AM5/21/13
to open...@googlegroups.com
That's correct.
Reply all
Reply to author
Forward
0 new messages