Initialize pad bytes in GinFormTuple().
authorNoah Misch <noah@leadboat.com>
Wed, 26 Jun 2013 23:55:15 +0000 (19:55 -0400)
committerNoah Misch <noah@leadboat.com>
Wed, 26 Jun 2013 23:55:15 +0000 (19:55 -0400)
Every other core buffer page consumer initializes the bytes it furnishes
to PageAddItem().  For consistency, do the same here.  No back-patch;
regardless, we couldn't count on the fix so long as binary upgrade can
carry forward affected index builds.

src/backend/access/gin/ginentrypage.c

index 8ead38f234ab36e4920650775d2591e3df0ab4be..7733028fba8b8b6dab19441edd0e682670ede9ea 100644 (file)
@@ -112,6 +112,12 @@ GinFormTuple(GinState *ginstate,
        if (newsize != IndexTupleSize(itup))
        {
                itup = repalloc(itup, newsize);
+               /*
+                * PostgreSQL 9.3 and earlier did not clear this new space, so we
+                * might find uninitialized padding when reading tuples from disk.
+                */
+               memset((char *) itup + IndexTupleSize(itup),
+                          0, newsize - IndexTupleSize(itup));
 
                /* set new size in tuple header */
                itup->t_info &= ~INDEX_SIZE_MASK;