BUG #18410: SQL Error [XX000]: ERROR: variable not found in subplan target list - Mailing list pgsql-bugs

From PG Bug reporting form
Subject BUG #18410: SQL Error [XX000]: ERROR: variable not found in subplan target list
Date
Msg-id 18410-b6ad04652311ce33@postgresql.org
Whole thread Raw
Responses Re: BUG #18410: SQL Error [XX000]: ERROR: variable not found in subplan target list  (Laurenz Albe <laurenz.albe@cybertec.at>)
List pgsql-bugs
The following bug has been logged on the website:

Bug reference:      18410
Logged by:          Fernando Asulay
Email address:      fernando.asulay@es.abb.com
PostgreSQL version: 16.2
Operating system:   TimescaleDB linux Docker  image
Description:

The issue was found to happend on timescaledb extension hypertables using
postgres 14 and above. We tested different version of timescaledb and
doesn't seem to take any effect. Only changing pg version from 13 to 14.

Tested using images from
https://hub.docker.com/r/timescale/timescaledb/tags

To reproduce the error:

The following compose was used:

version: "3.5"
services:
  works:
    image: timescale/timescaledb:2.14.2-pg13
    container_name: works
    restart: always
    environment:
      POSTGRES_USER: admin
      POSTGRES_PASSWORD: password
    ports:
      - "5432:5432"
  
  doesntwork:
    image: timescale/timescaledb:2.14.2-pg14
    container_name: doesntwork
    environment:
      POSTGRES_USER: admin
      POSTGRES_PASSWORD: password
    ports:
        - "5433:5432"

  doesntworkeither:
    image: timescale/timescaledb:2.14.2-pg16
    container_name: doesntworkeither
    environment:
      POSTGRES_USER: admin
      POSTGRES_PASSWORD: password
    ports:
        - "5434:5432"


connect to "doesntwork" or "doesntworkeither" containers and run the
following SQL:

-- Create test table
CREATE TABLE public.test1(
    id text NOT null,
    created timestamptz NOT NULL
);
-- Make the table an timescaledb hypertable
SELECT create_hypertable('public.test1', 'created', chunk_time_interval =>
interval'4 days');
-- Insert some data
INSERT INTO public.test1 VALUES (1, '2024-01-01');
-- Verify data is correclty inserted
SELECT * FROM public.test1;
-- Run the query to trigger the error 
DELETE  FROM
   "public".test1
WHERE 
   (EXISTS (SELECT 1));


pgsql-bugs by date:

Previous
From: "Hayato Kuroda (Fujitsu)"
Date:
Subject: RE: Potential data loss due to race condition during logical replication slot creation
Next
From: Laurenz Albe
Date:
Subject: Re: BUG #18410: SQL Error [XX000]: ERROR: variable not found in subplan target list