MCPcopy Create free account
hub / github.com/documentdb/documentdb / command_coll_stats

Function command_coll_stats

pg_documentdb/src/commands/coll_stats.c:106–141  ·  view source on GitHub ↗

* command_coll_stats is the implementation of the internal logic for * dbcommand/collStats. */

Source from the content-addressed store, hash-verified

104 * dbcommand/collStats.
105 */
106Datum
107command_coll_stats(PG_FUNCTION_ARGS)
108{
109 if (PG_ARGISNULL(0))
110 {
111 ereport(ERROR, (errmsg("Database name must not be NULL")));
112 }
113 Datum databaseName = PG_GETARG_DATUM(0);
114
115 if (PG_ARGISNULL(1))
116 {
117 ereport(ERROR, (errmsg("collection name cannot be NULL")));
118 }
119 Datum collectionName = PG_GETARG_DATUM(1);
120
121 if (PG_ARGISNULL(2))
122 {
123 /* Scale is optional in the collStats command but here
124 * the sql method must provide scale to this C func */
125 ereport(ERROR, (errmsg("scale cannot be NULL")));
126 }
127 double scaleDouble = PG_GETARG_FLOAT8(2);
128
129 ReportFeatureUsage(FEATURE_COMMAND_COLLSTATS);
130
131 /* Truncate the fractional part of the scale */
132 scaleDouble = trunc(scaleDouble);
133
134 /* The 'scale' value is capped to int32 for compatibility with expected behavior */
135 int32 scale = scaleDouble > INT32_MAX ? INT32_MAX :
136 scaleDouble < INT32_MIN ? INT32_MIN :
137 (int32) scaleDouble;
138
139 pgbson *response = CollStatsCoordinator(databaseName, collectionName, scale);
140 PG_RETURN_POINTER(response);
141}
142
143
144/*

Callers

nothing calls this directly

Calls 2

ReportFeatureUsageFunction · 0.85
CollStatsCoordinatorFunction · 0.85

Tested by

no test coverage detected