You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pr@cassandra.apache.org by "dipAch (via GitHub)" <gi...@apache.org> on 2026/10/11 08:28:43 UTC
[PR] Prepared statement metadata no longer reports NOT IN, !=, slice, and LIKE bind markers on a partition key as partition key bind indexes [cassandra]
dipAch opened a new pull request, #5249:
URL: https://github.com/apache/cassandra/pull/5249
## Summary
`VariableSpecifications#getPartitionKeyBindVariableIndexes()` only tracks "which column does this bind marker target," not which operator the relation used. `Relation#toRestriction()` handed every single-column restriction's bind marker the real `ColumnMetadata` receiver regardless of operator, so a `NOT IN`, `!=`, slice (`<`, `<=`, `>`, `>=`, `BETWEEN`), or `LIKE` bind marker on a partition key column was indistinguishable from an `EQ`/`IN` one, and got reported to clients as safe for token-aware routing even though its bound value does not identify the partition being queried. Token-aware drivers using this metadata would route such requests to the wrong replica.
Only `EQ` and single/multi-value `IN` restrict a column to a value it must equal; every other operator excludes a value, bounds a range, or matches a pattern. This was found to affect every such operator on a bare partition key column, not just `NOT IN` as described in the ticket title.
## Fix
In `Relation#toRestriction()`, only keep the real `ColumnMetadata` receiver (which makes a bind marker eligible for partition-key routing metadata) for `operator == EQ || operator.isIN()`. Every other operator gets a plain `ColumnSpecification` wrapper with the same name/type instead, so `VariableSpecifications` never tracks it as a routing candidate. This is allowlist-based rather than a per-operator denylist, so it is safe against future new operators too.
## Test plan
- [x] New unit test `PartitionKeyBindVariableIndexesTest` covering `EQ`/`IN` (unchanged), `NOT IN` (single and multi-value), every other non-exact-value operator found by an empirical audit (`!=`, `<`, `<=`, `>`, `>=`, `BETWEEN`, `LIKE`), and a composite partition key with one non-exact-value column.
- [x] `SelectSingleColumnRelationTest`, `SelectMultiColumnRelationTest`, `ClusteringColumnRestrictionsTest`, `PreparedStatementsTest` all pass unmodified.
- [x] `.build/check-code.sh` (checkstyle + RAT) passes clean.
CASSANDRA-21740
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
Re: [PR] [CASSANDRA-21740] Prepared statement metadata no longer reports NOT IN, !=, slice, and LIKE bind markers on a partition key as partition key bind indexes [cassandra]
Posted by "smiklosovic (via GitHub)" <gi...@apache.org>.
smiklosovic commented on PR #5249:
URL: https://github.com/apache/cassandra/pull/5249#issuecomment-6364891506
nice, we need patches for 4.0 and 5.0 where it is related.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
Re: [PR] [CASSANDRA-21740] Prepared statement metadata no longer reports NOT IN, !=, slice, and LIKE bind markers on a partition key as partition key bind indexes [cassandra]
Posted by "dipAch (via GitHub)" <gi...@apache.org>.
dipAch closed pull request #5249: [CASSANDRA-21740] Prepared statement metadata no longer reports NOT IN, !=, slice, and LIKE bind markers on a partition key as partition key bind indexes
URL: https://github.com/apache/cassandra/pull/5249
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
Re: [PR] [CASSANDRA-21740] Prepared statement metadata no longer reports NOT IN, !=, slice, and LIKE bind markers on a partition key as partition key bind indexes [cassandra]
Posted by "dipAch (via GitHub)" <gi...@apache.org>.
dipAch commented on PR #5249:
URL: https://github.com/apache/cassandra/pull/5249#issuecomment-6107400182
Closing and reopening to retrigger title/Jira-link automation after fixing the PR title to include the CASSANDRA-21740 bracket prefix.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org