Rodrigo Rosenfeld Rosas wrote: > I'm curious though. Why wouldn't this behavior be considered a > bug? Is there any link to previous discussions about this subject > that I could read?
A plpgsql function generates a plan on initial execution which chooses which particular tables are used. On subsequent executions that saves the overhead of parsing out the statement and looking up the table and its details, which can help performance quite a bit. If you want to have source code evaluated each time the function is called, you should use the EXECUTE statement within your function body, which will force parsing and path resolution of the statement for each execution. That should give you the behavior you want, with some cost in performance. To try to get your function code to work as you expect, the language would essentially need to identify which statements could be pre-planned, and which would needed to be treated as raw source on each execution. That would be tricky to implement, and would itself have some run-time cost. At this point we've put the burden on the programmer to identify this at the time the code is written, rather than adding run-time expense. -Kevin -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs