2012-09-28 17 views

risposta

45

Guardando la fonte per 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)); 
} 

Aggiornamento per PostgreSQL 9.3.5:

Il codice è cambiato nella funzione json_in, ma la rappresentazione interna JSON è ancora il testo:

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

Così sembra che, almeno per ora, json è lo stesso di un tipo di dati text ma w con convalida JSON. La dimensione massima del tipo di dati text è 1GB.

+7

Il tipo di dati (nuovo dal post?) Postgres 'jsonb' utilizza qualcosa di diverso dal puro testo? –

+2

1 GB! è carino Sono contento che il numero non sia in MB. – edencorbin

Problemi correlati