Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2d3e909

Browse files
author
Nikita Glukhov
committed
Rename GUC json_as_jsonb to sql_json
1 parent87508c8 commit2d3e909

File tree

9 files changed

+45
-27
lines changed

9 files changed

+45
-27
lines changed

‎doc/src/sgml/config.sgml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9347,19 +9347,20 @@ dynamic_library_path = 'C:\tools\postgresql;H:\my_project\lib;$libdir'
93479347
</listitem>
93489348
</varlistentry>
93499349

9350-
<varlistentry id="guc-json-as-jsonb" xreflabel="json_as_jsonb">
9351-
<term><varname>json_as_jsonb</varname> (<type>boolean</type>)
9350+
<varlistentry id="guc-sql-json" xreflabel="sql_json">
9351+
<term><varname>sql_json</varname> (<type>enum</type>)
93529352
<indexterm><primary>json</primary></indexterm>
93539353
<indexterm><primary>jsonb</primary></indexterm>
93549354
<indexterm>
9355-
<primary><varname>json_as_jsonb</varname> configuration parameter</primary>
9355+
<primary><varname>sql_json</varname> configuration parameter</primary>
93569356
</indexterm>
93579357
</term>
93589358
<listitem>
93599359
<para>
9360-
When on, SQL type <type>JSON</type> is mapped to
9361-
<productname>PostgreSQL</productname> type <type>jsonb</type>.
9362-
But SQL type <type>JSON TEXT</type> is always mapped to
9360+
Valid values are <literal>json</literal> and <literal>jsonb</literal>.
9361+
Specifies what <productname>PostgreSQL</productname> type is used
9362+
as an implementation of SQL type <type>JSON</type>.
9363+
SQL type <type>JSON TEXT</type> is always mapped to
93639364
<productname>PostgreSQL</productname> type <type>json</type>.
93649365
</para>
93659366
</listitem>

‎src/backend/parser/gram.y

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13144,7 +13144,7 @@ interval_second:
1314413144
JsonType:
1314513145
JSON
1314613146
{
13147-
$$ = SystemTypeName(json_as_jsonb ?"jsonb" :"json");
13147+
$$ = SystemTypeName(SQLJSON_TYPE_NAME());
1314813148
$$->location =@1;
1314913149
}
1315013150
|JSONTEXT_P
@@ -13844,7 +13844,7 @@ c_expr:columnref{ $$ = $1; }
1384413844
}
1384513845
|JSON'('a_expr')'
1384613846
{
13847-
List *typname = list_make1(makeString(json_as_jsonb ?"jsonb" :"json"));
13847+
List *typname = list_make1(makeString(SQLJSON_TYPE_NAME()));
1384813848

1384913849
$$ = (Node *) makeFuncCall(typname, list_make1($3),@1);
1385013850
}

‎src/backend/utils/adt/format_type.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,11 +285,11 @@ format_type_extended(Oid type_oid, int32 typemod, bits16 flags)
285285
break;
286286

287287
caseJSONBOID:
288-
buf=pstrdup(json_as_jsonb ?"json" :"jsonb");
288+
buf=pstrdup(SQLJSON_TYPE_IS_JSONB() ?"json" :"jsonb");
289289
break;
290290

291291
caseJSONOID:
292-
buf=pstrdup(json_as_jsonb ?"json text" :"json");
292+
buf=pstrdup(SQLJSON_TYPE_IS_JSONB() ?"json text" :"json");
293293
break;
294294
}
295295

‎src/backend/utils/adt/jsonb.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ static JsonbParseState *clone_parse_state(JsonbParseState *state);
9090
staticchar*JsonbToCStringWorker(StringInfoout,JsonbContainer*in,intestimated_len,boolindent);
9191
staticvoidadd_indent(StringInfoout,boolindent,intlevel);
9292

93-
booljson_as_jsonb;/* GUC for mapping jsonb to SQL/JSON JSON */
93+
intsql_json_type;/* GUC for mapping jsonb to SQL/JSON JSON */
9494

9595
/*
9696
* jsonb type input function

‎src/backend/utils/misc/guc.c

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,12 @@ static struct config_enum_entry shared_memory_options[] = {
504504
{NULL,0, false}
505505
};
506506

507+
conststructconfig_enum_entrysql_json_type_info[]= {
508+
{"json",SQLJSON_TYPE_JSON, false},
509+
{"jsonb",SQLJSON_TYPE_JSONB, false},
510+
{NULL,0, false}
511+
};
512+
507513
/*
508514
* Options for enum values stored in other modules
509515
*/
@@ -2061,17 +2067,6 @@ static struct config_bool ConfigureNamesBool[] =
20612067
NULL,NULL,NULL
20622068
},
20632069

