{"record":{"id":"e2053a3b1b908954","repo":"risingwavelabs/risingwave","slug":"no-affected-rows-in-output","errorCode":null,"errorMessage":"no affected rows in output","messagePattern":"no affected rows in output","errorType":"exception","errorClass":"PsqlError","httpStatus":null,"severity":"error","filePath":"src/utils/pgwire/src/pg_protocol.rs","lineNumber":957,"sourceCode":"                        .await?;\n                    rows_cnt += 1;\n                }\n            }\n\n            // Run the callback before sending the `CommandComplete` message.\n            res.run_callback().await?;\n\n            self.stream\n                .write_no_flush(BeMessage::CommandComplete(BeCommandCompleteMessage {\n                    stmt_type: res.stmt_type(),\n                    rows_cnt,\n                }))?;\n        } else if res.stmt_type().is_dml() && !res.stmt_type().is_returning() {\n            let first_row_set = res.values_stream().next().await;\n            let first_row_set = match first_row_set {\n                None => {\n                    return Err(PsqlError::Uncategorized(\n                        anyhow::anyhow!(\"no affected rows in output\").into(),\n                    ));\n                }\n                Some(row) => row.map_err(PsqlError::SimpleQueryError)?,\n            };\n            let affected_rows_str = first_row_set[0].values()[0]\n                .as_ref()\n                .expect(\"compute node should return affected rows in output\");\n\n            assert!(matches!(res.row_cnt_format(), Some(Format::Text)));\n            let affected_rows_cnt = String::from_utf8(affected_rows_str.to_vec())\n                .unwrap()\n                .parse()\n                .unwrap_or_default();\n\n            // Run the callback before sending the `CommandComplete` message.\n            res.run_callback().await?;\n\n            self.stream","sourceCodeStart":939,"sourceCodeEnd":975,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/utils/pgwire/src/pg_protocol.rs#L939-L975","documentation":"For DML statements without RETURNING, `inner_process_query_msg_one_stmt` expects the first row set of the simple-query response to contain the affected-rows count (as produced by the `pg affected rows` statement). If the values stream yields nothing, the protocol layer cannot report a row count and returns this `PsqlError::Uncategorized`.","triggerScenarios":"Executing an INSERT/UPDATE/DELETE via pgwire where the batch engine produces no row set for the affected-rows output — e.g. internal executor bug, statement misclassified as DML, or empty result from `values_stream()`.","commonSituations":"Client running simple-protocol DML through a proxy or tool against a RisingWave version with an affected-rows regression; hitting an unhandled statement type reported as DML.","solutions":["Upgrade RisingWave to the latest version (likely an internal bug fixed upstream).","Check which statement triggered it and try running it via extended protocol (prepared statement) or psql to reproduce.","Report/inspect the statement type: verify the DML classification in the frontend for that SQL.","As a workaround, add RETURNING or restructure the statement so a row set is produced."],"exampleFix":"null","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"match run_dml(stmt) {\n    Err(PsqlError::Uncategorized(e)) if e.to_string().contains(\"no affected rows in output\") => {\n        log::error!(\"affected-rows row set missing for {stmt}; check RW version\");\n    }\n    other => other?,\n}","preventionTips":["Keep RisingWave updated — this is an internal invariant bug, not user error.","Test DML paths of your client tooling against the target RW version.","Prefer extended protocol for DML if simple protocol misbehaves."],"tags":["rust","pgwire","dml","batch"],"backgroundTag":"empty-result-set","analyzedSha":"6469eb736d691e8e9b8a419a57edd6429ca77417","analyzedAt":"2026-09-11T21:06:21.487Z","contentChangedAt":"2026-09-11T21:06:21.487Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}