Thread: What happen to the VARATT_SIZEP macro in version 8.3?
Hello all,
I have C code which defines some user defined postgres functions. This code has been used with Postgres version 7.4 and it uses the VARATT_SIZEP macro.
I updated to Postgres version 8.3 and attempted to compile my C code and noticed that the VARATT_SIZEP macro (which my code uses) no longer is defined in the 8.3 code base (which needless to say prevents my code from compiling). The macro use to be defined in postgres.h in version 7.4.
What replaces the VARATT_SIZEP macro in version 8.3? I have spent a long time checking the documentation and have not found the answer.
Thanks
P.S.
I posted this question to the wrong mailing list earlier and meant to post it to this list. I apologize to the people who are on both lists that got this message twice.
On 8/5/08, Don Pannese <don.pannese@hds.com> wrote: > > I have C code which defines some user defined postgres functions. This code > has been used with Postgres version 7.4 and it uses the VARATT_SIZEP macro. > seems that macro was deprecated in 8.3... this is the commit that removed it: http://archives.postgresql.org/pgsql-committers/2007-02/msg00517.php The new comment says: ! * TOASTed. Generally, only the code closely associated with TOAST logic ! * should mess directly with struct varattrib or use the VARATT_FOO macros. Why you need that macro at all? Now, of you really need it maybe you can make your own wrapper in ine of your includes: #define VARATT_SIZEP(_PTR) \ VARATT_SIZEP_DEPRECATED(PTR) -- regards, Jaime Casanova Soporte y capacitación de PostgreSQL Guayaquil - Ecuador Cel. (593) 87171157
> > What replaces the VARATT_SIZEP macro in version 8.3? I have > spent a long > time checking the documentation and have not found the > answer. > SET_VARSIZE __________________________________________________________ Not happy with your email address?. Get the one you really want - millions of new email addresses available now at Yahoo! http://uk.docs.yahoo.com/ymail/new.html
Glyn Astill <glynastill@yahoo.co.uk> writes: >> What replaces the VARATT_SIZEP macro in version 8.3? I have spent a >> long time checking the documentation and have not found the answer. > SET_VARSIZE Yes; you should always use VARSIZE() to fetch the length and SET_VARSIZE() to set it. If you need your code to still work with pre-8.3 releases, you can make yourself a compatibility macro like this: #ifndef SET_VARSIZE #define SET_VARSIZE(v,l) (VARATT_SIZEP(v) = (l)) #endif Also note that detoasting might be needed in more places than it was in 7.4; if you were cutting corners on a toastable type, you'll have to check your code carefully. See more advice here: http://archives.postgresql.org/pgsql-general/2007-10/msg00604.php regards, tom lane