aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTatsuo Ishii <ishii@postgresql.org>2001-10-12 02:08:34 +0000
committerTatsuo Ishii <ishii@postgresql.org>2001-10-12 02:08:34 +0000
commitf426465ba911051fa9fce57c7c4b49350e9dbbd3 (patch)
tree29eabd6b837d08d0eb67ca81fd41b26df7b16b7e
parent9d13fcf0af024b0ce9bc344a758c6b4072e50e95 (diff)
downloadpostgresql-f426465ba911051fa9fce57c7c4b49350e9dbbd3.tar.gz
postgresql-f426465ba911051fa9fce57c7c4b49350e9dbbd3.zip
Add a new function "pg_client_encoding" which returns the current client
side encoding name. This is necessary for client API's such as JDBC to perform correct encoding conversions. See my email "[HACKERS] pg_client_encoding" 10 Sep 2001.
-rw-r--r--doc/src/sgml/func.sgml12
-rw-r--r--src/backend/utils/init/miscinit.c8
-rw-r--r--src/backend/utils/mb/mbutils.c9
-rw-r--r--src/include/catalog/pg_proc.h8
4 files changed, 32 insertions, 5 deletions
diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml
index 334a8a9ee59..3cbd8cdf6b5 100644
--- a/doc/src/sgml/func.sgml
+++ b/doc/src/sgml/func.sgml
@@ -1,4 +1,4 @@
-<!-- $Header: /cvsroot/pgsql/doc/src/sgml/func.sgml,v 1.77 2001/10/10 00:02:42 petere Exp $ -->
+<!-- $Header: /cvsroot/pgsql/doc/src/sgml/func.sgml,v 1.78 2001/10/12 02:08:34 ishii Exp $ -->
<chapter id="functions">
<title>Functions and Operators</title>
@@ -1009,6 +1009,16 @@
</row>
<row>
+ <entry><function>pg_client_encoding</function>()</entry>
+ <entry><type>name</type></entry>
+ <entry>
+ Returns current client encoding name.
+ </entry>
+ <entry><literal>pg_client_encoding()</literal></entry>
+ <entry><literal>SQL_ASCII</literal></entry>
+ </row>
+
+ <row>
<entry><function>repeat</function>(<type>text</type>, <type>integer</type>)</entry>
<entry><type>text</type></entry>
<entry>Repeat text a number of times.</entry>
diff --git a/src/backend/utils/init/miscinit.c b/src/backend/utils/init/miscinit.c
index e6da787bc4e..6f6bc5f9fd3 100644
--- a/src/backend/utils/init/miscinit.c
+++ b/src/backend/utils/init/miscinit.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.77 2001/09/08 15:24:00 petere Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.78 2001/10/12 02:08:34 ishii Exp $
*
*-------------------------------------------------------------------------
*/
@@ -198,6 +198,12 @@ getdatabaseencoding(PG_FUNCTION_ARGS)
}
Datum
+pg_client_encoding(PG_FUNCTION_ARGS)
+{
+ return DirectFunctionCall1(namein, CStringGetDatum("SQL_ASCII"));
+}
+
+Datum
PG_encoding_to_char(PG_FUNCTION_ARGS)
{
return DirectFunctionCall1(namein, CStringGetDatum("SQL_ASCII"));
diff --git a/src/backend/utils/mb/mbutils.c b/src/backend/utils/mb/mbutils.c
index 177cd3a1d6f..c0949a6324f 100644
--- a/src/backend/utils/mb/mbutils.c
+++ b/src/backend/utils/mb/mbutils.c
@@ -3,7 +3,7 @@
* client encoding and server internal encoding.
* (currently mule internal code (mic) is used)
* Tatsuo Ishii
- * $Id: mbutils.c,v 1.23 2001/09/21 15:27:38 tgl Exp $
+ * $Id: mbutils.c,v 1.24 2001/10/12 02:08:34 ishii Exp $
*/
#include "postgres.h"
@@ -471,3 +471,10 @@ getdatabaseencoding(PG_FUNCTION_ARGS)
Assert(DatabaseEncoding);
return DirectFunctionCall1(namein, CStringGetDatum(DatabaseEncoding->name));
}
+
+Datum
+pg_client_encoding(PG_FUNCTION_ARGS)
+{
+ Assert(ClientEncoding);
+ return DirectFunctionCall1(namein, CStringGetDatum(ClientEncoding->name));
+}
diff --git a/src/include/catalog/pg_proc.h b/src/include/catalog/pg_proc.h
index 92a675174d9..7f179d96307 100644
--- a/src/include/catalog/pg_proc.h
+++ b/src/include/catalog/pg_proc.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: pg_proc.h,v 1.215 2001/10/03 17:22:05 tgl Exp $
+ * $Id: pg_proc.h,v 1.216 2001/10/12 02:08:34 ishii Exp $
*
* NOTES
* The script catalog/genbki.sh reads this file and generates .bki
@@ -2140,10 +2140,14 @@ DESCR("return portion of string");
/* for multi-byte support */
-/* old encoding names - back compatibility only */
+/* return database encoding name */
DATA(insert OID = 1039 ( getdatabaseencoding PGUID 12 f t f t 0 f 19 "0" 100 0 0 100 getdatabaseencoding - ));
DESCR("encoding name of current database");
+/* return client encoding name i.e. session encoding */
+DATA(insert OID = 810 ( pg_client_encoding PGUID 12 f t f t 0 f 19 "0" 100 0 0 100 pg_client_encoding - ));
+DESCR("encoding name of current database");
+
DATA(insert OID = 1717 ( convert PGUID 12 f t f t 2 f 25 "25 19" 100 0 0 100 pg_convert - ));
DESCR("convert string with specified destination encoding name");