Thread: Wrong default values of columns

Wrong default values of columns

From
Andre Rothe
Date:
Hi,

I have installed Postgres 8.3.8 on Fedora Linux. 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
defaults should be NULL. I have read some posts about this point, it
seems to be a problem of a so called "acts_as_tsearch plugin", but I'm
not familiar enough with Postgres to know, what it means. Any other
detailled solutions?

Thanks
Andre

Re: Wrong default values of columns

From
Robert Haas
Date:
On Thu, Sep 17, 2009 at 8:15 AM, Andre Rothe <phosco@gmx.de> wrote:
> Hi,
>
> I have installed Postgres 8.3.8 on Fedora Linux. 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
> defaults should be NULL.

Uh... that's exactly what they were set to.  The :: stuff is just a
type-annotation.  Your defaults really are NULL.

> I have read some posts about this point, it
> seems to be a problem of a so called "acts_as_tsearch plugin", but I'm
> not familiar enough with Postgres to know, what it means. Any other
> detailled solutions?

I don't think that has anything to do with this.

...Robert

Re: Wrong default values of columns

From
Andre Rothe
Date:
The problem is, that I get the default values from a metadata query
with JDBC,
so I have to parse every return value for such an annotation before I
can
use them.

So it seems that I could change the jdbc driver to a newer version. I
use the
PostgreSQL 8.1 JDBC3 with SSL (build 407).

Thanks
Andre

On Sep 17, 3:53=A0pm, robertmh...@gmail.com (Robert Haas) wrote:
> Uh... that's exactly what they were set to. =A0The :: stuff is just a
> type-annotation. =A0Your defaults really are NULL.

Re: Wrong default values of columns

From
Robert Haas
Date:
On Thu, Sep 17, 2009 at 10:44 AM, Andre Rothe <phosco@gmx.de> wrote:
> The problem is, that I get the default values from a metadata query
> with JDBC,
> so I have to parse every return value for such an annotation before I
> can
> use them.

That sounds annoying, but it's not a PostgreSQL bug.

> So it seems that I could change the jdbc driver to a newer version. I
> use the
> PostgreSQL 8.1 JDBC3 with SSL (build 407).

I don't really know anything about the JDBC driver, but the closest
thing I see here:

http://jdbc.postgresql.org/download/

...is a link to
http://jdbc.postgresql.org/download/postgresql-8.1-407.jdbc3.jar, with
a date of 23-May-2006.  So yeah, updating might be a good idea.  If
you're still on PG 8.1, updating that might be a REALLY good idea,
though it probably won't do anything for you on this particular issue.

I would suggest asking on pgsql-jdbc; not too many jdbc folks reading
this list, AFAICT.

...Robert

Re: Wrong default values of columns

From
Tom Lane
Date:
Robert Haas <robertmhaas@gmail.com> writes:
> On Thu, Sep 17, 2009 at 10:44 AM, Andre Rothe <phosco@gmx.de> wrote:
>> The problem is, that I get the default values from a metadata query
>> with JDBC,
>> so I have to parse every return value for such an annotation before I
>> can use them.

> That sounds annoying, but it's not a PostgreSQL bug.

I think the type decoration must be getting injected on the client side,
actually.  Postgres won't insert that for itself, not even if you
explicitly say "default null".  Pre-8.3, if you say "default
null::varchar" then Postgres will regurgitate it that way (8.3 and up
throw the cast away even in that case).  But it had to have come from
the client initially.

So pgsql-jdbc are the folks to talk to.

            regards, tom lane