After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 515528 - PostgreSQL provider unreasonably drops AUTO_INCREMENT
PostgreSQL provider unreasonably drops AUTO_INCREMENT
Status: RESOLVED DUPLICATE of bug 515306
Product: libgda
Classification: Other
Component: PostgreSQL provider
3.1.x
Other Linux
: Normal normal
: ---
Assigned To: malerba
gnome-db Maintainers
Depends on:
Blocks:
 
 
Reported: 2008-02-10 05:27 UTC by Mark Johnson
Modified: 2008-02-21 17:21 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Mark Johnson 2008-02-10 05:27:54 UTC
The gnucash-gda backend creates one table that has an auto_increment column.  The PostgreSQL provider silently ignores the request to make a column auto_increment.  The result is an apparently successful table creation.  However, later all inserts fail!  This is an excerpt from the postgresql log file:
ERROR:  null value in column "slot_id" violates not-null constraint
STATEMENT:  INSERT INTO slots (obj_guid, name, slot_type, int64_val, string_val, double_val, timespec_val, guid_val, numeric_val_num, numeric_val_denom) VALUES ('77889f8da5fb434ae68891da19bef5ad', 'reconcile-info/last-date', 1, 1199170799, NULL, NULL, '1969-12-31', NULL, 0, 1)


The same XML is passed to gda_server_operation_load_data_from_xml for each gda backend.  In the case of MySQL and SQLite, the table is created correctly.  In the case of PostgreSQL, the table is not created correctly.

Clearly, PostgreSQL does not support the AUTO_INCREMENT keyword.  It DOES support a SERIAL and BIGSERIAL column type that do the same thing.  Therefore, the PostgreSQL provider should translate the request for AUTO_INCREMENT to using SERIAL type column instead.

Here is the output from psql showing the created table:
gnucash_db=# \d+ slots
                         Table "public.slots"
      Column       |          Type          | Modifiers | Description
-------------------+------------------------+-----------+-------------
 slot_id           | integer                | not null  |
 obj_guid          | character(32)          | not null  |
 name              | character varying(500) | not null  |
 slot_type         | integer                | not null  |
 int64_val         | bigint                 |           |
 string_val        | character varying(500) |           |
 double_val        | bigint                 |           |
 timespec_val      | date                   |           |
 guid_val          | character(32)          |           |
 numeric_val_num   | bigint                 |           |
 numeric_val_denom | bigint                 |           |
Indexes:
    "slots_pkey" PRIMARY KEY, btree (slot_id)
Has OIDs: no


Here is the output from mysql showing the corresponding table (editted for clarity):
mysql> show create table slots;
 slots | CREATE TABLE `slots` (
  `slot_id` int(11) NOT NULL auto_increment,
  `obj_guid` char(32) NOT NULL,
  `name` varchar(500) NOT NULL,
  `slot_type` int(11) NOT NULL,
  `int64_val` bigint(20) default NULL,
  `string_val` varchar(500) default NULL,
  `double_val` bigint(20) default NULL,
  `timespec_val` date default NULL,
  `guid_val` char(32) default NULL,
  `numeric_val_num` bigint(20) default NULL,
  `numeric_val_denom` bigint(20) default NULL,
  PRIMARY KEY  (`slot_id`)
) ENGINE=MyISAM AUTO_INCREMENT=1608 DEFAULT CHARSET=utf8 |

Please fix the PostgreSQL provider so that it translates a column attribute of AUTO_INCREMENT to a column type of SERIAL/BIGSERIAL.
Comment 1 Daniel Espinosa 2008-02-19 18:13:02 UTC
This is a duplicated bug for #515306, 
Comment 2 malerba 2008-02-21 17:21:14 UTC

*** This bug has been marked as a duplicate of 515306 ***