Two small fixes for hstore-new. The hstore_compat one is arguable as to what is the best approach; the assert that was there was just wrong, but I have been unable after considerable searching to find any architectures that would fail the check. The version in this patch will just treat any old-format non-empty hstore as being invalid on a platform where the upgrade to the new format would fail. (And this version _is_ tested on at least i386 and amd64, where upgrading works.)
The gist one is just that the old code was abusing DatumGetHStoreP by applying it to something that wasn't an hstore. This didn't matter before the format upgrade code was put in, and it didn't show up in tests because you need to index a very large number of hstores before any problem shows up. -- Andrew (irc:RhodiumToad)
Index: contrib/hstore/hstore_compat.c =================================================================== RCS file: /projects/cvsroot/pgsql/contrib/hstore/hstore_compat.c,v retrieving revision 1.2 diff -c -r1.2 hstore_compat.c *** contrib/hstore/hstore_compat.c 26 Feb 2010 02:00:32 -0000 1.2 --- contrib/hstore/hstore_compat.c 15 Sep 2010 21:16:46 -0000 *************** *** 180,190 **** if (hs->size_ & HS_FLAG_NEWVERSION) return 0; - Assert(sizeof(HOldEntry) == sizeof(HEntry)); - if (count == 0) return 2; if (count > 0xFFFFFFF) return 0; --- 180,191 ---- if (hs->size_ & HS_FLAG_NEWVERSION) return 0; if (count == 0) return 2; + if (sizeof(HOldEntry) != 2*sizeof(HEntry)) + return 0; + if (count > 0xFFFFFFF) return 0; Index: contrib/hstore/hstore_gist.c =================================================================== RCS file: /projects/cvsroot/pgsql/contrib/hstore/hstore_gist.c,v retrieving revision 1.12 diff -c -r1.12 hstore_gist.c *** contrib/hstore/hstore_gist.c 26 Feb 2010 02:00:32 -0000 1.12 --- contrib/hstore/hstore_gist.c 15 Sep 2010 21:16:47 -0000 *************** *** 173,183 **** { GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0); GISTENTRY *retval; ! HStore *key; ! key = DatumGetHStoreP(entry->key); ! ! if (key != (HStore *) DatumGetPointer(entry->key)) { /* need to pass back the decompressed item */ retval = palloc(sizeof(GISTENTRY)); --- 173,183 ---- { GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0); GISTENTRY *retval; ! void *key; /* this is not an hstore, but a ghstore */ ! key = DatumGetPointer(PG_DETOAST_DATUM(entry->key)); ! ! if (key != DatumGetPointer(entry->key)) { /* need to pass back the decompressed item */ retval = palloc(sizeof(GISTENTRY));
-- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs