PostgreSQL中JSON数据类型的大小限制 [英] Size limit of JSON data type in PostgreSQL

查看:1161
本文介绍了PostgreSQL中JSON数据类型的大小限制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道PostgreSQL 9.2中JSON数据类型的大小限制是什么吗?

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

推荐答案

查看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));
}

PostgreSQL 9.3.5更新:

Update for PostgreSQL 9.3.5:

json_in函数中的代码已更改,但json内部表示仍为文本:

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);
}

因此,看来至少到目前为止,jsontext数据类型相同,但具有JSON验证. text数据类型的最大大小为 1GB .

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.

这篇关于PostgreSQL中JSON数据类型的大小限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