From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: work.anvesh@gmail.com
Subject: BUG #18231: String conversion function is adding special characters in Postgres 15
Date: Thu, 07 Dec 2023 09:16:00 +0000
Message-ID: <18231-12decf23063f87ef@postgresql.org> (raw)
The following bug has been logged on the website:
Bug reference: 18231
Logged by: anvesh work
Email address: work.anvesh@gmail.com
PostgreSQL version: 15.0
Operating system: Windows 10
Description:
I have a function which was working fine in Postgres 10 but not in Postgres
15.
When I traced the program, I am facing issue with the VARDATA(arg2).
The arg2 is 2nd argument used in the calling function from PGAdmin4.
After conversion it is returning text with special characters.
In Postgres 10, note that 4 characters are concatenated with special
characters, but other characters are working fine.
Following are the lines of code:
pgsql:
select functionname('arg1', 'arg2', 'arg3');
My Method in C program has
text *arg2 = PG_GETARG_TEXT_P(1);
int output = PbValue (VARDATA(arg2));
Postgres.h file:
#define VARDATA(PTR) VARDATA_4B(PTR)
#define VARDATA_4B(PTR) (((varattrib_4b *) (PTR))->va_4byte.va_data)
To resolve this, we have used memcpy for converting characters.
memcpy(str, VARDATA(arg2), arg_size);
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-bugs@postgresql.org
Cc: noreply@postgresql.org, pgsql-bugs@lists.postgresql.org, work.anvesh@gmail.com
Subject: Re: BUG #18231: String conversion function is adding special characters in Postgres 15
In-Reply-To: <18231-12decf23063f87ef@postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox