1 /*-------------------------------------------------------------------------
3 * pgsp_json_int.h: Definitions for internal use for pgsp_json.c
5 * Copyright (c) 2012-2021, NIPPON TELEGRAPH AND TELEPHONE CORPORATION
8 * pg_store_plans/pgsp_json_int.h
10 *-------------------------------------------------------------------------
32 typedef const char *(converter_t)(const char *src, pgsp_parser_mode mode);
33 typedef void (setter_t)(node_vals *vals, const char *val);
142 int tag; /* Tag to identify words */
143 char *shortname; /* Property name for short-style JSON */
144 char *longname; /* Property name for long(normal)-style JSON */
145 char *textname; /* Property name for Text representation */
146 bool normalize_use; /* True means this word to be used for
147 normalization, which makes difference of
149 converter_t *converter; /* Converter function for the property name */
150 setter_t *setter; /* Converter function for the property value */
155 StringInfo dest; /* Storage for parse result */
156 pgsp_parser_mode mode; /* Tells what to do to the parser */
157 node_vals *nodevals; /* Node value holder */
158 char *org_string; /* What to parse */
160 /* Working variables used internally in parser */
161 int level; /* Next (indent or object) level */
162 Bitmapset *plan_levels; /* Level list for Plan objects */
163 Bitmapset *first; /* Bitmap set holds whether the first element
164 * has been processed for each level */
165 Bitmapset *not_item; /* Bitmap set holds whether the node name at
166 the level was literally "Item" or not. */
167 bool remove; /* True if the current node is not shown in
169 bool last_elem_is_object; /* True if the last processed element
171 pgsp_prop_tags section; /* explain section under processing */
172 pgsp_prop_tags current_list; /* current list tag that needs special treat*/
173 StringInfo work_str; /* StringInfor for very-short term usage */
174 char *list_fname; /* the field name of the current_list */
175 char *fname; /* Field name*/
176 char *wbuf; /* Working buffer */
177 int wbuflen; /* Length of the working buffer */
178 int wlist_level; /* Nest level of list for Grouping Sets */
179 grouping_set *tmp_gset; /* Working area for grouping sets */
181 converter_t *valconverter; /* field name converter for the current
183 setter_t *setter; /* value converter for the current element */
187 extern word_table nodetypes[];
188 extern word_table strategies[];
189 extern word_table propfields[];
191 extern void init_word_index(void);
192 extern word_table *search_word_table(word_table *tbl,
193 const char *word, int mode);
194 extern const char *conv_nodetype(const char *src, pgsp_parser_mode mode);
195 extern const char *conv_operation(const char *src, pgsp_parser_mode mode);
196 extern const char *conv_scandir(const char *src, pgsp_parser_mode mode);
197 extern const char *conv_expression(const char *src, pgsp_parser_mode mode);
198 extern const char *conv_relasionship(const char *src, pgsp_parser_mode mode);
199 extern const char *conv_jointype(const char *src, pgsp_parser_mode mode);
200 extern const char *conv_strategy(const char *src, pgsp_parser_mode mode);
201 extern const char *conv_setsetopcommand(const char *src, pgsp_parser_mode mode);
202 extern const char *conv_sortmethod(const char *src, pgsp_parser_mode mode);
203 extern const char *conv_sortspacetype(const char *src, pgsp_parser_mode mode);
204 extern const char *conv_partialmode(const char *src, pgsp_parser_mode mode);
206 extern bool run_pg_parse_json(JsonLexContext *lex, JsonSemAction *sem);
207 extern void init_parser_context(pgspParserContext *ctx, int mode,
208 char *orgstr, char *buf,int buflen);
209 extern void init_json_lex_context(JsonLexContext *lex, char *json);