2064-
{
2065-
{"json_as_jsonb",PGC_USERSET,COMPAT_OPTIONS_CLIENT,
2066-
gettext_noop("Use jsonb type as default implementation of SQL JSON type."),
2067-
gettext_noop("When turned on, jsonb type is mapped to SQL JSON type, "
2068-
"json type is mapped to JSON TEXT type.")
2069-
},
2070-
&json_as_jsonb,
2071-
false,
2072-
NULL,NULL,NULL
2073-
},
2074-
20752070
/* End-of-list marker */
20762071
{
20772072
{NULL,0,0,NULL,NULL},NULL, false,NULL,NULL,NULL
@@ -4788,6 +4783,17 @@ static struct config_enum ConfigureNamesEnum[] =
47884783
NULL,NULL,NULL
47894784
},
47904785

4786+
{
4787+
{"sql_json",PGC_USERSET,COMPAT_OPTIONS_CLIENT,
4788+
gettext_noop("Sets what PostgreSQL type to use as an implementaion of SQL JSON type."),
4789+
NULL
4790+
},
4791+
&sql_json_type,
4792+
SQLJSON_TYPE_JSON,
4793+
sql_json_type_info,
4794+
NULL,NULL,NULL
4795+
},
4796+
47914797
/* End-of-list marker */
47924798
{
47934799
{NULL,0,0,NULL,NULL},NULL,0,NULL,NULL,NULL,NULL

‎src/backend/utils/misc/postgresql.conf.sample

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -744,6 +744,7 @@
744744
# - Other Platforms and Clients -
745745

746746
#transform_null_equals = off
747+
#sql_json = json # jsonb
747748

748749

749750
#------------------------------------------------------------------------------

‎src/include/utils/jsonb.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,16 @@ extern char *JsonbToCStringIndent(StringInfo out, JsonbContainer *in,
407407
externboolJsonbExtractScalar(JsonbContainer*jbc,JsonbValue*res);
408408
externconstchar*JsonbTypeName(JsonbValue*jb);
409409

410-
externbooljson_as_jsonb;/* GUC */
410+
typedefenumSqlJsonType
411+
{
412+
SQLJSON_TYPE_JSON=0,
413+
SQLJSON_TYPE_JSONB=1
414+
}SqlJsonType;
415+
416+
#defineSQLJSON_TYPE_IS_JSONB() (sql_json_type == SQLJSON_TYPE_JSONB)
417+
#defineSQLJSON_TYPE_OID() (SQLJSON_TYPE_IS_JSONB() ? JSONBOID : JSONOID)
418+
#defineSQLJSON_TYPE_NAME() (SQLJSON_TYPE_IS_JSONB() ? "jsonb" : "json")
419+
420+
externintsql_json_type;/* GUC */
411421

412422
#endif/* __JSONB_H__ */

‎src/test/regress/expected/jsonb.out

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5041,7 +5041,7 @@ create table test_json_as_json (js json, jb jsonb);
50415041
js | json | | |
50425042
jb | jsonb | | |
50435043

5044-
setjson_as_jsonb =on;
5044+
setsql_json =jsonb;
50455045
select json(' { "aa": 1, "b" : 2 }');
50465046
jsonb
50475047
-------------------
@@ -5106,7 +5106,7 @@ select json_object_field(jt, 'a') from test_json_as_jsonb;
51065106
1
51075107
(1 row)
51085108

5109-
setjson_as_jsonb =off;
5109+
setsql_json =json;
51105110
\d test_json_as_jsonb
51115111
Table "public.test_json_as_jsonb"
51125112
Column | Type | Collation | Nullable | Default

‎src/test/regress/sql/jsonb.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1289,7 +1289,7 @@ select json text ' { "aa": 1, "b" : 2 }';
12891289
createtabletest_json_as_json (js json, jb jsonb);
12901290
\d test_json_as_json
12911291

1292-
setjson_as_jsonb=on;
1292+
setsql_json=jsonb;
12931293

12941294
select json(' { "aa": 1, "b" : 2 }');
12951295
select json' { "aa": 1, "b" : 2 }';
@@ -1309,7 +1309,7 @@ select jsonb_object_field(jb, 'a') from test_json_as_jsonb;
13091309
select jsonb_object_field(jt,'a')from test_json_as_jsonb;
13101310
select json_object_field(jt,'a')from test_json_as_jsonb;
13111311

1312-
setjson_as_jsonb=off;
1312+
setsql_json=json;
13131313
\d test_json_as_jsonb
13141314

13151315
select*from test_json_as_jsonb;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp