Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Gpdb
提交
243ee266
G
Gpdb
项目概览
Greenplum
/
Gpdb
通知
7
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
Gpdb
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
243ee266
编写于
1月 22, 2014
作者:
A
Andrew Dunstan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Reindent json.c and jsonfuncs.c.
This will help in preparation of clean patches for upcoming json work.
上级
6c36f383
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
45 addition
and
42 deletion
+45
-42
src/backend/utils/adt/json.c
src/backend/utils/adt/json.c
+35
-32
src/backend/utils/adt/jsonfuncs.c
src/backend/utils/adt/jsonfuncs.c
+10
-10
未找到文件。
src/backend/utils/adt/json.c
浏览文件 @
243ee266
...
...
@@ -751,11 +751,12 @@ json_lex_string(JsonLexContext *lex)
report_json_context
(
lex
)));
/*
* For UTF8, replace the escape sequence by the actual utf8
* character in lex->strval. Do this also for other encodings
* if the escape designates an ASCII character, otherwise
* raise an error. We don't ever unescape a \u0000, since that
* would result in an impermissible nul byte.
* For UTF8, replace the escape sequence by the actual
* utf8 character in lex->strval. Do this also for other
* encodings if the escape designates an ASCII character,
* otherwise raise an error. We don't ever unescape a
* \u0000, since that would result in an impermissible nul
* byte.
*/
if
(
ch
==
0
)
...
...
@@ -771,8 +772,9 @@ json_lex_string(JsonLexContext *lex)
else
if
(
ch
<=
0x007f
)
{
/*
* This is the only way to designate things like a form feed
* character in JSON, so it's useful in all encodings.
* This is the only way to designate things like a
* form feed character in JSON, so it's useful in all
* encodings.
*/
appendStringInfoChar
(
lex
->
strval
,
(
char
)
ch
);
}
...
...
@@ -866,7 +868,7 @@ json_lex_string(JsonLexContext *lex)
ereport
(
ERROR
,
(
errcode
(
ERRCODE_INVALID_TEXT_REPRESENTATION
),
errmsg
(
"invalid input syntax for type json"
),
errdetail
(
"Unicode low surrogate must follow a high surrogate."
),
errdetail
(
"Unicode low surrogate must follow a high surrogate."
),
report_json_context
(
lex
)));
/* Hooray, we found the end of the string! */
...
...
@@ -1221,7 +1223,7 @@ datum_to_json(Datum val, bool is_null, StringInfo result,
{
char
*
outputstr
;
text
*
jsontext
;
bool
numeric_error
;
bool
numeric_error
;
JsonLexContext
dummy_lex
;
if
(
is_null
)
...
...
@@ -1246,13 +1248,14 @@ datum_to_json(Datum val, bool is_null, StringInfo result,
break
;
case
TYPCATEGORY_NUMERIC
:
outputstr
=
OidOutputFunctionCall
(
typoutputfunc
,
val
);
/*
* Don't call escape_json here if it's a valid JSON number.
*/
dummy_lex
.
input
=
*
outputstr
==
'-'
?
outputstr
+
1
:
outputstr
;
dummy_lex
.
input_length
=
strlen
(
dummy_lex
.
input
);
json_lex_number
(
&
dummy_lex
,
dummy_lex
.
input
,
&
numeric_error
);
if
(
!
numeric_error
)
if
(
!
numeric_error
)
appendStringInfoString
(
result
,
outputstr
);
else
escape_json
(
result
,
outputstr
);
...
...
@@ -1808,34 +1811,34 @@ json_typeof(PG_FUNCTION_ARGS)
JsonLexContext
*
lex
=
makeJsonLexContext
(
json
,
false
);
JsonTokenType
tok
;
char
*
type
;
char
*
type
;
/* Lex exactly one token from the input and check its type. */
json_lex
(
lex
);
tok
=
lex_peek
(
lex
);
switch
(
tok
)
{
case
JSON_TOKEN_OBJECT_START
:
type
=
"object"
;
break
;
case
JSON_TOKEN_ARRAY_START
:
type
=
"array"
;
break
;
case
JSON_TOKEN_STRING
:
type
=
"string"
;
break
;
case
JSON_TOKEN_NUMBER
:
type
=
"number"
;
break
;
case
JSON_TOKEN_TRUE
:
case
JSON_TOKEN_FALSE
:
type
=
"boolean"
;
break
;
case
JSON_TOKEN_NULL
:
type
=
"null"
;
break
;
default:
elog
(
ERROR
,
"unexpected json token: %d"
,
tok
);
case
JSON_TOKEN_OBJECT_START
:
type
=
"object"
;
break
;
case
JSON_TOKEN_ARRAY_START
:
type
=
"array"
;
break
;
case
JSON_TOKEN_STRING
:
type
=
"string"
;
break
;
case
JSON_TOKEN_NUMBER
:
type
=
"number"
;
break
;
case
JSON_TOKEN_TRUE
:
case
JSON_TOKEN_FALSE
:
type
=
"boolean"
;
break
;
case
JSON_TOKEN_NULL
:
type
=
"null"
;
break
;
default:
elog
(
ERROR
,
"unexpected json token: %d"
,
tok
);
}
PG_RETURN_TEXT_P
(
cstring_to_text
(
type
));
...
...
src/backend/utils/adt/jsonfuncs.c
浏览文件 @
243ee266
...
...
@@ -106,7 +106,7 @@ typedef struct OkeysState
int
result_size
;
int
result_count
;
int
sent_count
;
}
OkeysState
;
}
OkeysState
;
/* state for json_get* functions */
typedef
struct
GetState
...
...
@@ -127,14 +127,14 @@ typedef struct GetState
bool
*
pathok
;
int
*
array_level_index
;
int
*
path_level_index
;
}
GetState
;
}
GetState
;
/* state for json_array_length */
typedef
struct
AlenState
{
JsonLexContext
*
lex
;
int
count
;
}
AlenState
;
}
AlenState
;
/* state for json_each */
typedef
struct
EachState
...
...
@@ -147,7 +147,7 @@ typedef struct EachState
bool
normalize_results
;
bool
next_scalar
;
char
*
normalized_scalar
;
}
EachState
;
}
EachState
;
/* state for json_array_elements */
typedef
struct
ElementsState
...
...
@@ -157,7 +157,7 @@ typedef struct ElementsState
TupleDesc
ret_tdesc
;
MemoryContext
tmp_cxt
;
char
*
result_start
;
}
ElementsState
;
}
ElementsState
;
/* state for get_json_object_as_hash */
typedef
struct
JhashState
...
...
@@ -168,7 +168,7 @@ typedef struct JhashState
char
*
save_json_start
;
bool
use_json_as_text
;
char
*
function_name
;
}
JHashState
;
}
JHashState
;
/* used to build the hashtable */
typedef
struct
JsonHashEntry
...
...
@@ -177,7 +177,7 @@ typedef struct JsonHashEntry
char
*
val
;
char
*
json
;
bool
isnull
;
}
JsonHashEntry
;
}
JsonHashEntry
;
/* these two are stolen from hstore / record_out, used in populate_record* */
typedef
struct
ColumnIOData
...
...
@@ -209,7 +209,7 @@ typedef struct PopulateRecordsetState
HeapTupleHeader
rec
;
RecordIOData
*
my_extra
;
MemoryContext
fn_mcxt
;
/* used to stash IO funcs */
}
PopulateRecordsetState
;
}
PopulateRecordsetState
;
/*
* SQL function json_object-keys
...
...
@@ -1239,7 +1239,7 @@ json_populate_record(PG_FUNCTION_ARGS)
if
(
!
type_is_rowtype
(
argtype
))
ereport
(
ERROR
,
(
errcode
(
ERRCODE_DATATYPE_MISMATCH
),
errmsg
(
"first argument of json_populate_record must be a row type"
)));
errmsg
(
"first argument of json_populate_record must be a row type"
)));
if
(
PG_ARGISNULL
(
0
))
{
...
...
@@ -1836,7 +1836,7 @@ populate_recordset_array_element_start(void *state, bool isnull)
_state
->
lex
->
token_type
!=
JSON_TOKEN_OBJECT_START
)
ereport
(
ERROR
,
(
errcode
(
ERRCODE_INVALID_PARAMETER_VALUE
),
errmsg
(
"must call json_populate_recordset on an array of objects"
)));
errmsg
(
"must call json_populate_recordset on an array of objects"
)));
}
static
void
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录