[PATCH] Rename "getdatabaseencoding()" to "pg_database_encoding()", and document

From: Ian Lawrence Barwick <barwick(at)gmail(dot)com>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: [PATCH] Rename "getdatabaseencoding()" to "pg_database_encoding()", and document
Date: 2026-07-17 06:44:50
Message-ID: CAB8KJ=iQQ3j1ZzJkgF_CGF5TvJsugp6JFOrS-LB7kT=XivV_Vg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi

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?

The only minor niggle I can see is that psql uses "getdatabaseencoding()"
for tab completion of collation names, and it looks like it would be
tricky/ugly to try and shoehorn in version-dependent queries for backwards
compatibility, but we can just substitute "current_setting('server_encoding')".

[1] https://www.postgresql.org/message-id/flat/allgZ34IHVFZo35b%40paquier.xyz#be92a887e2abe944926cdce750ae73e1

Regards

Ian Barwick

Attachment Content-Type Size
v1-0001-Rename-getdatabaseencoding-to-pg_database_encodin.patch application/octet-stream 44.4 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Ian Lawrence Barwick 2026-07-17 06:49:55 Re: Remove getpgusername()
Previous Message Amit Kapila 2026-07-17 06:44:19 Re: sequencesync worker race with REFRESH SEQUENCES