TimescaleDB function recompress_chunk() converted to procedure in version 2.6.0

In TimescaleDB version 2.6.0 the recompress_chunk() function is converted to a procedure to allow transaction control, a requirement that can’t be supported by a function.

Applications that use the function, for example as a part of an SQL statement such as SELECT recompress_chunk(i.show_chunks, true) FROM... , will encounter this error:

ERROR:  recompress_chunk(regclass, boolean) is a procedure
LINE 1: select recompress_chunk(i.show_chunks, true) from (
               ^
HINT:  To call a procedure, use CALL.

Instead, this example procedure call can be used to recompress chunks:

DO $$
DECLARE chunk regclass;
BEGIN
  FOR chunk IN SELECT format('%I.%I', chunk_schema, chunk_name)::regclass
  FROM timescaledb_information.chunks
  WHERE is_compressed = true
  LOOP
    RAISE NOTICE 'Recompressing %', chunk::text;
    CALL recompress_chunk(chunk, true);
  END LOOP;
END
$$;
4 Likes