Skip to content

Regression in 8.2.2 - Prepared statements break nested queries if there are "gaps" #5512

@megakoresh

Description

@megakoresh

To reproduce

Happens when using prepared statements which are references in nested queries and there are gaps (unused values) between the sent values. Yes, very obscure, but it worked in 8.2.1 and doesn't in 8.2.2

Create tables and populate values

CREATE TABLE test_table (
  value double,
  state symbol,
  opened_at timestamp
) timestamp(opened_at) PARTITION BY YEAR;

INSERT INTO test_table(value,state,opened_at) VALUES
(1, 'OPEN', dateadd('d', -1, now())),
(4, 'CLOSED', dateadd('d', -2, now())),
(2, 'CLOSED', dateadd('d', -3, now())),
(7, 'CLOSED', dateadd('d', -4, now())),
(1, 'CLOSED', dateadd('d', -5, now()));

Run query:

WITH s AS (SELECT * from test_table WHERE value < 7) SELECT s.state, s.opened_at FROM s WHERE 1=1 AND state <> 'OPEN';

Observe as the query returns results without issues. Now open node.js repl and do this:

$ npx ts-node
> import { Pool } from "pg";
> const pool = new Pool({ host: 'localhost', port: 8812, user: 'admin', password: 'quest', database: 'quest', max: 10});
> let res = await pool.query("WITH s AS (SELECT * from test_table WHERE value < $1) SELECT s.state, s.opened_at FROM s WHERE 1=1 AND state <> $2", [7, "OPEN"]);
> res = await pool.query("WITH s AS (SELECT * from test_table WHERE value < $1) SELECT s.state, s.opened_at FROM s WHERE 1=1 AND state <> $4", [7, "", "", "OPEN"]);
> res = await pool.query("WITH s AS (SELECT * from test_table WHERE value < 7) SELECT s.state, s.opened_at FROM s WHERE 1=1 AND state <> 'OPEN'");

Observe as the one time that you have these prepared statements with a gap in between them fails with that weird exception and the rest succeed. The same code works fine in 8.2.1 and we have not changed the postgres library during the upgrade. So regression is on questdb side, plz investigate!

QuestDB version:

8.2.2

OS, in case of Docker specify Docker and the Host OS:

Ubuntu 22.04 (Docker)

File System, in case of Docker specify Host File System:

ext4

Full Name:

Stanislav Simovski

Affiliation:

Solita Oy

Have you followed Linux, MacOs kernel configuration steps to increase Maximum open files and Maximum virtual memory areas limit?

  • Yes, I have

Additional context

The regression is present in 8.2.3 also

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions