{"record":{"id":"2640745e02680dd1","repo":"googleapis/mcp-toolbox","slug":"unable-to-execute-query-w-264074","errorCode":null,"errorMessage":"unable to execute query: %w","messagePattern":"unable to execute query: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/sources/clickhouse/clickhouse.go","lineNumber":115,"sourceCode":"\treturn SourceType\n}\n\nfunc (s *Source) ToConfig() sources.SourceConfig {\n\treturn s.Config\n}\n\nfunc (s *Source) ClickHousePool() *sql.DB {\n\treturn s.Pool\n}\n\nfunc (s *Source) RunSQL(ctx context.Context, statement string, params parameters.ParamValues) (any, error) {\n\tvar sliceParams []any\n\tif params != nil {\n\t\tsliceParams = params.AsSlice()\n\t}\n\tresults, err := s.ClickHousePool().QueryContext(ctx, statement, sliceParams...)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"unable to execute query: %w\", err)\n\t}\n\tdefer results.Close()\n\n\tcols, err := results.Columns()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"unable to retrieve rows column name: %w\", err)\n\t}\n\n\t// create an array of values for each column, which can be re-used to scan each row\n\trawValues := make([]any, len(cols))\n\tvalues := make([]any, len(cols))\n\tfor i := range rawValues {\n\t\tvalues[i] = &rawValues[i]\n\t}\n\n\tcolTypes, err := results.ColumnTypes()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"unable to get column types: %w\", err)","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/sources/clickhouse/clickhouse.go#L97-L133","documentation":"RunSQL executes the statement through the pool's QueryContext. Any error returned by the driver during query execution is wrapped as 'unable to execute query', preserving the original via %w.","triggerScenarios":"Calling RunSQL with an invalid SQL statement, syntax error, missing table/column, insufficient permissions, or a connection dropped mid-query.","commonSituations":"Typos in SQL, referencing non-existent tables, ClickHouse rejecting the query syntax, auth failures, query size/limits exceeded.","solutions":["Unwrap the error to see ClickHouse's server-side message.","Test the statement directly in clickhouse-client.","Verify table/column names and permissions for the configured user.","Check the connection is still alive (server may have closed it)."],"exampleFix":"// before\n\"SELECT * FORM my_table\"\n// after\n\"SELECT * FROM my_table\"","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"rows, err := src.RunSQL(ctx, stmt)\nif err != nil {\n    if strings.Contains(err.Error(), \"unable to execute query\") {\n        return fmt.Errorf(\"sql rejected: %w\", err)\n    }\n    return err\n}","preventionTips":["Test SQL in clickhouse-client before deployment.","Verify user permissions on target tables.","Keep statements syntactically valid for your server version."],"tags":["clickhouse","query","execution"],"backgroundTag":"query-execution-failed","analyzedSha":"8cc6e09de2ad7b8bffc77751799585a1401a48eb","analyzedAt":"2026-09-05T01:10:36.887Z","contentChangedAt":"2026-09-05T01:10:36.887Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}