Redo pgaccess' queries about views so that they will work in both 7.1
and prior releases --- rely on pg_views view instead of direct access to pg_class and pg_rewrite.
This commit is contained in:
parent
62a029b5c6
commit
6aa0821bcd
@ -4,24 +4,21 @@ proc {getTablesList} {} {
|
|||||||
global CurrentDB PgAcVar
|
global CurrentDB PgAcVar
|
||||||
set tlist {}
|
set tlist {}
|
||||||
if {[catch {
|
if {[catch {
|
||||||
wpg_select $CurrentDB "select c.relname,count(c.relname) from pg_class C, pg_rewrite R where (r.ev_class = C.oid) and (r.ev_type = '1') group by relname" rec {
|
# As of Postgres 7.1, testing for view-ness is not needed
|
||||||
if {$rec(count)!=0} {
|
# because relkind = 'r' eliminates views. But we should
|
||||||
set itsaview($rec(relname)) 1
|
# leave the code in for awhile yet, so as not to fail when
|
||||||
}
|
# running against older releases.
|
||||||
|
wpg_select $CurrentDB "select viewname from pg_views" rec {
|
||||||
|
set itsaview($rec(viewname)) 1
|
||||||
}
|
}
|
||||||
if {! $PgAcVar(pref,systemtables)} {
|
if {! $PgAcVar(pref,systemtables)} {
|
||||||
wpg_select $CurrentDB "select relname from pg_class where (relname !~ '^pg_') and (relkind='r') order by relname" rec {
|
set sysconstraint "and (relname !~ '^pg_') and (relname !~ '^pga_')"
|
||||||
if {![regexp "^pga_" $rec(relname)]} then {
|
|
||||||
if {![info exists itsaview($rec(relname))]} {
|
|
||||||
lappend tlist $rec(relname)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
wpg_select $CurrentDB "select relname from pg_class where (relkind='r') order by relname" rec {
|
set sysconstraint ""
|
||||||
if {![info exists itsaview($rec(relname))]} {
|
}
|
||||||
lappend tlist $rec(relname)
|
wpg_select $CurrentDB "select relname from pg_class where (relkind='r') $sysconstraint order by relname" rec {
|
||||||
}
|
if {![info exists itsaview($rec(relname))]} {
|
||||||
|
lappend tlist $rec(relname)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} gterrmsg]} {
|
} gterrmsg]} {
|
||||||
|
@ -295,19 +295,17 @@ catch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
proc {cmd_Views} {} {
|
proc {cmd_Views} {} {
|
||||||
global CurrentDB
|
global CurrentDB PgAcVar
|
||||||
setCursor CLOCK
|
setCursor CLOCK
|
||||||
.pgaw:Main.lb delete 0 end
|
.pgaw:Main.lb delete 0 end
|
||||||
catch {
|
catch {
|
||||||
wpg_select $CurrentDB "select c.relname,count(c.relname) from pg_class C, pg_rewrite R where (relname !~ '^pg_') and (r.ev_class = C.oid) and (r.ev_type = '1') group by relname" rec {
|
if {! $PgAcVar(pref,systemtables)} {
|
||||||
if {$rec(count)!=0} {
|
set sysconstraint "where (viewname !~ '^pg_') and (viewname !~ '^pga_')"
|
||||||
set itsaview($rec(relname)) 1
|
} else {
|
||||||
}
|
set sysconstraint ""
|
||||||
}
|
}
|
||||||
wpg_select $CurrentDB "select relname from pg_class where (relname !~ '^pg_') and (relkind='r') and (relhasrules) order by relname" rec {
|
wpg_select $CurrentDB "select viewname from pg_views $sysconstraint order by viewname" rec {
|
||||||
if {[info exists itsaview($rec(relname))]} {
|
.pgaw:Main.lb insert end $rec(viewname)
|
||||||
.pgaw:Main.lb insert end $rec(relname)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
setCursor DEFAULT
|
setCursor DEFAULT
|
||||||
|
Loading…
x
Reference in New Issue
Block a user