Обсуждение: pgsql: Use TypeName to represent type names in certain commands

Поиск
Список
Период
Сортировка

pgsql: Use TypeName to represent type names in certain commands

От
Alvaro Herrera
Дата:
Use TypeName to represent type names in certain commands

In COMMENT, DROP, SECURITY LABEL, and the new pg_get_object_address
function, we were representing types as a list of names, same as other
objects; but types are special objects that require their own
representation to be totally accurate.  In the original COMMENT code we
had a note about fixing it which was lost in the course of c10575ff005.
Change all those places to use TypeName instead, as suggested by that
comment.

Right now the original coding doesn't cause any bugs, so no backpatch.
It is more problematic for proposed future code that operate with object
addresses from the SQL interface; type details such as array-ness are
lost when working with the degraded representation.

Thanks to Petr Jelínek and Dimitri Fontaine for offlist help on finding
a solution to a shift/reduce grammar conflict.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/3f88672a4e4d8e648d24ccc65937da61c7660854

Modified Files
--------------
src/backend/catalog/objectaddress.c     |   43 +++----------
src/backend/commands/dropcmds.c         |   10 +++-
src/backend/parser/gram.y               |  100 ++++++++++++++++++++++++++++---
src/test/regress/sql/object_address.sql |    2 +-
4 files changed, 107 insertions(+), 48 deletions(-)


Re: pgsql: Use TypeName to represent type names in certain commands

От
Heikki Linnakangas
Дата:
On 12/30/2014 06:58 PM, Alvaro Herrera wrote:
> -                        errmsg("name list length must be %d", 1)));
> +                        errmsg("name list length must be exactly %d", 1)));

Seems silly to pass constant 1 as an argument. (Yeah, it was silly
before this commit too.)

There is one instance of the old message left in pg_get_object_address.
Should change that too for consistency, and to reduce translation work.

- Heikki



Re: pgsql: Use TypeName to represent type names in certain commands

От
Alvaro Herrera
Дата:
Heikki Linnakangas wrote:
> On 12/30/2014 06:58 PM, Alvaro Herrera wrote:
> >-                        errmsg("name list length must be %d", 1)));
> >+                        errmsg("name list length must be exactly %d", 1)));
>
> Seems silly to pass constant 1 as an argument. (Yeah, it was silly before
> this commit too.)

It seems silly, but if we had another message with a different constant,
this would make them both be a single translatable string.  I have
changed other messages in the same way, for example see the (seemingly
unrelated) change to src/backend/libpq/hba.c in 73c986adde5d73a5e2555da.

> There is one instance of the old message left in pg_get_object_address.
> Should change that too for consistency, and to reduce translation work.

Hm, I couldn't find it ... care to provide a line number?

--
Álvaro Herrera                http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services


Re: pgsql: Use TypeName to represent type names in certain commands

От
Heikki Linnakangas
Дата:
On 12/30/2014 07:21 PM, Alvaro Herrera wrote:
> Heikki Linnakangas wrote:
>> There is one instance of the old message left in pg_get_object_address.
>> Should change that too for consistency, and to reduce translation work.
>
> Hm, I couldn't find it ... care to provide a line number?

Never mind, I must've been looking at an old version, it looks OK now.

- Heikki