Re: CREATE TYPE delimiter?

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: CREATE TYPE delimiter?
Дата
Msg-id 2942.1004821548@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: CREATE TYPE delimiter?  ("Command Prompt, Inc." <pgsql-general@commandprompt.com>)
Ответы Re: CREATE TYPE delimiter?  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
"Command Prompt, Inc." <pgsql-general@commandprompt.com> writes:
> Wonderful. While you're in there, you might look at the wording on the
> input and output function descriptions; it says that they must take either
> one or two arguments of type opaque, but it's not at all clear what the
> second argument would be for, in either circumstance.

On checking the code, that's actually wrong, as well as insufficient.
Fixed.

> Also, the DEFAULT clause was a bit curious; it says you can describe "some
> specific bit pattern" to mean "data not present"; presumably in place of
> NULL?

This is bogus too.  A default value is just a default value supplied at
the datatype level instead of the column level.  Basically INSERT does
this for each column:

    * Column value given explicitly in INSERT command?
        => use it
    * DEFAULT specified for column in table creation command?
        => use that
    * DEFAULT specified for column's datatype?
        => use that
    * Else, insert a NULL

There isn't anything in there that could allow a datatype-specific
representation of NULL, which is what the existing wording seems to
suggest the clause is for.

> I figured this meant it took a bit string for some kind of internal
> handling, but it seems to accept any arbitrary value I give it (integer,
> text, though not a b'1001' style bit string!). However, I got some ugly
> disconnections from the server after experimenting with this value, and
> attempting to SELECT values that would have otherwise been NULL. ;) I

IIRC, until recently the datatype-level DEFAULT was essentially useless,
because the way it was coded, you'd have to enter a textual string whose
contents are the *internal* representation of the desired default value.
This is pretty silly, so it's been fixed to accept a normal
external-form string that gets fed through the type's input routine.
But I think that may only be in 7.2, not any earlier release.

I'm working on improving the CREATE TYPE ref page now ...

            regards, tom lane

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

Предыдущее
От: "Eric Ridge"
Дата:
Сообщение: Re: SETOF and language 'plpgsql'
Следующее
От: Tom Lane
Дата:
Сообщение: Re: SETOF and language 'plpgsql'