From be629abfc85dd4a51b53a27a472f79f94f95de0f Mon Sep 17 00:00:00 2001
From: Tatsuo Ishii <ishii@postgresql.org>
Date: Sun, 23 Sep 2001 10:59:45 +0000
Subject: [PATCH] Add pg_database_encoding_max_length() function.

---
 src/backend/utils/mb/wchar.c | 12 +++++++++++-
 src/include/mb/pg_wchar.h    |  3 ++-
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/src/backend/utils/mb/wchar.c b/src/backend/utils/mb/wchar.c
index 2da50bdd17..445e0e503a 100644
--- a/src/backend/utils/mb/wchar.c
+++ b/src/backend/utils/mb/wchar.c
@@ -1,7 +1,7 @@
 /*
  * conversion functions between pg_wchar and multi-byte streams.
  * Tatsuo Ishii
- * $Id: wchar.c,v 1.21 2001/09/21 15:27:38 tgl Exp $
+ * $Id: wchar.c,v 1.22 2001/09/23 10:59:45 ishii Exp $
  *
  * WIN1250 client encoding updated by Pavel Behal
  *
@@ -573,4 +573,14 @@ pg_verifymbstr(const unsigned char *mbstr, int len)
 	}
 	return NULL;
 }
+
+/*
+ * fetch maximum length of a char encoding for the current database
+ */
+int
+pg_database_encoding_max_length(void)
+{
+	return pg_wchar_table[GetDatabaseEncoding()].maxmblen;
+}
+
 #endif
diff --git a/src/include/mb/pg_wchar.h b/src/include/mb/pg_wchar.h
index d27e316bde..eb8bf54e64 100644
--- a/src/include/mb/pg_wchar.h
+++ b/src/include/mb/pg_wchar.h
@@ -1,4 +1,4 @@
-/* $Id: pg_wchar.h,v 1.31 2001/09/21 15:27:38 tgl Exp $ */
+/* $Id: pg_wchar.h,v 1.32 2001/09/23 10:59:45 ishii Exp $ */
 
 #ifndef PG_WCHAR_H
 #define PG_WCHAR_H
@@ -226,6 +226,7 @@ extern int	pg_mbstrlen_with_len(const unsigned char *, int);
 extern int	pg_mbcliplen(const unsigned char *, int, int);
 extern int	pg_mbcharcliplen(const unsigned char *, int, int);
 extern int	pg_encoding_max_length(int);
+extern int	pg_database_encoding_max_length(void);
 
 extern int		pg_set_client_encoding(int);
 extern int		pg_get_client_encoding(void);
-- 
2.24.1