Skip to content

fix(pgwire): answer kv writes with one INSERT tag - #326

Open
EnRaiha wants to merge 1 commit into
NodeDB-Lab:mainfrom
EnRaiha:fix/kv-insert-tag
Open

EnRaiha wants to merge 1 commit into
NodeDB-Lab:mainfrom
EnRaiha:fix/kv-insert-tag

Conversation

@EnRaiha

@EnRaiha EnRaiha commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

Summary

kv INSERT and PUT writes reported no affected count, so pgwire emitted a bare OK; a client reads that as zero rows written. Separately, routed response-shaper errors were flattened to XX000 at each pgwire shaper call site even when the error already carried a classifying numeric code.

  • report affected = 1 in execute_kv_insert and execute_kv_put, and map KvOp::Insert, KvOp::Put, KvOp::BatchPut to the INSERT tag (response_shape/types.rs, kv/crud/write_basic.rs);
  • route the pgwire shaper call sites through numeric_code_to_sqlstate (pgwire/types/error_map.rs plus the six routing sites) and add the read-path arms it was missing: UNDEFINED_OBJECT, OBJECT_NOT_READY, NOT_FOUND, DATABASE_NOT_FOUND, SQL_NOT_ENABLED, TYPE_MISMATCH, OVERFLOW.

Red proof (the test fails on main without the fix)

panicked at nodedb/tests/wire/cases/sql_dml_affected_counts.rs:302:5:
assertion `left == right` failed: a KV INSERT that wrote one key must report 1, not a bare tag the client reads as 0
  left: 0
 right: 1

Validation (local, on this branch)

Check Result
the four tests in this PR (error_map ×2, kv affected counts ×2) 4 passed
cargo fmt --all clean
cargo clippy -p nodedb --all-targets --all-features --profile ci -- -D warnings clean
repository hygiene gate (test registry, comment and commit hygiene, module contracts) pass

One commit; no changes outside the files listed above.

kv insert and put report affected = 1, so pgwire emits one INSERT 0 1 tag instead of a bare OK; routed response-shaper errors keep their own numeric sqlstate class through numeric_code_to_sqlstate instead of a hardcoded XX000.
Copilot AI lite review requested due to automatic review settings September 16, 2026 06:42

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants