pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: gmail Vladimir Koković <vladimir.kokovic@gmail.com>
To: Andrew Gierth <andrew@tao11.riddles.org.uk>
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #15653: pg_detoast_datum_packed problem
Date: Sat, 9 Mar 2019 12:03:52 +0100
Message-ID: <052d8d24-46de-e6ae-f1f2-5b12cc7ec6be@gmail.com> (raw)
In-Reply-To: <b47c8361-e2b2-a0a0-85e9-e17aacb8a3cb@gmail.com>
References: <15653-a9979a97bd11577d@postgresql.org>
	<f06d47f0-3e93-fed4-d538-9e012deec2c4@gmail.com>
	<8a0d54a5-1c94-aa00-7e22-7d16566839b4@gmail.com>
	<13b4fc8a-b790-ddec-bf02-fe99ed793a5b@gmail.com>
	<87a7i5b2ok.fsf@news-spur.riddles.org.uk>
	<5236e747-2107-35f8-6741-99298f0bd6a4@gmail.com>
	<87r2bg9yb2.fsf@news-spur.riddles.org.uk>
	<e9d8413b-068e-2b27-12b1-59007539dec8@gmail.com>
	<b47c8361-e2b2-a0a0-85e9-e17aacb8a3cb@gmail.com>

Hi Andrew,

Definitely the problem is solved with the following version pg_bvarchar!

/* SQL function: bvarchar(varchar) returns bytea */

PG_FUNCTION_INFO_V1(pg_bvarchar);
Datum pg_bvarchar(PG_FUNCTION_ARGS) {
   VarChar *arg = PG_GETARG_VARCHAR_PP(0);
   unsigned len;
   bytea *res;

   len = VARSIZE_ANY_EXHDR(arg);
   res = (text *) palloc(len + VARHDRSZ);
   SET_VARSIZE(res, len + VARHDRSZ);
   memcpy(VARDATA(res), VARDATA_ANY(arg), len);
   PG_RETURN_BYTEA_P(res);
}

'select' has passed and no more warnigs.

Thanks again.

Vladimir Koković, DP senior(69)
Belgrade, Mar. 9 2019


On 9.3.19. 11:54, gmail Vladimir Koković wrote:
>
> Hi Andrew,
>
> I forgot to show the final version of pg_bvarchar.
>
> /* SQL function: bvarchar(varchar) returns bytea */
>
> PG_FUNCTION_INFO_V1(pg_bvarchar);
> Datum pg_bvarchar(PG_FUNCTION_ARGS) {
>   VarChar *arg = PG_GETARG_VARCHAR_PP(0);
>   unsigned len;
>   bytea *res;
>
>   len = VARSIZE_ANY_EXHDR(arg);
>   res = (text *) palloc(len);
>   SET_VARSIZE(res, len + VARHDRSZ);
>   memcpy(VARDATA(res), VARDATA_ANY(arg), len);
>   PG_RETURN_BYTEA_P(res);
> }
>
> On 9.3.19. 11:08, gmail Vladimir Koković wrote:
>>
>> Hi Andrew,
>>
>> You are absolutely right and "select ", OID from ispp_wmpl where 
>> (bvarchar (key))> = (bvarchar ('W' :: varchar)) and (bvarchar (key)) 
>> <= (bvarchar ~~~~~~~~ ':: varchar)) order by key" has passed! 
>> However, pg log file now has hundreds of warning message: 2019-03-09 
>> 10:53:29 CET ispp-pionir-test :: 1 (53858) 14721 0 01000 WARNING: 
>> problem in allocation set ExprContext: detected write past chunk end 
>> block 0x55ccb0b36468, chunk 0x55ccb0b36490 2019-03-09 10:53:29 CET 
>> ispp-pionir-test :: 1 (53858) 14721 0 01000 WARNING: problem in 
>> allocation set ExprContext: detected write past chunk end in block 
>> 0x55ccb0b36468, chunk 0x55ccb0b36490 2019-03-09 10:53:29 CET 
>> ispp-pionir-test :: 1 (53858) 14721 0 01000 WARNING: problem in 
>> allocation set ExprContext: detected write past chunk end in block 
>> 0x55ccb0b36468, chunk 0x55ccb0b36490 ... Andrew, I have to thank you 
>> for this help because without this, my 'select' would never have passed. Vladimir Koković, DP senior(69)
>> Belgrade, Mar. 9 2019
>>
>> On 9.3.19. 10:48, Andrew Gierth wrote:
>
>> "gmail" == gmail Vladimir Koković<vladimir.kokovic@gmail.com>  writes:
>>>   gmail> Hi Andrew.
>>>   gmail> I changed VARSIZE to VARSIZE_ANY_EXHDR and VARDATA in
>>>   gmail> VARDATA_ANY as you said, but there is still a problem I can not
>>>   gmail> understand !
>>>
>>> Your message formatting was all messed up, but I can see that you are
>>> still subtracting VARHDRSZ - don't do that: VARSIZE_ANY_EXHDR already
>>> has the header size subtracted (hence "EXHDR"), it returns only the data
>>> size. (The header size is variable, 1 or 4 bytes, so it wouldn't make
>>> sense to include it.)
>>>

view thread (9+ messages)

Message-ID: <052d8d24-46de-e6ae-f1f2-5b12cc7ec6be@gmail.com>
Permalink:  ../052d8d24-46de-e6ae-f1f2-5b12cc7ec6be@gmail.com/
Also on:    postgresql.org/message-id/052d8d24-46de-e6ae-f1f2-5b12cc7ec6be@gmail.com

 · 

reply

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: vladimir.kokovic@gmail.com, andrew@tao11.riddles.org.uk
  Subject: Re: BUG #15653: pg_detoast_datum_packed problem
  In-Reply-To: <052d8d24-46de-e6ae-f1f2-5b12cc7ec6be@gmail.com>
  References: <15653-a9979a97bd11577d@postgresql.org> <f06d47f0-3e93-fed4-d538-9e012deec2c4@gmail.com> <8a0d54a5-1c94-aa00-7e22-7d16566839b4@gmail.com> <13b4fc8a-b790-ddec-bf02-fe99ed793a5b@gmail.com> <87a7i5b2ok.fsf@news-spur.riddles.org.uk> <5236e747-2107-35f8-6741-99298f0bd6a4@gmail.com> <87r2bg9yb2.fsf@news-spur.riddles.org.uk> <e9d8413b-068e-2b27-12b1-59007539dec8@gmail.com> <b47c8361-e2b2-a0a0-85e9-e17aacb8a3cb@gmail.com> <052d8d24-46de-e6ae-f1f2-5b12cc7ec6be@gmail.com>

* 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