* bson_in converts an extended json text format string to a binary serialized bson document. */
| 101 | * bson_in converts an extended json text format string to a binary serialized bson document. |
| 102 | */ |
| 103 | Datum |
| 104 | bson_in(PG_FUNCTION_ARGS) |
| 105 | { |
| 106 | char *arg = PG_GETARG_CSTRING(0); |
| 107 | |
| 108 | pgbson *bson; |
| 109 | if (arg == NULL) |
| 110 | { |
| 111 | bson = NULL; |
| 112 | } |
| 113 | else if (IsBsonHexadecimalString(arg)) |
| 114 | { |
| 115 | bson = PgbsonInitFromHexadecimalString(arg); |
| 116 | } |
| 117 | else |
| 118 | { |
| 119 | /* It's a json string use json deserialization */ |
| 120 | bson = PgbsonInitFromJson(arg); |
| 121 | } |
| 122 | |
| 123 | PG_RETURN_POINTER(bson); |
| 124 | } |
| 125 | |
| 126 | |
| 127 | /* |
nothing calls this directly
no test coverage detected