pgstat's truncation of query string needs to be multibyte-aware.
authorTom Lane <[email protected]>
Thu, 7 Feb 2002 22:20:26 +0000 (22:20 +0000)
committerTom Lane <[email protected]>
Thu, 7 Feb 2002 22:20:26 +0000 (22:20 +0000)
Patch from [email protected].

src/backend/postmaster/pgstat.c

index 9eb8d2afe988c41443399bd42f5b03c314bdf9a2..26b0104247c51ce356059d78e84a684d3f8c8403 100644 (file)
@@ -38,6 +38,9 @@
 #include "catalog/pg_shadow.h"
 #include "catalog/pg_database.h"
 #include "libpq/pqsignal.h"
+#ifdef MULTIBYTE
+#include "mb/pg_wchar.h"
+#endif
 #include "miscadmin.h"
 #include "utils/memutils.h"
 #include "storage/backendid.h"
@@ -424,8 +427,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';