Add a new function "pg_client_encoding" which returns the current client
authorTatsuo Ishii
Fri, 12 Oct 2001 02:08:34 +0000 (02:08 +0000)
committerTatsuo Ishii
Fri, 12 Oct 2001 02:08:34 +0000 (02:08 +0000)
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.

doc/src/sgml/func.sgml
src/backend/utils/init/miscinit.c
src/backend/utils/mb/mbutils.c
src/include/catalog/pg_proc.h

index 334a8a9ee593840993492562d18260a6a969c9aa..3cbd8cdf6b572a26c6e2a0e3b89be71d0519acb7 100644 (file)
@@ -1,4 +1,4 @@
-
+
 
 
  Functions and Operators
       trim
      
 
+     
+      pg_client_encoding()
+      name
+      
+       Returns current client encoding name.
+      
+      pg_client_encoding()
+      SQL_ASCII
+     
+
      
       repeat(textinteger)
       text
index e6da787bc4e5f15c3410e78604e4c0aa275107ef..6f6bc5f9fd3946aa993ad8aadc527fdba9925020 100644 (file)
@@ -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 $
  *
  *-------------------------------------------------------------------------
  */
@@ -197,6 +197,12 @@ getdatabaseencoding(PG_FUNCTION_ARGS)
    return DirectFunctionCall1(namein, CStringGetDatum("SQL_ASCII"));
 }
 
+Datum
+pg_client_encoding(PG_FUNCTION_ARGS)
+{
+   return DirectFunctionCall1(namein, CStringGetDatum("SQL_ASCII"));
+}
+
 Datum
 PG_encoding_to_char(PG_FUNCTION_ARGS)
 {
index 177cd3a1d6f390d17d05faf24c720d0b341d1099..c0949a6324f28007d5f0212f4423dfc46db329da 100644 (file)
@@ -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));
+}
index 92a675174d9c8996a156ed5c8099a59d9ab7a5bf..7f179d96307d66fbfc6935885155eba052847d73 100644 (file)
@@ -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");