Thread: 7.5 backend crash

7.5 backend crash

From
Gaetano Mendola
Date:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi all,
I'm playing with complex row type:


kalman=# create table test ( a integer, b integer );
CREATE TABLE
kalman=# create table test1 ( c integer , d test );
CREATE TABLE
kalman=# insert into test1 values ( 1, (2,3) );
INSERT 17277 1
kalman=# select * from test1;
~ c |   d
- ---+-------
~ 1 | (2,3)
(1 row)

kalman=# alter table test drop column b;
ALTER TABLE        <--- Here I think the server shall complain about
~                             ( 7.4 doesn't complain neither )

the following select on table test1 will crash the back end

kalman=# select * from test1;
server closed the connection unexpectedly
~        This probably means the server terminated abnormally
~        before or while processing the request.
The connection to the server was lost. Attempting reset: Failed.
!>




Regards
Gaetano Mendola



-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (MingW32)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFBBFQH7UpzwH2SGd4RAvIXAJ0bcfGdP5sfPFRYdfKOJ0YchRYXPgCfZti7
wKfzG4GwdFft0a1LDXK9fmo=
=wjvZ
-----END PGP SIGNATURE-----



Re: 7.5 backend crash

From
Tom Lane
Date:
Gaetano Mendola <mendola@bigfoot.com> writes:
> kalman=# create table test ( a integer, b integer );
> CREATE TABLE
> kalman=# create table test1 ( c integer , d test );
> CREATE TABLE

> kalman=# alter table test drop column b;
> ALTER TABLE        <--- Here I think the server shall complain about

Yeah, the design intention is that the ALTER should refuse to do it.
Looks like I missed a case.  Will fix, thanks for the report.
        regards, tom lane


Re: 7.5 backend crash

From
Gaetano Mendola
Date:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Tom Lane wrote:

| Gaetano Mendola <mendola@bigfoot.com> writes:
|
|>kalman=# create table test ( a integer, b integer );
|>CREATE TABLE
|>kalman=# create table test1 ( c integer , d test );
|>CREATE TABLE
|
|
|>kalman=# alter table test drop column b;
|>ALTER TABLE        <--- Here I think the server shall complain about
|
|
| Yeah, the design intention is that the ALTER should refuse to do it.
| Looks like I missed a case.  Will fix, thanks for the report.

Hi,
in the mean time that you are working on it I believe that this is ugly too:

kalman=# create table test ( a integer );
CREATE TABLE
kalman=# alter table test add columb b test;
ALTER TABLE
kalman=#  insert into test values (1 ,(2,(3,(4,(5,(6, null))))));
INSERT 33639 1
kalman=# select * from  test;
~ a |                         b
- ---+----------------------------------------------------
~ 1 | (2,"(3,""(4,""""(5,""""""""(6,)"""""""")"""")"")")
(1 row)

The uglyness is on that series of '"'

why not the following result ?

kalman=# select * from  test;
~ a |                         b
- ---+----------------------------------------------------
~ 1 | (2,(3,(4,(5,(6,)))))
(1 row)



Regards
Gaetano Mendola













-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (MingW32)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFBBMRp7UpzwH2SGd4RAuV+AJsFBLv0pD8U9UaXQKwxnFvqSqWacACgzipD
0ZdJ2csaQ5kBEI3ADnMX4zk=
=iKgR
-----END PGP SIGNATURE-----



Re: 7.5 backend crash

From
Greg Stark
Date:
Gaetano Mendola <mendola@bigfoot.com> writes:

> kalman=#  insert into test values (1 ,(2,(3,(4,(5,(6, null))))));
> INSERT 33639 1
> kalman=# select * from  test;
> ~ a |                         b
> ---+----------------------------------------------------
> ~ 1 | (2,"(3,""(4,""""(5,""""""""(6,)"""""""")"""")"")")
> (1 row)

Omg.....

This is pretty cool and frankly amazing that it works.

But I don't really think it's tenable is it? What happens when you try to
pg_dump this? I expect other tools will have trouble dealing with this as
well.

-- 
greg



Re: 7.5 backend crash

From
Tom Lane
Date:
Greg Stark <gsstark@mit.edu> writes:
> Gaetano Mendola <mendola@bigfoot.com> writes:
>> kalman=#  insert into test values (1 ,(2,(3,(4,(5,(6, null))))));
>> INSERT 33639 1
>> kalman=# select * from  test;
>> ~ a |                         b
>> ---+----------------------------------------------------
>> ~ 1 | (2,"(3,""(4,""""(5,""""""""(6,)"""""""")"""")"")")
>> (1 row)

> Omg.....

> This is pretty cool and frankly amazing that it works.

It shouldn't work --- the ALTER TABLE code should reject it.  Looks like
there are a few holes to be plugged here ...
        regards, tom lane


Re: 7.5 backend crash

From
Gaetano Mendola
Date:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Tom Lane wrote:
| Greg Stark <gsstark@mit.edu> writes:
|
|>Gaetano Mendola <mendola@bigfoot.com> writes:
|>
|>>kalman=#  insert into test values (1 ,(2,(3,(4,(5,(6, null))))));
|>>INSERT 33639 1
|>>kalman=# select * from  test;
|>>~ a |                         b
|>>---+----------------------------------------------------
|>>~ 1 | (2,"(3,""(4,""""(5,""""""""(6,)"""""""")"""")"")")
|>>(1 row)
|
|
|>Omg.....
|
|
|>This is pretty cool and frankly amazing that it works.
|
|
| It shouldn't work --- the ALTER TABLE code should reject it.  Looks like
| there are a few holes to be plugged here ...

The SQL standard forbid it ? I was believing that was a pretty cool feature!
:-)


Regards
Gaetano Mendola

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (MingW32)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFBBYB47UpzwH2SGd4RAoyfAJ9B5AIHC8A8nyWLOt+Xw6GXJa3kFACgxkzu
kBxnvugWhzjNvc+UboAwAjE=
=xEBD
-----END PGP SIGNATURE-----



Re: 7.5 backend crash

From
Tom Lane
Date:
Gaetano Mendola <mendola@bigfoot.com> writes:
> Tom Lane wrote:
> | It shouldn't work --- the ALTER TABLE code should reject it.  Looks like
> | there are a few holes to be plugged here ...

> The SQL standard forbid it ? I was believing that was a pretty cool feature!
> :-)

I don't think we can support it sanely ...
        regards, tom lane


Re: 7.5 backend crash

From
Tom Lane
Date:
Gaetano Mendola <mendola@bigfoot.com> writes:
> I'm playing with complex row type:
> ...
> kalman=# alter table test drop column b;
> ALTER TABLE        <--- Here I think the server shall complain about
> ~                             ( 7.4 doesn't complain neither )

Actually, on looking back at the code, the intention was that should
work.  The DROP doesn't have to alter physical storage of the table,
so there's no need for rowtype columns in other tables to change either.

> the following select on table test1 will crash the back end

> kalman=# select * from test1;
> server closed the connection unexpectedly

Fixed --- it was just an oversight in record_out().
        regards, tom lane