Skip to content

Commit 49ff9ab

Browse files
author
Nikita Glukhov
committed
Replace type JSON TEXT with pg_catalog.json
1 parent f104cc5 commit 49ff9ab

File tree

5 files changed

+22
-28
lines changed

5 files changed

+22
-28
lines changed

doc/src/sgml/config.sgml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9523,8 +9523,9 @@ dynamic_library_path = 'C:\tools\postgresql;H:\my_project\lib;$libdir'
95239523
Valid values are <literal>json</literal> and <literal>jsonb</literal>.
95249524
Specifies what <productname>PostgreSQL</productname> type is used
95259525
as an implementation of SQL type <type>JSON</type>.
9526-
SQL type <type>JSON TEXT</type> is always mapped to
9527-
<productname>PostgreSQL</productname> type <type>json</type>.
9526+
When <varname>sql_json</varname> is set to <literal>jsonb</literal>,
9527+
<productname>PostgreSQL</productname> type <type>json</type> can be
9528+
accessed using explicit qualification <type>pg_catalog.json</type>.
95289529
</para>
95299530
</listitem>
95309531
</varlistentry>

src/backend/parser/gram.y

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -776,8 +776,6 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
776776
%left '*' '/' '%'
777777
%left '^'
778778
/* Unary Operators */
779-
%nonassoc JSON
780-
%left TEXT_P /* sets precedence for JSON TEXT */
781779
%left AT /* sets precedence for AT TIME ZONE */
782780
%left COLLATE
783781
%right UMINUS
@@ -12943,11 +12941,6 @@ JsonType:
1294312941
$$ = SystemTypeName(SQLJSON_TYPE_NAME());
1294412942
$$->location = @1;
1294512943
}
12946-
| JSON TEXT_P
12947-
{
12948-
$$ = SystemTypeName("json");
12949-
$$->location = @1;
12950-
}
1295112944
;
1295212945

1295312946

src/backend/utils/adt/format_type.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ format_type_extended(Oid type_oid, int32 typemod, bits16 flags)
301301
break;
302302

303303
case JSONOID:
304-
buf = pstrdup(SQLJSON_TYPE_IS_JSONB() ? "json text" : "json");
304+
buf = pstrdup(SQLJSON_TYPE_IS_JSONB() ? "pg_catalog.json" : "json");
305305
break;
306306
}
307307

src/test/regress/expected/jsonb.out

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5030,7 +5030,7 @@ select json ' { "aa": 1, "b" : 2 }';
50305030
{ "aa": 1, "b" : 2 }
50315031
(1 row)
50325032

5033-
select json text ' { "aa": 1, "b" : 2 }';
5033+
select pg_catalog.json ' { "aa": 1, "b" : 2 }';
50345034
json
50355035
-----------------------
50365036
{ "aa": 1, "b" : 2 }
@@ -5057,27 +5057,27 @@ select json ' { "aa": 1, "b" : 2 }';
50575057
{"b": 2, "aa": 1}
50585058
(1 row)
50595059

5060-
select json text ' { "aa": 1, "b" : 2 }';
5060+
select pg_catalog.json ' { "aa": 1, "b" : 2 }';
50615061
json
50625062
-----------------------
50635063
{ "aa": 1, "b" : 2 }
50645064
(1 row)
50655065

50665066
\d test_json_as_json
5067-
Table "public.test_json_as_json"
5068-
Column | Type | Collation | Nullable | Default
5069-
--------+-----------+-----------+----------+---------
5070-
js | json text | | |
5071-
jb | json | | |
5067+
Table "public.test_json_as_json"
5068+
Column | Type | Collation | Nullable | Default
5069+
--------+-----------------+-----------+----------+---------
5070+
js | pg_catalog.json | | |
5071+
jb | json | | |
50725072

5073-
create table test_json_as_jsonb (js json, jb jsonb, jt json text);
5073+
create table test_json_as_jsonb (js json, jb jsonb, jt pg_catalog.json);
50745074
\d test_json_as_jsonb
5075-
Table "public.test_json_as_jsonb"
5076-
Column | Type | Collation | Nullable | Default
5077-
--------+-----------+-----------+----------+---------
5078-
js | json | | |
5079-
jb | json | | |
5080-
jt | json text | | |
5075+
Table "public.test_json_as_jsonb"
5076+
Column | Type | Collation | Nullable | Default
5077+
--------+-----------------+-----------+----------+---------
5078+
js | json | | |
5079+
jb | json | | |
5080+
jt | pg_catalog.json | | |
50815081

50825082
insert into test_json_as_jsonb values ('{ "a" : 1 }', '{ "a" : 1 }', '{ "a" : 1 }');
50835083
select * from test_json_as_jsonb;
@@ -5099,7 +5099,7 @@ select jsonb_object_field(jb, 'a') from test_json_as_jsonb;
50995099
(1 row)
51005100

51015101
select jsonb_object_field(jt, 'a') from test_json_as_jsonb;
5102-
ERROR: function jsonb_object_field(json text, unknown) does not exist
5102+
ERROR: function jsonb_object_field(pg_catalog.json, unknown) does not exist
51035103
LINE 1: select jsonb_object_field(jt, 'a') from test_json_as_jsonb;
51045104
^
51055105
HINT: No function matches the given name and argument types. You might need to add explicit type casts.

src/test/regress/sql/jsonb.sql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1284,7 +1284,7 @@ select '12345.0000000000000000000000000000000000000000000005'::jsonb::int8;
12841284
-- test mapping of jsonb to SQL/JSON JSON type
12851285
select json(' { "aa": 1, "b" : 2 }');
12861286
select json ' { "aa": 1, "b" : 2 }';
1287-
select json text ' { "aa": 1, "b" : 2 }';
1287+
select pg_catalog.json ' { "aa": 1, "b" : 2 }';
12881288

12891289
create table test_json_as_json (js json, jb jsonb);
12901290
\d test_json_as_json
@@ -1293,11 +1293,11 @@ set sql_json = jsonb;
12931293

12941294
select json(' { "aa": 1, "b" : 2 }');
12951295
select json ' { "aa": 1, "b" : 2 }';
1296-
select json text ' { "aa": 1, "b" : 2 }';
1296+
select pg_catalog.json ' { "aa": 1, "b" : 2 }';
12971297

12981298
\d test_json_as_json
12991299

1300-
create table test_json_as_jsonb (js json, jb jsonb, jt json text);
1300+
create table test_json_as_jsonb (js json, jb jsonb, jt pg_catalog.json);
13011301
\d test_json_as_jsonb
13021302

13031303
insert into test_json_as_jsonb values ('{ "a" : 1 }', '{ "a" : 1 }', '{ "a" : 1 }');

0 commit comments

Comments
 (0)