Closed (fixed)
Project:
Metatag
Version:
7.x-1.x-dev
Component:
Code
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
26 Mar 2013 at 22:00 UTC
Updated:
14 Apr 2013 at 11:23 UTC
Jump to comment: Most recent file
Comments
Comment #1
damienmckenna:-\
The purpose of this query is to join the {metatag} and {node} tables together and delete anything in {metatag} that doesn't have a matching record in {node}. I don't have PostgreSQL installed, if you have any ideas on how to handle this query I'd love to hear it. Thanks.
Comment #2
twistor commentedWould something like this work? It is frowned upon to do DELETE queries with db_query(). I haven't tested this at all.
Comment #3
traveller commentedSorry, I'm not able to test it now. For one website I just uninstalled the module and installed it again (as I didn't lose any data in the process), but I wouldn't like to do it for another bigger installation, without being forced to reconfigure the metadata again.
Comment #4
wiifmAlso getting the error on PostgreSQL 9.1.8, my SQL skills are not good enough to fix this though.
Comment #5
damienmckennaClosed a duplicate: #1955598: Error updating db last update
Comment #6
jibus commentedI encouter the same problem
Comment #7
jim.applebee commentedTraveller - were you able to resolve this issue with reinstalling the meta tags module? Is it currently working?
Comment #8
twistor commentedI don't have Postgres lying around to test this on, but here's a patch.
Comment #10
twistor commentedApply to dev.
Comment #11
twistor commented#8: metatag-sql-syntax-error-1953724-8.patch queued for re-testing.
Comment #12
jibus commentedTested the patch, when updating the db, i got this error message :
Fatal error: Call to a member function isNull() on a non-object in /usr/local/www/sites/all/modules/metatag/metatag.install on line 324
Comment #13
twistor commentedOy, this should fix that.
Comment #14
jibus commentedThanks for you help Twistor !
- Tested patch #13,
- Applied patch metatag.install cleanly
Update #7007 result with this error
Failed: PDOException : SQLSTATE[42601]: Syntax error: 7 ERROR: syntax error at or near "SELECT" LINE 2: WHERE (entity_type = 'node') AND (entity_id = SELECT m.enti... ^: DELETE FROM {metatag} WHERE (entity_type = :db_condition_placeholder_0) AND (entity_id = SELECT m.entity_id AS entity_id FROM {metatag} m LEFT OUTER JOIN {node} n ON m.entity_id=n.nid WHERE (m.entity_type = :db_condition_placeholder_1) AND (n.nid IS NULL ) ) ; Array ( [:db_condition_placeholder_0] => node [:db_condition_placeholder_1] => node ) dans metatag_update_7007() (ligne 329 dans /usr/local/www/sites/all/modules/metatag/metatag.install).
Comment #15
damienmckennaI think this is the correct approach - build a separate list of entity IDs using a SELECT statement, then delete those values. Obviously, please test this on a *copy* of your site, just in case =)
Comment #16
jibus commentedThanks for your time :)
Patch applied cleanly (3 lines add whitespace errors)
Now it's the #7008 update which fails :
Update #7008
Failed: PDOException : SQLSTATE[42601]: Syntax error: 7 ERROR: syntax error at or near "m" LINE 1: DELETE m FROM metatag m WHERE m.data IS NULL or m.data = '' ... ^: DELETE m FROM {metatag} m WHERE m.data IS NULL or m.data = '' OR m.data = :empty; Array ( [:empty] => a:0:{} ) dans metatag_update_7008() (ligne 388 dans /usr/local/www/sites/all/modules/metatag/metatag.install).
Probably the same error ?
Comment #17
damienmckennaTry these patches, they remove the 'm' from after 'delete'.
Comment #18
twistor commentedYeah, that's where I was going. You can't DELETE from the same table that you SELECT from. The 2 queries is annoying though.
The only alternative I can come up with would be to use different db_query()'s based on the driver. :(
Comment #19
damienmckenna@twistor: It's not that much of a big deal, I'm going to test the patch on MySQL too and then will commit the changes so it's in the next release.
Comment #20
twistor commentedm.entity_id
@DamienMcKenn I know. I'm just anal.
Comment #21
damienmckenna@twistor: That's perfectly reasonable - there's only one "entity_id" field, thus no chance of confusion as to which one is being referenced, but it's best to specify the table anyway.
Comment #22
twistor commentedAhh, well. Seeing as how I've been zero help on this issue, I will shut up now :)
Comment #23
damienmckenna@twistor: There's no need for self-deprecation, you've helped. You can even help a little more - does the patch in #21 work for you? :)
Comment #24
wiifm@DamienMcKenna your patch at #21 did not apply using drush make, so I have re-made it (hopefully this is a little better now).
Update hooks 7007 and 7008 work now, but not 7009
Getting closer
Comment #25
twistor commentedhaha, it works on MySQL.
Comment #26
wiifmPlease do not change the status, this issue clearly still needs work as the latest "stable" release does not work on PostgreSQL. I am aware the module maintainer uses MySQL ;)
Comment #27
damienmckenna@wiifm: Does this one work?
Comment #28
damienmckennaSimplifying the title.
Comment #29
damienmckennaTagging.
Comment #30
twistor commented@wiifm, that was a cross-post. Although, I'm not sure what a stable release has to do with anything.
Comment #31
wiifm@DamienMcKenna bumped to --dev, and then drush make will apply your patch, now it gets passed 7009 and stuck on 7014:
Comment #32
damienmckennaThis should resolve update 7014.
Comment #33
wiifmCan confirm this does resolved any exceptions
Happy to RTBC this for now as it is a giant leap over what is currently on --dev.
Comment #34
damienmckennaThank you all for the help debugging this, I've committed the fix and will be releasing beta6 very soon.
Comment #35
jibus commentedTested the 7.x-1.x-dev 2013-Apr-05 release.
I have this error :
Update #7011
Failed: PDOException : SQLSTATE[42601]: Syntax error: 7 ERROR: syntax error at or near "INNER" LINE 1: UPDATE metatag AS m INNER JOIN node n ON m.entity_id=n.nid A... ^: UPDATE {metatag} AS m INNER JOIN {node} n ON m.entity_id=n.nid AND m.entity_type='node' SET m.language = n.language; Array ( ) dans metatag_update_7011() (ligne 440 dans /usr/local/www/sites/all/modules/metatag/metatag.install).
Comment #36
joshf commentedHere's a patch for the error described in #35, which I also got.
Comment #37
damienmckenna@joshf: Thanks for helping. That query really works? That's some strange SQL :-) We need to test it on MySQL before committing it, just in case.
Comment #38
joshf commented@ DamienMcKenna Thanks for the module!
Yeah, see http://www.nexusdb.com/forums/showthread.php?t=16473#4 it looks like neither one of these are actually SQL compliant. I have doubts about sqlite's ability to parse this, as well. I'll test that when I can and maybe come up with a less efficient but more cross-compatible two-query fix.
Comment #39
damienmckennaThis should resolve the problem with metatag_update_7011().
Comment #40
damienmckennaAck, #39 won't work, it needs to run a loop via batch_api otherwise it'll time out - that's what I was hoping to avoid with the more advanced query.
Comment #41
damienmckennaLets try this - it loops over 20 records at a time and only updates records that have a different language.
Comment #42
damienmckennaComment #43
damienmckennaI tested #41 with MySQL and found a problem with the DELETE statement in update 7008, so this fixes that.
Comment #44
damienmckennaA small improvement to metatag_update_7011.
Comment #45
jibus commentedA big thanks for your work :)
- Tested patch #44,
- Applied patch metatag.install cleanly
No duplicate node records were found (this is a good thing).
There were no other records to fix.
No corrupt records to fix, this is good news :-)
The following updates returned messages
metatag module
Update #7011
No nodes need the Metatag language values fixed.
Update #7013
No meta tag records need updating.
Thanks !
Comment #46
damienmckennaExcellent. Committed!
Comment #47
jlnknz commentedJust a note to let you know that the patched metatag.install file also fixes updates with an sqlite database.
The error occuring on update #7007 was the following:
Comment #48
damienmckenna@clrdd: Good to know, thanks :)
Comment #49
lookas commentedA had similar problem with PostgreSQL, and i've used DBTNG Migrator. I've just migrated PQSQL to MySQL and all updatest are done ok.
So I probably wont get back to PostgreSQL.
Comment #50
dfurman commentedIs there an aggregate path or release scheduled? I'm experiencing all described problems with the updates.
Comment #51
jibus commentedYou can use the latest dev version
Comment #52
damienmckenna1.0-beta6 is out, so I'm closing this issue in the interest of keeping the issue queue clean.