Commit 38ab83c
fix(qwp): accept empty arrays in the egress result decoder (#50)
* fix(qwp): accept empty arrays in the egress result decoder
QuestDB emits a non-null empty array (cardinality 0) on QWP egress inline
with a 0-length dimension, distinct from a NULL array (carried in the null
bitmap). parseArrayColumn rejected dl < 1, so reading an empty array back
failed with "ARRAY dim N must be >= 1". Accept dl >= 0, keeping nDims >= 1
and a per-dimension cap so a 0 in one dimension cannot slip an arbitrary
value past the element-count cap. Flip the zero-dim hardening case to
assert the empty array decodes while a hostile oversized dim is still
rejected.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* Cap ARRAY dim at server's DIM_MAX_LEN
The egress decoder bounded each array dimension by MAX_ARRAY_ELEMENTS,
the total element-count cap. That value is 128 below DIM_MAX_LEN
((1 << 28) - 1), the server's per-dimension ceiling. For an empty
array the 0-length dimension drives the element-count product to 0,
so a sibling dimension is bounded only by the per-dimension check.
The old cap therefore rejected empty arrays carrying a dimension above
MAX_ARRAY_ELEMENTS but within DIM_MAX_LEN -- shapes the server can
build and emit, since it checks each dimension against DIM_MAX_LEN at
construction and applies no per-dimension cap when encoding egress.
Add MAX_ARRAY_DIM_LEN, mirroring the server's DIM_MAX_LEN, and bound
each dimension by it. The element-count product guard is unchanged, so
the payload still fits the int-addressed buffer and the product stays
within long range. A boundary test pins acceptance at DIM_MAX_LEN and
rejection one element past it.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 2f4d7c7 commit 38ab83c
2 files changed
Lines changed: 76 additions & 20 deletions
File tree
- core/src
- main/java/io/questdb/client/cutlass/qwp/client
- test/java/io/questdb/client/test/cutlass/qwp/client
Lines changed: 21 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
56 | 66 | | |
57 | 67 | | |
58 | 68 | | |
| |||
605 | 615 | | |
606 | 616 | | |
607 | 617 | | |
608 | | - | |
609 | | - | |
610 | | - | |
611 | | - | |
612 | | - | |
613 | | - | |
614 | | - | |
615 | | - | |
616 | | - | |
617 | | - | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
618 | 629 | | |
619 | 630 | | |
620 | 631 | | |
| |||
Lines changed: 55 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
63 | 61 | | |
64 | 62 | | |
65 | | - | |
| 63 | + | |
| 64 | + | |
66 | 65 | | |
67 | 66 | | |
68 | 67 | | |
69 | 68 | | |
70 | 69 | | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
71 | 110 | | |
72 | 111 | | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
73 | 118 | | |
74 | 119 | | |
75 | | - | |
| 120 | + | |
76 | 121 | | |
77 | 122 | | |
78 | 123 | | |
| |||
0 commit comments