Re: Odd behavior with 'currval'

Поиск
Список
Период
Сортировка
От David G. Johnston
Тема Re: Odd behavior with 'currval'
Дата
Msg-id CAKFQuwYOid4vqN6abpxS=VrrYnt3PBnmvSF+Lk317cuL_jW32w@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Odd behavior with 'currval'  (Steven Hirsch <snhirsch@gmail.com>)
Ответы Re: Odd behavior with 'currval'  (Steven Hirsch <snhirsch@gmail.com>)
Список pgsql-general
On Thu, Feb 8, 2018 at 10:58 AM, Steven Hirsch <snhirsch@gmail.com> wrote:
On a hunch, I tried 'SELECT currval(NULL)' to see if it returned '0', but that too returns NULL.  So, where is the '0' coming from when I do:

SELECT currval( pg_get_serial_sequence('udm_asset_type_definition','def_id'))

? I've already established that the inner expression evaluates to NULL!

​This is indeed unusual...to be specific here pg_get_serial_sequence returns null in lieu of an error for being unable to locate the indicated sequence.  currval is returning null because it is defined "STRICT" and so given a null input it will always return null.  currval itself, when provided a non-null input, is going to error or provide a number (which should never be zero...).

I'm wondering whether someone didn't like the fact that currval errors and instead wrote a overriding function that instead returns zero?

David J.

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

Предыдущее
От: Steven Hirsch
Дата:
Сообщение: Re: Odd behavior with 'currval'
Следующее
От: Adrian Klaver
Дата:
Сообщение: Re: Odd behavior with 'currval'