* Takes an IndexSpec Datum (Composite type) and converts it to a serialized * BSON format. Supports two ways of serializing it: * 1) GetIndexes - converts it to a format that the wire protocol "list_indexes" command needs * 2) CreateIndexes - converts to a format that create_indexes needs (used in shard_collection) * or similar scenarios. */
| 151 | * or similar scenarios. |
| 152 | */ |
| 153 | Datum |
| 154 | index_spec_as_bson(PG_FUNCTION_ARGS) |
| 155 | { |
| 156 | IndexSpec *indexSpec = DatumGetIndexSpec(ExpandedRecordGetDatum( |
| 157 | PG_GETARG_EXPANDED_RECORD(0))); |
| 158 | bool isGetIndexes = PG_GETARG_BOOL(1); |
| 159 | |
| 160 | char *namespaceName = NULL; |
| 161 | if (!PG_ARGISNULL(2)) |
| 162 | { |
| 163 | namespaceName = text_to_cstring(PG_GETARG_TEXT_P(2)); |
| 164 | } |
| 165 | |
| 166 | pgbson *result = SerializeIndexSpec(indexSpec, isGetIndexes, namespaceName); |
| 167 | PG_RETURN_POINTER(result); |
| 168 | } |
| 169 | |
| 170 | |
| 171 | /* |
nothing calls this directly
no test coverage detected