From: Denis Erokhin =0A= Date: Tue, 19 Sep 2023 11:40:31 +0300=0A= Subject: [PATCH v1 2/3] Replace magic "one" in tsvector binary receiving=0A= =0A= ---=0A= src/backend/utils/adt/tsvector.c | 4 ++--=0A= 1 file changed, 2 insertions(+), 2 deletions(-)=0A= =0A= diff --git a/src/backend/utils/adt/tsvector.c = b/src/backend/utils/adt/tsvector.c=0A= index dfc12c4cc7..dff0bfe41f 100644=0A= --- a/src/backend/utils/adt/tsvector.c=0A= +++ b/src/backend/utils/adt/tsvector.c=0A= @@ -498,7 +498,7 @@ tsvectorrecv(PG_FUNCTION_ARGS)=0A= * But make sure the buffer is large enough first.=0A= */=0A= while (hdrlen + SHORTALIGN(datalen + lex_len) +=0A= - (npos + 1) * sizeof(WordEntryPos) >=3D len)=0A= + sizeof(uint16) + npos * sizeof(WordEntryPos) >=3D len)=0A= {=0A= len *=3D 2;=0A= vec =3D (TSVector) repalloc(vec, len);=0A= @@ -544,7 +544,7 @@ tsvectorrecv(PG_FUNCTION_ARGS)=0A= elog(ERROR, "position information is misordered");=0A= }=0A= =0A= - datalen +=3D (npos + 1) * sizeof(WordEntryPos);=0A= + datalen +=3D sizeof(uint16) + npos * sizeof(WordEntryPos);=0A= }=0A= }=0A= =0A= -- =0A= 2.39.2.windows.1=0A= =0A= ------=_NextPart_000_0099_01D9F2F3.17E4DDF0 Content-Type: application/octet-stream; name="v1-0003-Optimize-memory-allocation-during-tsvector-binary.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="v1-0003-Optimize-memory-allocation-during-tsvector-binary.patch"