OSDN Git Service

Change target version to PG11 and fix the SPEC file
[pghintplan/pg_hint_plan.git] / normalize_query.h
1 /*-------------------------------------------------------------------------
2  *
3  * normalize_query.h
4  *              Normalize query string.
5  *
6  * This header file is created from pg_stat_statements.c to implement
7  * normalization of query string.
8  *
9  * Portions Copyright (c) 2008-2017, PostgreSQL Global Development Group
10  */
11 #ifndef NORMALIZE_QUERY_H
12 #define NORMALIZE_QUERY_H
13
14 /*
15  * Struct for tracking locations/lengths of constants during normalization
16  */
17 typedef struct pgssLocationLen
18 {
19         int                     location;               /* start offset in query text */
20         int                     length;                 /* length in bytes, or -1 to ignore */
21 } pgssLocationLen;
22
23 /*
24  * Working state for computing a query jumble and producing a normalized
25  * query string
26  */
27 typedef struct pgssJumbleState
28 {
29         /* Jumble of current query tree */
30         unsigned char *jumble;
31
32         /* Number of bytes used in jumble[] */
33         Size            jumble_len;
34
35         /* Array of locations of constants that should be removed */
36         pgssLocationLen *clocations;
37
38         /* Allocated length of clocations array */
39         int                     clocations_buf_size;
40
41         /* Current number of valid entries in clocations array */
42         int                     clocations_count;
43
44         /* highest Param id we've seen, in order to start normalization correctly */
45         int                     highest_extern_param_id;
46 } pgssJumbleState;
47
48 static char *
49 generate_normalized_query(pgssJumbleState *jstate, const char *query,
50                                                   int query_loc, int *query_len_p, int encoding);
51 static void JumbleQuery(pgssJumbleState *jstate, Query *query);
52
53 #define JUMBLE_SIZE             1024
54
55 #endif  /* NORMALIZE_QUERY_H */