Re: function depend on view - Mailing list pgsql-general

From Andreas Kretschmer
Subject Re: function depend on view
Date
Msg-id 20120820145929.GA13148@tux
Whole thread Raw
In response to Re: function depend on view  (salah jubeh <s_jubeh@yahoo.com>)
Responses Re: function depend on view  (Merlin Moncure <mmoncure@gmail.com>)
List pgsql-general
salah jubeh <s_jubeh@yahoo.com> wrote:

> Hello Andreas,
>
> Thanks for the reply,  The example I have posted is very simple and you are
> right it is very similar to select max (id) from table_that_does_not_exist; But
> there are more here, for example imagine I have something like
>
> CREATE VIEW a4 as select .... from  a3(), .... ;
>
> In my opinion, this might leads to many problems such as

Again, the functions doesn't depend on the table, other example:

test=# select * from foo;
 id | val
----+-----
  1 | 100
  2 | 200
  3 | 300
(3 rows)

Time: 0,235 ms
test=*# create or replace function fail(int) returns int as $$declare r
int; begin execute 'select val from foo where id = ' || $1 || ';' into
r; return r;end; $$language plpgsql;
CREATE FUNCTION
Time: 0,547 ms
test=*# select * from fail(1);
 fail
------
  100
(1 row)

Time: 0,473 ms
test=*# drop table foo;
DROP TABLE
Time: 0,387 ms
test=*# select * from fail(1);
ERROR:  relation "foo" does not exist
LINE 1: select val from foo where id = 1;
                        ^
QUERY:  select val from foo where id = 1;
CONTEXT:  PL/pgSQL function "fail" line 1 at EXECUTE statement


In this case, the query inside the function is a dynamic query. So what?



Andreas
--
Really, I'm not out to destroy Microsoft. That will just be a completely
unintentional side effect.                              (Linus Torvalds)
"If I was god, I would recompile penguin with --enable-fly."   (unknown)
Kaufbach, Saxony, Germany, Europe.              N 51.05082°, E 13.56889°


pgsql-general by date:

Previous
From: Merlin Moncure
Date:
Subject: Re: function depend on view
Next
From: Merlin Moncure
Date:
Subject: Re: function depend on view