Consider the output of the test case when run in vanilla PG
test=# create table my_tab1 (a int);
CREATE TABLE
test=# insert into my_tab1 values(1);
INSERT 0 1
test=# SET check_function_bodies = false;
SET
test=# create function f1 () returns setof my_tab1 as $$ create table my_tab2 (a int); select * from my_tab1; $$ language sql;
CREATE FUNCTION
test=# select f1();
f1
-----
(1)
(1 row)
test=# SET check_function_bodies = true;
SET
test=# drop function f1();
DROP FUNCTION
test=# drop table my_tab1;
DROP TABLE
test=# drop table my_tab2;
DROP TABLE
The same test case when run in XC produces errors
test=# create table my_tab1 (a int);
CREATE TABLE
test=# insert into my_tab1 values(1);
INSERT 0 1
test=# SET check_function_bodies = false;
SET
test=# create function f1 () returns setof my_tab1 as $$ create table my_tab2 (a int); select * from my_tab1; $$ language sql;
CREATE FUNCTION
test=# select f1();
ERROR: Unexpected response from the Datanodes for 'T' message, current request type 1
CONTEXT: SQL function "f1" statement 1
test=# SET check_function_bodies = true;
SET
test=# drop function f1();
DROP FUNCTION
test=# drop table my_tab1;
DROP TABLE
test=# drop table my_tab2;
ERROR: table "my_tab2" does not exist
We need deparser which could be in 9.3 infrastructure. We should wait for this feature in PG.