?
avatar syraxes
syraxes
9 Mar 2014
The issue

When using Joomla 3.2.3 with a PostgreSQL database,
most actions done in the administration page result in SQL errors.

For example adding new categories generate this error :
Database query failed (error # %s): %s ERROR: current transaction is aborted, commands ignored until end of transaction block SQL=INSERT INTO "joo_categories" ("parent_id","level","lft","rgt","alias","id","extension","title","note","description","published","access","params","metadesc","metakey", "metadata","created_user_id","created_time","hits","language") VALUES (1,1,15,16,'filme',0,'com_content','Filme','','',1,1,'{"category_layout":"","image":""}','','','{"author":"","robots":""}',59,'2014-03-08 19:52:08',0,'*') RETURNING id

In short: for PostgreSQL, the insert commands must NOT include the ID field.
The ID must be skipped, so that the database can take the next value from sequence.

The ANALYSIS of the issue

Lets' assume that a table is defined like this :
create table TBL (
ID serial primary key, -- this expands into: ID integer not null default nextval('tbl_id_seq')
FLD1 text ,
FLD2 integer
);

Most (or all) of the INSERT commands seem to be broken because they follow this pattern :

insert into TBL ( id, fld1, fld2 ) values (0 , 'aaa', 10 ) returning id;
insert into TBL ( id, fld1, fld2 ) values (0 , 'bbb', 20 ) returning id;

At runtime, the ID receives the explicit value 0,
so obviously the nextval('tbl_is_seq') will not be executed for getting the
next value from the sequence.

The second insert will give a duplicate key error in unique index (the id=0 already exists).

The right thing to do is that the INSERTs never include the ID field,
allowing PostgreSQL to apply the "default nextval(...)" :

insert into TBL ( fld1, fld2 ) values ( 'aaa', 10 ) returning id;
insert into TBL ( fld1, fld2 ) values ( 'bbb', 20 ) returning id;

I am not sure if it's possible to modify in a single place Joomla so that
all of the INSERTs are skipping the ID.

avatar syraxes syraxes - open - 9 Mar 2014
avatar rbrenton
rbrenton - comment - 12 Apr 2014

This commit fixed the issue for me:
vdespa@b58e70b

avatar zero-24 zero-24 - close - 23 Jul 2014
avatar brianteeman
brianteeman - comment - 23 Jul 2014

Closing as this specific issue is reported as fixed

avatar brianteeman brianteeman - change - 23 Jul 2014
Status New Closed
Closed_Date 0000-00-00 00:00:00 2014-07-23 15:01:54
avatar brianteeman brianteeman - close - 23 Jul 2014
avatar zero-24 zero-24 - change - 7 Jul 2015
Labels Added: ?
Removed: ? ?

Add a Comment

Login with GitHub to post a comment