Re: BUG #9088: default are not working

From: Patrick Lademan <mjfrog14(at)gmail(dot)com>
To: Marko Tiikkaja <marko(at)joh(dot)to>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #9088: default are not working
Date: 2014-02-03 23:38:42
Message-ID: CADMm_6BOKJ=4vNCAu7KfMQ2potAFmxqsDpsGBWpm2p4RyGe=vA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

I am sorry, I tried to break it down to the simplest test. It was on the
not null that it was failing. When I reconstructed the test in the
database, I went down the path of thinking it was a timestamp issue not a
default issue.

Here is the issue again.
-- It appears that default values are no longer working in 9.3.1.

-- This is the version that I am running:
-- "PostgreSQL 9.3.1 on x86_64-apple-darwin, compiled by
i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build
5658) (LLVM build 2336.9.00), 64-bit"

-- Test Case
drop table default_test;

create table default_test
(
userId varchar(20) default 'test' not null,
date1 timestamp default now() not null,
date2 timestamp default current_timestamp not null,
date3 timestamp default localtimestamp not null
);

insert into default_test
( userId, date1, date2, date3 )
values
( null, null, null, null );

select * from default_test;

ERROR: null value in column "userid" violates not-null constraint
DETAIL: Failing row contains (null, null, null, null).
********** Error **********

ERROR: null value in column "userid" violates not-null constraint
SQL state: 23502
Detail: Failing row contains (null, null, null, null).

On Mon, Feb 3, 2014 at 5:31 PM, Marko Tiikkaja <marko(at)joh(dot)to> wrote:

> On 2/3/14, 11:23 PM, plademan(at)comcast(dot)net wrote:
>
>> It appears that default values are no longer working in 9.3.1.
>>
>> insert into default_test
>> ( userId, date1, date2, date3 )
>> values
>> ( null, null, null, null );
>>
>> select * from default_test;
>>
>
> This wouldn't have worked in previous versions either. You want:
>
> INSERT INTO default_test (userid, date1, date2, date) VALUES (DEFAULT,
> DEFAULT, DEFAULT, DEFAULT)
>
> or perhaps
>
> INSERT INTO default_test DEFAULT VALUES;
>
>
> Regards,
> Marko Tiikkaja
>
>
> --
> Sent via pgsql-bugs mailing list (pgsql-bugs(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-bugs
>

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2014-02-04 01:19:42 Re: BUG #9087: Foreign data wrapper connection management issues
Previous Message Marko Tiikkaja 2014-02-03 22:31:17 Re: BUG #9088: default are not working