Does anyone know what is the limit on the size of JSON data type in PostgreSQL 9.2?
有人知道PostgreSQL 9.2中JSON数据类型的大小的限制是什么吗?
1 个解决方案
#1
47
Looking at the source for PostgreSQL 9.2.1:
查看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));
}
Update for PostgreSQL 9.3.5:
PostgreSQL 9.3.5更新:
The code has changed in the json_in
function, but the json internal representation is still text:
在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);
}
So it appears that, for now at least, json
is the same as a text
datatype but with JSON validation. The text
datatype's maximum size is 1GB.
因此,至少现在看来,json与文本数据类型相同,但使用了json验证。文本数据类型的最大大小为1GB。
#1
47
Looking at the source for PostgreSQL 9.2.1:
查看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));
}
Update for PostgreSQL 9.3.5:
PostgreSQL 9.3.5更新:
The code has changed in the json_in
function, but the json internal representation is still text:
在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);
}
So it appears that, for now at least, json
is the same as a text
datatype but with JSON validation. The text
datatype's maximum size is 1GB.
因此,至少现在看来,json与文本数据类型相同,但使用了json验证。文本数据类型的最大大小为1GB。