Menu

#319 CREATE functions with views: fails at creation

1.3 Dev Q
open
nobody
None
5
2013-12-02
2012-06-20
No

Reported by Dimitrije Radojevic

1) create a table
CREATE TABLE test_table (
id SERIAL NOT NULL,
other_id int4 NOT NULL,
PRIMARY KEY("id") )
DISTRIBUTE BY REPLICATION;

2) create a view
CREATE VIEW some_view AS SELECT test_table.* FROM test_table;

3) create a function using the view
CREATE OR REPLACE FUNCTION some_function() RETURNS SETOF some_view AS
$body$
BEGIN
RETURN QUERY SELECT * FROM some_view;
END;
$body$
LANGUAGE 'plpgsql'
VOLATILE
CALLED ON NULL INPUT
SECURITY INVOKER
COST 100;

I get the following error:
ERROR: type "some_view" does not exist

This runs fine in postgres 9.1.4.

Discussion

  • Michael Paquier

    Michael Paquier - 2012-06-20

    Here is my answer on this thread:
    A view is only created on Coordinators. It is basically a projection of the data that is located on remote Datanodes, so selecting data from a view means that you need to fallback to a given table (or tables for a join), and to analyse the distribution type of those tables before fetching the data from Datanodes. So it doesn't really make sense to define view on Datanodes.
    When creating a function, we create it on all the nodes, resulting in the error you see as the process fails at the function creation.

    This indeed looks like a bug, and based on the definition XC has about views, it would make sense to create such functions only on Coordinators.
    As you are giving a test case so it will be easier to fix this particular function creation.

     
  • Koichi Suzuki

    Koichi Suzuki - 2013-03-12
    • assigned_to: michaelpq --> nobody
    • milestone: 2663488 --> 1,2 Dev Q
     
  • Koichi Suzuki

    Koichi Suzuki - 2013-12-02
    • Group: 1.2 Dev Q --> 1.3 Dev Q
     

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.