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);
141 int tag; /* Tag to identify words */
142 char *shortname; /* Property name for short-style JSON */
143 char *longname; /* Property name for long(normal)-style JSON */
144 char *textname; /* Property name for Text representation */
145 bool normalize_use; /* True means this word to be used for
146 normalization, which makes difference of
148 converter_t *converter; /* Converter function for the property name */
149 setter_t *setter; /* Converter function for the property value */
154 StringInfo dest; /* Storage for parse result */
155 pgsp_parser_mode mode; /* Tells what to do to the parser */
156 node_vals *nodevals; /* Node value holder */
157 char *org_string; /* What to parse */
159 /* Working variables used internally in parser */
160 int level; /* Next (indent or object) level */
161 Bitmapset *plan_levels; /* Level list for Plan objects */
162 Bitmapset *first; /* Bitmap set holds whether the first element
163 * has been processed for each level */
164 Bitmapset *not_item; /* Bitmap set holds whether the node name at
165 the level was literally "Item" or not. */
166 bool remove; /* True if the current node is not shown in
168 bool last_elem_is_object; /* True if the last processed element
170 pgsp_prop_tags section; /* explain section under processing */
171 pgsp_prop_tags current_list; /* current list tag that needs special treat*/
172 StringInfo work_str; /* StringInfor for very-short term usage */
173 char *list_fname; /* the field name of the current_list */
174 char *fname; /* Field name*/
175 char *wbuf; /* Working buffer */
176 int wbuflen; /* Length of the working buffer */
177 int wlist_level; /* Nest level of list for Grouping Sets */
178 grouping_set *tmp_gset; /* Working area for grouping sets */
180 converter_t *valconverter; /* field name converter for the current
182 setter_t *setter; /* value converter for the current element */
186 extern word_table nodetypes[];
187 extern word_table strategies[];
188 extern word_table propfields[];
190 extern void init_word_index(void);
191 extern word_table *search_word_table(word_table *tbl,
192 const char *word, int mode);
193 extern const char *conv_nodetype(const char *src, pgsp_parser_mode mode);
194 extern const char *conv_operation(const char *src, pgsp_parser_mode mode);
195 extern const char *conv_scandir(const char *src, pgsp_parser_mode mode);
196 extern const char *conv_expression(const char *src, pgsp_parser_mode mode);
197 extern const char *conv_relasionship(const char *src, pgsp_parser_mode mode);
198 extern const char *conv_jointype(const char *src, pgsp_parser_mode mode);
199 extern const char *conv_strategy(const char *src, pgsp_parser_mode mode);
200 extern const char *conv_setsetopcommand(const char *src, pgsp_parser_mode mode);
201 extern const char *conv_sortmethod(const char *src, pgsp_parser_mode mode);
202 extern const char *conv_sortspacetype(const char *src, pgsp_parser_mode mode);
203 extern const char *conv_partialmode(const char *src, pgsp_parser_mode mode);
205 extern bool run_pg_parse_json(JsonLexContext *lex, JsonSemAction *sem);
206 extern void init_parser_context(pgspParserContext *ctx, int mode,
207 char *orgstr, char *buf,int buflen);
208 extern void init_json_lex_context(JsonLexContext *lex, char *json);