At 12:11 PM 2/21/00 -0600, Ed Loehr wrote:
>Don Baccus wrote:
>>
>> Even pg_dump works, though I had to modify a couple of views in order
>> to get them reload correctly.
>
>Don, could you elaborate on what you had to do to make your views
>reload correctly?
Good timing - I was about to post on this subject anyway.
I was able to fix my views by changing:
create view foo as select * from bar;
to:
...select * from bar bar;
In other words, an explicit declaration of the range table name (is
that the right term?P my mind's numb from porting queries all weekend)
leads to a rule that will reload.
I figured this out because there are some fairly complex views in
this datamodel, which use explicit names to avoid ambiguous column
references.
The standard actually says that a from clause like "from bar"
implicitly declares "bar" for you, i.e. is exactly equivalent
to "from bar bar". If Postgres name scoping - which I know is
not standard-compliant in the JOIN syntax case - is close enough
so that a transformation of "from bar" to "from bar bar" could
be done in the parser without breaking existing code, then a
lot more views could be successfully be dumped and reloaded.
Would all views dump/reload, or are there other problems I don't know
about? I'm not in a position to judge, I've been too deeply embedded
in getting this toolkit ready for release (our first will be Wednesday)
to worry about the general case. However, I do know that doing the
transformation by hand in the datamodel source has fixed the problem
for me.
Does anyone know if there are other problems?
Even if there are, a simple transformation such as I describe would
help - IF it didn't break existing code. If it would break existing
code, then it is due to non-compliance with the standard so perhaps
wouldn't be such a terrible thing, either. I'm not really in a
position to judge.
What do folks think?
- Don Baccus, Portland OR <dhogaza@pacifier.com> Nature photos, on-line guides, Pacific Northwest Rare Bird Alert
Serviceand other goodies at http://donb.photo.net.