Skip to content

DECLARE fails when defined twice, but error is misleading #6155

@javier

Description

@javier

To reproduce

This query is wrong because it is using DECLARE for each variable, rather than using it just once and comma separate all the variables. However, the SQL parser is not complaining about DECLARE not expected there, or being duplicate, but instead it is complaining that the variable @from_time is not being used, so it seems it is ignoring whatever it is before the last DECLARE.

DECLARE 
  @from_time := dateadd('h',-1,now()),
DECLARE @to_time := now()
WITH t as (    
  select now() as ts
 ) 
 select * from t where ts between @from_time and @to_time;

QuestDB version:

9.0.3

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

ubuntu, mac, demo instance

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

ext4

Full Name:

javier

Affiliation:

questdb

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

  • Yes, I have

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugIncorrect or unexpected behaviorSQLIssues or changes relating to SQL executionhacktoberfestA good issue for Hacktoberfest 2025 contributors. No AI-driven commits, pleaseinternalopen source

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions