BUG #8027: Get generated key value while inserting in partitioned table

Поиск
Список
Период
Сортировка
От mohansammeta@gmail.com
Тема BUG #8027: Get generated key value while inserting in partitioned table
Дата
Msg-id E1UMvNP-0002z1-Fr@wrigleys.postgresql.org
обсуждение исходный текст
Ответы Re: BUG #8027: Get generated key value while inserting in partitioned table  (bricklen <bricklen@gmail.com>)
Список pgsql-bugs
The following bug has been logged on the website:

Bug reference:      8027
Logged by:          mohan sammeta
Email address:      mohansammeta@gmail.com
PostgreSQL version: 8.4.0
Operating system:   ubuntu
Description:        =




Hi I have a table in Postgres, say email_messages. It is partitioned so
whatever the inserts i do it using my java application will not effect the
master table, as the data is actually getting inserted in the child tables.
Here is the problem, I want to get an auto generated column value (say
email_message_id which is of big serial type). Postgres is returning it as
null since there is no insert being done on master table. For oracle I used
GeneratedKeyHolder to get that value. But I'm unable to do the same for
partitioned table in postgres. Please help me out.

Here is the code snippet we used for oracle

public void createAndFetchPKImpl(final Entity pEntity, final String
pStatementId, final String pPKColumnName) {

final SqlParameterSource parameterSource =3D
  new BeanPropertySqlParameterSource(pEntity);

  final String[] columnNames =3D new String[]{"email_message_id"};
  final KeyHolder keyHolder =3D new GeneratedKeyHolder();
  final int numberOfRowsEffected =3D mNamedParameterJdbcTemplate.update(
      getStatement(pStatementId), parameterSource, keyHolder, columnNames);
  pEntity.setId(ConversionUtil.getLongValue(keyHolder.getKey()));

}
We are using spring 3.1.1.
I am getting numberOfRowsEffected as zero and keyHolder.getKey() as null
even though the insert is happening in the table.

В списке pgsql-bugs по дате отправления:

Предыдущее
От: Andres Freund
Дата:
Сообщение: Re: Completely broken replica after PANIC: WAL contains references to invalid pages
Следующее
От: bricklen
Дата:
Сообщение: Re: BUG #8027: Get generated key value while inserting in partitioned table