FirebirdSQL / firebird

Firebird server, client and tools
https://www.firebirdsql.org/
1.22k stars 214 forks source link

The Large SQL crashes Firebird Server [CORE6536] #6763

Open firebird-automations opened 3 years ago

firebird-automations commented 3 years ago

Submitted by: Vadim Mescheryakov (vadimmescheryakov)

Attachments: create-database-script.sql Large Query.sql

The Large SQL with 10000 OR operators and the size above 137 kb crashes Firebird Server 3.0.1 and 3.0.7.33374_1. The Firebird Server version 2.5 shows only this error "Unsuccessful execution caused by an unavailable resource. Implementation limit exceeded. block size exceeds implementation restriction." and it stills working

firebird-automations commented 3 years ago

Commented by: Vadim Mescheryakov (vadimmescheryakov)

I attached two files for reproduction

firebird-automations commented 3 years ago
Modified by: Vadim Mescheryakov (vadimmescheryakov) Attachment: create\-database\-script\.sql \[ 13580 \] Attachment: Large Query\.sql \[ 13581 \]
firebird-automations commented 3 years ago

Commented by: @dyemanov

Looks like a duplicate for CORE6223 and CORE395. Binary operations (+ - * / AND OR) are parsed and evaluated recursively and stack size is a limited resource, thus causing a crash (or stack overflow error sometimes) when a number of arguments becomes too big.

firebird-automations commented 3 years ago

Commented by: Vadim Mescheryakov (vadimmescheryakov)

FB 2.5 copes well with this SQL

firebird-automations commented 3 years ago

Commented by: @dyemanov

AFAIU, it does not execute your query at all -- due to "block size exceeds implementation restriction" error.

firebird-automations commented 3 years ago

Commented by: Vadim Mescheryakov (vadimmescheryakov)

Yes. I meant "copes" in sense - Fb 2.5 doesn't crash, only returns error