Antal Attila wrote:
Hi!

I found a problem with the views in PostgreSQL if I want to use temporary tables in it. See the next case!
[snip]
The problem is that the view use the original permanent table, but the 1) query use the temporary actual_code table. I read the temporally table definition in the documentation (http://www.postgresql.org/docs/8.1/interactive/sql-createtable.html) and I concluded it should be working.

Is it BUG, or FEATURE? Has anybody got good ideas for solve this problem?

Feature, I'd guess.

When the view was built there was no TEMP TABLE. If you do \d a_view you'll see it actually will link to something like "public.a". If it didn't, your view could change depending on your search_path settings and even break.

You'll see a similar problem with plpgsql functions.

This construction came to my mind, because I tried to solve my another question: http://groups.google.co.hu/group/pgsql.performance/browse_thread/thread/c7aec005f4a1f3eb/83fa0053cad33dea

I think you need to explain why you're trying to do this:
   CREATE VIEW ab_view AS
        SELECT a.id AS id,
                       a.userid AS userid_a, b.userid AS userid_b,
                       a.col AS col_a, b.col AS col_b
        FROM a LEFT JOIN b ON (a.id = b.a_id);

    EXPLAIN ANALYSE SELECT * FROM ab_view
        WHERE userid_a = 23 AND userid_b = 23 AND col_a LIKE 's%'
        ORDER BY col_b
        LIMIT 10 OFFSET 10;

If you want userid_a=userid_b ALWAYS to be the same, just put it in the view. If you sometimes want them different, then you'll have to provide two parameters anyway. It's not clear how you intend to use this.

--
  Richard Huxton
  Archonet Ltd

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
      subscribe-nomail command to [EMAIL PROTECTED] so that your
      message can get through to the mailing list cleanly

Reply via email to