googleapis/mcp-toolbox · error

unable to execute query: %w

Error message

unable to execute query: %w

What it means

QueryContext failed executing the statement in RunSQL — TiDB rejected the SQL (syntax, unknown table, permissions) or the connection dropped before results were produced.

Source

Thrown at internal/sources/tidb/tidb.go:116

	return false
}

func (s *Source) SourceType() string {
	return SourceType
}

func (s *Source) ToConfig() sources.SourceConfig {
	return s.Config
}

func (s *Source) TiDBPool() *sql.DB {
	return s.Pool
}

func (s *Source) RunSQL(ctx context.Context, statement string, params []any) (any, error) {
	results, err := s.TiDBPool().QueryContext(ctx, statement, params...)
	if err != nil {
		return nil, fmt.Errorf("unable to execute query: %w", err)
	}

	cols, err := results.Columns()
	if err != nil {
		return nil, fmt.Errorf("unable to retrieve rows column name: %w", err)
	}

	// create an array of values for each column, which can be re-used to scan each row
	rawValues := make([]any, len(cols))
	values := make([]any, len(cols))
	for i := range rawValues {
		values[i] = &rawValues[i]
	}
	defer results.Close()

	colTypes, err := results.ColumnTypes()
	if err != nil {
		return nil, fmt.Errorf("unable to get column types: %w", err)

View on GitHub (pinned to 8cc6e09de2)

Solutions

  1. Check the SQL syntax and referenced tables
  2. Verify user privileges on the database
  3. Retry on transient connection errors
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at internal/sources/tidb/tidb.go:116 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of googleapis/mcp-toolbox@8cc6e09de2 (2026-09-05). Data as JSON: /api/errors/99c054bf52c2497b. Report an issue: GitHub.