{"record":{"id":"6d1c1af27b013b01","repo":"risingwavelabs/risingwave","slug":"failed-to-run-the-query-0","errorCode":null,"errorMessage":"Failed to run the query: {0}","messagePattern":"Failed to run the query: (.+?)","errorType":"error_code","errorClass":"PsqlError","httpStatus":null,"severity":"error","filePath":"src/utils/pgwire/src/error.rs","lineNumber":44,"sourceCode":"pub enum PsqlError {\n    #[error(\"Failed to start a new session: {0}\")]\n    StartupError(\n        #[source]\n        #[backtrace]\n        BoxedError,\n    ),\n\n    #[error(\"Invalid password\")]\n    PasswordError,\n\n    #[error(\"Protocol violation: {0}\")]\n    ProtocolError(\n        #[source]\n        #[backtrace]\n        ProtocolViolationError,\n    ),\n\n    #[error(\"Failed to run the query: {0}\")]\n    SimpleQueryError(\n        #[source]\n        #[backtrace]\n        BoxedError,\n    ),\n\n    #[error(\"Failed to prepare the statement: {0}\")]\n    ExtendedPrepareError(\n        #[source]\n        #[backtrace]\n        BoxedError,\n    ),\n\n    #[error(\"Failed to execute the statement: {0}\")]\n    ExtendedExecuteError(\n        #[source]\n        #[backtrace]\n        BoxedError,","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/utils/pgwire/src/error.rs#L26-L62","documentation":"pgwire wraps errors raised while executing a simple-query (text protocol 'Q' message) into PsqlError::SimpleQueryError with this display message. The BoxedError source is the actual error from the frontend planner/executor (SQL syntax, permission, catalog errors, etc.).","triggerScenarios":"A client sends a simple query via psql or any driver using the text protocol, and query planning or execution in the frontend returns an error (parse failure, unhandled statement type, runtime failure).","commonSituations":"SQL syntax errors; unsupported statements sent via simple protocol; permission/catalog errors (missing table); frontend panics or timeouts surfaced during execution.","solutions":["Inspect the #[source] BoxedError for the concrete frontend error message.","Fix the SQL statement reported by the source error (syntax, object names, permissions).","Try the query via extended protocol/prepared statements to get richer error positioning if the message is unclear.","Check frontend/meta service logs for the corresponding query execution error."],"exampleFix":"// before: swallowing inner cause\nErr(PsqlError::SimpleQueryError(e)) => error!(\"query failed\");\n// after: surface the source\nErr(PsqlError::SimpleQueryError(e)) => error!(\"query failed: {e}; source: {:?}\", e.source());","handlingStrategy":"try-catch","validationCode":"// lint SQL with a parser before sending simple queries\nlet parsed = pg_query::parse(sql);\nif parsed.is_err() { return Err(\"invalid SQL syntax\"); }","typeGuard":"fn is_simple_query_error(e: &PsqlError) -> bool { matches!(e, PsqlError::SimpleQueryError(_)) }","tryCatchPattern":"match client.simple_query(sql).await {\n    Err(e) if is_simple_query_error(&e) => { log::error!(\"query failed: {e}; cause: {:?}\", e.source()); surface_to_user(e); }\n    other => other,\n}","preventionTips":["Validate SQL syntax and object names before execution.","Grant required permissions to the connecting user up front.","Split large multi-statement scripts so failures are attributable per statement."],"tags":["pgwire","sql","query-execution"],"backgroundTag":"sql-query-failed","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"}