Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d0850a6

Browse files
committed
fix: do not to change an owner for toasts (joe#124)
1 parent a0ba626 commit d0850a6

File tree

1 file changed

+5
-14
lines changed

1 file changed

+5
-14
lines changed

pkg/services/provision/databases/postgres/postgres_mgmt.go

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,6 @@ func CreateUser(c *resources.AppConfig, user resources.EphemeralUser) error {
8484
query = superuserQuery(user.Name, user.Password)
8585
}
8686

87-
log.Msg(query)
88-
8987
out, err := runSimpleSQL(query, getPgConnStr(c.Host, dbName, c.DB.Username, c.Port))
9088
if err != nil {
9189
return errors.Wrap(err, "failed to run psql")
@@ -116,16 +114,16 @@ begin
116114
new_owner := '%[1]s';
117115
118116
-- c: composite type
119-
-- t: type (TOAST)
120-
-- S: sequence
117+
-- p: partitioned table
121118
-- i: index
122119
-- r: table
123120
-- v: view
124121
-- m: materialized view
122+
-- S: sequence
125123
for object_type in
126124
select
127-
unnest('{type,table,sequence,table,view,materialized view}'::text[]) type_name,
128-
unnest('{c,t,S,r,v,m}'::text[]) code
125+
unnest('{type,table,table,view,materialized view,sequence}'::text[]) type_name,
126+
unnest('{c,p,r,v,m,S}'::text[]) code
129127
loop
130128
for r in
131129
execute format(
@@ -136,14 +134,7 @@ begin
136134
n.oid = c.relnamespace
137135
and not n.nspname in ('pg_catalog', 'information_schema')
138136
and c.relkind = %%L
139-
left join pg_class cc on
140-
c.relkind = 't' /*leave 't' hardcoded!*/
141-
and cc.oid = nullif(regexp_replace(c.relname, '^pg_toast_(.*)', '\1'), c.relname)::int8
142-
left join pg_namespace nn on
143-
nn.oid = cc.relnamespace
144-
where
145-
c.relkind <> 't' /*leave 't' hardcoded!*/
146-
or not nn.nspname in ('pg_catalog', 'information_schema')
137+
order by c.relname
147138
$sql$,
148139
object_type.code
149140
)

0 commit comments

Comments
 (0)