Forum OpenACS Q&A: pg_dump problem

Collapse
Posted by Hal Heisler on
I'm having trouble with pg_dump I get this every time. I'm
using postgresql-server-7.0.3-8 rpm from redhat 7.1.  Do I need
to upgrade?

dumpRules(): SELECT failed for table ec_items_money_view.  
Explanation from backend: 'pqReadData() -- backend closed the 
channel unexpectedly.
        This probably means the backend terminated abnormally
        before or while processing the request.
'.

Collapse
Posted by David Walker on
postgres seems to have mistaken a view for a table.  It did that to
me and I just figured out today what had happened.

dropping and recreating the view should fix the problem.  the
definition is in ecommerce.sql

Collapse
Posted by Hal Heisler on
Thanks, droping view ec_items_money_view resolved the problem.  Re-creating the view causes pg_dump to fail again.  Good thing I don't need it right now.
Collapse
4: Views Dumped as Tables (response to 1)
Posted by Carl Coryell-Martin on
We have been bitten by that a couple of times. I wrote a little script that will check for views that were restored as tables. Here it is (the general_permissions_grid view does this alot):

set input_dir "[ns_info pageroot]/doc/sql"
ReturnHeaders
ns_write "examining $input_dir

" set db [ns_db gethandle] # iterate through all the .sql files in the directory looking for views foreach filename [glob -nocomplain $input_dir/*.sql] { set input_file [open $filename r] set contents [read $input_file] close $input_file set html "" # Match all the views while { [regexp { (create view +([A-Za-z_]+)[^;]+;)(.*)} $contents match view name rest] } { # check the state of relhasrules in the pg_class table # for the view. it should be t if it is a view. if its false, # it is certainly a table set sql " select relhasrules from pg_class where relname = '$name'" set okay [database_to_tcl_string_or_null $db $sql] if {$okay == "f"} { append html "<li>$name <br> <pre>$view</pre>" } set contents $rest } if [exists_and_not_null html] { ns_write " $filename <ul> $html </ul> " } } ns_db releasehandle $db ns_write "DONE"