Skip to content

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

fix: exp check proto size (#12192)

Danny Xua192825a9bee
diff --git a/backend/plugin/db/bigquery/bigquery.go b/backend/plugin/db/bigquery/bigquery.go
index f2c740d474..e7d6b4143b 100644
--- a/backend/plugin/db/bigquery/bigquery.go
+++ b/backend/plugin/db/bigquery/bigquery.go
@@ -245,8 +245,8 @@ func (d *Driver) querySingleSQL(ctx context.Context, statement string) (*v1pb.Qu
row.Values = append(row.Values, convertValue(v, fieldTypes[i]))
}
result.Rows = append(result.Rows, row)
-
- if proto.Size(result) > common.MaximumSQLResultSize {
+ n := len(result.Rows)
+ if (n&(n-1) == 0) && proto.Size(result) > common.MaximumSQLResultSize {
result.Error = common.MaximumSQLResultSizeExceeded
result.Latency = durationpb.New(time.Since(startTime))
return result, nil
diff --git a/backend/plugin/db/clickhouse/clickhouse.go b/backend/plugin/db/clickhouse/clickhouse.go
index 12b125cce1..9849b52170 100644
--- a/backend/plugin/db/clickhouse/clickhouse.go
+++ b/backend/plugin/db/clickhouse/clickhouse.go
@@ -508,7 +508,8 @@ func readRowsForClickhouse(result *v1pb.QueryResult, rows *sql.Rows, columnTypes
}
result.Rows = append(result.Rows, &rowData)
- if proto.Size(result) > common.MaximumSQLResultSize {
+ n := len(result.Rows)
+ if (n&(n-1) == 0) && proto.Size(result) > common.MaximumSQLResultSize {
result.Error = common.MaximumSQLResultSizeExceeded
return nil
}
diff --git a/backend/plugin/db/hive/hive.go b/backend/plugin/db/hive/hive.go
index b8d9603aca..ac21d109b2 100644
--- a/backend/plugin/db/hive/hive.go
+++ b/backend/plugin/db/hive/hive.go
@@ -240,7 +240,8 @@ func runSingleStatement(ctx context.Context, conn *gohive.Connection, statement
// Rows.
result.Rows = append(result.Rows, &queryRow)
- if proto.Size(result) > common.MaximumSQLResultSize {
+ n := len(result.Rows)
+ if (n&(n-1) == 0) && proto.Size(result) > common.MaximumSQLResultSize {
result.Error = common.MaximumSQLResultSizeExceeded
result.Latency = durationpb.New(time.Since(startTime))
return result, nil
diff --git a/backend/plugin/db/redis/redis.go b/backend/plugin/db/redis/redis.go
index 8f223dd5c6..4d84779ce9 100644
--- a/backend/plugin/db/redis/redis.go
+++ b/backend/plugin/db/redis/redis.go
@@ -259,7 +259,8 @@ func setQueryResultRows(result *v1pb.QueryResult, cmd *redis.Cmd) {
if ok {
for i, v := range l {
result.Rows = append(result.Rows, getResultRow(i+1, v))
- if proto.Size(result) > common.MaximumSQLResultSize {
+ n := len(result.Rows)
+ if (n&(n-1) == 0) && proto.Size(result) > common.MaximumSQLResultSize {
result.Error = common.MaximumSQLResultSizeExceeded
return
}
diff --git a/backend/plugin/db/spanner/spanner.go b/backend/plugin/db/spanner/spanner.go
index 2f7fd4c728..d7b2cb6cc2 100644
--- a/backend/plugin/db/spanner/spanner.go
+++ b/backend/plugin/db/spanner/spanner.go
@@ -320,7 +320,8 @@ func (d *Driver) querySingleSQL(ctx context.Context, statement string) (*v1pb.Qu
return nil, err
}
result.Rows = append(result.Rows, rowData)
- if proto.Size(result) > common.MaximumSQLResultSize {
+ n := len(result.Rows)
+ if (n&(n-1) == 0) && proto.Size(result) > common.MaximumSQLResultSize {
result.Error = common.MaximumSQLResultSizeExceeded
result.Latency = durationpb.New(time.Since(startTime))
return result, nil
diff --git a/backend/plugin/db/util/driverutil.go b/backend/plugin/db/util/driverutil.go
index b855b9c91c..2d53fbbcac 100644
--- a/backend/plugin/db/util/driverutil.go
+++ b/backend/plugin/db/util/driverutil.go
@@ -226,7 +226,8 @@ func readRows(result *v1pb.QueryResult, dbType storepb.Engine, rows *sql.Rows, c
}
result.Rows = append(result.Rows, &rowData)
- if proto.Size(result) > common.MaximumSQLResultSize {
+ n := len(result.Rows)
+ if (n&(n-1) == 0) && proto.Size(result) > common.MaximumSQLResultSize {
result.Error = common.MaximumSQLResultSizeExceeded
return nil
}