Thread: dump and schema

dump and schema

From
van Elsacker Frans
Date:
I have a problem with date default and schema's and don't know wether I am 
doing something wrong or not.

All my tables (more than 100) have a field datumi of type date default 
today, as this example:
CREATE TABLE tabel (    ....    datumi date DEFAULT 'today',    ....
);
taking a dump or a schema of this table via pg_dump and restoring or using 
it went fine

Now I am using postgres 7.4 and  making a schema (and also the table in a 
dump gave this result)
CREATE TABLE  tabel(    ....    datumi date DEFAULT '2003-12-10'::date,    ....
);

which is not expected for a schema. Even worse by restoring a dump, all my 
new records have this fixed date in the field datumi.
Something has changed? I do it in the wrong way?  Is there a solution ?

many thanks



Re: dump and schema

From
Tom Lane
Date:
van Elsacker Frans <fve@atbib.be> writes:
> All my tables (more than 100) have a field datumi of type date default 
> today, as this example:
> CREATE TABLE tabel (
>      ....
>      datumi date DEFAULT 'today',
>      ....
> );

This does not work anymore in PG 7.4.  You need something like
datumi date DEFAULT CURRENT_DATE,
        regards, tom lane


Re: dump and schema

From
Olivier Hubaut
Date:
Tom Lane wrote:

> van Elsacker Frans <fve@atbib.be> writes:
> 
>>All my tables (more than 100) have a field datumi of type date default 
>>today, as this example:
>>CREATE TABLE tabel (
>>     ....
>>     datumi date DEFAULT 'today',
>>     ....
>>);
> 
> 
> This does not work anymore in PG 7.4.  You need something like
> 
>     datumi date DEFAULT CURRENT_DATE,
> 
>             regards, tom lane
> 
I think this won't get the same result he expects. As I know, the 
CURRENT_DATE will always give the current day, not the day you inserted 
the row.

I think the now()::date seems to be a better way to translate the 
'today' value.

-- 
Ci-git une signature avortee.
** RIP **


Re: dump and schema

From
Peter Eisentraut
Date:
Olivier Hubaut wrote:
> I think this won't get the same result he expects. As I know, the
> CURRENT_DATE will always give the current day, not the day you
> inserted the row.

Your knowledge is incorrect.



Re: dump and schema

From
Tom Lane
Date:
Olivier Hubaut <olivier@scmbb.ulb.ac.be> writes:
> Tom Lane wrote:
>> This does not work anymore in PG 7.4.  You need something like
>> datumi date DEFAULT CURRENT_DATE,

> I think the now()::date seems to be a better way to translate the 
> 'today' value.

There is no real difference.
        regards, tom lane