pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
identity not working with inherited table
9+ messages / 5 participants
[nested] [flat]

* identity not working with inherited table
@ 2019-05-04 05:11  José Luis Viejo <jlviejo@gmail.com>
  0 siblings, 1 reply; 9+ messages in thread

From: José Luis Viejo @ 2019-05-04 05:11 UTC (permalink / raw)
  To: pgsql-bugs@lists.postgresql.org

Hi

I hope this helps to clarify the problem

https://stackoverflow.com/questions/55979456/identity-not-working-with-inherited-table


Thanks for great job

Best regards

Jose

^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: identity not working with inherited table
@ 2019-05-05 09:31  Michael Paquier <michael@paquier.xyz>
  parent: José Luis Viejo <jlviejo@gmail.com>
  0 siblings, 1 reply; 9+ messages in thread

From: Michael Paquier @ 2019-05-05 09:31 UTC (permalink / raw)
  To: José Luis Viejo <jlviejo@gmail.com>; +Cc: pgsql-bugs@lists.postgresql.org

On Sat, May 04, 2019 at 12:11:51AM -0500, José Luis Viejo wrote:
> I hope this helps to clarify the problem
> 
> https://stackoverflow.com/questions/55979456/identity-not-working-with-inherited-table

If Stack overflow goes away, then we would lost this information when
referring to the archives of PostgreSQL mailing lists, and not
everybody is willing to follow the information on the link.  Could you
send directly to this thread what you think the actual problem is,
what you are noticing, and what you would expect?  Using SQL queries
is of course recommended.
--
Michael

Attachments:

  signature.asc (application/pgp-signature, 832B) download

^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: identity not working with inherited table
@ 2019-05-05 10:49  José Luis Viejo <jlviejo@gmail.com>
  parent: Michael Paquier <michael@paquier.xyz>
  0 siblings, 1 reply; 9+ messages in thread

From: José Luis Viejo @ 2019-05-05 10:49 UTC (permalink / raw)
  To: Michael Paquier <michael@paquier.xyz>; +Cc: pgsql-bugs@lists.postgresql.org

Hi Michael

I'm using PostgreSQL 11 latest version, having problems with an identity as
PK that inherits a table.

assume you have simple parent table like:

CREATE TABLE test7
    (
    id_t7 int GENERATED always AS IDENTITY PRIMARY KEY,
    folio int GENERATED always AS IDENTITY,
    client int
    );

with any inherited table like:

CREATE TABLE test7_detail1(
  --  uuid uuid DEFAULT uuid_generate_v4(), <-- fiddle doesn't support it
    in_process boolean,
    id_corte integer,
    ts_captura timestamp(6) without time zone DEFAULT
(now())::timestamp without time zone) INHERITS (test7);

if I try insert like:

insert into test7_detail1 (client,in_process, id_corte)values (20797,'t',101)

it returns:

ERROR:  null value in column "id_t7" violates not-null constraint
DETAIL:  Failing row contains (null, null, 20797, t, 101, 2019-05-03
22:27:54.823894).

here <https://www.db-fiddle.com/f/iYkASiKbr8t1oEg1U2MCcX/2; is the fiddle

thanks in advance, best regards

jose

On Sun, May 5, 2019 at 4:31 AM Michael Paquier <michael@paquier.xyz> wrote:

> On Sat, May 04, 2019 at 12:11:51AM -0500, José Luis Viejo wrote:
> > I hope this helps to clarify the problem
> >
> >
> https://stackoverflow.com/questions/55979456/identity-not-working-with-inherited-table
>
> If Stack overflow goes away, then we would lost this information when
> referring to the archives of PostgreSQL mailing lists, and not
> everybody is willing to follow the information on the link.  Could you
> send directly to this thread what you think the actual problem is,
> what you are noticing, and what you would expect?  Using SQL queries
> is of course recommended.
> --
> Michael
>

^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: identity not working with inherited table
@ 2019-05-05 11:15  Francisco Olarte <folarte@peoplecall.com>
  parent: José Luis Viejo <jlviejo@gmail.com>
  0 siblings, 1 reply; 9+ messages in thread

From: Francisco Olarte @ 2019-05-05 11:15 UTC (permalink / raw)
  To: José Luis Viejo <jlviejo@gmail.com>; +Cc: Michael Paquier <michael@paquier.xyz>; pgsql-bugs@lists.postgresql.org

