Thread: PGS 7.2 : Insert with wrong number of values did not fail

PGS 7.2 : Insert with wrong number of values did not fail

From
Geoffrey KRETZ
Date:
Hi,

I've got a question about a difference beetween PGS 7.2 and PGS 7.4
behaviours.

With PGS 7.2 :
 INSERT INTO table (col1, col2) VALUES (val1) doesn't fail

With PGS 7.4 :
 INSERT INTO table (col1, col2) VALUES (val1) failed

Is it a known bug ?

Thx.

Geoffrey KRETZ
Four J's Development Tools

Re: PGS 7.2 : Insert with wrong number of values did not

From
Scott Marlowe
Date:
On Mon, 2005-02-21 at 09:38, Geoffrey KRETZ wrote:
> Hi,
>
> I've got a question about a difference beetween PGS 7.2 and PGS 7.4
> behaviours.
>
> With PGS 7.2 :
>  INSERT INTO table (col1, col2) VALUES (val1) doesn't fail
>
> With PGS 7.4 :
>  INSERT INTO table (col1, col2) VALUES (val1) failed
>
> Is it a known bug ?

Yes, if 7.2 did that it WAS a known bug.  Fixed in 7.4.  It is illegal
to have unmatching numbers of columns in the insert list and the column
list.

Did 7.2 really do that?

Re: PGS 7.2 : Insert with wrong number of values did not

From
Geoffrey KRETZ
Date:
Scott Marlowe wrote:

>On Mon, 2005-02-21 at 09:38, Geoffrey KRETZ wrote:
>
>
>>Hi,
>>
>>I've got a question about a difference beetween PGS 7.2 and PGS 7.4
>>behaviours.
>>
>>With PGS 7.2 :
>> INSERT INTO table (col1, col2) VALUES (val1) doesn't fail
>>
>>With PGS 7.4 :
>> INSERT INTO table (col1, col2) VALUES (val1) failed
>>
>>Is it a known bug ?
>>
>>
>
>Yes, if 7.2 did that it WAS a known bug.  Fixed in 7.4.  It is illegal
>to have unmatching numbers of columns in the insert list and the column
>list.
>
>Did 7.2 really do that?
>
>
>

7.1 do that and while testing recently, we found that in 7.2, it's the
same behaviour. In 7.3, it's already ok.

I've answer the question just to be sure that it's a postgresql bug.

Geoffrey KRETZ
Four J's Development Tools


Re: PGS 7.2 : Insert with wrong number of values did not

From
Geoffrey KRETZ
Date:
Geoffrey KRETZ wrote:

> Scott Marlowe wrote:
>
>> On Mon, 2005-02-21 at 09:38, Geoffrey KRETZ wrote:
>>
>>
>>> Hi,
>>>
>>> I've got a question about a difference beetween PGS 7.2 and PGS 7.4
>>> behaviours.
>>>
>>> With PGS 7.2 :
>>> INSERT INTO table (col1, col2) VALUES (val1) doesn't fail
>>>
>>> With PGS 7.4 :
>>> INSERT INTO table (col1, col2) VALUES (val1) failed
>>>
>>> Is it a known bug ?
>>>
>>
>>
>> Yes, if 7.2 did that it WAS a known bug.  Fixed in 7.4.  It is illegal
>> to have unmatching numbers of columns in the insert list and the column
>> list.
>>
>> Did 7.2 really do that?
>>
>>
>>
>
> 7.1 do that and while testing recently, we found that in 7.2, it's the
> same behaviour. In 7.3, it's already ok.
>
> I've answer the question just to be sure that it's a postgresql bug.


I've ASK the question (not answered it !!)

Sorry for the mistake :-/

Geoffrey


Re: PGS 7.2 : Insert with wrong number of values did not fail

From
Tom Lane
Date:
Geoffrey KRETZ <gk@4js.com> writes:
> I've got a question about a difference beetween PGS 7.2 and PGS 7.4
> behaviours.

> With PGS 7.2 :
>  INSERT INTO table (col1, col2) VALUES (val1) doesn't fail

> With PGS 7.4 :
>  INSERT INTO table (col1, col2) VALUES (val1) failed

> Is it a known bug ?

More a deliberate change in behavior.  The old behavior was intentional
but we decided it was too much at variance with the SQL spec.  Now you
can only omit columns when you don't specify a column name list.

            regards, tom lane

Re: PGS 7.2 : Insert with wrong number of values did not

From
Scott Marlowe
Date:
On Mon, 2005-02-21 at 09:49, Geoffrey KRETZ wrote:
> Scott Marlowe wrote:
>
> >On Mon, 2005-02-21 at 09:38, Geoffrey KRETZ wrote:
> >
> >
> >>Hi,
> >>
> >>I've got a question about a difference beetween PGS 7.2 and PGS 7.4
> >>behaviours.
> >>
> >>With PGS 7.2 :
> >> INSERT INTO table (col1, col2) VALUES (val1) doesn't fail
> >>
> >>With PGS 7.4 :
> >> INSERT INTO table (col1, col2) VALUES (val1) failed
> >>
> >>Is it a known bug ?
> >>
> >>
> >
> >Yes, if 7.2 did that it WAS a known bug.  Fixed in 7.4.  It is illegal
> >to have unmatching numbers of columns in the insert list and the column
> >list.
> >
> >Did 7.2 really do that?
> >
> >
> >
>
> 7.1 do that and while testing recently, we found that in 7.2, it's the
> same behaviour. In 7.3, it's already ok.
>
> I've answer the question just to be sure that it's a postgresql bug.


Note that in the old version, postgresql would have inserted a default
value or a NULL if there was no default.  With the addition of the
DEFAULT keyword, you can get the same basic effect with:

insert into table (col1, col2) values (val1,DEFAULT);

Re: PGS 7.2 : Insert with wrong number of values did not

From
Geoffrey KRETZ
Date:
Scott Marlowe wrote:

>On Mon, 2005-02-21 at 09:49, Geoffrey KRETZ wrote:
>
>
>>Scott Marlowe wrote:
>>
>>
>>
>>>On Mon, 2005-02-21 at 09:38, Geoffrey KRETZ wrote:
>>>
>>>
>>>
>>>
>>>>Hi,
>>>>
>>>>I've got a question about a difference beetween PGS 7.2 and PGS 7.4
>>>>behaviours.
>>>>
>>>>With PGS 7.2 :
>>>>INSERT INTO table (col1, col2) VALUES (val1) doesn't fail
>>>>
>>>>With PGS 7.4 :
>>>>INSERT INTO table (col1, col2) VALUES (val1) failed
>>>>
>>>>Is it a known bug ?
>>>>
>>>>
>>>>
>>>>
>>>Yes, if 7.2 did that it WAS a known bug.  Fixed in 7.4.  It is illegal
>>>to have unmatching numbers of columns in the insert list and the column
>>>list.
>>>
>>>Did 7.2 really do that?
>>>
>>>
>>>
>>>
>>>
>>7.1 do that and while testing recently, we found that in 7.2, it's the
>>same behaviour. In 7.3, it's already ok.
>>
>>I've answer the question just to be sure that it's a postgresql bug.
>>
>>
>
>
>Note that in the old version, postgresql would have inserted a default
>value or a NULL if there was no default.  With the addition of the
>DEFAULT keyword, you can get the same basic effect with:
>
>insert into table (col1, col2) values (val1,DEFAULT);
>
>

I've read a thread about that, but I wasn't sure about the PostgreSQL's
version where the change was made.

Thx for your answers !

Geoffrey KRETZ
Four J's Development Tools