diff --git a/mongoerrors.csv b/mongoerrors.csv index 32f938fa..ba4119b9 100644 --- a/mongoerrors.csv +++ b/mongoerrors.csv @@ -184,6 +184,7 @@ Location31109,31109,183 Location31119,31119,184 Location31120,31120,185 Location31138,31138,186 +Location31170,31170,490 Location31249,31249,187 Location31250,31250,188 Location31253,31253,189 diff --git a/pg_helio_api/src/commands/coll_stats.c b/pg_helio_api/src/commands/coll_stats.c index 34e4955e..36797f2d 100644 --- a/pg_helio_api/src/commands/coll_stats.c +++ b/pg_helio_api/src/commands/coll_stats.c @@ -191,6 +191,14 @@ command_coll_stats_aggregation(PG_FUNCTION_ARGS) { /* This is fine: validate */ EnsureTopLevelFieldValueType("$collStats.count", value, BSON_TYPE_DOCUMENT); + if (!IsBsonValueEmptyDocument(value)) + { + ereport(ERROR, (errcode(ERRCODE_HELIO_LOCATION31170), + errmsg("expected an empty object, but got %s", + BsonValueToJsonForLogging(value)), + errdetail_log( + "expected an empty object for `count` in $collStats"))); + } aggregateMode |= CollStatsAggMode_Count; } else if (strcmp(key, "queryExecStats") == 0) diff --git a/pg_helio_core/include/utils/helio_codes.txt b/pg_helio_core/include/utils/helio_codes.txt index cabf82ab..c90b7574 100644 --- a/pg_helio_core/include/utils/helio_codes.txt +++ b/pg_helio_core/include/utils/helio_codes.txt @@ -488,3 +488,4 @@ Location5624901,M00DH,5624901,486 Location6050202,M00DI,6050202,487 Location6050204,M00DJ,6050204,488 Location5788604,M00DK,5788604,489 +Location31170,M00DL,31170,490 diff --git a/pg_helio_core/include/utils/helio_errors.h b/pg_helio_core/include/utils/helio_errors.h index 527071f3..2460ad54 100644 --- a/pg_helio_core/include/utils/helio_errors.h +++ b/pg_helio_core/include/utils/helio_errors.h @@ -1533,4 +1533,7 @@ typedef int HelioErrorEreportCode; #define ERRCODE_HELIO_LOCATION5788604 MAKE_SQLSTATE('M', '0', '0', 'D', 'K') #define MONGO_CODE_LOCATION5788604 5788604 +#define ERRCODE_HELIO_LOCATION31170 MAKE_SQLSTATE('M', '0', '0', 'D', 'L') +#define MONGO_CODE_LOCATION31170 31170 + #endif