Re: Tagged types module and varlena changes
От | Tom Lane |
---|---|
Тема | Re: Tagged types module and varlena changes |
Дата | |
Msg-id | 16331.1251300102@sss.pgh.pa.us обсуждение исходный текст |
Ответ на | Re: Tagged types module and varlena changes (Alban Hertroys <dalroi@solfertje.student.utwente.nl>) |
Список | pgsql-general |
Alban Hertroys <dalroi@solfertje.student.utwente.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
В списке pgsql-general по дате отправления: