Re: Wrong column default values

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Wrong column default values
Дата
Msg-id 5562.1253304906@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Wrong column default values  (Dave Cramer <pg@fastcrypt.com>)
Ответы Re: Wrong column default values  (Kris Jurka <books@ejurka.com>)
Список pgsql-jdbc
Dave Cramer <pg@fastcrypt.com> writes:
> On Fri, Sep 18, 2009 at 4:24 AM, Andre Rothe <phosco@gmx.de> wrote:
>> I have installed Postgres 8.3.8 on Fedora Linux and I access it per
>> JDBC (PostgreSQL 8.1 JDBC3 with SSL (build 407)). If I create a table,
>> the default values will be set by the database to
>> NULL::timestamp without time zone
>> for a timezone column and to
>> NULL::character varying
>> for a varchar column. How I can prevent such a behaviour? Both column

> How do you create this table ?

Indeed.  In 8.3 it seems that even if you try to set the default that
way, the system will throw away the cast:

regression=# create table t1 (f1 varchar default null::varchar);
CREATE TABLE
regression=# \d t1
           Table "public.t1"
 Column |       Type        | Modifiers
--------+-------------------+-----------
 f1     | character varying |

regression=# create table t2 (f1 varchar);
CREATE TABLE
regression=# alter table t2 alter column f1 set default null::varchar;
ALTER TABLE
regression=# \d t2
           Table "public.t2"
 Column |       Type        | Modifiers
--------+-------------------+-----------
 f1     | character varying |

I'm thinking that this has less to do with what the server thinks
and more to do with whatever tool the OP is using to examine the
table ...

            regards, tom lane

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

Предыдущее
От: Dave Cramer
Дата:
Сообщение: Re: Wrong column default values
Следующее
От: Andre Rothe
Дата:
Сообщение: Re: Wrong column default values