Menu

#396 SQL functions containing utility statements do not work

Development Queue
open
nobody
5
2013-06-12
2013-02-23
Abbas Butt
No

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

Discussion

  • Koichi Suzuki

    Koichi Suzuki - 2013-03-12
    • milestone: 2663467 --> 5139567
     
  • Koichi Suzuki

    Koichi Suzuki - 2013-03-12

    We need deparser which could be in 9.3 infrastructure. We should wait for this feature in PG.

     
  • Koichi Suzuki

    Koichi Suzuki - 2013-06-12
    • milestone: 5139567 --> Development Queue
     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.