sql >> Base de Datos >  >> RDS >> PostgreSQL

Límite de tamaño del tipo de datos JSON en PostgreSQL

Mirando la fuente de 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));
}

Actualización para PostgreSQL 9.3.5:

El código ha cambiado en json_in función, pero la representación interna json sigue siendo texto:

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

Entonces parece que, al menos por ahora, json es lo mismo que un text tipo de datos pero con validación JSON. El text el tamaño máximo del tipo de datos es de 1 GB.