Add pg_get_publication_ddl function

Поиск
Список
Период
Сортировка
От Jonathan Gonzalez V.
Тема Add pg_get_publication_ddl function
Дата
Msg-id 70d20c14d1c14f93e4200c1a9327b97d7c18a782.camel@gmail.com
обсуждение исходный текст
Ответы Re:Add pg_get_publication_ddl function
Список pgsql-hackers
Hi all!

Following the set of pg_get_{object}_ddl functions described by Andrew
Dustan[1] I'm attaching another patch that I created for the
PUBLICATION object, I had to left some stuff out and added others based
on other patches feedback for the same type of functions:

* Pretty print: There's a few patched that implemented the pretty print
  using spaces or tabs, by default or not, etc. I just decided to keep
  this out of this patch, the idea is to follow any decision that can
  be made for all the patches at some point, and mostly probably have
a  common set of functions to use in all these functions since there
  will be a lot of them, and rewriting every time the same and
  reviewing the same possible code may take some time and I think it's
  better to have the base set of functions and later work on stuff like
  pretty print.

* Testing: I've added a regress test with the name
  `publiction_ddl.sql`, those, it's close to the publication object in
  names on the list of files and not inside a big generic file with
  many SQL for different objects. Those, we can keep a list of file in
  a fixed section inside the file `parallel_schedule`.

The patch add the function, tests and documentation, but on the
documentation side I don't know if it should go anywhere else or if the
current location it's ok, I haven't found any decision on the that
specific subject.

Related to the required privileges, to CREATE or ALTER a PUBLICATION
you require a specific set of privileges, but there's no defined
privilege to "view" a publication, being really strict, this function
could leak information like columns and tables that exist inside the
database without even have permissions to see those tables, the same
will be for sequences in the future. This took me to the question, does
a kind of "view" privilege exists for these objects? Because you can
have access to the database or even some tables but not all of them at
the same time, and this could lead to a leak of data. I'm really new on
PostgreSQL development, but I couldn't find the "view" privilege that
will allow to read a PUBLICATION and check it, but in my opinion not
being allowed to create a publication doesn't mean that you cannot see
the content of it, am I missing a privilege here or if you can't create
you shouldn't be able to "view" a publication?

Related to the default values, there's a couple of things that I think
it should be there just because, either are always defined or to make
clear the value is there since it will affect the object:

* publish: this field contains a list of permissions [2] that are a
  list of variables inside a struct with values always being set

* publish_generated_columns: the default is well defined and not adding
  the default to the statement will make sense, but since the others
  two will be there, for useful and educational purposes, this makes
  sense to me.

* publish_via_partition_root: this boolean is always set, so adding it
  make sense since it will make explicit to someone debugging a
  publication how this will behave on a TRUNCATE situation.

Thank you in advance for the reviews and all the time on this!

[1]
https://www.postgresql.org/message-id/flat/945db7c5-be75-45bf-b55b-cb1e56f2e3e9%40dunslane.net
[2]
https://www.postgresql.org/docs/18/sql-createpublication.html#SQL-CREATEPUBLICATION-PARAMS-WITH

--
Jonathan Gonzalez V. <jonathan.abdiel@gmail.com>
EnterpriseDB

Вложения

В списке pgsql-hackers по дате отправления: