Re: Now for the VARDATA, VARSIZE, and VARHDRSZ stuff - Mailing list pgsql-interfaces

From Peter Eisentraut
Subject Re: Now for the VARDATA, VARSIZE, and VARHDRSZ stuff
Date
Msg-id Pine.LNX.4.30.0104161558510.760-100000@peter.localdomain
Whole thread Raw
In response to Now for the VARDATA, VARSIZE, and VARHDRSZ stuff  (Lonnie Cumberland <lonnie_cumberland@yahoo.com>)
List pgsql-interfaces
Lonnie Cumberland writes:

> I now have a simple question about the use of these VARDATA() VARSIZE() and
> VARHDRSZ() wrappers

VARDATA is a pointer (to char?) to where the actual data of the specific
value starts.  VARSIZE is the length of the specific value, plus the
header.  VARHRDZ is the size of the header, currently always 4.  For
example, if you have a text string 'abc' then the memory representation is

int    4    <-- text* points here
char    'a'    <-- VARDATA points here
char    'b'
char    'c'

VARHDRZ == 4, VARSIZE = 7

Note that the data is not null-terminated.

The best things might be not to mess with this but call textin() and
textout() to convert your data to C strings.

-- 
Peter Eisentraut   peter_e@gmx.net   http://funkturm.homeip.net/~peter



pgsql-interfaces by date:

Previous
From: Lonnie Cumberland
Date:
Subject: making data types
Next
From: "Avinash K.G"
Date:
Subject: