diskquota icon indicating copy to clipboard operation
diskquota copied to clipboard

dump and restore the user configurations

Open ironfogre opened this issue 1 year ago • 0 comments

hi, when i test the dump/restore of diskquota with pg_dump/pg_restore, i found that what we saved in diskquota.quota_config and diskquota.target (called user configurations for short) is oids but not object names.

yes, i know that storing oids in these tables helps improve processing efficiency, but when i delete database objects and then restore them with dumped file, the database objects are created again and the oids are changed, which making the user configurations became invalid.

test1=# create schema s1;
CREATE SCHEMA
test1=# select diskquota.set_schema_quota('s1', '1 MB');
 set_schema_quota
------------------

(1 row)

test1=# select * from diskquota.config;
 targetoid | quotatype | quotalimitmb | segratio
-----------+-----------+--------------+----------
     16739 |         0 |            1 |        0
(1 row)

test1=# select oid from pg_namespace where nspname like 's1';
  oid
-------
 16793
(1 row)

...

pg_dump -Fc test1 > /tmp/test1.dump
...
dropdb test1
pg_restore -C -d postgres /tmp/test1.dump

...
test1=# select * from diskquota.config;
 targetoid | quotatype | quotalimitmb | segratio
-----------+-----------+--------------+----------
     16739 |         0 |            1 |        0     <----this quota setting is useless
(1 row)

test1=# select oid from pg_namespace where nspname like 's1';
  oid
-------
 16831   <--- new oid
(1 row)

so, is it a problem? how to solve it? or should i write a little piece of customized dump code to convert the data to quota-setting SQLs ?

ironfogre avatar Nov 17 '23 07:11 ironfogre