[PATCH] pg_prewarm: validate that first_block <= last_block

Поиск
Список
Период
Сортировка
Искать

[PATCH] pg_prewarm: validate that first_block <= last_block

От:
Postgress Cybrosys <postgress@cybrosys.com>
Дата:
Вложения:
Hi psql hackers,

While reviewing contrib/pg_prewarm/pg_prewarm.c, I noticed that
pg_prewarm() does not validate that first_block <= last_block after
both values are resolved. When a caller passes a reversed range such
as pg_prewarm('mytable', 'buffer', 'main', 100, 50), the function
silently returns 0 without any indication that the range was empty.
Both block numbers pass their individual bounds checks, so the caller
gets no feedback that anything went wrong.

The fix adds an explicit check after both endpoints are fully resolved
(including NULL defaults) and emits an ERROR message.

Reproduction:

  CREATE TABLE t (id int);
  INSERT INTO t SELECT generate_series(1, 10000);

  -- Before patch: silently returns 0
  SELECT pg_prewarm('t', 'buffer', 'main', 100, 50);
   pg_prewarm
  ------------
            0
  (1 row)

  -- After patch: raises a clear error

 SELECT pg_prewarm('t', 'buffer', 'main', 100, 50);
ERROR:  ending block number cannot be less than starting block number  

The patch is attached. It touches only contrib/pg_prewarm/pg_prewarm.c

--

Thanks & Regards,

Jhon k

Postgres Specialist

Project & IT Department

Cybrosys Technologies


Mail

Mobile

WhatsApp


postgress@cybrosys.com

+91 8606827707

+91 8606827707


FAQ