2026年7月17日(金) 23:29 Tom Lane <[email protected]>:
>
> Daniel Gustafsson <[email protected]> writes:
> >> On 17 Jul 2026, at 08:44, Ian Lawrence Barwick <[email protected]> wrote:
> >> It was noted here [1] that we have the undocumented SQL function
> >> "getdatabaseencoding()", used mainly in regression tests and a couple
> >> of psql queries. While considering a documentation patch, it occurred
> >> to me that it's a horrible function name which doesn't look like other
> >> public functions, and we already have "pg_client_encoding()", so why not
> >> rename it to match that while we're at it?
>
> > This function seems to be referred to in extensions, how about adding 
> > keeping
> > the existin name and adding the new name as an alias?  It would keep 
> > existing
> > code from breaking and cause less churn in the code.
>
> Yeah, the odds that we would remove the old name (without a multi-year
> deprecation period) are zero, full stop.
>
> However, I can't really get excited about this proposal in the first
> place.  There are plenty of ugly and inconsistent names in Postgres,
> and an enormous amount of more-valuable work to do.

Makes sense.

Here's a patch to at least document it, in the table "Other String
Functions and Operators"
(as "pg_client_encoding()" is already there).


Regards

Ian Barwick
From 97877786763dcdcdfed7d08367b587b94ad7733e Mon Sep 17 00:00:00 2001
From: Ian Barwick <[email protected]>
Date: Sat, 18 Jul 2026 13:49:45 +0900
Subject: [PATCH v1] Document getdatabaseencoding()

This function was added in PostgreSQL 6.5 and is used for regression
tests and some psql queries, but was never documented.
---
 doc/src/sgml/func/func-string.sgml | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/doc/src/sgml/func/func-string.sgml b/doc/src/sgml/func/func-string.sgml
index 0786573d7be..fb7408ee014 100644
--- a/doc/src/sgml/func/func-string.sgml
+++ b/doc/src/sgml/func/func-string.sgml
@@ -753,6 +753,23 @@
        </para></entry>
       </row>
 
+      <row>
+       <entry role="func_table_entry"><para role="func_signature">
+        <indexterm>
+         <primary>getdatabaseencoding</primary>
+        </indexterm>
+        <function>getdatabaseencoding</function> ( )
+        <returnvalue>name</returnvalue>
+       </para>
+       <para>
+        Returns current database encoding name.
+       </para>
+       <para>
+        <literal>getdatabaseencoding()</literal>
+        <returnvalue>UTF8</returnvalue>
+       </para></entry>
+      </row>
+
       <row>
        <entry role="func_table_entry"><para role="func_signature">
         <indexterm>
-- 
2.52.0

Reply via email to