{
if (len > JENTRY_POSMASK)
ereport(ERROR,
- (errcode(ERRCODE_STRING_DATA_RIGHT_TRUNCATION),
- errmsg("string too long for jsonb string")));
+ (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
+ errmsg("string too long to represent as jsonb string"),
+ errdetail("Due to an implementation restriction, jsonb strings cannot exceed %d bytes.",
+ JENTRY_POSMASK)));
+
return len;
}
v.estSize += v.string.len;
break;
case JSON_TOKEN_NUMBER:
+ /*
+ * No need to check size of numeric values, because maximum numeric
+ * size is well in excess of the restriction we separately impose
+ * of the size of JsonbValues
+ */
v.type = jbvNumeric;
v.numeric = DatumGetNumeric(DirectFunctionCall3(numeric_in, CStringGetDatum(token), 0, -1));
-
- v.estSize += VARSIZE_ANY(v.numeric) +sizeof(JEntry) /* alignment */ ;
+ v.estSize += VARSIZE_ANY(v.numeric) + sizeof(JEntry) /* alignment */ ;
break;
case JSON_TOKEN_TRUE:
v.type = jbvBool;