* Gets the set of documents that are serialized by the bsonsequence. */
| 158 | * Gets the set of documents that are serialized by the bsonsequence. |
| 159 | */ |
| 160 | Datum |
| 161 | bsonsequence_get_bson(PG_FUNCTION_ARGS) |
| 162 | { |
| 163 | pgbsonsequence *sequence = PG_GETARG_PGBSON_SEQUENCE(0); |
| 164 | TupleDesc descriptor; |
| 165 | Tuplestorestate *tupleStore = SetupBsonTuplestore(fcinfo, &descriptor); |
| 166 | |
| 167 | List *docsList = PgbsonSequenceGetDocumentBsonValues(sequence); |
| 168 | |
| 169 | |
| 170 | ListCell *cell; |
| 171 | foreach(cell, docsList) |
| 172 | { |
| 173 | const bson_value_t *docValue = lfirst(cell); |
| 174 | Datum values[1]; |
| 175 | bool nulls[1]; |
| 176 | |
| 177 | values[0] = PointerGetDatum(PgbsonInitFromDocumentBsonValue(docValue)); |
| 178 | nulls[0] = false; |
| 179 | |
| 180 | tuplestore_putvalues(tupleStore, descriptor, values, nulls); |
| 181 | } |
| 182 | |
| 183 | PG_RETURN_VOID(); |
| 184 | } |
| 185 | |
| 186 | |
| 187 | /* |
nothing calls this directly
no test coverage detected