1
0
mirror of https://github.com/rancher/steve.git synced 2025-09-16 15:29:04 +00:00

vai: do not discard closing statement errors (#462)

This commit is contained in:
Silvio Moioli
2025-02-07 08:31:08 +01:00
committed by GitHub
parent 772dc7577e
commit 9139e492e0
2 changed files with 23 additions and 7 deletions

View File

@@ -454,13 +454,17 @@ func (l *ListOptionIndexer) constructQuery(lo ListOptions, partitions []partitio
return queryInfo, nil
}
func (l *ListOptionIndexer) executeQuery(ctx context.Context, queryInfo *QueryInfo) (*unstructured.UnstructuredList, int, string, error) {
func (l *ListOptionIndexer) executeQuery(ctx context.Context, queryInfo *QueryInfo) (result *unstructured.UnstructuredList, total int, token string, err error) {
stmt := l.Prepare(queryInfo.query)
defer l.CloseStmt(stmt)
defer func() {
cerr := l.CloseStmt(stmt)
if cerr != nil {
err = errors.Join(err, &db.QueryError{QueryString: queryInfo.query, Err: cerr})
}
}()
var items []any
var total int
err := l.WithTransaction(ctx, false, func(tx transaction.Client) error {
err = l.WithTransaction(ctx, false, func(tx transaction.Client) error {
txStmt := tx.Stmt(stmt)
rows, err := txStmt.QueryContext(ctx, queryInfo.params...)
if err != nil {
@@ -474,7 +478,12 @@ func (l *ListOptionIndexer) executeQuery(ctx context.Context, queryInfo *QueryIn
total = len(items)
if queryInfo.countQuery != "" {
countStmt := l.Prepare(queryInfo.countQuery)
defer l.CloseStmt(countStmt)
defer func() {
cerr := l.CloseStmt(countStmt)
if cerr != nil {
err = errors.Join(err, &db.QueryError{QueryString: queryInfo.countQuery, Err: cerr})
}
}()
txStmt := tx.Stmt(countStmt)
rows, err := txStmt.QueryContext(ctx, queryInfo.countParams...)
if err != nil {