rqlite/rqlite · error

${res[i].Error}

Error message

${res[i].Error}

What it means

When collecting PRAGMA values into a map (db.go:1905), the code runs a batched query and checks each result for a per-row Error string; the first non-empty one is returned verbatim as a Go error. The message equals the SQLite error text stored in res[i].Error, so it is dynamic and points at the specific PRAGMA that failed.

Source

Thrown at db/db.go:1905

		"hard_heap_limit",
		"soft_heap_limit",
		"cache_size",
		"freelist_count",
	}
	stmts := make([]*command.Statement, len(pragmas))
	for i, p := range pragmas {
		stmts[i] = &command.Statement{
			Sql: fmt.Sprintf("PRAGMA %s", p),
		}
	}
	req := &command.Request{Statements: stmts}
	res, err := db.Query(req, false)
	if err != nil {
		return nil, err
	}
	for i, p := range pragmas {
		if res[i].Error != "" {
			return nil, errors.New(res[i].Error)
		}
		ms[p] = res[i].Values[0].Parameters[0].GetI()
	}
	return ms, nil
}

// qualifyRowColumns prefixes each column name in rows with its originating table name.
func qualifyRowColumns(conn *sql.Conn, query string, rows *command.QueryRows) error {
	if len(rows.Columns) == 0 {
		return nil
	}

	var tableNames []string
	err := conn.Raw(func(driverConn any) error {
		sqliteConn := driverConn.(*sqlite3.SQLiteConn)
		stmt, err := sqliteConn.Prepare(query)
		if err != nil {
			return err

View on GitHub (pinned to 7586a4d1bd)

Solutions

  1. Inspect the returned message (it is res[i].Error) and correlate it with the pragma at index i in the request list.
  2. Remove or correct the unsupported/misspelled PRAGMA in the request list.
  3. If transient (e.g. locked db), retry once the database is idle; check for checkpoint/backup activity.
Defensive patterns

Strategy: type-guard

Validate before calling

for i, r := range res {
  if r.GetError() != "" {
    return fmt.Errorf("pragma %q failed: %s", pragmas[i], r.GetError())
  }
}

Type guard

func pragmaResultsOK(res []*command.QueryRow, pragmas []string) error {
  for i, r := range res {
    if r.GetError() != "" { return fmt.Errorf("pragma %q: %s", pragmas[i], r.GetError()) }
  }
  return nil
}

Try / catch

ms, err := helperPragmas(req)
if err != nil {
  // message is the raw SQLite error from one pragma; identify which and fix or drop it
}

Prevention

When it happens

Trigger: Calling the PRAGMA-collection helper (used for status/introspection like pragma journal_mode, page_size, etc.) when one of the PRAGMA statements in the batch fails — e.g. an unsupported PRAGMA name or a locked/failed database handle.

Common situations: Requesting a PRAGMA not supported by the linked SQLite build; calling during a transient database error; status endpoints surfacing a failed pragma after a restore or hot-backup operation.

Related errors


AI-assisted analysis of rqlite/rqlite@7586a4d1bd (2026-09-03). Data as JSON: /api/errors/e2da41fa629c0d4c. Report an issue: GitHub.