fix(spec): reject a non-positive or non-integer bucket number - #956
jackylee-ch wants to merge 2 commits into
Conversation
543fa8a to
721a86e
Compare
|
Production review found one P2 validation gap in The new validator trims the value before parsing, but I reproduced this through a native primary-key table: create with Validation: all 128 existing schema/schema-change tests passed; the additional real write/commit/read probe reproduced the mismatch. Please add coverage that checks the resulting bucket mode, including the alter-options path. |
`CoreOptions::bucket()` parses the option with `unwrap_or(DEFAULT_BUCKET)`, so `bucket=0` was taken verbatim (silently disabling read-side bucket pruning) and a non-integer such as `bucket=abc` silently fell back to dynamic (-1) instead of the fixed bucketing the user asked for. Validate the option at create/alter time, mirroring Java `validateBucket`: allow -1 (dynamic), -2 (postpone) and any value >= 1; reject 0, values <= -3, and non-integers with a clear error.
`validate_bucket_count` trimmed the value before parsing, but `CoreOptions::bucket()` parses the raw persisted string without trimming and falls back to -1 on failure. So `bucket=' 4 '` passed create/alter validation yet selected dynamic bucketing at runtime — the exact silent fallback this validator aims to prevent, reachable through the newly accepted padded input. Parse the raw value the same way `bucket()` does (no trim), so a value the runtime cannot parse is rejected up front. Added coverage that a padded value is rejected while the runtime reads it as -1, and that the accepted spelling runs as the requested fixed count.
721a86e to
dc58f19
Compare
|
Addressed.
This runs on both create and alter: Regression Rebased onto current main. The schema |
CoreOptions::bucket()parses thebucketoption withunwrap_or(DEFAULT_BUCKET), so a bad value never surfaced:bucket=0was taken verbatim (silently turning off read-side bucket pruning), and a non-integer likebucket=abcsilently fell back to dynamic bucketing (-1) instead of the fixed bucketing the user intended.This validates the option at create/alter time, mirroring Java
SchemaValidation.validateBucket: -1 (dynamic), -2 (postpone) and any value >= 1 are allowed; 0, values <= -3, and non-integers are rejected with a clear error. (The Javabucket=-1+bucket-keyarm is left to the existing bucket-key validation.)Tests cover the 0 / non-integer rejections and the accepted -1 / -2 / >=1 values.