problem with varlena and extended type

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: problem with varlena and extended type
Date: 2009-07-04 19:58:46
Message-ID: 162867790907041258w13efe267odfd641e181b80c84@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello,

I can't to find reason of my problem. I have a varlena type. This type
works well with plain storage, but this raise some random exception
with extended storage. It finish on Assert((data - start) ==
data_size)[heaptuple.c]; I checked - when I return varlena from in
function, then it has correct size, but in this function VARSIZE
returns different value.

some log
NOTICE: KOKES SIZE 36242, pointer: 149948300 -- varlena check
NOTICE: heap_fill_tuple [size: 36250, bits -1, tupleesc: 150141444, attrs: 3
NOTICE: iteration 0
NOTICE: >>> attbyval 1, attlen 4
NOTICE: [data: 150208808d, data length: 4]
NOTICE: iteration 1
NOTICE: >>> attbyval 1, attlen 4
NOTICE: [data: 150208812d, data length: 4]
NOTICE: iteration 2
NOTICE: >>> attbyval 0, attlen -1
NOTICE: FULL VARLENA 149948300 <36242> -- correct size in heap_fill_tuple

but
NOTICE: KOKES SIZE 55966, pointer: 150029636, -- varlena size
NOTICE: heap_fill_tuple [size: 55974, bits -1, tupleesc: 149930464, attrs: 3
NOTICE: iteration 0
NOTICE: >>> attbyval 1, attlen 4
NOTICE: [data: 150029680d, data length: 4]
NOTICE: iteration 1
NOTICE: >>> attbyval 1, attlen 4
NOTICE: [data: 150029684d, data length: 4]
NOTICE: iteration 2
NOTICE: >>> attbyval 0, attlen -1
NOTICE: FULL VARLENA 150029636 <13999> -- wrong size, why?
NOTICE: 14007 [55974]
psql83:/home/pavel/src/postgresql-8.3.7/contrib/kokes/objerr1.sql:4:
server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.

any idea, why size of varlena is broken?

thank you
Pavel Stehule

p.s. I use macros SET_VARSIZE and VARSIZE

define DatumGetKokesData(x)<-->((KokesData*)DatumGetPointer(x))
#define PG_GETARG_KokesData(x)<>DatumGetKokesData(
PG_DETOAST_DATUM(PG_GETARG_DATUM(x)) )
#define PG_RETURN_KokesData(x)<>PG_RETURN_POINTER(x)

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Greg Stark 2009-07-04 21:31:21 Re: problem with varlena and extended type
Previous Message Boszormenyi Zoltan 2009-07-04 15:09:04 Re: ECPG support for string pseudo-type