Skip to content

Query parameters fail with some escape sequences #70240

@al13n321

Description

@al13n321

This works:

:) select 'hello\nworld'

SELECT 'hello\nworld'

Query id: f8ab4b49-3cf0-4baa-b16e-948c77c24509

   ┌─'hello\nworld'─┐
1. │ hello
world     │
   └────────────────┘

1 row in set. Elapsed: 0.002 sec.

But this doesn't:

:) set param_a = 'hello\nworld'

SET param_a = 'hello\nworld'

Query id: 0bc67eea-0ef3-4359-8f4a-8fdda793f754

Ok.

0 rows in set. Elapsed: 0.001 sec. 

:) select {a: String}

SELECT {a:String}

Query id: 27496ba6-0e00-4b89-a4af-b4b14b7ecd78


Elapsed: 0.002 sec. 

Received exception from server (version 24.10.1):
Code: 457. DB::Exception: Received from localhost:9000. DB::Exception: Value hello
world cannot be parsed as String for query parameter 'a' because it isn't parsed completely: only 5 of 11 bytes was parsed: hello. (BAD_QUERY_PARAMETER)

Same for \t:

:) set param_a = 'hello\tworld'

SET param_a = 'hello\tworld'

Query id: cc8cc949-bd8d-4eda-9a3a-79a83af28023

Ok.

0 rows in set. Elapsed: 0.001 sec. 

:) select {a: String}

SELECT {a:String}

Query id: f685c623-b1d7-4933-9478-4522da4be428


Elapsed: 0.002 sec. 

Received exception from server (version 24.10.1):
Code: 457. DB::Exception: Received from localhost:9000. DB::Exception: Value hello      world cannot be parsed as String for query parameter 'a' because it isn't parsed completely: only 5 of 11 bytes was parsed: hello. (BAD_QUERY_PARAMETER)

But \\ works:

:) set param_a = 'hello\\world'

SET param_a = 'hello\\world'

Query id: 8a963a2d-56aa-4bfe-b7b3-fd2854b14231

Ok.

0 rows in set. Elapsed: 0.001 sec. 

:) select {a: String}

SELECT {a:String}

Query id: ffb740a9-7b3f-4c2a-9b0d-1b272250810d

   ┌─'hello\\world'─┐
1. │ hello\world    │
   └────────────────┘

1 row in set. Elapsed: 0.002 sec. 

Is this a bug, or is there some logic behind it? I would expect any valid string literal to be usable as parameter value.

Metadata

Metadata

Assignees

No one assigned

    Labels

    unexpected behaviourResult is unexpected, but not entirely wrong at the same time.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions