Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Extrange Add Category error

Quote Reply
Extrange Add Category error

I obtain an extrange error when I try to manualy add a new category to my LSQL database. This *only* happen when I try to insert a new category (Database -> Category -> Add or Browse the category tree) *after* a backup restore, import from a dump or import from Links 2. This not happen when I delete all my database and try to add category for first time.

The error is:
  • Failed to execute query: 'INSERT INTO lsql_Category (Description,Newest_Link,Category_Template,Timestmp,Meta_Description,Name,Footer,Header,Has_New_Links,Number_of_Links,Has_Changed_Links,Full_Name,Meta_Keywords,FatherID,ID) VALUES (?,NULL,?,?,?,?,?,?,?,?,?,?,?,?,NEXTVAL('lsql_Category_seq'))' Reason: ERROR: Cannot insert a duplicate key into unique index lsql_category_pkey

  • I show in my category idīs to see if I could have one or more with the same ID, but I have not any and all seems correct.

    I run LSQL in Redhat 7.2 with PostgreSQL. Any help?

    Quote Reply
    [Bug] Re: [avant] Extrange Add Category error In reply to

    I found the problem and I think its a bug in LSQL when working with PostgreSQL.

    The problem is that after import (backup, links, dump...) the software does not update the Category Sequence and the Links Sequence.

    After an import (400 categories and 3000 links) I execute:

    select max(ID) from lsql_Category ;

    RETURN: 400

    select max(ID) from lsql_Links ;

    RETURN: 3000

    Then execute:

    select NEXTVAL('lsql_Category_seq');

    RETURN: 2 (when the correct value would be 401) The solution is to run the query 400 times... to update the nextval value of 'lsql_category_seq' to 401. Same aply to all seq.

    Could someone fix this better?


    Quote Reply
    Re: [avant] [Bug] Re: [avant] Extrange Add Category error In reply to

    Sorry about the late reply on this. A quicker fix (but not ideal) will be to run:

    select setval('lsql_Category_seq', max(ID)) FROM lsql_Category;
    select setval('lsql_Links_seq', max(ID)) FROM lsql_Links;

    which will update the sequences to the proper values. I'll update the repair table function so it can reset sequences properly (as this should be run after any import anyways).


    Gossamer Threads Inc.