提交 ef09a3a6 编写于 作者: A Asim R P

Refactor query string truncation on top of 889ba39e

Commit 889ba39e fixed the query string truncation in dispatcher
to make it locale-aware.  This patch refactors that change so as to
avoid accessing a string beyond its length.

Reviewed by: Heikki, Ning Yu and Polina Bungina
上级 b1c19196
......@@ -872,8 +872,6 @@ buildGpQueryString(DispatchCommandQueryParms *pQueryParms,
int total_query_len;
char *shared_query,
*pos;
int cnt,
character_len;
MemoryContext oldContext;
/*
......@@ -888,19 +886,14 @@ buildGpQueryString(DispatchCommandQueryParms *pQueryParms,
*
* Here we only need to determine the truncated size, the actual work is
* done later when copying it to the result buffer.
*
* The +1 and -1 below are adjustments to accommodate terminating null
* character.
*/
cnt = 0;
if (querytree || plantree)
{
while (cnt < QUERY_STRING_TRUNCATE_SIZE)
{
character_len = pg_encoding_mblen(GetDatabaseEncoding(), command + cnt);
cnt += character_len;
}
command_len = strnlen(command, cnt - character_len) + 1;
}
else
command_len = strlen(command) + 1;
command_len = strlen(command) + 1;
if ((querytree || plantree) && command_len > QUERY_STRING_TRUNCATE_SIZE)
command_len = pg_mbcliplen(command, command_len,
QUERY_STRING_TRUNCATE_SIZE-1) + 1;
initStringInfo(&resgroupInfo);
if (IsResGroupActivated())
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册