Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
f33a71a7
Commit
f33a71a7
authored
Apr 02, 2014
by
Tom Lane
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
De-anonymize the union in JsonbValue.
Needed for strict C89 compliance.
parent
682c5bbe
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
202 additions
and
202 deletions
+202
-202
contrib/hstore/hstore_io.c
contrib/hstore/hstore_io.c
+16
-16
src/backend/utils/adt/jsonb.c
src/backend/utils/adt/jsonb.c
+17
-17
src/backend/utils/adt/jsonb_gin.c
src/backend/utils/adt/jsonb_gin.c
+3
-3
src/backend/utils/adt/jsonb_op.c
src/backend/utils/adt/jsonb_op.c
+8
-8
src/backend/utils/adt/jsonb_util.c
src/backend/utils/adt/jsonb_util.c
+133
-133
src/backend/utils/adt/jsonfuncs.c
src/backend/utils/adt/jsonfuncs.c
+23
-23
src/include/utils/jsonb.h
src/include/utils/jsonb.h
+2
-2
No files found.
contrib/hstore/hstore_io.c
View file @
f33a71a7
...
...
@@ -1397,9 +1397,9 @@ hstore_to_jsonb(PG_FUNCTION_ARGS)
key
.
estSize
=
sizeof
(
JEntry
);
key
.
type
=
jbvString
;
key
.
string
.
len
=
HS_KEYLEN
(
entries
,
i
);
key
.
string
.
val
=
pnstrdup
(
HS_KEY
(
entries
,
base
,
i
),
key
.
string
.
len
);
key
.
estSize
+=
key
.
string
.
len
;
key
.
val
.
string
.
len
=
HS_KEYLEN
(
entries
,
i
);
key
.
val
.
string
.
val
=
pnstrdup
(
HS_KEY
(
entries
,
base
,
i
),
key
.
val
.
string
.
len
);
key
.
estSize
+=
key
.
val
.
string
.
len
;
res
=
pushJsonbValue
(
&
state
,
WJB_KEY
,
&
key
);
...
...
@@ -1412,9 +1412,9 @@ hstore_to_jsonb(PG_FUNCTION_ARGS)
{
val
.
estSize
=
sizeof
(
JEntry
);
val
.
type
=
jbvString
;
val
.
string
.
len
=
HS_VALLEN
(
entries
,
i
);
val
.
string
.
val
=
pnstrdup
(
HS_VAL
(
entries
,
base
,
i
),
val
.
string
.
len
);
val
.
estSize
+=
val
.
string
.
len
;
val
.
val
.
string
.
len
=
HS_VALLEN
(
entries
,
i
);
val
.
val
.
string
.
val
=
pnstrdup
(
HS_VAL
(
entries
,
base
,
i
),
val
.
val
.
string
.
len
);
val
.
estSize
+=
val
.
val
.
string
.
len
;
}
res
=
pushJsonbValue
(
&
state
,
WJB_VALUE
,
&
val
);
}
...
...
@@ -1449,9 +1449,9 @@ hstore_to_jsonb_loose(PG_FUNCTION_ARGS)
key
.
estSize
=
sizeof
(
JEntry
);
key
.
type
=
jbvString
;
key
.
string
.
len
=
HS_KEYLEN
(
entries
,
i
);
key
.
string
.
val
=
pnstrdup
(
HS_KEY
(
entries
,
base
,
i
),
key
.
string
.
len
);
key
.
estSize
+=
key
.
string
.
len
;
key
.
val
.
string
.
len
=
HS_KEYLEN
(
entries
,
i
);
key
.
val
.
string
.
val
=
pnstrdup
(
HS_KEY
(
entries
,
base
,
i
),
key
.
val
.
string
.
len
);
key
.
estSize
+=
key
.
val
.
string
.
len
;
res
=
pushJsonbValue
(
&
state
,
WJB_KEY
,
&
key
);
...
...
@@ -1465,12 +1465,12 @@ hstore_to_jsonb_loose(PG_FUNCTION_ARGS)
else
if
(
HS_VALLEN
(
entries
,
i
)
==
1
&&
*
(
HS_VAL
(
entries
,
base
,
i
))
==
't'
)
{
val
.
type
=
jbvBool
;
val
.
boolean
=
true
;
val
.
val
.
boolean
=
true
;
}
else
if
(
HS_VALLEN
(
entries
,
i
)
==
1
&&
*
(
HS_VAL
(
entries
,
base
,
i
))
==
'f'
)
{
val
.
type
=
jbvBool
;
val
.
boolean
=
false
;
val
.
val
.
boolean
=
false
;
}
else
{
...
...
@@ -1519,17 +1519,17 @@ hstore_to_jsonb_loose(PG_FUNCTION_ARGS)
if
(
is_number
)
{
val
.
type
=
jbvNumeric
;
val
.
numeric
=
DatumGetNumeric
(
val
.
val
.
numeric
=
DatumGetNumeric
(
DirectFunctionCall3
(
numeric_in
,
CStringGetDatum
(
tmp
.
data
),
0
,
-
1
));
val
.
estSize
+=
VARSIZE_ANY
(
val
.
numeric
)
+
sizeof
(
JEntry
);
val
.
estSize
+=
VARSIZE_ANY
(
val
.
val
.
numeric
)
+
sizeof
(
JEntry
);
}
else
{
val
.
estSize
=
sizeof
(
JEntry
);
val
.
type
=
jbvString
;
val
.
string
.
len
=
HS_VALLEN
(
entries
,
i
);
val
.
string
.
val
=
pnstrdup
(
HS_VAL
(
entries
,
base
,
i
),
val
.
string
.
len
);
val
.
estSize
+=
val
.
string
.
len
;
val
.
val
.
string
.
len
=
HS_VALLEN
(
entries
,
i
);
val
.
val
.
string
.
val
=
pnstrdup
(
HS_VAL
(
entries
,
base
,
i
),
val
.
val
.
string
.
len
);
val
.
estSize
+=
val
.
val
.
string
.
len
;
}
}
res
=
pushJsonbValue
(
&
state
,
WJB_VALUE
,
&
val
);
...
...
src/backend/utils/adt/jsonb.c
View file @
f33a71a7
...
...
@@ -247,9 +247,9 @@ jsonb_in_object_field_start(void *pstate, char *fname, bool isnull)
Assert
(
fname
!=
NULL
);
v
.
type
=
jbvString
;
v
.
string
.
len
=
checkStringLen
(
strlen
(
fname
));
v
.
string
.
val
=
pnstrdup
(
fname
,
v
.
string
.
len
);
v
.
estSize
=
sizeof
(
JEntry
)
+
v
.
string
.
len
;
v
.
val
.
string
.
len
=
checkStringLen
(
strlen
(
fname
));
v
.
val
.
string
.
val
=
pnstrdup
(
fname
,
v
.
val
.
string
.
len
);
v
.
estSize
=
sizeof
(
JEntry
)
+
v
.
val
.
string
.
len
;
_state
->
res
=
pushJsonbValue
(
&
_state
->
parseState
,
WJB_KEY
,
&
v
);
}
...
...
@@ -263,15 +263,15 @@ jsonb_put_escaped_value(StringInfo out, JsonbValue * scalarVal)
appendBinaryStringInfo
(
out
,
"null"
,
4
);
break
;
case
jbvString
:
escape_json
(
out
,
pnstrdup
(
scalarVal
->
string
.
val
,
scalarVal
->
string
.
len
));
escape_json
(
out
,
pnstrdup
(
scalarVal
->
val
.
string
.
val
,
scalarVal
->
val
.
string
.
len
));
break
;
case
jbvNumeric
:
appendStringInfoString
(
out
,
DatumGetCString
(
DirectFunctionCall1
(
numeric_out
,
PointerGetDatum
(
scalarVal
->
numeric
))));
PointerGetDatum
(
scalarVal
->
val
.
numeric
))));
break
;
case
jbvBool
:
if
(
scalarVal
->
boolean
)
if
(
scalarVal
->
val
.
boolean
)
appendBinaryStringInfo
(
out
,
"true"
,
4
);
else
appendBinaryStringInfo
(
out
,
"false"
,
5
);
...
...
@@ -298,9 +298,9 @@ jsonb_in_scalar(void *pstate, char *token, JsonTokenType tokentype)
case
JSON_TOKEN_STRING
:
Assert
(
token
!=
NULL
);
v
.
type
=
jbvString
;
v
.
string
.
len
=
checkStringLen
(
strlen
(
token
));
v
.
string
.
val
=
pnstrdup
(
token
,
v
.
string
.
len
);
v
.
estSize
+=
v
.
string
.
len
;
v
.
val
.
string
.
len
=
checkStringLen
(
strlen
(
token
));
v
.
val
.
string
.
val
=
pnstrdup
(
token
,
v
.
val
.
string
.
len
);
v
.
estSize
+=
v
.
val
.
string
.
len
;
break
;
case
JSON_TOKEN_NUMBER
:
/*
...
...
@@ -309,16 +309,16 @@ jsonb_in_scalar(void *pstate, char *token, JsonTokenType tokentype)
*/
Assert
(
token
!=
NULL
);
v
.
type
=
jbvNumeric
;
v
.
numeric
=
DatumGetNumeric
(
DirectFunctionCall3
(
numeric_in
,
CStringGetDatum
(
token
),
0
,
-
1
));
v
.
estSize
+=
VARSIZE_ANY
(
v
.
numeric
)
+
sizeof
(
JEntry
)
/* alignment */
;
v
.
val
.
numeric
=
DatumGetNumeric
(
DirectFunctionCall3
(
numeric_in
,
CStringGetDatum
(
token
),
0
,
-
1
));
v
.
estSize
+=
VARSIZE_ANY
(
v
.
val
.
numeric
)
+
sizeof
(
JEntry
)
/* alignment */
;
break
;
case
JSON_TOKEN_TRUE
:
v
.
type
=
jbvBool
;
v
.
boolean
=
true
;
v
.
val
.
boolean
=
true
;
break
;
case
JSON_TOKEN_FALSE
:
v
.
type
=
jbvBool
;
v
.
boolean
=
false
;
v
.
val
.
boolean
=
false
;
break
;
case
JSON_TOKEN_NULL
:
v
.
type
=
jbvNull
;
...
...
@@ -335,8 +335,8 @@ jsonb_in_scalar(void *pstate, char *token, JsonTokenType tokentype)
JsonbValue
va
;
va
.
type
=
jbvArray
;
va
.
array
.
rawScalar
=
true
;
va
.
array
.
nElems
=
1
;
va
.
val
.
array
.
rawScalar
=
true
;
va
.
val
.
array
.
nElems
=
1
;
_state
->
res
=
pushJsonbValue
(
&
_state
->
parseState
,
WJB_BEGIN_ARRAY
,
&
va
);
_state
->
res
=
pushJsonbValue
(
&
_state
->
parseState
,
WJB_ELEM
,
&
v
);
...
...
@@ -399,7 +399,7 @@ JsonbToCString(StringInfo out, JsonbSuperHeader in, int estimated_len)
appendBinaryStringInfo
(
out
,
", "
,
2
);
first
=
true
;
if
(
!
v
.
array
.
rawScalar
)
if
(
!
v
.
val
.
array
.
rawScalar
)
appendStringInfoChar
(
out
,
'['
);
level
++
;
break
;
...
...
@@ -448,7 +448,7 @@ JsonbToCString(StringInfo out, JsonbSuperHeader in, int estimated_len)
break
;
case
WJB_END_ARRAY
:
level
--
;
if
(
!
v
.
array
.
rawScalar
)
if
(
!
v
.
val
.
array
.
rawScalar
)
appendStringInfoChar
(
out
,
']'
);
first
=
false
;
break
;
...
...
src/backend/utils/adt/jsonb_gin.c
View file @
f33a71a7
...
...
@@ -618,7 +618,7 @@ make_scalar_key(const JsonbValue * scalarVal, char flag)
item
=
make_text_key
(
"n"
,
1
,
flag
);
break
;
case
jbvBool
:
item
=
make_text_key
(
scalarVal
->
boolean
?
"t"
:
"f"
,
1
,
flag
);
item
=
make_text_key
(
scalarVal
->
val
.
boolean
?
"t"
:
"f"
,
1
,
flag
);
break
;
case
jbvNumeric
:
/*
...
...
@@ -630,12 +630,12 @@ make_scalar_key(const JsonbValue * scalarVal, char flag)
* storing a "union" type in the GIN B-Tree, and indexing Jsonb
* strings takes precedence.
*/
cstr
=
numeric_normalize
(
scalarVal
->
numeric
);
cstr
=
numeric_normalize
(
scalarVal
->
val
.
numeric
);
item
=
make_text_key
(
cstr
,
strlen
(
cstr
),
flag
);
pfree
(
cstr
);
break
;
case
jbvString
:
item
=
make_text_key
(
scalarVal
->
string
.
val
,
scalarVal
->
string
.
len
,
item
=
make_text_key
(
scalarVal
->
val
.
string
.
val
,
scalarVal
->
val
.
string
.
len
,
flag
);
break
;
default:
...
...
src/backend/utils/adt/jsonb_op.c
View file @
f33a71a7
...
...
@@ -31,8 +31,8 @@ jsonb_exists(PG_FUNCTION_ARGS)
* top level. No recursion occurs.
*/
kval
.
type
=
jbvString
;
kval
.
string
.
val
=
VARDATA_ANY
(
key
);
kval
.
string
.
len
=
VARSIZE_ANY_EXHDR
(
key
);
kval
.
val
.
string
.
val
=
VARDATA_ANY
(
key
);
kval
.
val
.
string
.
len
=
VARSIZE_ANY_EXHDR
(
key
);
v
=
findJsonbValueFromSuperHeader
(
VARDATA
(
jb
),
JB_FOBJECT
|
JB_FARRAY
,
...
...
@@ -52,7 +52,7 @@ jsonb_exists_any(PG_FUNCTION_ARGS)
lowbound
=
0
;
int
i
;
if
(
arrKey
==
NULL
||
arrKey
->
object
.
nPairs
==
0
)
if
(
arrKey
==
NULL
||
arrKey
->
val
.
object
.
nPairs
==
0
)
PG_RETURN_BOOL
(
false
);
if
(
JB_ROOT_IS_OBJECT
(
jb
))
...
...
@@ -64,12 +64,12 @@ jsonb_exists_any(PG_FUNCTION_ARGS)
* each search can start one entry past the previous "found" entry, or at
* the lower bound of the last search.
*/
for
(
i
=
0
;
i
<
arrKey
->
array
.
nElems
;
i
++
)
for
(
i
=
0
;
i
<
arrKey
->
val
.
array
.
nElems
;
i
++
)
{
if
(
findJsonbValueFromSuperHeader
(
VARDATA
(
jb
),
JB_FOBJECT
|
JB_FARRAY
,
plowbound
,
arrKey
->
array
.
elems
+
i
)
!=
NULL
)
arrKey
->
val
.
array
.
elems
+
i
)
!=
NULL
)
PG_RETURN_BOOL
(
true
);
}
...
...
@@ -86,7 +86,7 @@ jsonb_exists_all(PG_FUNCTION_ARGS)
uint32
lowbound
=
0
;
int
i
;
if
(
arrKey
==
NULL
||
arrKey
->
array
.
nElems
==
0
)
if
(
arrKey
==
NULL
||
arrKey
->
val
.
array
.
nElems
==
0
)
PG_RETURN_BOOL
(
true
);
if
(
JB_ROOT_IS_OBJECT
(
jb
))
...
...
@@ -98,12 +98,12 @@ jsonb_exists_all(PG_FUNCTION_ARGS)
* each search can start one entry past the previous "found" entry, or at
* the lower bound of the last search.
*/
for
(
i
=
0
;
i
<
arrKey
->
array
.
nElems
;
i
++
)
for
(
i
=
0
;
i
<
arrKey
->
val
.
array
.
nElems
;
i
++
)
{
if
(
findJsonbValueFromSuperHeader
(
VARDATA
(
jb
),
JB_FOBJECT
|
JB_FARRAY
,
plowbound
,
arrKey
->
array
.
elems
+
i
)
==
NULL
)
arrKey
->
val
.
array
.
elems
+
i
)
==
NULL
)
PG_RETURN_BOOL
(
false
);
}
...
...
src/backend/utils/adt/jsonb_util.c
View file @
f33a71a7
This diff is collapsed.
Click to expand it.
src/backend/utils/adt/jsonfuncs.c
View file @
f33a71a7
...
...
@@ -295,9 +295,9 @@ jsonb_object_keys(PG_FUNCTION_ARGS)
{
char
*
cstr
;
cstr
=
palloc
(
v
.
string
.
len
+
1
*
sizeof
(
char
));
memcpy
(
cstr
,
v
.
string
.
val
,
v
.
string
.
len
);
cstr
[
v
.
string
.
len
]
=
'\0'
;
cstr
=
palloc
(
v
.
val
.
string
.
len
+
1
*
sizeof
(
char
));
memcpy
(
cstr
,
v
.
val
.
string
.
val
,
v
.
val
.
string
.
len
);
cstr
[
v
.
val
.
string
.
len
]
=
'\0'
;
state
->
result
[
state
->
result_count
++
]
=
cstr
;
}
}
...
...
@@ -491,7 +491,7 @@ jsonb_object_field(PG_FUNCTION_ARGS)
if
(
r
==
WJB_KEY
)
{
if
(
klen
==
v
.
string
.
len
&&
strncmp
(
key
,
v
.
string
.
val
,
klen
)
==
0
)
if
(
klen
==
v
.
val
.
string
.
len
&&
strncmp
(
key
,
v
.
val
.
string
.
val
,
klen
)
==
0
)
{
/*
* The next thing the iterator fetches should be the value, no
...
...
@@ -552,7 +552,7 @@ jsonb_object_field_text(PG_FUNCTION_ARGS)
if
(
r
==
WJB_KEY
)
{
if
(
klen
==
v
.
string
.
len
&&
strncmp
(
key
,
v
.
string
.
val
,
klen
)
==
0
)
if
(
klen
==
v
.
val
.
string
.
len
&&
strncmp
(
key
,
v
.
val
.
string
.
val
,
klen
)
==
0
)
{
text
*
result
;
...
...
@@ -568,7 +568,7 @@ jsonb_object_field_text(PG_FUNCTION_ARGS)
*/
if
(
v
.
type
==
jbvString
)
{
result
=
cstring_to_text_with_len
(
v
.
string
.
val
,
v
.
string
.
len
);
result
=
cstring_to_text_with_len
(
v
.
val
.
string
.
val
,
v
.
val
.
string
.
len
);
}
else
if
(
v
.
type
==
jbvNull
)
{
...
...
@@ -699,7 +699,7 @@ jsonb_array_element_text(PG_FUNCTION_ARGS)
if
(
v
.
type
==
jbvString
)
{
result
=
cstring_to_text_with_len
(
v
.
string
.
val
,
v
.
string
.
len
);
result
=
cstring_to_text_with_len
(
v
.
val
.
string
.
val
,
v
.
val
.
string
.
len
);
}
else
if
(
v
.
type
==
jbvNull
)
{
...
...
@@ -1209,11 +1209,11 @@ get_jsonb_path_all(FunctionCallInfo fcinfo, bool as_text)
if
(
jbvp
->
type
==
jbvBinary
)
{
JsonbIterator
*
it
=
JsonbIteratorInit
(
jbvp
->
binary
.
data
);
JsonbIterator
*
it
=
JsonbIteratorInit
(
jbvp
->
val
.
binary
.
data
);
int
r
;
r
=
JsonbIteratorNext
(
&
it
,
&
tv
,
true
);
superHeader
=
(
JsonbSuperHeader
)
jbvp
->
binary
.
data
;
superHeader
=
(
JsonbSuperHeader
)
jbvp
->
val
.
binary
.
data
;
have_object
=
r
==
WJB_BEGIN_OBJECT
;
have_array
=
r
==
WJB_BEGIN_ARRAY
;
}
...
...
@@ -1227,7 +1227,7 @@ get_jsonb_path_all(FunctionCallInfo fcinfo, bool as_text)
if
(
as_text
)
{
if
(
jbvp
->
type
==
jbvString
)
PG_RETURN_TEXT_P
(
cstring_to_text_with_len
(
jbvp
->
string
.
val
,
jbvp
->
string
.
len
));
PG_RETURN_TEXT_P
(
cstring_to_text_with_len
(
jbvp
->
val
.
string
.
val
,
jbvp
->
val
.
string
.
len
));
else
if
(
jbvp
->
type
==
jbvNull
)
PG_RETURN_NULL
();
}
...
...
@@ -1443,7 +1443,7 @@ each_worker_jsonb(FunctionCallInfo fcinfo, bool as_text)
/* Use the tmp context so we can clean up after each tuple is done */
old_cxt
=
MemoryContextSwitchTo
(
tmp_cxt
);
key
=
cstring_to_text_with_len
(
v
.
string
.
val
,
v
.
string
.
len
);
key
=
cstring_to_text_with_len
(
v
.
val
.
string
.
val
,
v
.
val
.
string
.
len
);
/*
* The next thing the iterator fetches should be the value, no
...
...
@@ -1468,7 +1468,7 @@ each_worker_jsonb(FunctionCallInfo fcinfo, bool as_text)
if
(
v
.
type
==
jbvString
)
{
/* In text mode, scalar strings should be dequoted */
sv
=
cstring_to_text_with_len
(
v
.
string
.
val
,
v
.
string
.
len
);
sv
=
cstring_to_text_with_len
(
v
.
val
.
string
.
val
,
v
.
val
.
string
.
len
);
}
else
{
...
...
@@ -1788,7 +1788,7 @@ elements_worker_jsonb(FunctionCallInfo fcinfo, bool as_text)
if
(
v
.
type
==
jbvString
)
{
/* in text mode scalar strings should be dequoted */
sv
=
cstring_to_text_with_len
(
v
.
string
.
val
,
v
.
string
.
len
);
sv
=
cstring_to_text_with_len
(
v
.
val
.
string
.
val
,
v
.
val
.
string
.
len
);
}
else
{
...
...
@@ -2270,18 +2270,18 @@ populate_record_worker(FunctionCallInfo fcinfo, bool have_record_arg)
else
{
if
(
v
->
type
==
jbvString
)
s
=
pnstrdup
(
v
->
string
.
val
,
v
->
string
.
len
);
s
=
pnstrdup
(
v
->
val
.
string
.
val
,
v
->
val
.
string
.
len
);
else
if
(
v
->
type
==
jbvBool
)
s
=
pnstrdup
((
v
->
boolean
)
?
"t"
:
"f"
,
1
);
s
=
pnstrdup
((
v
->
val
.
boolean
)
?
"t"
:
"f"
,
1
);
else
if
(
v
->
type
==
jbvNumeric
)
s
=
DatumGetCString
(
DirectFunctionCall1
(
numeric_out
,
PointerGetDatum
(
v
->
numeric
)));
PointerGetDatum
(
v
->
val
.
numeric
)));
else
if
(
!
use_json_as_text
)
ereport
(
ERROR
,
(
errcode
(
ERRCODE_INVALID_PARAMETER_VALUE
),
errmsg
(
"cannot populate with a nested object unless use_json_as_text is true"
)));
else
if
(
v
->
type
==
jbvBinary
)
s
=
JsonbToCString
(
NULL
,
v
->
binary
.
data
,
v
->
binary
.
len
);
s
=
JsonbToCString
(
NULL
,
v
->
val
.
binary
.
data
,
v
->
val
.
binary
.
len
);
else
elog
(
ERROR
,
"invalid jsonb type"
);
}
...
...
@@ -2570,18 +2570,18 @@ make_row_from_rec_and_jsonb(Jsonb * element, PopulateRecordsetState *state)
char
*
s
=
NULL
;
if
(
v
->
type
==
jbvString
)
s
=
pnstrdup
(
v
->
string
.
val
,
v
->
string
.
len
);
s
=
pnstrdup
(
v
->
val
.
string
.
val
,
v
->
val
.
string
.
len
);
else
if
(
v
->
type
==
jbvBool
)
s
=
pnstrdup
((
v
->
boolean
)
?
"t"
:
"f"
,
1
);
s
=
pnstrdup
((
v
->
val
.
boolean
)
?
"t"
:
"f"
,
1
);
else
if
(
v
->
type
==
jbvNumeric
)
s
=
DatumGetCString
(
DirectFunctionCall1
(
numeric_out
,
PointerGetDatum
(
v
->
numeric
)));
PointerGetDatum
(
v
->
val
.
numeric
)));
else
if
(
!
state
->
use_json_as_text
)
ereport
(
ERROR
,
(
errcode
(
ERRCODE_INVALID_PARAMETER_VALUE
),
errmsg
(
"cannot populate with a nested object unless use_json_as_text is true"
)));
else
if
(
v
->
type
==
jbvBinary
)
s
=
JsonbToCString
(
NULL
,
v
->
binary
.
data
,
v
->
binary
.
len
);
s
=
JsonbToCString
(
NULL
,
v
->
val
.
binary
.
data
,
v
->
val
.
binary
.
len
);
else
elog
(
ERROR
,
"invalid jsonb type"
);
...
...
@@ -3027,8 +3027,8 @@ findJsonbValueFromSuperHeaderLen(JsonbSuperHeader sheader, uint32 flags,
JsonbValue
k
;
k
.
type
=
jbvString
;
k
.
string
.
val
=
key
;
k
.
string
.
len
=
keylen
;
k
.
val
.
string
.
val
=
key
;
k
.
val
.
string
.
len
=
keylen
;
return
findJsonbValueFromSuperHeader
(
sheader
,
flags
,
NULL
,
&
k
);
}
src/include/utils/jsonb.h
View file @
f33a71a7
...
...
@@ -141,7 +141,7 @@ typedef struct
/*
* JsonbValue: In-memory representation of Jsonb. This is a convenient
* deserialized representation, that can easily support using the
anonymous
* deserialized representation, that can easily support using the
"val"
* union across underlying types during manipulation. The Jsonb on-disk
* representation has various alignment considerations.
*/
...
...
@@ -192,7 +192,7 @@ struct JsonbValue
int
len
;
char
*
data
;
}
binary
;
};
}
val
;
};
/*
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment