File tree Expand file tree Collapse file tree 2 files changed +48
-2
lines changed Expand file tree Collapse file tree 2 files changed +48
-2
lines changed Original file line number Diff line number Diff line change @@ -623,3 +623,31 @@ select * from d;
623
623
32 | one | two | three
624
624
(1 row)
625
625
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;
Original file line number Diff line number Diff line change @@ -146,7 +146,25 @@ SELECT * FROM inhf; /* Single entry with value 'text' */
146
146
147
147
-- Test changing the type of inherited columns
148
148
insert into d values (' test' ,' one' ,' two' ,' three' );
149
-
150
149
alter table a alter column aa type integer using bit_length(aa);
151
-
152
150
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;
You can’t perform that action at this time.
0 commit comments