* BuildEmptyResponseMessage func builds pgbson response for collStats() when * the provided collection is not present */
| 1004 | * the provided collection is not present |
| 1005 | */ |
| 1006 | static pgbson * |
| 1007 | BuildEmptyResponseMessage(CollStatsResult *result) |
| 1008 | { |
| 1009 | pgbson_writer writer; |
| 1010 | PgbsonWriterInit(&writer); |
| 1011 | |
| 1012 | /* |
| 1013 | * Note: For empty collections, the response includes only a subset of fields, |
| 1014 | * and the order of fields may differ from the response for non-empty collections. |
| 1015 | * Values are written as Int32 since empty collections will always fit within this range. |
| 1016 | */ |
| 1017 | PgbsonWriterAppendUtf8(&writer, "ns", 2, result->ns); |
| 1018 | PgbsonWriterAppendInt32(&writer, "size", 4, 0); |
| 1019 | PgbsonWriterAppendInt32(&writer, "count", 5, 0); |
| 1020 | PgbsonWriterAppendInt32(&writer, "storageSize", 11, 0); |
| 1021 | PgbsonWriterAppendInt32(&writer, "totalSize", 9, 0); |
| 1022 | PgbsonWriterAppendInt32(&writer, "nindexes", 8, 0); |
| 1023 | PgbsonWriterAppendInt32(&writer, "totalIndexSize", 14, 0); |
| 1024 | PgbsonWriterAppendDocument(&writer, "indexSizes", 10, PgbsonInitEmpty()); |
| 1025 | PgbsonWriterAppendInt32(&writer, "scaleFactor", 11, result->scaleFactor); |
| 1026 | PgbsonWriterAppendInt32(&writer, "ok", 2, result->ok); |
| 1027 | |
| 1028 | return PgbsonWriterGetPgbson(&writer); |
| 1029 | } |
| 1030 | |
| 1031 | |
| 1032 | /* |
no test coverage detected