Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitcd55aa2

Browse files
committed
Fix two new-in-9.0 bugs in hstore.
There was an incorrect Assert in hstoreValidOldFormat(), which would causeimmediate core dumps when attempting to work with pre-9.0 hstore data,but of course only in an assert-enabled build.Also, ghstore_decompress() incorrectly applied DatumGetHStoreP() to a datumthat wasn't actually an hstore, but rather a ghstore (ie, a gist signaturebitstring). That used to be harmless, but could now result in misbehaviorif the hstore format conversion code happened to trigger. In reality,since ghstore is not marked toastable (and doesn't need to be), thisfunction is useless anyway; we can lobotomize it down to returning thepassed-in pointer.Both bugs found by Andrew Gierth, though this isn't exactly his proposedpatch.
1 parente1089e3 commitcd55aa2

File tree

2 files changed

+9
-22
lines changed

2 files changed

+9
-22
lines changed

‎contrib/hstore/hstore_compat.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* $PostgreSQL: pgsql/contrib/hstore/hstore_compat.c,v 1.2 2010/02/26 02:00:32 momjian Exp $
2+
* $PostgreSQL: pgsql/contrib/hstore/hstore_compat.c,v 1.3 2010/09/16 02:54:01 tgl Exp $
33
*
44
* Notes on old/new hstore format disambiguation.
55
*
@@ -180,7 +180,8 @@ hstoreValidOldFormat(HStore *hs)
180180
if (hs->size_&HS_FLAG_NEWVERSION)
181181
return0;
182182

183-
Assert(sizeof(HOldEntry)==sizeof(HEntry));
183+
/* New format uses an HEntry for key and another for value */
184+
Assert(sizeof(HOldEntry)== (2*sizeof(HEntry)));
184185

185186
if (count==0)
186187
return2;

‎contrib/hstore/hstore_gist.c

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* $PostgreSQL: pgsql/contrib/hstore/hstore_gist.c,v 1.12 2010/02/26 02:00:32 momjian Exp $
2+
* $PostgreSQL: pgsql/contrib/hstore/hstore_gist.c,v 1.13 2010/09/16 02:54:01 tgl Exp $
33
*/
44
#include"postgres.h"
55

@@ -168,28 +168,14 @@ ghstore_compress(PG_FUNCTION_ARGS)
168168
PG_RETURN_POINTER(retval);
169169
}
170170

171+
/*
172+
* Since type ghstore isn't toastable (and doesn't need to be),
173+
* this function can be a no-op.
174+
*/
171175
Datum
172176
ghstore_decompress(PG_FUNCTION_ARGS)
173177
{
174-
GISTENTRY*entry= (GISTENTRY*)PG_GETARG_POINTER(0);
175-
GISTENTRY*retval;
176-
HStore*key;
177-
178-
key=DatumGetHStoreP(entry->key);
179-
180-
if (key!= (HStore*)DatumGetPointer(entry->key))
181-
{
182-
/* need to pass back the decompressed item */
183-
retval=palloc(sizeof(GISTENTRY));
184-
gistentryinit(*retval,PointerGetDatum(key),
185-
entry->rel,entry->page,entry->offset,entry->leafkey);
186-
PG_RETURN_POINTER(retval);
187-
}
188-
else
189-
{
190-
/* we can return the entry as-is */
191-
PG_RETURN_POINTER(entry);
192-
}
178+
PG_RETURN_POINTER(PG_GETARG_POINTER(0));
193179
}
194180

195181
Datum

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp