Does anyone know what is the limit on the size of JSON data type in PostgreSQL 9.2?
Does anyone know what is the limit on the size of JSON data type in PostgreSQL 9.2?
查看PostgreSQL 9.2.1的源代码:
Source: postgresql-9.2.1\src\backend\utils\adt\json.c:
/*
* Input.
*/
Datum
json_in(PG_FUNCTION_ARGS)
{
char *text = PG_GETARG_CSTRING(0);
json_validate_cstring(text);
/* Internal representation is the same as text, for now */
PG_RETURN_TEXT_P(cstring_to_text(text));
}
PostgreSQL 9.3.5的更新:
json_in
函数中的代码已更改,但json内部表示仍然是文本:
Source: postgresql-9.3.5\src\backend\utils\adt\json.c:
/*
* Input.
*/
Datum
json_in(PG_FUNCTION_ARGS)
{
char *json = PG_GETARG_CSTRING(0);
text *result = cstring_to_text(json);
JsonLexContext *lex;
/* validate it */
lex = makeJsonLexContext(result, false);
pg_parse_json(lex, &nullSemAction);
/* Internal representation is the same as text, for now */
PG_RETURN_TEXT_P(result);
}
因此,至少目前来看,json
与text
数据类型相同,但带有JSON验证.text
数据类型的最大大小为1GB.