mirror of
https://github.com/taosdata/TDengine
synced 2026-05-24 10:09:01 +00:00
* fix(scalar): prevent crash when IN expression has invalid type from unhandled node
Root cause: sclGetNodeType() silently set *type = -1 and returned
TSDB_CODE_SUCCESS for unhandled node types. This propagated -1 as
ctx->type.selfType, which was then cast to (uint32_t)-1 = 4294967295
and used as an index into tDataTypes[], causing an out-of-bounds
crash in scalarGenerateSetFromList().
The bug was triggered by semantically odd SQL such as:
ifnull(b not between vb and a, n in (...)) in (today(), today(), now())
where a boolean result is compared against a timestamp list.
Fixes:
1. sclGetNodeType(): return TSDB_CODE_QRY_INVALID_INPUT for unhandled
node types instead of silently setting type = -1.
2. sclInitParam(): validate selfType before using it as list element
type to prevent OOB access in vectorGetConvertType(-1, ...).
3. scalarGenerateSetFromList(): add IS_INVALID_TYPE() guard at entry
as a defensive check against any future invalid-type paths.
Add regression test: test_scalar_invalid_type.py
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* fix: case when and decimal query crash issues
* fix: CAST to JSON returns Unknown error 65535; mavg/csum/diff with constant arg returns invalid input
- builtins.c: reject CAST(expr AS JSON) in translateCast() with
TSDB_CODE_CAST_TO_JSON_NOT_ALLOWED instead of silently passing
validation and failing at execution with TSDB_CODE_FAILED (-1)
- scalar.c: add QUERY_NODE_LEFT_VALUE case in sclGetNodeType() so
rewritten constant operands (ASSIGN operator left side) resolve
their type from ctx->type.opResType instead of hitting the
'unsupported node type' fallthrough (error 0x070F invalid input)
- executorInt.c: create dummy column for the first arg of indefinite-
rows functions when it is a constant, preventing NULL pData[0]
- test_fun_sca_cast.py: add do_cast_to_json_invalid() covering all
19 sql-fuzzing repro queries for the CAST-to-JSON bug
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* fix: sclGetNodeType missing cases cause invalid input in query/subquery
Add missing node type cases to sclGetNodeType() that were hit after
|
||
|---|---|---|
| .. | ||
| inc | ||
| src | ||
| test | ||
| CMakeLists.txt | ||