Re: psql \dFp's behavior - Mailing list pgsql-hackers
From | Guillaume Lelarge |
---|---|
Subject | Re: psql \dFp's behavior |
Date | |
Msg-id | 475EF82D.6070904@lelarge.info Whole thread Raw |
In response to | Re: psql \dFp's behavior (Tom Lane <tgl@sss.pgh.pa.us>) |
Responses |
Re: psql \dFp's behavior
|
List | pgsql-hackers |
Tom Lane a écrit : > Guillaume Lelarge <guillaume@lelarge.info> writes: >> I'm not sure psql handles \dFp the right way. The query allows >> translators to translate some columns' values but forgets to escape the >> strings. So, here is a patch that escapes these translated strings. > > This seems mighty ugly, and it's not the way we handle any other \d > command. Why is it needed for \dFp (and only that)? > Oh I didn't say only \dFp needs this kind of fix. I've found an issue with \dFp+ today, so I'm trying to fix it. Here is the issue I found : guillaume@laptop:/opt/postgresql-head$ LANG=en psql postgres Welcome to psql 8.3beta4, the PostgreSQL interactive terminal. Type: \copyright for distribution terms \h for help with SQL commands \? for help with psql commands \g orterminate with semicolon to execute query \q to quit Text search parser "pg_catalog.default" Method | Function | Description -----------------+----------------+-------------Start parse | prsd_start |Get next token | prsd_nexttoken |End parse | prsd_end |Get headline | prsd_headline |Get token types | prsd_lextype | Token types for parser "pg_catalog.default" [...] OK, it works great. Now, in french : guillaume@laptop:/opt/postgresql-head$ LANG=fr_FR.UTF-8 psql postgres Bienvenue dans psql 8.3beta4, l'interface interactive de PostgreSQL. Saisissez: \copyright pour les termes de distribution \h pour l'aide-mémoire des commandes SQL \? pour l'aide-mémoiredes commandes psql \g ou point-virgule en fin d'instruction pour exécuter la requête \q pour quitter postgres=# set lc_messages to 'C'; SET postgres=# \dFp+ ERROR: syntax error at or near "analyse" LIGNE 1 : SELECT 'Début de l'analyse' AS "Méthode", ^ The problem here is that "Start parse" is translated with "Début de l'analyse" (which is a bad translation but that's not the point). The point is that the query is not protected against quotes and backslashes and this is bad. My code is probably ugly, I trust you on this, but I think we need to fix this. I think we have two ways to do it :- escaping the translated words ;- removing the call to gettext(so no translations for these strings). I found \dFp but we could have the same problems with \dp because it puts directly in the query the translations of some words (table, view, sequence, aggregate, function, operator, datatype, rule, trigger) which is not a problem in French but can be one in another language. \du, \dg, \d seem to have problems too. Regards. -- Guillaume.http://www.postgresqlfr.orghttp://dalibo.com
pgsql-hackers by date: