From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Alban Hertroys <dalroi(at)solfertje(dot)student(dot)utwente(dot)nl> |
Cc: | Greg Stark <gsstark(at)mit(dot)edu>, postgres list <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Tagged types module and varlena changes |
Date: | 2009-08-26 15:21:42 |
Message-ID: | 16331.1251300102@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Alban Hertroys <dalroi(at)solfertje(dot)student(dot)utwente(dot)nl> writes:
> I changed it to:
>> SET_VARSIZE(tv->vl_len_, a);
This is just wrong; use SET_VARSIZE(tv, ...).
>> memcpy( tv->vl_dat, &typev->val, b );
And I wouldn't recommend referencing vl_dat directly either.
Use VARDATA().
In general you're supposed to apply VARSIZE() and VARDATA() and
friends to pointers not Datums. Although it would usually work
to be sloppy about this, I can't recommend it. I would extract
the typev pointer first and then apply the VARSIZE macro to it.
> (gdb) print *tv
> $1 = {vl_len_ = "\000\000\000", vl_dat = ""}
> (gdb) print a
> $2 = 0
> (gdb) print b
> $3 = -4
> (gdb) print *typev
> $4 = {len = "\020\000\000", tag = 68899, val = "!\000\000"}
Where did the input come from? On a little-endian machine that len
value means 4 bytes, so it's wrong right off the bat if it's
supposed to include the tag.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Vick Khera | 2009-08-26 15:30:34 | Re: How to simulate crashes of PostgreSQL? |
Previous Message | Naoko Reeves | 2009-08-26 15:17:10 | Aggregate function with Join stop working under certain condition |