/*
* jsonb type send function
*
- * Just send jsonb as a string of text
+ * Just send jsonb as a version number, then a string of text
*/
Datum
jsonb_send(PG_FUNCTION_ARGS)
JsonbInState *_state = (JsonbInState *) state;
JsonbValue v;
+ Assert (fname != NULL);
v.type = jbvString;
- v.string.len = fname ? checkStringLen(strlen(fname)) : 0;
- v.string.val = fname ? pnstrdup(fname, v.string.len) : NULL;
+ v.string.len = checkStringLen(strlen(fname));
+ v.string.val = pnstrdup(fname, v.string.len);
v.estSize = sizeof(JEntry) + v.string.len;
_state->res = pushJsonbValue(&_state->state, WJB_KEY, &v);
{
case JSON_TOKEN_STRING:
+ Assert (token != NULL);
v.type = jbvString;
- v.string.len = token ? checkStringLen(strlen(token)) : 0;
- v.string.val = token ? pnstrdup(token, v.string.len) : NULL;
+ v.string.len = checkStringLen(strlen(token));
+ v.string.val = pnstrdup(token, v.string.len);
v.estSize += v.string.len;
break;
case JSON_TOKEN_NUMBER:
* size is well in excess of the restriction we separately impose
* of the size of JsonbValues
*/
+ Assert (token != NULL);
v.type = jbvNumeric;
v.numeric = DatumGetNumeric(DirectFunctionCall3(numeric_in, CStringGetDatum(token), 0, -1));
v.estSize += VARSIZE_ANY(v.numeric) + sizeof(JEntry) /* alignment */ ;
v.type = jbvNull;
break;
default:
+ /* should not be possible */
elog(ERROR, "invalid json token type");
break;
}