Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

fix: do not set limit for non query statement (#14247)

h3n4l08e0940b986d
diff --git a/backend/plugin/db/pg/pg.go b/backend/plugin/db/pg/pg.go
index cdce89a403..9099f47e0e 100644
--- a/backend/plugin/db/pg/pg.go
+++ b/backend/plugin/db/pg/pg.go
@@ -659,7 +659,11 @@ func (driver *Driver) QueryConn(ctx context.Context, conn *sql.Conn, statement s
if queryContext.Explain {
statement = fmt.Sprintf("EXPLAIN %s", statement)
} else if queryContext.Limit > 0 {
- statement = getStatementWithResultLimit(statement, queryContext.Limit)
+ // Quick fix for do not add limit to non-select statement.
+ t := util.TrimStatement(statement)
+ if strings.HasPrefix(strings.ToUpper(t), "SELECT") || strings.HasPrefix(strings.ToUpper(t), "WITH") {
+ statement = getStatementWithResultLimit(statement, queryContext.Limit)
+ }
}
_, allQuery, err := base.ValidateSQLForEditor(storepb.Engine_POSTGRES, statement)