Duplicate entry error
foxtrotcharlie - April 7, 2008 - 13:17
| Project: | RelatedContent |
| Version: | 5.x-1.6 |
| Component: | Code |
| Category: | support request |
| Priority: | normal |
| Assigned: | TBarregren |
| Status: | closed |
Jump to:
Description
When I edit and save a specific cck content type which has the related content fieldset at the bottom, I firstly, get a watchdog lock tables error:
Duplicate entry &#039;relatedcontent_exclude_teasers_intersection_news&#039; for key 1\nquery: INSERT INTO variable (name, value) VALUES (&#039;relatedcontent_exclude_teasers_intersection_newsletter&#039;, &#039;s:1:\\&quot;1\\&quot;;&#039;)</em> in <em>/whatever/includes/database.mysql.inc</em> on line <em>172</em>.', 2,And secondly, when I refresh the page, the following mysql error:
* user warning: Duplicate entry 'relatedcontent_exclude_teasers_intersection_news' for key 1 query: INSERT INTO variable (name, value) VALUES ('relatedcontent_exclude_teasers_intersection_newsletter', 's:1:\"1\";') in /whatever/includes/database.mysql.inc on line 172.
* user warning: Duplicate entry 'relatedcontent_output_placing_intersection_newsl' for key 1 query: INSERT INTO variable (name, value) VALUES ('relatedcontent_output_placing_intersection_newsletter', 's:3:\"end\";') in /whatever/includes/database.mysql.inc on line 172.
* user warning: Duplicate entry 'relatedcontent_output_teasers_intersection_newsl' for key 1 query: INSERT INTO variable (name, value) VALUES ('relatedcontent_output_teasers_intersection_newsletter', 's:1:\"1\";') in /whatever/includes/database.mysql.inc on line 172.
* user warning: Duplicate entry 'relatedcontent_output_grouped_intersection_newsl' for key 1 query: INSERT INTO variable (name, value) VALUES ('relatedcontent_output_grouped_intersection_newsletter', 's:4:\"type\";') in /whatever/includes/database.mysql.inc on line 172.I have read the faq pages: http://drupal.org/node/17241 and http://drupal.org/node/69722 so have a general idea of what the errors mean, but I'm at a bit of a loss as to what to do to sort it out. Should I delete the relatedcontent variables (mentioned above) from the variable table?
Does this actually have anything to do with relatedcontent, or is it just something a bit screwed up with my drupal database?
Just checked on my local machine - I get a different error:
user warning: Data too long for column 'name' at row 1 query: INSERT INTO variable (name, value) VALUES ('relatedcontent_exclude_teasers_intersection_newsletter', 's:1:\"1\";') in C:\Apache2\htdocs\whatever\includes\database.mysql.inc on line 172.This seems to imply that the variable table field 'name' is too short...so, should I just change the table field to be a longer varchar?
If I do change the length, how should I go about cleaning up the relatedcontent variables in the variable table - should I just delete them all?
Thanks :-)

#1
The simplest solution is probably to just shorten the name of your content type, e.g. from
intersection_newstointersec_news, so the variable names don't become too long (i.e. more than 48 characters). You can also alter the variable table to allow longer variable names.You don't have need to delete the already existing variables. But if you want to do that, you can do any of following alternatives:
DELETE FROM variable WHERE name LIKE 'relatedcontent_%'.I will shorten the variable names in future version to minimize the risk for this kind of problem. See #243592: Shorten the variable names.
#2
Thank you so much for the quick and useful help :-)