Skip to content

Commit 0cc9917

Browse files
committed
pgstat's truncation of query string needs to be multibyte-aware.
Patch from sugita@sra.co.jp.
1 parent fe1a9c3 commit 0cc9917

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/backend/postmaster/pgstat.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*
1717
* Copyright (c) 2001, PostgreSQL Global Development Group
1818
*
19-
* $Header: /cvsroot/pgsql/src/backend/postmaster/pgstat.c,v 1.16 2001/12/03 19:02:58 tgl Exp $
19+
* $Header: /cvsroot/pgsql/src/backend/postmaster/pgstat.c,v 1.17 2002/02/07 22:20:26 tgl Exp $
2020
* ----------
2121
*/
2222
#include "postgres.h"
@@ -38,6 +38,9 @@
3838
#include "catalog/pg_shadow.h"
3939
#include "catalog/pg_database.h"
4040
#include "libpq/pqsignal.h"
41+
#ifdef MULTIBYTE
42+
#include "mb/pg_wchar.h"
43+
#endif
4144
#include "miscadmin.h"
4245
#include "utils/memutils.h"
4346
#include "storage/backendid.h"
@@ -424,8 +427,12 @@ pgstat_report_activity(char *what)
424427
return;
425428

426429
len = strlen(what);
430+
#ifdef MULTIBYTE
431+
len = pg_mbcliplen((const unsigned char *)what, len, PGSTAT_ACTIVITY_SIZE - 1);
432+
#else
427433
if (len >= PGSTAT_ACTIVITY_SIZE)
428434
len = PGSTAT_ACTIVITY_SIZE - 1;
435+
#endif
429436

430437
memcpy(msg.m_what, what, len);
431438
msg.m_what[len] = '\0';

0 commit comments

Comments
 (0)