PHPwiki postgres database error

Pat Grogan <[email protected]> Sun, 17 Apr 2011 10:57:14 +1000
Newsgroups gmane.comp.web.wiki.phpwiki.talk
Message-ID <1303001834.17528.27.camel@c678014>
I have just migrated from a very early version of phpwiki to the very
latest.

I have got the wiki up and working but a soon as I try and edit the main
page I get the following error:

Fatal Error:

lib/WikiDB/backend/PearDB.php:1061 Error[256]:
WikiDB_backend_PearDB_pgsql: fatal database error

    * DB Error: constraint violation
    * (DELETE FROM version WHERE id=98 AND version=1 [nativecode=ERROR:
update or delete on table "version" violates foreign key constraint
"recent_id_fkey1" on table "recent"
    * DETAIL: Key (id,version)=(98,1) is still referenced from table
"recent".])

Here is the database setup for each of the tables:
phpwiki=# \d recent
        Table "public.recent"
    Column     |  Type   | Modifiers 
---------------+---------+-----------
 id            | integer | 
 latestversion | integer | 
 latestmajor   | integer | 
 latestminor   | integer | 
Indexes:
    "recent_id_idx" UNIQUE, btree (id)
    "recent_lv_idx" btree (latestversion)
Check constraints:
    "recent_check" CHECK (latestminor >= latestmajor)
Foreign-key constraints:
    "recent_id_fkey" FOREIGN KEY (id) REFERENCES page(id)
    "recent_id_fkey1" FOREIGN KEY (id, latestversion) REFERENCES
version(id, version)

phpwiki=# 

phpwiki=# \d page
                                   Table "public.page"
   Column    |          Type          |
Modifiers                     
-------------+------------------------+---------------------------------------------------
 id          | integer                | not null default
nextval('page_id_seq'::regclass)
 pagename    | character varying(100) | not null
 hits        | integer                | not null default 0
 pagedata    | text                   | not null default ''::text
 cached_html | text                   | default ''::text
Indexes:
    "page_pkey" PRIMARY KEY, btree (id)
    "page_pagename_key" UNIQUE, btree (pagename)
Check constraints:
    "page_pagename_check" CHECK (pagename::text <> ''::text)
Referenced by:
    TABLE "link" CONSTRAINT "link_linkfrom_fkey" FOREIGN KEY (linkfrom)
REFERENCES page(id)
    TABLE "link" CONSTRAINT "link_linkto_fkey" FOREIGN KEY (linkto)
REFERENCES page(id)
    TABLE "nonempty" CONSTRAINT "nonempty_id_fkey" FOREIGN KEY (id)
REFERENCES page(id)
    TABLE "pagedata" CONSTRAINT "pagedata_id_fkey" FOREIGN KEY (id)
REFERENCES page(id)
    TABLE "pageperm" CONSTRAINT "pageperm_id_fkey" FOREIGN KEY (id)
REFERENCES page(id)
    TABLE "rating" CONSTRAINT "rating_rateepage_fkey" FOREIGN KEY
(rateepage) REFERENCES page(id)
    TABLE "rating" CONSTRAINT "rating_raterpage_fkey" FOREIGN KEY
(raterpage) REFERENCES page(id)
    TABLE "recent" CONSTRAINT "recent_id_fkey" FOREIGN KEY (id)
REFERENCES page(id)
    TABLE "version" CONSTRAINT "version_id_fkey" FOREIGN KEY (id)
REFERENCES page(id)

I manually went into the postgres database phpwiki and removed the entry
id 98 from table recent and was able to edit the home page. However once
saved another edit fails with the same error.

Is this a schema error or am I using an incorrect procedure?

I am using postgres on Ubuntu 10.10.

Any help would be most appreciated.

Thanks,

Pat




------------------------------------------------------------------------------
Benefiting from Server Virtualization: Beyond Initial Workload 
Consolidation -- Increasing the use of server virtualization is a top
priority.Virtualization can reduce costs, simplify management, and improve 
application availability and disaster protection. Learn more about boosting 
the value of server virtualization. http://p.sf.net/sfu/vmware-sfdev2dev