Seems like pilot error ( rtfm )?...

On Sun, May 5, 2019 at 12:50 PM José Luis Viejo <jlviejo@gmail.com> wrote:
> I'm using PostgreSQL 11 latest version, having problems with an identity as PK that inherits a table.

https://www.postgresql.org/docs/11/sql-createtable.html says in the
description of the inherits cluase of create table:

"If a column in the parent table is an identity column, that property
is not inherited. A column in the child table can be declared identity
column if desired."

So
> ERROR:  null value in column "id_t7" violates not-null constraint
> DETAIL:  Failing row contains (null, null, 20797, t, 101, 2019-05-03 22:27:54.823894).

Seems to be working exactly as documented, not-null inherited, identity not.

F.O.





^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: identity not working with inherited table
@ 2019-05-06 01:46  Euler Taveira <euler@timbira.com.br>
  parent: Francisco Olarte <folarte@peoplecall.com>
  0 siblings, 2 replies; 9+ messages in thread

From: Euler Taveira @ 2019-05-06 01:46 UTC (permalink / raw)
  To: Francisco Olarte <folarte@peoplecall.com>; +Cc: José Luis Viejo <jlviejo@gmail.com>; Michael Paquier <michael@paquier.xyz>; pgsql-bugs@lists.postgresql.org

Em dom, 5 de mai de 2019 às 08:16, Francisco Olarte
<folarte@peoplecall.com> escreveu:
>
> "If a column in the parent table is an identity column, that property
> is not inherited. A column in the child table can be declared identity
> column if desired."
>
Although, it is documented, it seems inconsistent with sequence
behavior (child table inherits sequences). Since sequences are
inherited I think identity columns (that use implicit sequences)
should be inherited as well. It seems an oversight in the current
implementation, however, I see it as a new feature.


-- 
   Euler Taveira                                   Timbira -
http://www.timbira.com.br/
   PostgreSQL: Consultoria, Desenvolvimento, Suporte 24x7 e Treinamento





^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: identity not working with inherited table
@ 2019-05-06 17:04  Francisco Olarte <folarte@peoplecall.com>
  parent: Euler Taveira <euler@timbira.com.br>
  1 sibling, 1 reply; 9+ messages in thread

From: Francisco Olarte @ 2019-05-06 17:04 UTC (permalink / raw)
  To: Euler Taveira <euler@timbira.com.br>; +Cc: José Luis Viejo <jlviejo@gmail.com>; Michael Paquier <michael@paquier.xyz>; pgsql-bugs@lists.postgresql.org

Euler:

On Mon, May 6, 2019 at 3:46 AM Euler Taveira <euler@timbira.com.br> wrote:
> Em dom, 5 de mai de 2019 às 08:16, Francisco Olarte
> <folarte@peoplecall.com> escreveu:
> > "If a column in the parent table is an identity column, that property
> > is not inherited. A column in the child table can be declared identity
> > column if desired."
> Although, it is documented, it seems inconsistent with sequence
> behavior (child table inherits sequences). Since sequences are
> inherited I think identity columns (that use implicit sequences)
> should be inherited as well. It seems an oversight in the current
> implementation, however, I see it as a new feature.

I'm not sure what you mean by "inherits sequence", may be you mean
"inherits default values" ( specifically on serial ) ?

I do not know the reason, but that is what the docs are for. You hit a
glitch, you RTFM a bit before spamming the bugs list. Then you
consider it a short coming and ask about it / request a feature  on
the general / hackers list where more knowledgeable people may give
you some insight ( they tend to be busy, and may see it and dismiss it
as "another one who does not bother to read the docs ).

If you see it as a feature, why do you report it as a bug?

>    Euler Taveira                                   Timbira -
> http://www.timbira.com.br/
>    PostgreSQL: Consultoria, Desenvolvimento, Suporte 24x7 e Treinamento

And, given your sig, you should have done it. I'm just an ocasional
user and found it in the docs in about a dozen seconds.

Francisco Olarte.





^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: identity not working with inherited table
@ 2019-05-06 18:57  Euler Taveira <euler@timbira.com.br>
  parent: Francisco Olarte <folarte@peoplecall.com>
  0 siblings, 1 reply; 9+ messages in thread

From: Euler Taveira @ 2019-05-06 18:57 UTC (permalink / raw)
  To: Francisco Olarte <folarte@peoplecall.com>; +Cc: José Luis Viejo <jlviejo@gmail.com>; Michael Paquier <michael@paquier.xyz>; pgsql-bugs@lists.postgresql.org

Em seg, 6 de mai de 2019 às 14:05, Francisco Olarte
<folarte@peoplecall.com> escreveu:
>
> If you see it as a feature, why do you report it as a bug?
>
First of all, I'm not José (who wrote the bug report). I see "inherits
identity columns" by child tables as a *new* feature (minor issue, no
bug fix, no backpatch).

> And, given your sig, you should have done it. I'm just an ocasional
> user and found it in the docs in about a dozen seconds.
>
What does my signature have to do with the discussion?


-- 
   Euler Taveira                                   Timbira -
http://www.timbira.com.br/
   PostgreSQL: Consultoria, Desenvolvimento, Suporte 24x7 e Treinamento





^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: identity not working with inherited table
@ 2019-05-06 19:21  Francisco Olarte <folarte@peoplecall.com>
  parent: Euler Taveira <euler@timbira.com.br>
  0 siblings, 0 replies; 9+ messages in thread

From: Francisco Olarte @ 2019-05-06 19:21 UTC (permalink / raw)
  To: Euler Taveira <euler@timbira.com.br>; +Cc: José Luis Viejo <jlviejo@gmail.com>; Michael Paquier <michael@paquier.xyz>; pgsql-bugs@lists.postgresql.org

Due to several errors interpreting the messages in this thread I sent
some comments to Euler Taveria which were inapropiate. Please ignore
them, and all my messages in this thread. Sorry for the noise.

Francisco Olarte Sanz.





^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: identity not working with inherited table
@ 2019-05-13 16:28  Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
  parent: Euler Taveira <euler@timbira.com.br>
  1 sibling, 0 replies; 9+ messages in thread

From: Peter Eisentraut @ 2019-05-13 16:28 UTC (permalink / raw)
  To: Euler Taveira <euler@timbira.com.br>; Francisco Olarte <folarte@peoplecall.com>; +Cc: José Luis Viejo <jlviejo@gmail.com>; Michael Paquier <michael@paquier.xyz>; pgsql-bugs@lists.postgresql.org

On 2019-05-06 03:46, Euler Taveira wrote:
> Em dom, 5 de mai de 2019 às 08:16, Francisco Olarte
> <folarte@peoplecall.com> escreveu:
>>
>> "If a column in the parent table is an identity column, that property
>> is not inherited. A column in the child table can be declared identity
>> column if desired."
>>
> Although, it is documented, it seems inconsistent with sequence
> behavior (child table inherits sequences). Since sequences are
> inherited I think identity columns (that use implicit sequences)
> should be inherited as well. It seems an oversight in the current
> implementation, however, I see it as a new feature.

Some of the semantics of this would not be entirely clear.  Who would
own the sequence?  What happens when you drop the identity property from
the inheritance root or an inheritance child?  It's probably doable, but
it would need some serious thinking.

-- 
Peter Eisentraut              http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services





^ permalink  raw  reply  [nested|flat] 9+ messages in thread


end of thread, other threads:[~2019-05-13 16:28 UTC | newest]

Thread overview: 9+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2019-05-04 05:11 identity not working with inherited table José Luis Viejo <jlviejo@gmail.com>
2019-05-05 09:31 ` Michael Paquier <michael@paquier.xyz>
2019-05-05 10:49   ` José Luis Viejo <jlviejo@gmail.com>
2019-05-05 11:15     ` Francisco Olarte <folarte@peoplecall.com>
2019-05-06 01:46       ` Euler Taveira <euler@timbira.com.br>
2019-05-06 17:04         ` Francisco Olarte <folarte@peoplecall.com>
2019-05-06 18:57           ` Euler Taveira <euler@timbira.com.br>
2019-05-06 19:21             ` Francisco Olarte <folarte@peoplecall.com>
2019-05-13 16:28         ` Peter Eisentraut <peter.eisentraut@2ndquadrant.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox