Re: pg_get_serial_sequence Strangeness/Unreliable?

Поиск
Список
Период
Сортировка
От V S P
Тема Re: pg_get_serial_sequence Strangeness/Unreliable?
Дата
Msg-id 1227624700.11990.1286683199@webmail.messagingengine.com
обсуждение исходный текст
Ответ на pg_get_serial_sequence Strangeness/Unreliable?  (Jeff MacDonald <oss@bignose.ca>)
Ответы Re: pg_get_serial_sequence Strangeness/Unreliable?  (Jeff MacDonald <oss@bignose.ca>)
Список pgsql-general
Did you first insert into
public.news_status

insert into public.news_status (status_id)
values (DEFAULT)

and then get the sequence?


Also since you have a domain 'public' I personally
always do 'set searc_path to public' before doing
any SQLs -- this way I know that I do not need
to prefix my table names with 'public' all the time.


V S P




On Tue, 25 Nov 2008 09:46:37 -0400, "Jeff MacDonald" <oss@bignose.ca>
said:
> Hello everyone,
>
> I'm using "PostgreSQL 8.2.5 on amd64-portbld-freebsd6.1, compiled by
> GCC cc (GCC) 3.4.4 [FreeBSD] 20050518"
>
> The issue, is that when I run pg_get_serial_sequence on a particular
> table/column it returns NULL.
>
> Here are my tests:
>
> simplyas_associations=> \d news_status
>                                       Table "public.news_status"
>      Column     |         Type          |
> Modifiers
> ---------------+-----------------------
> +------------------------------------------------------------
>   status_id     | integer               | not null default
> nextval('status_status_id_seq'::regclass)
>   newsletter_id | integer               | not null
>   status        | boolean               | not null
>   indate        | character varying(15) | not null
> Indexes:
>      "status_pkey" PRIMARY KEY, btree (status_id)
>      "status_newsletter_id" btree (newsletter_id)
>
> simplyas_associations=> select
> pg_get_serial_sequence('news_status','status_id');
>   pg_get_serial_sequence
> ------------------------
>
> (1 row)
>
> So, for fun I added a new column to this table , and ran
> pg_get_serial_sequence there
>
> simplyas_associations=> alter table news_status add column test_id
> serial;
> NOTICE:  ALTER TABLE will create implicit sequence
> "news_status_test_id_seq" for serial column "news_status.test_id"
> ALTER TABLE
> simplyas_associations=> select
> pg_get_serial_sequence('news_status','test_id');
>       pg_get_serial_sequence
> --------------------------------
>   public.news_status_test_id_seq
> ------------------------
>
> (1 row)
>
> So my new column works. The only next step I could think of was to
> compare my 2 sequences with \d, turns out their attributes are both
> identical.
>
> Ideas?
>
> Thanks
>
> Jeff MacDonald
>
> --
> Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
--
  V S P
  toreason@fastmail.fm

--
http://www.fastmail.fm - Or how I learned to stop worrying and
                          love email again


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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: pg_get_serial_sequence Strangeness/Unreliable?
Следующее
От: Bill Todd
Дата:
Сообщение: Cannot restore table using pg_restore