* The core logic for dbStats on the entry point function * i.e. the Coordinator of the dbStats. * This function simply calls the "worker" dbStats against * all available nodes, and then aggregates/merges the results into * the necessary wire protocol format. */
| 238 | * the necessary wire protocol format. |
| 239 | */ |
| 240 | static pgbson * |
| 241 | DbStatsCoordinator(Datum databaseName, int32 scale) |
| 242 | { |
| 243 | if (scale < 1) |
| 244 | { |
| 245 | ereport(ERROR, (errcode(ERRCODE_DOCUMENTDB_LOCATION51024), errmsg( |
| 246 | "scale has to be > 0"))); |
| 247 | } |
| 248 | |
| 249 | StringInfo namespaceString = makeStringInfo(); |
| 250 | |
| 251 | appendStringInfo(namespaceString, "%.*s", |
| 252 | (int) VARSIZE_ANY_EXHDR(databaseName), |
| 253 | (char *) VARDATA_ANY(databaseName)); |
| 254 | |
| 255 | DbStatsResult result = { 0 }; |
| 256 | result.db = namespaceString->data; |
| 257 | result.scaleFactor = scale; |
| 258 | result.ok = 1; |
| 259 | |
| 260 | BuildResultData(databaseName, &result, scale); |
| 261 | pgbson *response = BuildResponseMessage(&result); |
| 262 | |
| 263 | return response; |
| 264 | } |
| 265 | |
| 266 | |
| 267 | /* |
no test coverage detected