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"