Skip to content

Commit cda3e58

Browse files
author
Neil Conway
committed
Add regression tests for the fix committed by Tom for casting between
the row types of parent/child tables.
1 parent c604ed5 commit cda3e58

File tree

2 files changed

+48
-2
lines changed

2 files changed

+48
-2
lines changed

src/test/regress/expected/inherit.out

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -623,3 +623,31 @@ select * from d;
623623
32 | one | two | three
624624
(1 row)
625625

626+
-- Tests for casting between the rowtypes of parent and child
627+
-- tables. See the pgsql-hackers thread beginning Dec. 4/04
628+
create table base (i integer);
629+
create table derived () inherits (base);
630+
insert into derived (i) values (0);
631+
select derived::base from derived;
632+
derived
633+
---------
634+
(0)
635+
(1 row)
636+
637+
drop table derived;
638+
drop table base;
639+
create table p1(ff1 int);
640+
create table p2(f1 text);
641+
create function p2text(p2) returns text as 'select $1.f1' language sql;
642+
create table c1(f3 int) inherits(p1,p2);
643+
insert into c1 values(123456789, 'hi', 42);
644+
select p2text(c1.*) from c1;
645+
p2text
646+
--------
647+
hi
648+
(1 row)
649+
650+
drop function p2text(p2);
651+
drop table c1;
652+
drop table p2;
653+
drop table p1;

src/test/regress/sql/inherit.sql

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,25 @@ SELECT * FROM inhf; /* Single entry with value 'text' */
146146

147147
-- Test changing the type of inherited columns
148148
insert into d values('test','one','two','three');
149-
150149
alter table a alter column aa type integer using bit_length(aa);
151-
152150
select * from d;
151+
152+
-- Tests for casting between the rowtypes of parent and child
153+
-- tables. See the pgsql-hackers thread beginning Dec. 4/04
154+
create table base (i integer);
155+
create table derived () inherits (base);
156+
insert into derived (i) values (0);
157+
select derived::base from derived;
158+
drop table derived;
159+
drop table base;
160+
161+
create table p1(ff1 int);
162+
create table p2(f1 text);
163+
create function p2text(p2) returns text as 'select $1.f1' language sql;
164+
create table c1(f3 int) inherits(p1,p2);
165+
insert into c1 values(123456789, 'hi', 42);
166+
select p2text(c1.*) from c1;
167+
drop function p2text(p2);
168+
drop table c1;
169+
drop table p2;
170+
drop table p1;

0 commit comments

Comments
 (0)