From 0cc9917bb62da7a8f86e07ca80bfae3bceab17de Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Thu, 7 Feb 2002 22:20:26 +0000 Subject: [PATCH] pgstat's truncation of query string needs to be multibyte-aware. Patch from sugita@sra.co.jp. --- src/backend/postmaster/pgstat.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/backend/postmaster/pgstat.c b/src/backend/postmaster/pgstat.c index fc2619ee0c..0e9f57500d 100644 --- a/src/backend/postmaster/pgstat.c +++ b/src/backend/postmaster/pgstat.c @@ -16,7 +16,7 @@ * * Copyright (c) 2001, PostgreSQL Global Development Group * - * $Header: /cvsroot/pgsql/src/backend/postmaster/pgstat.c,v 1.16 2001/12/03 19:02:58 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/postmaster/pgstat.c,v 1.17 2002/02/07 22:20:26 tgl Exp $ * ---------- */ #include "postgres.h" @@ -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'; -- 2.40.0