{"record":{"id":"7f76b37dfcc8355f","repo":"googleapis/mcp-toolbox","slug":"unable-to-execute-query-w-7f76b3","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/singlestore/singlestore.go","lineNumber":118,"sourceCode":"}\n\nfunc (s *Source) SourceType() string {\n\treturn SourceType\n}\n\nfunc (s *Source) ToConfig() sources.SourceConfig {\n\treturn s.Config\n}\n\n// SingleStorePool returns the underlying *sql.DB connection pool for SingleStore.\nfunc (s *Source) SingleStorePool() *sql.DB {\n\treturn s.Pool\n}\n\nfunc (s *Source) RunSQL(ctx context.Context, statement string, params []any) (any, error) {\n\tresults, err := s.SingleStorePool().QueryContext(ctx, statement, params...)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"unable to execute query: %w\", err)\n\t}\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\tdefer results.Close()\n\n\tcolTypes, err := results.ColumnTypes()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"unable to get column types: %w\", err)","sourceCodeStart":100,"sourceCodeEnd":136,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/sources/singlestore/singlestore.go#L100-L136","documentation":"RunSQL wraps any error returned by sql.DB.QueryContext with this message. The pool accepted the query but the driver failed to execute it — this includes connection-level failures at query time as well as SQL syntax and permission errors reported by SingleStore. No rows are returned; the whole invocation fails.","triggerScenarios":"Calling the run-sql tool against a SingleStore source when the statement is invalid, the connection has dropped since initialization, the user lacks privileges, or params cannot be interpolated into the statement.","commonSituations":"Typos in SQL, referencing a non-existent table, executing DDL/DML without grants, using placeholder syntax the driver dislikes (should be `?`), or idle connection killed by a firewall between init and query.","solutions":["Run the exact statement in the `mysql` CLI against the same database to see the underlying SQL error.","Check the wrapped driver error in the message for the real cause (syntax, access denied, connection lost).","Use `?` placeholders for parameters and pass values via the tool's params field.","Ensure the configured user has privileges for the statement (SELECT/INSERT/DDL as needed).","If the error is connection-related, reinitialize the source or enable keepalives / tune readTimeout."],"exampleFix":"// before (invalid placeholder syntax)\n{\"statement\": \"SELECT * FROM t WHERE id = $1\", \"params\": [\"7\"]}\n// after\n{\"statement\": \"SELECT * FROM t WHERE id = ?\", \"params\": [\"7\"]}","handlingStrategy":"try-catch","validationCode":"// Validate the statement shape before invoking run-sql\nfunc validateStatement(stmt string) error {\n    s := strings.TrimSpace(stmt)\n    if s == \"\" { return errors.New(\"empty statement\") }\n    if strings.Contains(s, \"$\"+\"1\") || strings.Contains(s, \"%s\") { return errors.New(\"use ? placeholders\") }\n    return nil\n}","typeGuard":null,"tryCatchPattern":"result, err := source.RunSQL(ctx, stmt, params)\nif err != nil {\n    if strings.Contains(err.Error(), \"connection refused\") || strings.Contains(err.Error(), \"driver: bad connection\") {\n        // reconnect/reinitialize then retry once\n    }\n    return fmt.Errorf(\"run-sql failed: %w\", err)\n}","preventionTips":["Test statements in the mysql CLI first","Always use ? placeholders","Grant the configured user only the privileges it needs","Enable keepalives / sane readTimeout for long queries"],"tags":["singlestore","sql","query"],"backgroundTag":"sql-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"}