spgist: palloc() negative size with smaller BLCKSZ

Поиск
Список
Период
Сортировка
От Josh Kupershmidt
Тема spgist: palloc() negative size with smaller BLCKSZ
Дата
Msg-id CAK3UJRHQooy2zvKAkD4VsiLsLSD-K17pgLnK8n-YUyT56GUD7Q@mail.gmail.com
обсуждение исходный текст
Ответы Re: spgist: palloc() negative size with smaller BLCKSZ  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-bugs
Hi all,

I noticed that configuring Postgres with a BLCKSZ smaller than default
was causing 'make check' give an interesting error on git head. You
should be able to see this with a simple:

  ./configure --enable-debug --enable-cassert --with-blocksize=4 &&
  make check

which, among a few other seemingly-minor sorting and EXPLAIN
differences, gives this nasty regression (for a 64-bit binary, built
on OS X 10.6):

--- /media/src/OSS/postgresql/src/test/regress/results/create_index.out    2012-06-25
18:49:00.000000000 -0700
***************
*** 79,84 ****
--- 79,85 ----
  INSERT INTO suffix_text_tbl VALUES ('P0123456789abcde');
  INSERT INTO suffix_text_tbl VALUES ('P0123456789abcdefF');
  CREATE INDEX sp_suff_ind ON suffix_text_tbl USING spgist (t);
+ ERROR:  invalid memory alloc request size 18446744073709551520
  --
  -- Test GiST and SP-GiST indexes
  --

Or, for a similar 32-bit build on a Debian machine, I get:
+ ERROR:  invalid memory alloc request size 4294967200

I believe this problem stems from this definition in spgtextproc.c:

#define SPGIST_MAX_PREFIX_LENGTH        (BLCKSZ - 256 * 16 - 100)

With a BLCKSZ of 4096, that comes to -100, which gets picked up here:

        commonLen = Min(commonLen, SPGIST_MAX_PREFIX_LENGTH);

and ultimately palloc'ed as a size. I'm not sure what'd be the right
way to fix this after reading the comment above
SPGIST_MAX_PREFIX_LENGTH, but thought I'd share.

Josh

В списке pgsql-bugs по дате отправления:

Предыдущее
От: m.sakrejda@gmail.com
Дата:
Сообщение: BUG #6706: pg_upgrade fails when plpgsql dropped/re-created
Следующее
От: Tom Lane
Дата:
Сообщение: Re: spgist: palloc() negative size with smaller BLCKSZ