From fef3ab89cb99cbc33756893e46d08051ba9d1d36 Mon Sep 17 00:00:00 2001 From: Puskar Basu Date: Thu, 28 Nov 2024 15:58:20 +0530 Subject: [PATCH] Fix issue where steampipe query was returning exit code 0 even when there was an error. Closes #4451 --- pkg/db/db_client/db_client_execute.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/db/db_client/db_client_execute.go b/pkg/db/db_client/db_client_execute.go index a9b5748389..94c0a17119 100644 --- a/pkg/db/db_client/db_client_execute.go +++ b/pkg/db/db_client/db_client_execute.go @@ -279,6 +279,12 @@ func (c *DbClient) startQuery(ctx context.Context, conn *pgx.Conn, query string, select { case <-doneChan: + // once we are done, Err() on the returned rows must be checked after the rows is closed to + // determine if the query executed successfully. + rows.Close() + if rows.Err() != nil { + err = rows.Err() + } case <-ctx.Done(): err = ctx.Err() }