|
42 | 42 | #defineJB_PATH_CREATE_OR_INSERT \ |
43 | 43 | (JB_PATH_INSERT_BEFORE | JB_PATH_INSERT_AFTER | JB_PATH_CREATE) |
44 | 44 |
|
45 | | -/* semantic action functions for json_object_keys */ |
46 | | -staticvoidokeys_object_field_start(void*state,char*fname,boolisnull); |
47 | | -staticvoidokeys_array_start(void*state); |
48 | | -staticvoidokeys_scalar(void*state,char*token,JsonTokenTypetokentype); |
49 | | - |
50 | | -/* semantic action functions for json_get* functions */ |
51 | | -staticvoidget_object_start(void*state); |
52 | | -staticvoidget_object_end(void*state); |
53 | | -staticvoidget_object_field_start(void*state,char*fname,boolisnull); |
54 | | -staticvoidget_object_field_end(void*state,char*fname,boolisnull); |
55 | | -staticvoidget_array_start(void*state); |
56 | | -staticvoidget_array_end(void*state); |
57 | | -staticvoidget_array_element_start(void*state,boolisnull); |
58 | | -staticvoidget_array_element_end(void*state,boolisnull); |
59 | | -staticvoidget_scalar(void*state,char*token,JsonTokenTypetokentype); |
60 | | - |
61 | | -/* common worker function for json getter functions */ |
62 | | -staticDatumget_path_all(FunctionCallInfofcinfo,boolas_text); |
63 | | -statictext*get_worker(text*json,char**tpath,int*ipath,intnpath, |
64 | | -boolnormalize_results); |
65 | | -staticDatumget_jsonb_path_all(FunctionCallInfofcinfo,boolas_text); |
66 | | - |
67 | | -/* semantic action functions for json_array_length */ |
68 | | -staticvoidalen_object_start(void*state); |
69 | | -staticvoidalen_scalar(void*state,char*token,JsonTokenTypetokentype); |
70 | | -staticvoidalen_array_element_start(void*state,boolisnull); |
71 | | - |
72 | | -/* common workers for json{b}_each* functions */ |
73 | | -staticDatumeach_worker(FunctionCallInfofcinfo,boolas_text); |
74 | | -staticDatumeach_worker_jsonb(FunctionCallInfofcinfo,constchar*funcname, |
75 | | -boolas_text); |
76 | | - |
77 | | -/* semantic action functions for json_each */ |
78 | | -staticvoideach_object_field_start(void*state,char*fname,boolisnull); |
79 | | -staticvoideach_object_field_end(void*state,char*fname,boolisnull); |
80 | | -staticvoideach_array_start(void*state); |
81 | | -staticvoideach_scalar(void*state,char*token,JsonTokenTypetokentype); |
82 | | - |
83 | | -/* common workers for json{b}_array_elements_* functions */ |
84 | | -staticDatumelements_worker(FunctionCallInfofcinfo,constchar*funcname, |
85 | | -boolas_text); |
86 | | -staticDatumelements_worker_jsonb(FunctionCallInfofcinfo,constchar*funcname, |
87 | | -boolas_text); |
88 | | - |
89 | | -/* semantic action functions for json_array_elements */ |
90 | | -staticvoidelements_object_start(void*state); |
91 | | -staticvoidelements_array_element_start(void*state,boolisnull); |
92 | | -staticvoidelements_array_element_end(void*state,boolisnull); |
93 | | -staticvoidelements_scalar(void*state,char*token,JsonTokenTypetokentype); |
94 | | - |
95 | | -/* turn a json object into a hash table */ |
96 | | -staticHTAB*get_json_object_as_hash(text*json,constchar*funcname); |
97 | | - |
98 | | -/* common worker for populate_record and to_record */ |
99 | | -staticDatumpopulate_record_worker(FunctionCallInfofcinfo,constchar*funcname, |
100 | | -boolhave_record_arg); |
101 | | - |
102 | | -/* semantic action functions for get_json_object_as_hash */ |
103 | | -staticvoidhash_object_field_start(void*state,char*fname,boolisnull); |
104 | | -staticvoidhash_object_field_end(void*state,char*fname,boolisnull); |
105 | | -staticvoidhash_array_start(void*state); |
106 | | -staticvoidhash_scalar(void*state,char*token,JsonTokenTypetokentype); |
107 | | - |
108 | | -/* semantic action functions for populate_recordset */ |
109 | | -staticvoidpopulate_recordset_object_field_start(void*state,char*fname,boolisnull); |
110 | | -staticvoidpopulate_recordset_object_field_end(void*state,char*fname,boolisnull); |
111 | | -staticvoidpopulate_recordset_scalar(void*state,char*token,JsonTokenTypetokentype); |
112 | | -staticvoidpopulate_recordset_object_start(void*state); |
113 | | -staticvoidpopulate_recordset_object_end(void*state); |
114 | | -staticvoidpopulate_recordset_array_start(void*state); |
115 | | -staticvoidpopulate_recordset_array_element_start(void*state,boolisnull); |
116 | | - |
117 | | -/* semantic action functions for json_strip_nulls */ |
118 | | -staticvoidsn_object_start(void*state); |
119 | | -staticvoidsn_object_end(void*state); |
120 | | -staticvoidsn_array_start(void*state); |
121 | | -staticvoidsn_array_end(void*state); |
122 | | -staticvoidsn_object_field_start(void*state,char*fname,boolisnull); |
123 | | -staticvoidsn_array_element_start(void*state,boolisnull); |
124 | | -staticvoidsn_scalar(void*state,char*token,JsonTokenTypetokentype); |
125 | | - |
126 | | -/* worker function for populate_recordset and to_recordset */ |
127 | | -staticDatumpopulate_recordset_worker(FunctionCallInfofcinfo,constchar*funcname, |
128 | | -boolhave_record_arg); |
129 | | - |
130 | | -/* Worker that takes care of common setup for us */ |
131 | | -staticJsonbValue*findJsonbValueFromContainerLen(JsonbContainer*container, |
132 | | -uint32flags, |
133 | | -char*key, |
134 | | -uint32keylen); |
135 | | - |
136 | | -/* functions supporting jsonb_delete, jsonb_set and jsonb_concat */ |
137 | | -staticJsonbValue*IteratorConcat(JsonbIterator**it1,JsonbIterator**it2, |
138 | | -JsonbParseState**state); |
139 | | -staticJsonbValue*setPath(JsonbIterator**it,Datum*path_elems, |
140 | | -bool*path_nulls,intpath_len, |
141 | | -JsonbParseState**st,intlevel,Jsonb*newval, |
142 | | -intop_type); |
143 | | -staticvoidsetPathObject(JsonbIterator**it,Datum*path_elems, |
144 | | -bool*path_nulls,intpath_len,JsonbParseState**st, |
145 | | -intlevel, |
146 | | -Jsonb*newval,uint32npairs,intop_type); |
147 | | -staticvoidsetPathArray(JsonbIterator**it,Datum*path_elems, |
148 | | -bool*path_nulls,intpath_len,JsonbParseState**st, |
149 | | -intlevel,Jsonb*newval,uint32nelems,intop_type); |
150 | | -staticvoidaddJsonbToParseState(JsonbParseState**jbps,Jsonb*jb); |
151 | | - |
152 | 45 | /* state for json_object_keys */ |
153 | 46 | typedefstructOkeysState |
154 | 47 | { |
@@ -267,10 +160,118 @@ typedef struct StripnullState |
267 | 160 | boolskip_next_null; |
268 | 161 | }StripnullState; |
269 | 162 |
|
| 163 | +/* semantic action functions for json_object_keys */ |
| 164 | +staticvoidokeys_object_field_start(void*state,char*fname,boolisnull); |
| 165 | +staticvoidokeys_array_start(void*state); |
| 166 | +staticvoidokeys_scalar(void*state,char*token,JsonTokenTypetokentype); |
| 167 | + |
| 168 | +/* semantic action functions for json_get* functions */ |
| 169 | +staticvoidget_object_start(void*state); |
| 170 | +staticvoidget_object_end(void*state); |
| 171 | +staticvoidget_object_field_start(void*state,char*fname,boolisnull); |
| 172 | +staticvoidget_object_field_end(void*state,char*fname,boolisnull); |
| 173 | +staticvoidget_array_start(void*state); |
| 174 | +staticvoidget_array_end(void*state); |
| 175 | +staticvoidget_array_element_start(void*state,boolisnull); |
| 176 | +staticvoidget_array_element_end(void*state,boolisnull); |
| 177 | +staticvoidget_scalar(void*state,char*token,JsonTokenTypetokentype); |
| 178 | + |
| 179 | +/* common worker function for json getter functions */ |
| 180 | +staticDatumget_path_all(FunctionCallInfofcinfo,boolas_text); |
| 181 | +statictext*get_worker(text*json,char**tpath,int*ipath,intnpath, |
| 182 | +boolnormalize_results); |
| 183 | +staticDatumget_jsonb_path_all(FunctionCallInfofcinfo,boolas_text); |
| 184 | + |
| 185 | +/* semantic action functions for json_array_length */ |
| 186 | +staticvoidalen_object_start(void*state); |
| 187 | +staticvoidalen_scalar(void*state,char*token,JsonTokenTypetokentype); |
| 188 | +staticvoidalen_array_element_start(void*state,boolisnull); |
| 189 | + |
| 190 | +/* common workers for json{b}_each* functions */ |
| 191 | +staticDatumeach_worker(FunctionCallInfofcinfo,boolas_text); |
| 192 | +staticDatumeach_worker_jsonb(FunctionCallInfofcinfo,constchar*funcname, |
| 193 | +boolas_text); |
| 194 | + |
| 195 | +/* semantic action functions for json_each */ |
| 196 | +staticvoideach_object_field_start(void*state,char*fname,boolisnull); |
| 197 | +staticvoideach_object_field_end(void*state,char*fname,boolisnull); |
| 198 | +staticvoideach_array_start(void*state); |
| 199 | +staticvoideach_scalar(void*state,char*token,JsonTokenTypetokentype); |
| 200 | + |
| 201 | +/* common workers for json{b}_array_elements_* functions */ |
| 202 | +staticDatumelements_worker(FunctionCallInfofcinfo,constchar*funcname, |
| 203 | +boolas_text); |
| 204 | +staticDatumelements_worker_jsonb(FunctionCallInfofcinfo,constchar*funcname, |
| 205 | +boolas_text); |
| 206 | + |
| 207 | +/* semantic action functions for json_array_elements */ |
| 208 | +staticvoidelements_object_start(void*state); |
| 209 | +staticvoidelements_array_element_start(void*state,boolisnull); |
| 210 | +staticvoidelements_array_element_end(void*state,boolisnull); |
| 211 | +staticvoidelements_scalar(void*state,char*token,JsonTokenTypetokentype); |
| 212 | + |
| 213 | +/* turn a json object into a hash table */ |
| 214 | +staticHTAB*get_json_object_as_hash(text*json,constchar*funcname); |
| 215 | + |
| 216 | +/* common worker for populate_record and to_record */ |
| 217 | +staticDatumpopulate_record_worker(FunctionCallInfofcinfo,constchar*funcname, |
| 218 | +boolhave_record_arg); |
| 219 | + |
| 220 | +/* semantic action functions for get_json_object_as_hash */ |
| 221 | +staticvoidhash_object_field_start(void*state,char*fname,boolisnull); |
| 222 | +staticvoidhash_object_field_end(void*state,char*fname,boolisnull); |
| 223 | +staticvoidhash_array_start(void*state); |
| 224 | +staticvoidhash_scalar(void*state,char*token,JsonTokenTypetokentype); |
| 225 | + |
| 226 | +/* semantic action functions for populate_recordset */ |
| 227 | +staticvoidpopulate_recordset_object_field_start(void*state,char*fname,boolisnull); |
| 228 | +staticvoidpopulate_recordset_object_field_end(void*state,char*fname,boolisnull); |
| 229 | +staticvoidpopulate_recordset_scalar(void*state,char*token,JsonTokenTypetokentype); |
| 230 | +staticvoidpopulate_recordset_object_start(void*state); |
| 231 | +staticvoidpopulate_recordset_object_end(void*state); |
| 232 | +staticvoidpopulate_recordset_array_start(void*state); |
| 233 | +staticvoidpopulate_recordset_array_element_start(void*state,boolisnull); |
| 234 | + |
| 235 | +/* semantic action functions for json_strip_nulls */ |
| 236 | +staticvoidsn_object_start(void*state); |
| 237 | +staticvoidsn_object_end(void*state); |
| 238 | +staticvoidsn_array_start(void*state); |
| 239 | +staticvoidsn_array_end(void*state); |
| 240 | +staticvoidsn_object_field_start(void*state,char*fname,boolisnull); |
| 241 | +staticvoidsn_array_element_start(void*state,boolisnull); |
| 242 | +staticvoidsn_scalar(void*state,char*token,JsonTokenTypetokentype); |
| 243 | + |
270 | 244 | /* Turn a jsonb object into a record */ |
271 | 245 | staticvoidmake_row_from_rec_and_jsonb(Jsonb*element, |
272 | 246 | PopulateRecordsetState*state); |
273 | 247 |
|
| 248 | +/* worker function for populate_recordset and to_recordset */ |
| 249 | +staticDatumpopulate_recordset_worker(FunctionCallInfofcinfo,constchar*funcname, |
| 250 | +boolhave_record_arg); |
| 251 | + |
| 252 | +/* Worker that takes care of common setup for us */ |
| 253 | +staticJsonbValue*findJsonbValueFromContainerLen(JsonbContainer*container, |
| 254 | +uint32flags, |
| 255 | +char*key, |
| 256 | +uint32keylen); |
| 257 | + |
| 258 | +/* functions supporting jsonb_delete, jsonb_set and jsonb_concat */ |
| 259 | +staticJsonbValue*IteratorConcat(JsonbIterator**it1,JsonbIterator**it2, |
| 260 | +JsonbParseState**state); |
| 261 | +staticJsonbValue*setPath(JsonbIterator**it,Datum*path_elems, |
| 262 | +bool*path_nulls,intpath_len, |
| 263 | +JsonbParseState**st,intlevel,Jsonb*newval, |
| 264 | +intop_type); |
| 265 | +staticvoidsetPathObject(JsonbIterator**it,Datum*path_elems, |
| 266 | +bool*path_nulls,intpath_len,JsonbParseState**st, |
| 267 | +intlevel, |
| 268 | +Jsonb*newval,uint32npairs,intop_type); |
| 269 | +staticvoidsetPathArray(JsonbIterator**it,Datum*path_elems, |
| 270 | +bool*path_nulls,intpath_len,JsonbParseState**st, |
| 271 | +intlevel,Jsonb*newval,uint32nelems,intop_type); |
| 272 | +staticvoidaddJsonbToParseState(JsonbParseState**jbps,Jsonb*jb); |
| 273 | + |
| 274 | + |
274 | 275 | /* |
275 | 276 | * SQL function json_object_keys |
276 | 277 | * |
|