From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | pgsql-committers(at)postgresql(dot)org |
Subject: | pgsql: Prefer pg_any_to_server/pg_server_to_any over pg_do_encoding_con |
Date: | 2014-02-23 21:59:16 |
Message-ID: | E1WHh4u-0002Nf-K8@gemulon.postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-committers |
Prefer pg_any_to_server/pg_server_to_any over pg_do_encoding_conversion.
A large majority of the callers of pg_do_encoding_conversion were
specifying the database encoding as either source or target of the
conversion, meaning that we can use the less general functions
pg_any_to_server/pg_server_to_any instead.
The main advantage of using the latter functions is that they can make use
of a cached conversion-function lookup in the common case that the other
encoding is the current client_encoding. It's notationally cleaner too in
most cases, not least because of the historical artifact that the latter
functions use "char *" rather than "unsigned char *" in their APIs.
Note that pg_any_to_server will apply an encoding verification step in
some cases where pg_do_encoding_conversion would have just done nothing.
This seems to me to be a good idea at most of these call sites, though
it partially negates the performance benefit.
Per discussion of bug #9210.
Branch
------
master
Details
-------
http://git.postgresql.org/pg/commitdiff/769065c1b2471f484bb48bb58a8bdcf1d12a419c
Modified Files
--------------
contrib/pg_stat_statements/pg_stat_statements.c | 8 +++----
contrib/sslinfo/sslinfo.c | 10 ++-------
src/backend/commands/extension.c | 8 ++-----
src/backend/snowball/dict_snowball.c | 10 ++-------
src/backend/tsearch/ts_locale.c | 5 +----
src/backend/utils/adt/pg_locale.c | 23 ++++++++-----------
src/backend/utils/adt/xml.c | 27 ++++++++---------------
src/backend/utils/mb/mbutils.c | 4 +++-
src/pl/plperl/plperl.c | 8 ++-----
src/pl/plperl/plperl_helpers.h | 25 ++++++---------------
src/pl/plpython/plpy_util.c | 15 +++++--------
src/pl/tcl/pltcl.c | 8 +++++--
12 files changed, 51 insertions(+), 100 deletions(-)
From | Date | Subject | |
---|---|---|---|
Next Message | Peter Eisentraut | 2014-02-24 02:41:25 | pgsql: doc: Improve DocBook XML validity |
Previous Message | Tom Lane | 2014-02-23 20:22:57 | pgsql: Plug some more holes in encoding conversion. |