pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feedPostgreSQL 9.6: view based on sequence
12+ messages / 3 participants
[nested] [flat]
* PostgreSQL 9.6: view based on sequence
@ 2018-01-24 11:52 Enrico Pirozzi <e.pirozzi@nbsgroup.it>
2018-01-24 11:56 ` Re: PostgreSQL 9.6: view based on sequence Vincenzo Romano <vincenzo.romano@notorand.it>
2018-01-25 17:07 ` Re: PostgreSQL 9.6: view based on sequence Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
0 siblings, 2 replies; 12+ messages in thread
From: Enrico Pirozzi @ 2018-01-24 11:52 UTC (permalink / raw)
To: pgsql-general
Hi, I was doing a test on a 9.6 and I've seen a strange thing
if I run
create sequence test_sequence;
create view v_test_sequence as select * from test_sequence;
PostgreSQL creates a view based on the sequence and the strange thing
is that, among the various fields that are created in the view,
there is a field named sequence_name with datatype name.
I've seen in the docs
https://www.postgresql.org/docs/9.6/static/datatype-character.html
and the datatype name should be reserved only for structures internal of PG.
Does anyone help me?
Enrico
--
Enrico Pirozzi
e.pirozzi@nbsgroup.it
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: PostgreSQL 9.6: view based on sequence
2018-01-24 11:52 PostgreSQL 9.6: view based on sequence Enrico Pirozzi <e.pirozzi@nbsgroup.it>
@ 2018-01-24 11:56 ` Vincenzo Romano <vincenzo.romano@notorand.it>
2018-01-24 12:02 ` Re: PostgreSQL 9.6: view based on sequence Enrico Pirozzi <e.pirozzi@nbsgroup.it>
2018-01-24 12:05 ` Re: PostgreSQL 9.6: view based on sequence Enrico Pirozzi <e.pirozzi@nbsgroup.it>
1 sibling, 2 replies; 12+ messages in thread
From: Vincenzo Romano @ 2018-01-24 11:56 UTC (permalink / raw)
To: Enrico Pirozzi <e.pirozzi@nbsgroup.it>; +Cc: pgsql-general
2018-01-24 12:52 GMT+01:00 Enrico Pirozzi <e.pirozzi@nbsgroup.it>:
> Hi, I was doing a test on a 9.6 and I've seen a strange thing
>
> if I run
>
> create sequence test_sequence;
> create view v_test_sequence as select * from test_sequence;
>
> PostgreSQL creates a view based on the sequence and the strange thing is
> that, among the various fields that are created in the view,
> there is a field named sequence_name with datatype name.
>
> I've seen in the docs
> https://www.postgresql.org/docs/9.6/static/datatype-character.html
> and the datatype name should be reserved only for structures internal of PG.
>
> Does anyone help me?
>
> Enrico
>
>
>
> --
> Enrico Pirozzi
> e.pirozzi@nbsgroup.it
>
>
tmp1=# create sequence x;
CREATE SEQUENCE
Time: 69,857 ms
tmp1=# select * from x;
last_value | log_cnt | is_called
------------+---------+-----------
1 | 0 | f
(1 row)
Maybe what you want to do is
create view v_test_sequence as select nextval( 'test_sequence' );
Ciao.
--
Vincenzo Romano - NotOrAnd.IT
Information Technologies
--
NON QVIETIS MARIBVS NAVTA PERITVS
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: PostgreSQL 9.6: view based on sequence
2018-01-24 11:52 PostgreSQL 9.6: view based on sequence Enrico Pirozzi <e.pirozzi@nbsgroup.it>
2018-01-24 11:56 ` Re: PostgreSQL 9.6: view based on sequence Vincenzo Romano <vincenzo.romano@notorand.it>
@ 2018-01-24 12:02 ` Enrico Pirozzi <e.pirozzi@nbsgroup.it>
2018-01-24 12:06 ` Re: PostgreSQL 9.6: view based on sequence Vincenzo Romano <vincenzo.romano@notorand.it>
1 sibling, 1 reply; 12+ messages in thread
From: Enrico Pirozzi @ 2018-01-24 12:02 UTC (permalink / raw)
To: Vincenzo Romano <vincenzo.romano@notorand.it>; +Cc: pgsql-general
> tmp1=# create sequence x;
> CREATE SEQUENCE
> Time: 69,857 ms
> tmp1=# select * from x;
> last_value | log_cnt | is_called
> ------------+---------+-----------
> 1 | 0 | f
> (1 row)
>
> Maybe what you want to do is
>
> create view v_test_sequence as select nextval( 'test_sequence' );
>
> Ciao.
Yes but this appens on a 10.x version :)
Ciao
--
Enrico Pirozzi
e.pirozzi@nbsgroup.it
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: PostgreSQL 9.6: view based on sequence
2018-01-24 11:52 PostgreSQL 9.6: view based on sequence Enrico Pirozzi <e.pirozzi@nbsgroup.it>
2018-01-24 11:56 ` Re: PostgreSQL 9.6: view based on sequence Vincenzo Romano <vincenzo.romano@notorand.it>
2018-01-24 12:02 ` Re: PostgreSQL 9.6: view based on sequence Enrico Pirozzi <e.pirozzi@nbsgroup.it>
@ 2018-01-24 12:06 ` Vincenzo Romano <vincenzo.romano@notorand.it>
2018-01-24 12:10 ` Re: PostgreSQL 9.6: view based on sequence Enrico Pirozzi <e.pirozzi@nbsgroup.it>
0 siblings, 1 reply; 12+ messages in thread
From: Vincenzo Romano @ 2018-01-24 12:06 UTC (permalink / raw)
To: Enrico Pirozzi <e.pirozzi@nbsgroup.it>; +Cc: pgsql-general
2018-01-24 13:02 GMT+01:00 Enrico Pirozzi <e.pirozzi@nbsgroup.it>:
>
>> tmp1=# create sequence x;
>> CREATE SEQUENCE
>> Time: 69,857 ms
>> tmp1=# select * from x;
>> last_value | log_cnt | is_called
>> ------------+---------+-----------
>> 1 | 0 | f
>> (1 row)
>>
>> Maybe what you want to do is
>>
>> create view v_test_sequence as select nextval( 'test_sequence' );
>>
>> Ciao.
>
>
> Yes but this appens on a 10.x version :)
>
> Ciao
> --
>
> Enrico Pirozzi
> e.pirozzi@nbsgroup.it
>
I haven't any v9 any more in my deployments. Sorry.
What is the objective of that view?
If it's to hide the nextval() function, then the solution can be
similar to mine.
If it's to access the sequence metainfo, then maybe it'd be better to
explore the pg_catalog schema.
--
Vincenzo Romano - NotOrAnd.IT
Information Technologies
--
NON QVIETIS MARIBVS NAVTA PERITVS
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: PostgreSQL 9.6: view based on sequence
2018-01-24 11:52 PostgreSQL 9.6: view based on sequence Enrico Pirozzi <e.pirozzi@nbsgroup.it>
2018-01-24 11:56 ` Re: PostgreSQL 9.6: view based on sequence Vincenzo Romano <vincenzo.romano@notorand.it>
2018-01-24 12:02 ` Re: PostgreSQL 9.6: view based on sequence Enrico Pirozzi <e.pirozzi@nbsgroup.it>
2018-01-24 12:06 ` Re: PostgreSQL 9.6: view based on sequence Vincenzo Romano <vincenzo.romano@notorand.it>
@ 2018-01-24 12:10 ` Enrico Pirozzi <e.pirozzi@nbsgroup.it>
2018-01-24 12:11 ` Re: PostgreSQL 9.6: view based on sequence Vincenzo Romano <vincenzo.romano@notorand.it>
0 siblings, 1 reply; 12+ messages in thread
From: Enrico Pirozzi @ 2018-01-24 12:10 UTC (permalink / raw)
To: Vincenzo Romano <vincenzo.romano@notorand.it>; +Cc: pgsql-general
it's just to know why postgresql does not return a warning.
Il 24/01/2018 13:06, Vincenzo Romano ha scritto:
> I haven't any v9 any more in my deployments. Sorry.
>
> What is the objective of that view?
> If it's to hide the nextval() function, then the solution can be
> similar to mine.
> If it's to access the sequence metainfo, then maybe it'd be better to
> explore the pg_catalog schema.
--
Enrico Pirozzi
e.pirozzi@nbsgroup.it
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: PostgreSQL 9.6: view based on sequence
2018-01-24 11:52 PostgreSQL 9.6: view based on sequence Enrico Pirozzi <e.pirozzi@nbsgroup.it>
2018-01-24 11:56 ` Re: PostgreSQL 9.6: view based on sequence Vincenzo Romano <vincenzo.romano@notorand.it>
2018-01-24 12:02 ` Re: PostgreSQL 9.6: view based on sequence Enrico Pirozzi <e.pirozzi@nbsgroup.it>
2018-01-24 12:06 ` Re: PostgreSQL 9.6: view based on sequence Vincenzo Romano <vincenzo.romano@notorand.it>
2018-01-24 12:10 ` Re: PostgreSQL 9.6: view based on sequence Enrico Pirozzi <e.pirozzi@nbsgroup.it>
@ 2018-01-24 12:11 ` Vincenzo Romano <vincenzo.romano@notorand.it>
2018-01-24 13:52 ` Re: PostgreSQL 9.6: view based on sequence Enrico Pirozzi <e.pirozzi@nbsgroup.it>
0 siblings, 1 reply; 12+ messages in thread
From: Vincenzo Romano @ 2018-01-24 12:11 UTC (permalink / raw)
To: Enrico Pirozzi <e.pirozzi@nbsgroup.it>; +Cc: pgsql-general
2018-01-24 13:10 GMT+01:00 Enrico Pirozzi <e.pirozzi@nbsgroup.it>:
> it's just to know why postgresql does not return a warning.
>
>
>
> Il 24/01/2018 13:06, Vincenzo Romano ha scritto:
>>
>> I haven't any v9 any more in my deployments. Sorry.
>>
>> What is the objective of that view?
>> If it's to hide the nextval() function, then the solution can be
>> similar to mine.
>> If it's to access the sequence metainfo, then maybe it'd be better to
>> explore the pg_catalog schema.
>
>
> --
> Enrico Pirozzi
> e.pirozzi@nbsgroup.it
>
Those queries are all legal. No warning is due.
--
Vincenzo Romano - NotOrAnd.IT
Information Technologies
--
NON QVIETIS MARIBVS NAVTA PERITVS
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: PostgreSQL 9.6: view based on sequence
2018-01-24 11:52 PostgreSQL 9.6: view based on sequence Enrico Pirozzi <e.pirozzi@nbsgroup.it>
2018-01-24 11:56 ` Re: PostgreSQL 9.6: view based on sequence Vincenzo Romano <vincenzo.romano@notorand.it>
2018-01-24 12:02 ` Re: PostgreSQL 9.6: view based on sequence Enrico Pirozzi <e.pirozzi@nbsgroup.it>
2018-01-24 12:06 ` Re: PostgreSQL 9.6: view based on sequence Vincenzo Romano <vincenzo.romano@notorand.it>
2018-01-24 12:10 ` Re: PostgreSQL 9.6: view based on sequence Enrico Pirozzi <e.pirozzi@nbsgroup.it>
2018-01-24 12:11 ` Re: PostgreSQL 9.6: view based on sequence Vincenzo Romano <vincenzo.romano@notorand.it>
@ 2018-01-24 13:52 ` Enrico Pirozzi <e.pirozzi@nbsgroup.it>
2018-01-24 14:02 ` Re: PostgreSQL 9.6: view based on sequence Vincenzo Romano <vincenzo.romano@notorand.it>
0 siblings, 1 reply; 12+ messages in thread
From: Enrico Pirozzi @ 2018-01-24 13:52 UTC (permalink / raw)
To: Vincenzo Romano <vincenzo.romano@notorand.it>; +Cc: pgsql-general
Yes the query is legal,but if you use pg_upgrade to upgrade from 9.6 to
10.x , pg_upgrade will fail .
Enrico
Il 24/01/2018 13:11, Vincenzo Romano ha scritto:
> Those queries are all legal. No warning is due.
--
Enrico Pirozzi
e.pirozzi@nbsgroup.it
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: PostgreSQL 9.6: view based on sequence
2018-01-24 11:52 PostgreSQL 9.6: view based on sequence Enrico Pirozzi <e.pirozzi@nbsgroup.it>
2018-01-24 11:56 ` Re: PostgreSQL 9.6: view based on sequence Vincenzo Romano <vincenzo.romano@notorand.it>
2018-01-24 12:02 ` Re: PostgreSQL 9.6: view based on sequence Enrico Pirozzi <e.pirozzi@nbsgroup.it>
2018-01-24 12:06 ` Re: PostgreSQL 9.6: view based on sequence Vincenzo Romano <vincenzo.romano@notorand.it>
2018-01-24 12:10 ` Re: PostgreSQL 9.6: view based on sequence Enrico Pirozzi <e.pirozzi@nbsgroup.it>
2018-01-24 12:11 ` Re: PostgreSQL 9.6: view based on sequence Vincenzo Romano <vincenzo.romano@notorand.it>
2018-01-24 13:52 ` Re: PostgreSQL 9.6: view based on sequence Enrico Pirozzi <e.pirozzi@nbsgroup.it>
@ 2018-01-24 14:02 ` Vincenzo Romano <vincenzo.romano@notorand.it>
2018-01-24 14:38 ` Re: PostgreSQL 9.6: view based on sequence Enrico Pirozzi <e.pirozzi@nbsgroup.it>
0 siblings, 1 reply; 12+ messages in thread
From: Vincenzo Romano @ 2018-01-24 14:02 UTC (permalink / raw)
To: Enrico Pirozzi <e.pirozzi@nbsgroup.it>; +Cc: pgsql-general
2018-01-24 14:52 GMT+01:00 Enrico Pirozzi <e.pirozzi@nbsgroup.it>:
> Yes the query is legal,but if you use pg_upgrade to upgrade from 9.6 to 10.x
> , pg_upgrade will fail .
>
> Enrico
>
>
>
> Il 24/01/2018 13:11, Vincenzo Romano ha scritto:
>>
>> Those queries are all legal. No warning is due.
>
>
> --
> Enrico Pirozzi
> e.pirozzi@nbsgroup.it
>
It is all documented here:
https://www.postgresql.org/docs/10/static/release-10.html#idm46428658049888
"...selecting from a sequence relation now returns only the three
fields named above."
And there's no way to keep portability from 9.x to 10.x
--
Vincenzo Romano - NotOrAnd.IT
Information Technologies
--
NON QVIETIS MARIBVS NAVTA PERITVS
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: PostgreSQL 9.6: view based on sequence
2018-01-24 11:52 PostgreSQL 9.6: view based on sequence Enrico Pirozzi <e.pirozzi@nbsgroup.it>
2018-01-24 11:56 ` Re: PostgreSQL 9.6: view based on sequence Vincenzo Romano <vincenzo.romano@notorand.it>
2018-01-24 12:02 ` Re: PostgreSQL 9.6: view based on sequence Enrico Pirozzi <e.pirozzi@nbsgroup.it>
2018-01-24 12:06 ` Re: PostgreSQL 9.6: view based on sequence Vincenzo Romano <vincenzo.romano@notorand.it>
2018-01-24 12:10 ` Re: PostgreSQL 9.6: view based on sequence Enrico Pirozzi <e.pirozzi@nbsgroup.it>
2018-01-24 12:11 ` Re: PostgreSQL 9.6: view based on sequence Vincenzo Romano <vincenzo.romano@notorand.it>
2018-01-24 13:52 ` Re: PostgreSQL 9.6: view based on sequence Enrico Pirozzi <e.pirozzi@nbsgroup.it>
2018-01-24 14:02 ` Re: PostgreSQL 9.6: view based on sequence Vincenzo Romano <vincenzo.romano@notorand.it>
@ 2018-01-24 14:38 ` Enrico Pirozzi <e.pirozzi@nbsgroup.it>
0 siblings, 0 replies; 12+ messages in thread
From: Enrico Pirozzi @ 2018-01-24 14:38 UTC (permalink / raw)
To: Vincenzo Romano <vincenzo.romano@notorand.it>; +Cc: pgsql-general
> It is all documented here:
> https://www.postgresql.org/docs/10/static/release-10.html#idm46428658049888
>
> "...selecting from a sequence relation now returns only the three
> fields named above."
>
> And there's no way to keep portability from 9.x to 10.x
Thanks ;)
Enrico
--
Enrico Pirozzi
e.pirozzi@nbsgroup.it
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: PostgreSQL 9.6: view based on sequence
2018-01-24 11:52 PostgreSQL 9.6: view based on sequence Enrico Pirozzi <e.pirozzi@nbsgroup.it>
2018-01-24 11:56 ` Re: PostgreSQL 9.6: view based on sequence Vincenzo Romano <vincenzo.romano@notorand.it>
@ 2018-01-24 12:05 ` Enrico Pirozzi <e.pirozzi@nbsgroup.it>
1 sibling, 0 replies; 12+ messages in thread
From: Enrico Pirozzi @ 2018-01-24 12:05 UTC (permalink / raw)
To: ; +Cc: pgsql-general
tmp1=# create sequence x;
> CREATE SEQUENCE
> Time: 69,857 ms
> tmp1=# select * from x;
> last_value | log_cnt | is_called
> ------------+---------+-----------
> 1 | 0 | f
> (1 row)
>
> Maybe what you want to do is
>
> create view v_test_sequence as select nextval( 'test_sequence' );
>
> Ciao.
Yes but this happens on a 10.x version on a 9.6 version things are
differents
Ciao
Enrico
--
Enrico Pirozzi
e.pirozzi@nbsgroup.it
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: PostgreSQL 9.6: view based on sequence
2018-01-24 11:52 PostgreSQL 9.6: view based on sequence Enrico Pirozzi <e.pirozzi@nbsgroup.it>
@ 2018-01-25 17:07 ` Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
2018-01-25 17:38 ` Re: PostgreSQL 9.6: view based on sequence Enrico Pirozzi <e.pirozzi@nbsgroup.it>
1 sibling, 1 reply; 12+ messages in thread
From: Peter Eisentraut @ 2018-01-25 17:07 UTC (permalink / raw)
To: Enrico Pirozzi <e.pirozzi@nbsgroup.it>; pgsql-general
On 1/24/18 06:52, Enrico Pirozzi wrote:
> PostgreSQL creates a view based on the sequence and the strange thing
> is that, among the various fields that are created in the view,
> there is a field named sequence_name with datatype name.
>
> I've seen in the docs
> https://www.postgresql.org/docs/9.6/static/datatype-character.html
> and the datatype name should be reserved only for structures internal of PG.
There is nothing from with user code using the data type "name". It's
probably just not the best choice. But if you create a view over a
system table, then you'll get whatever types the system table uses.
There is nothing from with that.
--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: PostgreSQL 9.6: view based on sequence
2018-01-24 11:52 PostgreSQL 9.6: view based on sequence Enrico Pirozzi <e.pirozzi@nbsgroup.it>
2018-01-25 17:07 ` Re: PostgreSQL 9.6: view based on sequence Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
@ 2018-01-25 17:38 ` Enrico Pirozzi <e.pirozzi@nbsgroup.it>
0 siblings, 0 replies; 12+ messages in thread
From: Enrico Pirozzi @ 2018-01-25 17:38 UTC (permalink / raw)
To: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>; pgsql-general
I found this db, it's not mine
Thanks ;)
Enrico
Il 25/01/2018 18:07, Peter Eisentraut ha scritto:
> There is nothing from with user code using the data type "name". It's
> probably just not the best choice. But if you create a view over a
> system table, then you'll get whatever types the system table uses.
> There is nothing from with that.
--
Enrico Pirozzi
e.pirozzi@nbsgroup.it
^ permalink raw reply [nested|flat] 12+ messages in thread
end of thread, other threads:[~2018-01-25 17:38 UTC | newest]
Thread overview: 12+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-01-24 11:52 PostgreSQL 9.6: view based on sequence Enrico Pirozzi <e.pirozzi@nbsgroup.it>
2018-01-24 11:56 ` Vincenzo Romano <vincenzo.romano@notorand.it>
2018-01-24 12:02 ` Enrico Pirozzi <e.pirozzi@nbsgroup.it>
2018-01-24 12:06 ` Vincenzo Romano <vincenzo.romano@notorand.it>
2018-01-24 12:10 ` Enrico Pirozzi <e.pirozzi@nbsgroup.it>
2018-01-24 12:11 ` Vincenzo Romano <vincenzo.romano@notorand.it>
2018-01-24 13:52 ` Enrico Pirozzi <e.pirozzi@nbsgroup.it>
2018-01-24 14:02 ` Vincenzo Romano <vincenzo.romano@notorand.it>
2018-01-24 14:38 ` Enrico Pirozzi <e.pirozzi@nbsgroup.it>
2018-01-24 12:05 ` Enrico Pirozzi <e.pirozzi@nbsgroup.it>
2018-01-25 17:07 ` Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
2018-01-25 17:38 ` Enrico Pirozzi <e.pirozzi@nbsgroup.it>
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