Size limit of JSON data type in PostgreSQL

末鹿安然 提交于 2019-11-30 12:37:11

问题


Does anyone know what is the limit on the size of JSON data type in PostgreSQL 9.2?


回答1:


Looking at the source for 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:

The code has changed in the json_in function, but the json internal representation is still text:

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.



来源:https://stackoverflow.com/questions/12632871/size-limit-of-json-data-type-in-postgresql

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!