merge psql ef/ev sf/sv handling functions

Started by Fabien COELHOabout 9 years ago9 messageshackers
Jump to latest
#1Fabien COELHO
coelho@cri.ensmp.fr

Hello,

While reviewing Corey's \if patch, I complained that there was some amount
of copy-paste in "psql/command.c".

Here is an attempt at merging some functions which removes 160 lines of
code.

--
Fabien.

Attachments:

psql-merge-fv-1.patchtext/x-diff; name=psql-merge-fv-1.patchDownload+68-228
#2Victor Drobny
v.drobny@postgrespro.ru
In reply to: Fabien COELHO (#1)
Re: merge psql ef/ev sf/sv handling functions

On 2017-03-31 21:04, Fabien COELHO wrote:

Hello,

While reviewing Corey's \if patch, I complained that there was some
amount of copy-paste in "psql/command.c".

Here is an attempt at merging some functions which removes 160 lines of
code.

Hello,

I was looking through your patch. It seems good, the of the functions
was very similar.
I have a question for you. What was the reason to replace
"printfPQExpBuffer" by "resetPQExpBuffer" and "appendPQExpBufferStr"?

Thank you for attention!

--
------
Victor Drobny
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#3Fabien COELHO
coelho@cri.ensmp.fr
In reply to: Victor Drobny (#2)
Re: merge psql ef/ev sf/sv handling functions

Hello Victor,

While reviewing Corey's \if patch, I complained that there was some
amount of copy-paste in "psql/command.c".

Here is an attempt at merging some functions which removes 160 lines of
code.

I was looking through your patch. It seems good, the of the functions was
very similar.

Indeed. I guess that it was initially a copy paste.

I have a question for you. What was the reason to replace "printfPQExpBuffer"
by "resetPQExpBuffer" and "appendPQExpBufferStr"?

Because the "printf" version implies interpreting the format layer which
does not add significant value compared to just appending the string.

--
Fabien.

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#4Masahiko Sawada
sawada.mshk@gmail.com
In reply to: Fabien COELHO (#1)
Re: merge psql ef/ev sf/sv handling functions

On Sat, Apr 1, 2017 at 3:04 AM, Fabien COELHO <coelho@cri.ensmp.fr> wrote:

Hello,

While reviewing Corey's \if patch, I complained that there was some amount
of copy-paste in "psql/command.c".

Here is an attempt at merging some functions which removes 160 lines of
code.

Thank you for the patch. Is this an item for PG11?

Regards,

--
Masahiko Sawada
NIPPON TELEGRAPH AND TELEPHONE CORPORATION
NTT Open Source Software Center

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#5Fabien COELHO
fabien.coelho@mines-paristech.fr
In reply to: Masahiko Sawada (#4)
Re: merge psql ef/ev sf/sv handling functions

While reviewing Corey's \if patch, I complained that there was some amount
of copy-paste in "psql/command.c".

Here is an attempt at merging some functions which removes 160 lines of
code.

Thank you for the patch. Is this an item for PG11?

Yep.

--
Fabien.

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#6Fabien COELHO
coelho@cri.ensmp.fr
In reply to: Masahiko Sawada (#4)
Re: merge psql ef/ev sf/sv handling functions

While reviewing Corey's \if patch, I complained that there was some amount
of copy-paste in "psql/command.c".

Here is an attempt at merging some functions which removes 160 lines of
code.

Thank you for the patch. Is this an item for PG11?

Yes, as it is submitted to CF 2017-09.

--
Fabien.

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#7Masahiko Sawada
sawada.mshk@gmail.com
In reply to: Fabien COELHO (#6)
Re: merge psql ef/ev sf/sv handling functions

On Wed, Jul 19, 2017 at 2:41 PM, Fabien COELHO <coelho@cri.ensmp.fr> wrote:

While reviewing Corey's \if patch, I complained that there was some
amount
of copy-paste in "psql/command.c".

Here is an attempt at merging some functions which removes 160 lines of
code.

Thank you for the patch. Is this an item for PG11?

Yes, as it is submitted to CF 2017-09.

Thank!
It is already registered to next CF. I missed it, sorry.

Regards,

--
Masahiko Sawada
NIPPON TELEGRAPH AND TELEPHONE CORPORATION
NTT Open Source Software Center

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#8Tom Lane
tgl@sss.pgh.pa.us
In reply to: Fabien COELHO (#1)
Re: merge psql ef/ev sf/sv handling functions

Fabien COELHO <coelho@cri.ensmp.fr> writes:

Here is an attempt at merging some functions which removes 160 lines of
code.

Pushed with minor adjustments. I thought a couple of variable names
could be better chosen, but mostly, you can't do this sort of thing:

-            psql_error("The server (version %s) does not support editing function source.\n",
+            psql_error("The server (version %s) does not support editing %s.\n",
                        formatPGVersionNumber(pset.sversion, false,
-                                             sverbuf, sizeof(sverbuf)));
+                                             sverbuf, sizeof(sverbuf)),
+                       is_func ? "function source" : "view definitions");

It's too much of a pain in the rear for translators. See
https://www.postgresql.org/docs/devel/static/nls-programmer.html#nls-guidelines
Usually we just use two independent messages, and that's what I did.

regards, tom lane

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#9Fabien COELHO
coelho@cri.ensmp.fr
In reply to: Tom Lane (#8)
Re: merge psql ef/ev sf/sv handling functions

you can't do this sort of thing:

-            psql_error("The server (version %s) does not support editing function source.\n",
+            psql_error("The server (version %s) does not support editing %s.\n",
formatPGVersionNumber(pset.sversion, false,
-                                             sverbuf, sizeof(sverbuf)));
+                                             sverbuf, sizeof(sverbuf)),
+                       is_func ? "function source" : "view definitions");

It's too much of a pain in the rear for translators.

Argh, indeed, I totally forgot about translations. Usually there is a _()
hint for gettext.

See
https://www.postgresql.org/docs/devel/static/nls-programmer.html#nls-guidelines
Usually we just use two independent messages, and that's what I did.

Yep, makes sense. Thanks for the fix.

--
Fabien.

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers