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

Commit243ee26

Browse files
committed
Reindent json.c and jsonfuncs.c.
This will help in preparation of clean patches for upcomingjson work.
1 parent6c36f38 commit243ee26

File tree

2 files changed

+45
-42
lines changed

2 files changed

+45
-42
lines changed

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

Lines changed: 35 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -751,11 +751,12 @@ json_lex_string(JsonLexContext *lex)
751751
report_json_context(lex)));
752752

753753
/*
754-
* For UTF8, replace the escape sequence by the actual utf8
755-
* character in lex->strval. Do this also for other encodings
756-
* if the escape designates an ASCII character, otherwise
757-
* raise an error. We don't ever unescape a \u0000, since that
758-
* would result in an impermissible nul byte.
754+
* For UTF8, replace the escape sequence by the actual
755+
* utf8 character in lex->strval. Do this also for other
756+
* encodings if the escape designates an ASCII character,
757+
* otherwise raise an error. We don't ever unescape a
758+
* \u0000, since that would result in an impermissible nul
759+
* byte.
759760
*/
760761

761762
if (ch==0)
@@ -771,8 +772,9 @@ json_lex_string(JsonLexContext *lex)
771772
elseif (ch <=0x007f)
772773
{
773774
/*
774-
* This is the only way to designate things like a form feed
775-
* character in JSON, so it's useful in all encodings.
775+
* This is the only way to designate things like a
776+
* form feed character in JSON, so it's useful in all
777+
* encodings.
776778
*/
777779
appendStringInfoChar(lex->strval, (char)ch);
778780
}
@@ -866,7 +868,7 @@ json_lex_string(JsonLexContext *lex)
866868
ereport(ERROR,
867869
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
868870
errmsg("invalid input syntax for type json"),
869-
errdetail("Unicode low surrogate must follow a high surrogate."),
871+
errdetail("Unicode low surrogate must follow a high surrogate."),
870872
report_json_context(lex)));
871873

872874
/* Hooray, we found the end of the string! */
@@ -1221,7 +1223,7 @@ datum_to_json(Datum val, bool is_null, StringInfo result,
12211223
{
12221224
char*outputstr;
12231225
text*jsontext;
1224-
boolnumeric_error;
1226+
boolnumeric_error;
12251227
JsonLexContextdummy_lex;
12261228

12271229
if (is_null)
@@ -1246,13 +1248,14 @@ datum_to_json(Datum val, bool is_null, StringInfo result,
12461248
break;
12471249
caseTYPCATEGORY_NUMERIC:
12481250
outputstr=OidOutputFunctionCall(typoutputfunc,val);
1251+
12491252
/*
12501253
* Don't call escape_json here if it's a valid JSON number.
12511254
*/
12521255
dummy_lex.input=*outputstr=='-' ?outputstr+1 :outputstr;
12531256
dummy_lex.input_length=strlen(dummy_lex.input);
12541257
json_lex_number(&dummy_lex,dummy_lex.input,&numeric_error);
1255-
if (!numeric_error)
1258+
if (!numeric_error)
12561259
appendStringInfoString(result,outputstr);
12571260
else
12581261
escape_json(result,outputstr);
@@ -1808,34 +1811,34 @@ json_typeof(PG_FUNCTION_ARGS)
18081811

18091812
JsonLexContext*lex=makeJsonLexContext(json, false);
18101813
JsonTokenTypetok;
1811-
char*type;
1814+
char*type;
18121815

18131816
/* Lex exactly one token from the input and check its type. */
18141817
json_lex(lex);
18151818
tok=lex_peek(lex);
18161819
switch (tok)
18171820
{
1818-
caseJSON_TOKEN_OBJECT_START:
1819-
type="object";
1820-
break;
1821-
caseJSON_TOKEN_ARRAY_START:
1822-
type="array";
1823-
break;
1824-
caseJSON_TOKEN_STRING:
1825-
type="string";
1826-
break;
1827-
caseJSON_TOKEN_NUMBER:
1828-
type="number";
1829-
break;
1830-
caseJSON_TOKEN_TRUE:
1831-
caseJSON_TOKEN_FALSE:
1832-
type="boolean";
1833-
break;
1834-
caseJSON_TOKEN_NULL:
1835-
type="null";
1836-
break;
1837-
default:
1838-
elog(ERROR,"unexpected json token: %d",tok);
1821+
caseJSON_TOKEN_OBJECT_START:
1822+
type="object";
1823+
break;
1824+
caseJSON_TOKEN_ARRAY_START:
1825+
type="array";
1826+
break;
1827+
caseJSON_TOKEN_STRING:
1828+
type="string";
1829+
break;
1830+
caseJSON_TOKEN_NUMBER:
1831+
type="number";
1832+
break;
1833+
caseJSON_TOKEN_TRUE:
1834+
caseJSON_TOKEN_FALSE:
1835+
type="boolean";
1836+
break;
1837+
caseJSON_TOKEN_NULL:
1838+
type="null";
1839+
break;
1840+
default:
1841+
elog(ERROR,"unexpected json token: %d",tok);
18391842
}
18401843

18411844
PG_RETURN_TEXT_P(cstring_to_text(type));

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ typedef struct OkeysState
106106
intresult_size;
107107
intresult_count;
108108
intsent_count;
109-
}OkeysState;
109+
}OkeysState;
110110

111111
/* state for json_get* functions */
112112
typedefstructGetState
@@ -127,14 +127,14 @@ typedef struct GetState
127127
bool*pathok;
128128
int*array_level_index;
129129
int*path_level_index;
130-
}GetState;
130+
}GetState;
131131

132132
/* state for json_array_length */
133133
typedefstructAlenState
134134
{
135135
JsonLexContext*lex;
136136
intcount;
137-
}AlenState;
137+
}AlenState;
138138

139139
/* state for json_each */
140140
typedefstructEachState
@@ -147,7 +147,7 @@ typedef struct EachState
147147
boolnormalize_results;
148148
boolnext_scalar;
149149
char*normalized_scalar;
150-
}EachState;
150+
}EachState;
151151

152152
/* state for json_array_elements */
153153
typedefstructElementsState
@@ -157,7 +157,7 @@ typedef struct ElementsState
157157
TupleDescret_tdesc;
158158
MemoryContexttmp_cxt;
159159
char*result_start;
160-
}ElementsState;
160+
}ElementsState;
161161

162162
/* state for get_json_object_as_hash */
163163
typedefstructJhashState
@@ -168,7 +168,7 @@ typedef struct JhashState
168168
char*save_json_start;
169169
booluse_json_as_text;
170170
char*function_name;
171-
}JHashState;
171+
}JHashState;
172172

173173
/* used to build the hashtable */
174174
typedefstructJsonHashEntry
@@ -177,7 +177,7 @@ typedef struct JsonHashEntry
177177
char*val;
178178
char*json;
179179
boolisnull;
180-
}JsonHashEntry;
180+
}JsonHashEntry;
181181

182182
/* these two are stolen from hstore / record_out, used in populate_record* */
183183
typedefstructColumnIOData
@@ -209,7 +209,7 @@ typedef struct PopulateRecordsetState
209209
HeapTupleHeaderrec;
210210
RecordIOData*my_extra;
211211
MemoryContextfn_mcxt;/* used to stash IO funcs */
212-
}PopulateRecordsetState;
212+
}PopulateRecordsetState;
213213

214214
/*
215215
* SQL function json_object-keys
@@ -1239,7 +1239,7 @@ json_populate_record(PG_FUNCTION_ARGS)
12391239
if (!type_is_rowtype(argtype))
12401240
ereport(ERROR,
12411241
(errcode(ERRCODE_DATATYPE_MISMATCH),
1242-
errmsg("first argument of json_populate_record must be a row type")));
1242+
errmsg("first argument of json_populate_record must be a row type")));
12431243

12441244
if (PG_ARGISNULL(0))
12451245
{
@@ -1836,7 +1836,7 @@ populate_recordset_array_element_start(void *state, bool isnull)
18361836
_state->lex->token_type!=JSON_TOKEN_OBJECT_START)
18371837
ereport(ERROR,
18381838
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1839-
errmsg("must call json_populate_recordset on an array of objects")));
1839+
errmsg("must call json_populate_recordset on an array of objects")));
18401840
}
18411841

18421842
staticvoid

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp