pg_query 2.1.4 → 2.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 +29 -0
- data/README.md +32 -0
- data/Rakefile +2 -2
- data/ext/pg_query/include/access/twophase.h +2 -0
- data/ext/pg_query/include/access/xact.h +6 -0
- data/ext/pg_query/include/access/xlog_internal.h +10 -1
- data/ext/pg_query/include/access/xlogreader.h +10 -0
- data/ext/pg_query/include/catalog/dependency.h +2 -0
- data/ext/pg_query/include/catalog/pg_class.h +1 -1
- data/ext/pg_query/include/catalog/pg_class_d.h +1 -1
- data/ext/pg_query/include/catalog/pg_control.h +2 -0
- data/ext/pg_query/include/catalog/pg_operator.h +3 -1
- data/ext/pg_query/include/catalog/pg_publication.h +3 -0
- data/ext/pg_query/include/catalog/pg_type.h +1 -0
- data/ext/pg_query/include/commands/async.h +1 -1
- data/ext/pg_query/include/commands/tablespace.h +2 -0
- data/ext/pg_query/include/commands/trigger.h +8 -0
- data/ext/pg_query/include/lib/simplehash.h +13 -13
- data/ext/pg_query/include/libpq/libpq.h +1 -0
- data/ext/pg_query/include/mb/pg_wchar.h +1 -0
- data/ext/pg_query/include/miscadmin.h +24 -11
- data/ext/pg_query/include/nodes/execnodes.h +2 -2
- data/ext/pg_query/include/nodes/parsenodes.h +5 -4
- data/ext/pg_query/include/nodes/pathnodes.h +2 -1
- data/ext/pg_query/include/nodes/pg_list.h +1 -0
- data/ext/pg_query/include/nodes/plannodes.h +18 -3
- data/ext/pg_query/include/optimizer/optimizer.h +0 -5
- data/ext/pg_query/include/parser/gram.h +2 -2
- data/ext/pg_query/include/parser/kwlist.h +1 -1
- data/ext/pg_query/include/parser/parse_coerce.h +1 -0
- data/ext/pg_query/include/pg_config.h +16 -13
- data/ext/pg_query/include/pg_query.h +2 -2
- data/ext/pg_query/include/pg_query_fingerprint_defs.c +286 -314
- data/ext/pg_query/include/pg_query_outfuncs_defs.c +1 -0
- data/ext/pg_query/include/pg_query_readfuncs_defs.c +1 -0
- data/ext/pg_query/include/pgstat.h +2 -1
- data/ext/pg_query/include/plpgsql.h +2 -2
- data/ext/pg_query/include/port/pg_bitutils.h +48 -2
- data/ext/pg_query/include/port.h +4 -0
- data/ext/pg_query/include/protobuf/pg_query.pb-c.h +4 -3
- data/ext/pg_query/include/replication/reorderbuffer.h +6 -5
- data/ext/pg_query/include/replication/slot.h +1 -1
- data/ext/pg_query/include/storage/block.h +1 -1
- data/ext/pg_query/include/storage/lock.h +6 -5
- data/ext/pg_query/include/storage/lwlock.h +1 -0
- data/ext/pg_query/include/storage/proc.h +14 -0
- data/ext/pg_query/include/storage/s_lock.h +24 -0
- data/ext/pg_query/include/tcop/pquery.h +6 -0
- data/ext/pg_query/include/utils/builtins.h +1 -0
- data/ext/pg_query/include/utils/inval.h +1 -0
- data/ext/pg_query/include/utils/portal.h +13 -0
- data/ext/pg_query/include/utils/rel.h +0 -1
- data/ext/pg_query/include/utils/relcache.h +1 -2
- data/ext/pg_query/include/utils/snapmgr.h +1 -0
- data/ext/pg_query/pg_query.pb-c.c +18 -5
- data/ext/pg_query/pg_query_deparse.c +8 -8
- data/ext/pg_query/pg_query_fingerprint.c +1 -0
- data/ext/pg_query/pg_query_json_plpgsql.c +68 -0
- data/ext/pg_query/pg_query_normalize.c +43 -7
- data/ext/pg_query/pg_query_outfuncs.h +1 -0
- data/ext/pg_query/pg_query_outfuncs_json.c +11 -0
- data/ext/pg_query/pg_query_parse_plpgsql.c +58 -15
- data/ext/pg_query/src_backend_catalog_namespace.c +1 -0
- data/ext/pg_query/src_backend_libpq_pqcomm.c +8 -0
- data/ext/pg_query/src_backend_nodes_copyfuncs.c +23 -33
- data/ext/pg_query/src_backend_nodes_equalfuncs.c +1 -0
- data/ext/pg_query/src_backend_nodes_list.c +12 -0
- data/ext/pg_query/src_backend_parser_gram.c +18 -3
- data/ext/pg_query/src_backend_parser_scan.c +493 -253
- data/ext/pg_query/src_backend_tcop_postgres.c +11 -1
- data/ext/pg_query/src_backend_utils_adt_ruleutils.c +38 -10
- data/ext/pg_query/src_backend_utils_misc_guc.c +1 -0
- data/ext/pg_query/src_common_wchar.c +11 -0
- data/ext/pg_query/src_pl_plpgsql_src_pl_comp.c +4 -2
- data/ext/pg_query/src_pl_plpgsql_src_pl_gram.c +1 -1
- data/ext/pg_query/src_port_pg_bitutils.c +1 -22
- data/ext/pg_query/src_port_snprintf.c +9 -7
- data/lib/pg_query/deparse.rb +7 -1
- data/lib/pg_query/fingerprint.rb +13 -2
- data/lib/pg_query/parse.rb +5 -3
- data/lib/pg_query/pg_query_pb.rb +2 -1
- data/lib/pg_query/treewalker.rb +6 -0
- data/lib/pg_query/version.rb +1 -1
- metadata +2 -2
@@ -55,7 +55,6 @@
|
|
55
55
|
#include "catalog/pg_type.h"
|
56
56
|
#include "commands/async.h"
|
57
57
|
#include "commands/prepare.h"
|
58
|
-
#include "executor/spi.h"
|
59
58
|
#include "jit/jit.h"
|
60
59
|
#include "libpq/libpq.h"
|
61
60
|
#include "libpq/pqformat.h"
|
@@ -520,6 +519,12 @@ static void disable_statement_timeout(void);
|
|
520
519
|
* If an interrupt condition is pending, and it's safe to service it,
|
521
520
|
* then clear the flag and accept the interrupt. Called only when
|
522
521
|
* InterruptPending is true.
|
522
|
+
*
|
523
|
+
* Note: if INTERRUPTS_CAN_BE_PROCESSED() is true, then ProcessInterrupts
|
524
|
+
* is guaranteed to clear the InterruptPending flag before returning.
|
525
|
+
* (This is not the same as guaranteeing that it's still clear when we
|
526
|
+
* return; another interrupt could have arrived. But we promise that
|
527
|
+
* any pre-existing one will have been serviced.)
|
523
528
|
*/
|
524
529
|
void ProcessInterrupts(void) {}
|
525
530
|
|
@@ -568,9 +573,14 @@ ia64_get_bsp(void)
|
|
568
573
|
*
|
569
574
|
* Returns the old reference point, if any.
|
570
575
|
*/
|
576
|
+
#ifndef HAVE__BUILTIN_FRAME_ADDRESS
|
577
|
+
#endif
|
571
578
|
#if defined(__ia64__) || defined(__ia64)
|
572
579
|
#else
|
573
580
|
#endif
|
581
|
+
#ifdef HAVE__BUILTIN_FRAME_ADDRESS
|
582
|
+
#else
|
583
|
+
#endif
|
574
584
|
#if defined(__ia64__) || defined(__ia64)
|
575
585
|
#endif
|
576
586
|
|
@@ -62,6 +62,7 @@
|
|
62
62
|
#include "parser/parse_func.h"
|
63
63
|
#include "parser/parse_node.h"
|
64
64
|
#include "parser/parse_oper.h"
|
65
|
+
#include "parser/parse_relation.h"
|
65
66
|
#include "parser/parser.h"
|
66
67
|
#include "parser/parsetree.h"
|
67
68
|
#include "rewrite/rewriteHandler.h"
|
@@ -392,26 +393,29 @@ static void make_ruledef(StringInfo buf, HeapTuple ruletup, TupleDesc rulettc,
|
|
392
393
|
static void make_viewdef(StringInfo buf, HeapTuple ruletup, TupleDesc rulettc,
|
393
394
|
int prettyFlags, int wrapColumn);
|
394
395
|
static void get_query_def(Query *query, StringInfo buf, List *parentnamespace,
|
395
|
-
TupleDesc resultDesc,
|
396
|
+
TupleDesc resultDesc, bool colNamesVisible,
|
396
397
|
int prettyFlags, int wrapColumn, int startIndent);
|
397
398
|
static void get_values_def(List *values_lists, deparse_context *context);
|
398
399
|
static void get_with_clause(Query *query, deparse_context *context);
|
399
400
|
static void get_select_query_def(Query *query, deparse_context *context,
|
400
|
-
TupleDesc resultDesc);
|
401
|
-
static void get_insert_query_def(Query *query, deparse_context *context
|
402
|
-
|
401
|
+
TupleDesc resultDesc, bool colNamesVisible);
|
402
|
+
static void get_insert_query_def(Query *query, deparse_context *context,
|
403
|
+
bool colNamesVisible);
|
404
|
+
static void get_update_query_def(Query *query, deparse_context *context,
|
405
|
+
bool colNamesVisible);
|
403
406
|
static void get_update_query_targetlist_def(Query *query, List *targetList,
|
404
407
|
deparse_context *context,
|
405
408
|
RangeTblEntry *rte);
|
406
|
-
static void get_delete_query_def(Query *query, deparse_context *context
|
409
|
+
static void get_delete_query_def(Query *query, deparse_context *context,
|
410
|
+
bool colNamesVisible);
|
407
411
|
static void get_utility_query_def(Query *query, deparse_context *context);
|
408
412
|
static void get_basic_select_query(Query *query, deparse_context *context,
|
409
|
-
TupleDesc resultDesc);
|
413
|
+
TupleDesc resultDesc, bool colNamesVisible);
|
410
414
|
static void get_target_list(List *targetList, deparse_context *context,
|
411
|
-
TupleDesc resultDesc);
|
415
|
+
TupleDesc resultDesc, bool colNamesVisible);
|
412
416
|
static void get_setop_query(Node *setOp, Query *query,
|
413
417
|
deparse_context *context,
|
414
|
-
TupleDesc resultDesc);
|
418
|
+
TupleDesc resultDesc, bool colNamesVisible);
|
415
419
|
static Node *get_rule_sortgroupclause(Index ref, List *tlist,
|
416
420
|
bool force_colno,
|
417
421
|
deparse_context *context);
|
@@ -440,6 +444,8 @@ static void get_rule_expr(Node *node, deparse_context *context,
|
|
440
444
|
bool showimplicit);
|
441
445
|
static void get_rule_expr_toplevel(Node *node, deparse_context *context,
|
442
446
|
bool showimplicit);
|
447
|
+
static void get_rule_list_toplevel(List *lst, deparse_context *context,
|
448
|
+
bool showimplicit);
|
443
449
|
static void get_rule_expr_funccall(Node *node, deparse_context *context,
|
444
450
|
bool showimplicit);
|
445
451
|
static bool looks_like_function(Node *node);
|
@@ -1037,8 +1043,18 @@ static void get_reloptions(StringInfo buf, Datum reloptions);
|
|
1037
1043
|
/* ----------
|
1038
1044
|
* get_query_def - Parse back one query parsetree
|
1039
1045
|
*
|
1040
|
-
*
|
1041
|
-
*
|
1046
|
+
* query: parsetree to be displayed
|
1047
|
+
* buf: output text is appended to buf
|
1048
|
+
* parentnamespace: list (initially empty) of outer-level deparse_namespace's
|
1049
|
+
* resultDesc: if not NULL, the output tuple descriptor for the view
|
1050
|
+
* represented by a SELECT query. We use the column names from it
|
1051
|
+
* to label SELECT output columns, in preference to names in the query
|
1052
|
+
* colNamesVisible: true if the surrounding context cares about the output
|
1053
|
+
* column names at all (as, for example, an EXISTS() context does not);
|
1054
|
+
* when false, we can suppress dummy column labels such as "?column?"
|
1055
|
+
* prettyFlags: bitmask of PRETTYFLAG_XXX options
|
1056
|
+
* wrapColumn: maximum line length, or -1 to disable wrapping
|
1057
|
+
* startIndent: initial indentation amount
|
1042
1058
|
* ----------
|
1043
1059
|
*/
|
1044
1060
|
|
@@ -1074,6 +1090,8 @@ static void get_reloptions(StringInfo buf, Datum reloptions);
|
|
1074
1090
|
* get_target_list - Parse back a SELECT target list
|
1075
1091
|
*
|
1076
1092
|
* This is also used for RETURNING lists in INSERT/UPDATE/DELETE.
|
1093
|
+
*
|
1094
|
+
* resultDesc and colNamesVisible are as for get_query_def()
|
1077
1095
|
* ----------
|
1078
1096
|
*/
|
1079
1097
|
|
@@ -1291,6 +1309,16 @@ static void get_reloptions(StringInfo buf, Datum reloptions);
|
|
1291
1309
|
*/
|
1292
1310
|
|
1293
1311
|
|
1312
|
+
/*
|
1313
|
+
* get_rule_list_toplevel - Parse back a list of toplevel expressions
|
1314
|
+
*
|
1315
|
+
* Apply get_rule_expr_toplevel() to each element of a List.
|
1316
|
+
*
|
1317
|
+
* This adds commas between the expressions, but caller is responsible
|
1318
|
+
* for printing surrounding decoration.
|
1319
|
+
*/
|
1320
|
+
|
1321
|
+
|
1294
1322
|
/*
|
1295
1323
|
* get_rule_expr_funccall - Parse back a function-call expression
|
1296
1324
|
*
|
@@ -1618,6 +1618,11 @@ const pg_wchar_tbl pg_wchar_table[] = {
|
|
1618
1618
|
|
1619
1619
|
/*
|
1620
1620
|
* Returns the byte length of a multibyte character.
|
1621
|
+
*
|
1622
|
+
* Caution: when dealing with text that is not certainly valid in the
|
1623
|
+
* specified encoding, the result may exceed the actual remaining
|
1624
|
+
* string length. Callers that are not prepared to deal with that
|
1625
|
+
* should use pg_encoding_mblen_bounded() instead.
|
1621
1626
|
*/
|
1622
1627
|
int
|
1623
1628
|
pg_encoding_mblen(int encoding, const char *mbstr)
|
@@ -1627,6 +1632,12 @@ pg_encoding_mblen(int encoding, const char *mbstr)
|
|
1627
1632
|
pg_wchar_table[PG_SQL_ASCII].mblen((const unsigned char *) mbstr));
|
1628
1633
|
}
|
1629
1634
|
|
1635
|
+
/*
|
1636
|
+
* Returns the byte length of a multibyte character; but not more than
|
1637
|
+
* the distance to end of string.
|
1638
|
+
*/
|
1639
|
+
|
1640
|
+
|
1630
1641
|
/*
|
1631
1642
|
* Returns the display length of a multibyte character.
|
1632
1643
|
*/
|
@@ -385,9 +385,11 @@ add_dummy_return(PLpgSQL_function *function)
|
|
385
385
|
/*
|
386
386
|
* If the outer block has an EXCEPTION clause, we need to make a new outer
|
387
387
|
* block, since the added RETURN shouldn't act like it is inside the
|
388
|
-
* EXCEPTION clause.
|
388
|
+
* EXCEPTION clause. Likewise, if it has a label, wrap it in a new outer
|
389
|
+
* block so that EXIT doesn't skip the RETURN.
|
389
390
|
*/
|
390
|
-
if (function->action->exceptions != NULL
|
391
|
+
if (function->action->exceptions != NULL ||
|
392
|
+
function->action->label != NULL)
|
391
393
|
{
|
392
394
|
PLpgSQL_stmt_block *new;
|
393
395
|
|
@@ -5535,7 +5535,7 @@ make_execsql_stmt(int firsttoken, int location)
|
|
5535
5535
|
|
5536
5536
|
check_sql_expr(expr->query, location, 0);
|
5537
5537
|
|
5538
|
-
execsql =
|
5538
|
+
execsql = palloc0(sizeof(PLpgSQL_stmt_execsql));
|
5539
5539
|
execsql->cmd_type = PLPGSQL_STMT_EXECSQL;
|
5540
5540
|
execsql->lineno = plpgsql_location_to_lineno(location);
|
5541
5541
|
execsql->stmtid = ++plpgsql_curr_compile->nstatements;
|
@@ -1,13 +1,6 @@
|
|
1
1
|
/*--------------------------------------------------------------------
|
2
2
|
* Symbols referenced in this file:
|
3
3
|
* - pg_popcount64
|
4
|
-
* - pg_popcount64_choose
|
5
|
-
* - pg_popcount32
|
6
|
-
* - pg_popcount32_choose
|
7
|
-
* - pg_popcount_available
|
8
|
-
* - pg_popcount32_asm
|
9
|
-
* - pg_popcount64_asm
|
10
|
-
* - pg_popcount32_slow
|
11
4
|
* - pg_popcount64_slow
|
12
5
|
*--------------------------------------------------------------------
|
13
6
|
*/
|
@@ -92,7 +85,7 @@ static int pg_popcount64_asm(uint64 word);
|
|
92
85
|
int (*pg_popcount32) (uint32 word) = pg_popcount32_choose;
|
93
86
|
int (*pg_popcount64) (uint64 word) = pg_popcount64_choose;
|
94
87
|
#else
|
95
|
-
|
88
|
+
|
96
89
|
int (*pg_popcount64) (uint64 word) = pg_popcount64_slow;
|
97
90
|
#endif /* USE_POPCNT_ASM */
|
98
91
|
|
@@ -190,23 +183,9 @@ __asm__ __volatile__(" popcntq %1,%0\n":"=q"(res):"rm"(word):"cc");
|
|
190
183
|
* pg_popcount32_slow
|
191
184
|
* Return the number of 1 bits set in word
|
192
185
|
*/
|
193
|
-
static int
|
194
|
-
pg_popcount32_slow(uint32 word)
|
195
|
-
{
|
196
186
|
#ifdef HAVE__BUILTIN_POPCOUNT
|
197
|
-
return __builtin_popcount(word);
|
198
187
|
#else /* !HAVE__BUILTIN_POPCOUNT */
|
199
|
-
int result = 0;
|
200
|
-
|
201
|
-
while (word != 0)
|
202
|
-
{
|
203
|
-
result += pg_number_of_ones[word & 255];
|
204
|
-
word >>= 8;
|
205
|
-
}
|
206
|
-
|
207
|
-
return result;
|
208
188
|
#endif /* HAVE__BUILTIN_POPCOUNT */
|
209
|
-
}
|
210
189
|
|
211
190
|
/*
|
212
191
|
* pg_popcount64_slow
|
@@ -344,7 +344,7 @@ static bool find_arguments(const char *format, va_list args,
|
|
344
344
|
PrintfArgValue *argvalues);
|
345
345
|
static void fmtstr(const char *value, int leftjust, int minlen, int maxwidth,
|
346
346
|
int pointflag, PrintfTarget *target);
|
347
|
-
static void fmtptr(void *value, PrintfTarget *target);
|
347
|
+
static void fmtptr(const void *value, PrintfTarget *target);
|
348
348
|
static void fmtint(long long value, char type, int forcesign,
|
349
349
|
int leftjust, int minlen, int zpad, int precision, int pointflag,
|
350
350
|
PrintfTarget *target);
|
@@ -418,7 +418,7 @@ dopr(PrintfTarget *target, const char *format, va_list args)
|
|
418
418
|
int cvalue;
|
419
419
|
long long numvalue;
|
420
420
|
double fvalue;
|
421
|
-
char
|
421
|
+
const char *strvalue;
|
422
422
|
PrintfArgValue argvalues[PG_NL_ARGMAX + 1];
|
423
423
|
|
424
424
|
/*
|
@@ -463,7 +463,8 @@ dopr(PrintfTarget *target, const char *format, va_list args)
|
|
463
463
|
{
|
464
464
|
format++;
|
465
465
|
strvalue = va_arg(args, char *);
|
466
|
-
|
466
|
+
if (strvalue == NULL)
|
467
|
+
strvalue = "(null)";
|
467
468
|
dostr(strvalue, strlen(strvalue), target);
|
468
469
|
if (target->failed)
|
469
470
|
break;
|
@@ -694,8 +695,9 @@ nextch2:
|
|
694
695
|
strvalue = argvalues[fmtpos].cptr;
|
695
696
|
else
|
696
697
|
strvalue = va_arg(args, char *);
|
697
|
-
/*
|
698
|
-
|
698
|
+
/* If string is NULL, silently substitute "(null)" */
|
699
|
+
if (strvalue == NULL)
|
700
|
+
strvalue = "(null)";
|
699
701
|
fmtstr(strvalue, leftjust, fieldwidth, precision, pointflag,
|
700
702
|
target);
|
701
703
|
break;
|
@@ -705,7 +707,7 @@ nextch2:
|
|
705
707
|
strvalue = argvalues[fmtpos].cptr;
|
706
708
|
else
|
707
709
|
strvalue = va_arg(args, char *);
|
708
|
-
fmtptr((void *) strvalue, target);
|
710
|
+
fmtptr((const void *) strvalue, target);
|
709
711
|
break;
|
710
712
|
case 'e':
|
711
713
|
case 'E':
|
@@ -1019,7 +1021,7 @@ fmtstr(const char *value, int leftjust, int minlen, int maxwidth,
|
|
1019
1021
|
}
|
1020
1022
|
|
1021
1023
|
static void
|
1022
|
-
fmtptr(void *value, PrintfTarget *target)
|
1024
|
+
fmtptr(const void *value, PrintfTarget *target)
|
1023
1025
|
{
|
1024
1026
|
int vallen;
|
1025
1027
|
char convert[64];
|
data/lib/pg_query/deparse.rb
CHANGED
@@ -7,7 +7,13 @@ module PgQuery
|
|
7
7
|
|
8
8
|
# Reconstruct all of the parsed queries into their original form
|
9
9
|
def self.deparse(tree)
|
10
|
-
PgQuery
|
10
|
+
if PgQuery::ParseResult.method(:encode).arity == 1
|
11
|
+
PgQuery.deparse_protobuf(PgQuery::ParseResult.encode(tree)).force_encoding('UTF-8')
|
12
|
+
elsif PgQuery::ParseResult.method(:encode).arity == -1
|
13
|
+
PgQuery.deparse_protobuf(PgQuery::ParseResult.encode(tree, recursion_limit: 1_000)).force_encoding('UTF-8')
|
14
|
+
else
|
15
|
+
raise ArgumentError, 'Unsupported protobuf Ruby API'
|
16
|
+
end
|
11
17
|
end
|
12
18
|
|
13
19
|
# Convenience method for deparsing a statement of a specific type
|
data/lib/pg_query/fingerprint.rb
CHANGED
@@ -39,6 +39,11 @@ module PgQuery
|
|
39
39
|
subhash = FingerprintSubHash.new
|
40
40
|
|
41
41
|
if val.is_a?(Google::Protobuf::RepeatedField)
|
42
|
+
# For lists that have exactly one untyped node, just output the parent field (if needed) and return
|
43
|
+
if val.length == 1 && val[0].is_a?(Node) && val[0].node.nil?
|
44
|
+
hash.update(parent_field_name) if need_to_write_name
|
45
|
+
return
|
46
|
+
end
|
42
47
|
fingerprint_list(val, subhash, parent_node_name, parent_field_name)
|
43
48
|
elsif val.is_a?(List)
|
44
49
|
fingerprint_list(val.items, subhash, parent_node_name, parent_field_name)
|
@@ -90,12 +95,18 @@ module PgQuery
|
|
90
95
|
when 'location'
|
91
96
|
next
|
92
97
|
when 'name'
|
93
|
-
next if [PrepareStmt, ExecuteStmt, DeallocateStmt].include?(node.class)
|
98
|
+
next if [PrepareStmt, ExecuteStmt, DeallocateStmt, FunctionParameter].include?(node.class)
|
94
99
|
next if node.is_a?(ResTarget) && parent_node_name == 'SelectStmt' && parent_field_name == 'targetList'
|
95
|
-
when 'gid', '
|
100
|
+
when 'gid', 'savepoint_name'
|
96
101
|
next if node.is_a?(TransactionStmt)
|
102
|
+
when 'options'
|
103
|
+
next if [TransactionStmt, CreateFunctionStmt].include?(node.class)
|
97
104
|
when 'portalname'
|
98
105
|
next if [DeclareCursorStmt, FetchStmt, ClosePortalStmt].include?(node.class)
|
106
|
+
when 'conditionname'
|
107
|
+
next if [ListenStmt, UnlistenStmt, NotifyStmt].include?(node.class)
|
108
|
+
when 'args'
|
109
|
+
next if node.is_a?(DoStmt)
|
99
110
|
when 'relname'
|
100
111
|
next if node.is_a?(RangeVar) && node.relpersistence == 't'
|
101
112
|
if node.is_a?(RangeVar)
|
data/lib/pg_query/parse.rb
CHANGED
@@ -216,7 +216,7 @@ module PgQuery
|
|
216
216
|
when :OBJECT_FUNCTION
|
217
217
|
# Only one function can be dropped in a statement
|
218
218
|
obj = statement.drop_stmt.objects[0].object_with_args
|
219
|
-
@functions << { function: obj.objname
|
219
|
+
@functions << { function: obj.objname.map { |f| f.string.str }.join('.'), type: :ddl }
|
220
220
|
end
|
221
221
|
when :grant_stmt
|
222
222
|
objects = statement.grant_stmt.objects
|
@@ -235,18 +235,20 @@ module PgQuery
|
|
235
235
|
statements << statement.explain_stmt.query
|
236
236
|
when :create_function_stmt
|
237
237
|
@functions << {
|
238
|
-
function: statement.create_function_stmt.funcname
|
238
|
+
function: statement.create_function_stmt.funcname.map { |f| f.string.str }.join('.'),
|
239
239
|
type: :ddl
|
240
240
|
}
|
241
241
|
when :rename_stmt
|
242
242
|
if statement.rename_stmt.rename_type == :OBJECT_FUNCTION
|
243
|
-
original_name = statement.rename_stmt.object.object_with_args.objname
|
243
|
+
original_name = statement.rename_stmt.object.object_with_args.objname.map { |f| f.string.str }.join('.')
|
244
244
|
new_name = statement.rename_stmt.newname
|
245
245
|
@functions += [
|
246
246
|
{ function: original_name, type: :ddl },
|
247
247
|
{ function: new_name, type: :ddl }
|
248
248
|
]
|
249
249
|
end
|
250
|
+
when :prepare_stmt
|
251
|
+
statements << statement.prepare_stmt.query
|
250
252
|
end
|
251
253
|
end
|
252
254
|
|
data/lib/pg_query/pg_query_pb.rb
CHANGED
@@ -809,6 +809,7 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
|
|
809
809
|
optional :def, :message, 5, "pg_query.Node", json_name: "def"
|
810
810
|
optional :behavior, :enum, 6, "pg_query.DropBehavior", json_name: "behavior"
|
811
811
|
optional :missing_ok, :bool, 7, json_name: "missing_ok"
|
812
|
+
optional :recurse, :bool, 8, json_name: "recurse"
|
812
813
|
end
|
813
814
|
add_message "pg_query.AlterDomainStmt" do
|
814
815
|
optional :subtype, :string, 1, json_name: "subtype"
|
@@ -2766,7 +2767,7 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
|
|
2766
2767
|
value :REASSIGN, 579
|
2767
2768
|
value :RECHECK, 580
|
2768
2769
|
value :RECURSIVE, 581
|
2769
|
-
value :
|
2770
|
+
value :REF_P, 582
|
2770
2771
|
value :REFERENCES, 583
|
2771
2772
|
value :REFERENCING, 584
|
2772
2773
|
value :REFRESH, 585
|
data/lib/pg_query/treewalker.rb
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
module PgQuery
|
2
2
|
class ParserResult
|
3
|
+
def walk!
|
4
|
+
treewalker!(@tree) do |parent_node, parent_field, node, location|
|
5
|
+
yield(parent_node, parent_field, node, location)
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
3
9
|
private
|
4
10
|
|
5
11
|
def treewalker!(tree) # rubocop:disable Metrics/CyclomaticComplexity
|
data/lib/pg_query/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pg_query
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1
|
4
|
+
version: 2.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lukas Fittl
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-01-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake-compiler
|