Multi byte aware for pg_stat_activity

Поиск
Список
Период
Сортировка
Искать

Multi byte aware for pg_stat_activity

От:
sugita@sra.co.jp
Дата:
  Attached is a multi byte aware for pg_stat_activity.
Index: pgstat.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/backend/postmaster/pgstat.c,v
retrieving revision 1.16
diff -u -3 -p -u -r1.16 pgstat.c
--- pgstat.c	2001/12/03 19:02:58	1.16
+++ pgstat.c	2002/01/31 03:15:16
@@ -32,6 +32,10 @@
 #include 
 #include 
 
+#ifdef MULTIBYTE
+#include "mb/pg_wchar.h"
+#endif
+
 #include "access/xact.h"
 #include "access/heapam.h"
 #include "catalog/catname.h"
@@ -424,8 +428,12 @@ pgstat_report_activity(char *what)
 		return;
 
 	len = strlen(what);
+#ifdef MULTIBYTE
+	len = pg_mbcliplen((const unsigned char *)what, len, PGSTAT_ACTIVITY_SIZE);
+#else
 	if (len >= PGSTAT_ACTIVITY_SIZE)
 		len = PGSTAT_ACTIVITY_SIZE - 1;
+#endif
 
 	memcpy(msg.m_what, what, len);
 	msg.m_what[len] = '\0';

Re: Multi byte aware for pg_stat_activity

От:
sugita@sra.co.jp
Дата:
;;;   Attached is a multi byte aware for pg_stat_activity.

This patch has a fault. Attached is a fixed patch.

Index: pgstat.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/backend/postmaster/pgstat.c,v
retrieving revision 1.16
diff -u -3 -p -u -r1.16 pgstat.c
--- pgstat.c	2001/12/03 19:02:58	1.16
+++ pgstat.c	2002/01/31 03:22:46
@@ -32,6 +32,10 @@
 #include 
 #include 
 
+#ifdef MULTIBYTE
+#include "mb/pg_wchar.h"
+#endif
+
 #include "access/xact.h"
 #include "access/heapam.h"
 #include "catalog/catname.h"
@@ -424,8 +428,12 @@ pgstat_report_activity(char *what)
 		return;
 
 	len = strlen(what);
+#ifdef MULTIBYTE
+	len = pg_mbcliplen((const unsigned char *)what, len, PGSTAT_ACTIVITY_SIZE - 1);
+#else
 	if (len >= PGSTAT_ACTIVITY_SIZE)
 		len = PGSTAT_ACTIVITY_SIZE - 1;
+#endif
 
 	memcpy(msg.m_what, what, len);
 	msg.m_what[len] = '\0';

Re: Multi byte aware for pg_stat_activity

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
sugita@sra.co.jp writes:
> ;;;   Attached is a multi byte aware for pg_stat_activity.
> This patch has a fault. Attached is a fixed patch.

Patch applied.  Thanks.

			regards, tom lane
FAQ