>
>
> Again, apologies if this is a duplication from the past but I can't it in
> pgsql-questions :
>
> -------------------------------
>
> In the reference section, it states there are problems with dumping views
> and rules.
> A pg_dumpall/pg_dump stores the view as a table with a rule.
> Therefore, when loaded back in, the view is now a table and not loaded into
> pg_view.
>
> To change this, do I create a simple script to remove the 'CREATE TABLE' and
> transform the 'CREATE RULE' into a create view statement.

    I  don't see the point here. pg_views itself is a view, which
    uses  a  special  support  function  to  display  the   views
    definition  from  the  ON  SELECT rule that is defined on the
    table. There is no difference!  A view is  a  class  with  an
    INSTEAD rule on event SELECT in Postgres.  You might not have
    noticed, that after creating the rule, the table  appears  in
    pg_views.

    In  fact,  the  CREATE  TABLE, CREATE RULE is nearly what the
    backend internally does when you issue CREATE VIEW. Only that
    you don't see it. Again, in Postgres views are implemented as
    tables with a rewrite rule.

    The reason this is splitted in the dump  is,  that  rules  on
    other event's than SELECT would affect the reloaded result if
    you dump the data as INSERT statements instead of COPY  data.
    pg_dump just don't make any difference between rule events.

    The  problems  with  dumping views and rules is, that pg_dump
    uses the mentioned special support function to parse back the
    internal  (querytree)  representation of the rule action into
    something the parser accepts to generate the  same  querytree
    again.  This backparsing isn't tested very much. So you might
    be able to define views/rules,  that  pg_dump  will  fail  to
    output  the  correct statement that could reinstall the rule.
    Up to now, the rules create  command  isn't  stored  (I  plan
    change  this  in  the  future).  So the try to parse back the
    querytree is up to now the only chance pg_dump has.  As  long
    as  the views pg_views and pg_rules work and don't produce an
    error, pg_dump will output a reloadable dump and  you  aren't
    hit so far by that problem.


Jan

--

#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me.                                  #
#======================================== [EMAIL PROTECTED] (Jan Wieck) #


Reply via email to