pg_query 6.1.0 → 6.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +38 -1
- data/README.md +1 -1
- data/Rakefile +3 -2
- data/ext/pg_query/extconf.rb +2 -2
- data/ext/pg_query/include/pg_query.h +32 -2
- data/ext/pg_query/include/postgres/access/amapi.h +1 -1
- data/ext/pg_query/include/postgres/access/slru.h +1 -1
- data/ext/pg_query/include/postgres/access/tableam.h +11 -4
- data/ext/pg_query/include/postgres/access/xlog.h +1 -0
- data/ext/pg_query/include/postgres/access/xlogdefs.h +2 -1
- data/ext/pg_query/include/postgres/commands/defrem.h +1 -1
- data/ext/pg_query/include/postgres/commands/trigger.h +18 -0
- data/ext/pg_query/include/postgres/executor/executor.h +4 -0
- data/ext/pg_query/include/postgres/mb/pg_wchar.h +2 -0
- data/ext/pg_query/include/postgres/miscadmin.h +2 -1
- data/ext/pg_query/include/postgres/nodes/execnodes.h +6 -8
- data/ext/pg_query/include/postgres/nodes/pathnodes.h +1 -2
- data/ext/pg_query/include/postgres/pg_config.h +10 -9
- data/ext/pg_query/include/postgres/pg_config_manual.h +2 -0
- data/ext/pg_query/include/postgres/port/atomics/generic-gcc.h +10 -2
- data/ext/pg_query/include/postgres/port/pg_iovec.h +9 -3
- data/ext/pg_query/include/postgres/replication/reorderbuffer.h +29 -9
- data/ext/pg_query/include/postgres/replication/slot.h +2 -0
- data/ext/pg_query/include/postgres/utils/elog.h +1 -0
- data/ext/pg_query/include/postgres/utils/guc.h +1 -1
- data/ext/pg_query/include/postgres/utils/guc_hooks.h +0 -2
- data/ext/pg_query/include/postgres/utils/pg_locale.h +5 -0
- data/ext/pg_query/include/postgres_deparse.h +34 -0
- data/ext/pg_query/include/protobuf/pg_query.pb-c.h +673 -516
- data/ext/pg_query/pg_query.pb-c.c +488 -0
- data/ext/pg_query/pg_query_deparse.c +148 -15
- data/ext/pg_query/pg_query_internal.h +9 -8
- data/ext/pg_query/pg_query_is_utility_stmt.c +70 -0
- data/ext/pg_query/pg_query_normalize.c +3 -0
- data/ext/pg_query/pg_query_raw_tree_walker_supports.c +117 -0
- data/ext/pg_query/pg_query_ruby.c +150 -0
- data/ext/pg_query/pg_query_summary.c +941 -0
- data/ext/pg_query/pg_query_summary.h +109 -0
- data/ext/pg_query/pg_query_summary_statement_type.c +797 -0
- data/ext/pg_query/pg_query_summary_truncate.c +530 -0
- data/ext/pg_query/postgres_deparse.c +4481 -3870
- data/ext/pg_query/src_backend_catalog_namespace.c +29 -0
- data/ext/pg_query/src_backend_nodes_bitmapset.c +84 -1
- data/ext/pg_query/src_backend_nodes_list.c +60 -1
- data/ext/pg_query/src_backend_parser_gram.c +739 -732
- data/ext/pg_query/src_backend_utils_activity_pgstat_database.c +2 -2
- data/ext/pg_query/src_backend_utils_error_elog.c +11 -0
- data/ext/pg_query/src_backend_utils_mb_mbutils.c +43 -4
- data/ext/pg_query/src_backend_utils_mmgr_alignedalloc.c +22 -7
- data/ext/pg_query/src_backend_utils_mmgr_aset.c +3 -3
- data/ext/pg_query/src_backend_utils_mmgr_bump.c +1 -1
- data/ext/pg_query/src_common_stringinfo.c +20 -0
- data/ext/pg_query/src_common_wchar.c +46 -6
- data/lib/pg_query/deparse.rb +29 -8
- data/lib/pg_query/parse.rb +19 -0
- data/lib/pg_query/pg_query_pb.rb +7 -2
- data/lib/pg_query/split.rb +20 -0
- data/lib/pg_query/treewalker.rb +9 -7
- data/lib/pg_query/version.rb +1 -1
- data/lib/pg_query.rb +1 -0
- metadata +10 -3
- data/ext/pg_query/postgres_deparse.h +0 -9
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
#ifndef PG_QUERY_SUMMARY_H
|
|
2
|
+
#define PG_QUERY_SUMMARY_H
|
|
3
|
+
|
|
4
|
+
#include "pg_query.h"
|
|
5
|
+
#include "pg_query_internal.h"
|
|
6
|
+
|
|
7
|
+
#include "nodes/primnodes.h"
|
|
8
|
+
|
|
9
|
+
#include <unistd.h>
|
|
10
|
+
|
|
11
|
+
typedef enum
|
|
12
|
+
{
|
|
13
|
+
CONTEXT_NONE = 0,
|
|
14
|
+
CONTEXT_SELECT = 1,
|
|
15
|
+
CONTEXT_DML = 2,
|
|
16
|
+
CONTEXT_DDL = 3,
|
|
17
|
+
CONTEXT_CALL = 4,
|
|
18
|
+
} ContextType;
|
|
19
|
+
|
|
20
|
+
typedef struct
|
|
21
|
+
{
|
|
22
|
+
char *name;
|
|
23
|
+
char *schema_name;
|
|
24
|
+
char *table_name;
|
|
25
|
+
ContextType context;
|
|
26
|
+
} SummaryTable;
|
|
27
|
+
|
|
28
|
+
typedef struct
|
|
29
|
+
{
|
|
30
|
+
char *key;
|
|
31
|
+
char *value;
|
|
32
|
+
} SummaryAlias;
|
|
33
|
+
|
|
34
|
+
typedef struct
|
|
35
|
+
{
|
|
36
|
+
char *name;
|
|
37
|
+
char *function_name;
|
|
38
|
+
char *schema_name; /* optional */
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
ContextType context;
|
|
42
|
+
} SummaryFunction;
|
|
43
|
+
|
|
44
|
+
typedef struct
|
|
45
|
+
{
|
|
46
|
+
char *schema_name;
|
|
47
|
+
char *table_name;
|
|
48
|
+
char *column;
|
|
49
|
+
} FilterColumn;
|
|
50
|
+
|
|
51
|
+
typedef struct
|
|
52
|
+
{
|
|
53
|
+
List *tables; /* List of SummaryTable */
|
|
54
|
+
|
|
55
|
+
List *aliases; /* List of SummaryAlias */
|
|
56
|
+
List *cte_names; /* List of char */
|
|
57
|
+
List *functions; /* List of SummaryFunction */
|
|
58
|
+
List *filter_columns; /* List of FilterColumn */
|
|
59
|
+
List *statement_types; /* List of char * */
|
|
60
|
+
|
|
61
|
+
char *truncated_query;
|
|
62
|
+
} Summary;
|
|
63
|
+
|
|
64
|
+
typedef struct
|
|
65
|
+
{
|
|
66
|
+
List *tables; /* List of Table * */
|
|
67
|
+
List *aliases; /* List of SummaryAlias * */
|
|
68
|
+
List *functions; /* List of Function * */
|
|
69
|
+
List *range_vars; /* List of RangeVarWithContext * */
|
|
70
|
+
List *cte_names; /* list of CommonTableExpr */
|
|
71
|
+
List *filter_columns; /* List of FilterColumn * */
|
|
72
|
+
bool save_filter_columns; /* If true, we should be adding to
|
|
73
|
+
* filter columns. */
|
|
74
|
+
} WalkState;
|
|
75
|
+
|
|
76
|
+
typedef struct
|
|
77
|
+
{
|
|
78
|
+
RangeVar *node;
|
|
79
|
+
ContextType context;
|
|
80
|
+
} RangeVarWithContext;
|
|
81
|
+
|
|
82
|
+
/*
|
|
83
|
+
* This is like PgQuerySummaryParseResult, but the summary is not wrapped
|
|
84
|
+
* up in protobuf.
|
|
85
|
+
*/
|
|
86
|
+
typedef struct
|
|
87
|
+
{
|
|
88
|
+
Summary summary;
|
|
89
|
+
char *stderr_buffer;
|
|
90
|
+
PgQueryError *error;
|
|
91
|
+
} PgQuerySummaryParseResultInternal;
|
|
92
|
+
|
|
93
|
+
extern bool pg_query_raw_tree_walker_supports(Node *node);
|
|
94
|
+
|
|
95
|
+
extern void pg_query_summary_statement_walk(Summary * summary, Node *node);
|
|
96
|
+
|
|
97
|
+
extern void pg_query_summary_truncate(Summary * summary, Node *node, int truncate_limit);
|
|
98
|
+
|
|
99
|
+
/*
|
|
100
|
+
* This is like pg_query_summary(), but returns a (non-protobuf)
|
|
101
|
+
* PgQuerySummaryParseResultInternal instead of the usual
|
|
102
|
+
* PgQuerySummaryParseResult which converts the summary to protobuf.
|
|
103
|
+
*
|
|
104
|
+
* This is used for tests, to avoid having to process protobuf in C.
|
|
105
|
+
*/
|
|
106
|
+
extern PgQuerySummaryParseResultInternal pg_query_summary_internal(const char *input, int parser_options, int truncate_limit);
|
|
107
|
+
extern void pg_query_free_summary_parse_result_internal(PgQuerySummaryParseResultInternal result);
|
|
108
|
+
|
|
109
|
+
#endif
|