* CreateConstFromBsonValue returns a Const that mimics the output of bson_get_value. */
| 3432 | * CreateConstFromBsonValue returns a Const that mimics the output of bson_get_value. |
| 3433 | */ |
| 3434 | static Const * |
| 3435 | CreateConstFromBsonValue(const char *path, const bson_value_t *value, |
| 3436 | const char *collationString) |
| 3437 | { |
| 3438 | /* convert value to BSON Datum */ |
| 3439 | pgbson_writer writer; |
| 3440 | PgbsonWriterInit(&writer); |
| 3441 | PgbsonWriterAppendValue(&writer, path, strlen(path), value); |
| 3442 | |
| 3443 | if (IsCollationApplicable(collationString)) |
| 3444 | { |
| 3445 | PgbsonWriterAppendUtf8(&writer, "collation", 9, collationString); |
| 3446 | } |
| 3447 | |
| 3448 | pgbson *bson = PgbsonWriterGetPgbson(&writer); |
| 3449 | return MakeBsonConst(bson); |
| 3450 | } |
| 3451 | |
| 3452 | |
| 3453 | /* |
no test coverage detected