pg_query 6.0.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 +50 -1
- data/README.md +1 -1
- data/Rakefile +5 -4
- data/ext/pg_query/ext_symbols_freebsd_with_ruby_abi_version.sym +2 -0
- data/ext/pg_query/ext_symbols_openbsd.sym +1 -0
- data/ext/pg_query/ext_symbols_openbsd_with_ruby_abi_version.sym +2 -0
- data/ext/pg_query/ext_symbols_with_ruby_abi_version.sym +2 -0
- data/ext/pg_query/extconf.rb +21 -7
- data/ext/pg_query/include/pg_query.h +32 -2
- data/ext/pg_query/include/postgres/access/amapi.h +5 -1
- data/ext/pg_query/include/postgres/access/genam.h +9 -0
- data/ext/pg_query/include/postgres/access/slru.h +4 -7
- data/ext/pg_query/include/postgres/access/tableam.h +13 -5
- data/ext/pg_query/include/postgres/access/transam.h +43 -0
- 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/c.h +1 -1
- data/ext/pg_query/include/postgres/catalog/objectaddress.h +4 -0
- data/ext/pg_query/include/postgres/commands/defrem.h +1 -1
- data/ext/pg_query/include/postgres/commands/event_trigger.h +6 -0
- data/ext/pg_query/include/postgres/commands/trigger.h +18 -0
- data/ext/pg_query/include/postgres/common/hashfn_unstable.h +6 -52
- data/ext/pg_query/include/postgres/datatype/timestamp.h +1 -1
- data/ext/pg_query/include/postgres/executor/execdesc.h +1 -1
- data/ext/pg_query/include/postgres/executor/executor.h +4 -0
- data/ext/pg_query/include/postgres/libpq/libpq-be.h +6 -3
- data/ext/pg_query/include/postgres/mb/pg_wchar.h +3 -0
- data/ext/pg_query/include/postgres/miscadmin.h +12 -3
- data/ext/pg_query/include/postgres/nodes/execnodes.h +9 -8
- data/ext/pg_query/include/postgres/nodes/pathnodes.h +3 -1
- data/ext/pg_query/include/postgres/nodes/pg_list.h +1 -1
- data/ext/pg_query/include/postgres/nodes/primnodes.h +9 -5
- data/ext/pg_query/include/postgres/parser/parse_coerce.h +3 -0
- data/ext/pg_query/include/postgres/pg_config.h +32 -23
- 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 +11 -5
- data/ext/pg_query/include/postgres/port/win32_port.h +0 -2
- data/ext/pg_query/include/postgres/port.h +32 -1
- data/ext/pg_query/include/postgres/replication/reorderbuffer.h +38 -27
- data/ext/pg_query/include/postgres/replication/slot.h +7 -1
- data/ext/pg_query/include/postgres/storage/lockdefs.h +2 -0
- data/ext/pg_query/include/postgres/storage/proc.h +13 -16
- data/ext/pg_query/include/postgres/storage/smgr.h +5 -2
- data/ext/pg_query/include/postgres/utils/catcache.h +1 -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/utils/pgstat_internal.h +19 -0
- data/ext/pg_query/include/postgres/utils/portal.h +1 -1
- data/ext/pg_query/include/postgres/utils/syscache.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 +4531 -3879
- 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 +740 -733
- 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 +93 -7
- data/ext/pg_query/src_port_snprintf.c +14 -17
- data/lib/pg_query/deparse.rb +29 -8
- data/lib/pg_query/fingerprint.rb +3 -5
- data/lib/pg_query/param_refs.rb +1 -1
- data/lib/pg_query/parse.rb +24 -7
- data/lib/pg_query/parse_error.rb +1 -0
- data/lib/pg_query/pg_query_pb.rb +8 -24
- data/lib/pg_query/scan.rb +1 -0
- data/lib/pg_query/split.rb +20 -0
- data/lib/pg_query/treewalker.rb +11 -13
- data/lib/pg_query/truncate.rb +17 -19
- data/lib/pg_query/version.rb +1 -1
- data/lib/pg_query.rb +1 -0
- metadata +23 -81
- data/ext/pg_query/postgres_deparse.h +0 -9
- /data/ext/pg_query/{pg_query_ruby.sym → ext_symbols.sym} +0 -0
- /data/ext/pg_query/{pg_query_ruby_freebsd.sym → ext_symbols_freebsd.sym} +0 -0
|
@@ -47,6 +47,8 @@ typedef int LOCKMODE;
|
|
|
47
47
|
|
|
48
48
|
#define MaxLockMode 8 /* highest standard lock mode */
|
|
49
49
|
|
|
50
|
+
/* See README.tuplock section "Locking to write inplace-updated tables" */
|
|
51
|
+
#define InplaceUpdateTupleLock ExclusiveLock
|
|
50
52
|
|
|
51
53
|
/* WAL representation of an AccessExclusiveLock on a table */
|
|
52
54
|
typedef struct xl_standby_lock
|
|
@@ -212,7 +212,7 @@ struct PGPROC
|
|
|
212
212
|
Oid tempNamespaceId; /* OID of temp schema this backend is
|
|
213
213
|
* using */
|
|
214
214
|
|
|
215
|
-
bool isBackgroundWorker; /* true if
|
|
215
|
+
bool isBackgroundWorker; /* true if not a regular backend. */
|
|
216
216
|
|
|
217
217
|
/*
|
|
218
218
|
* While in hot standby mode, shows that a conflict signal has been sent
|
|
@@ -313,19 +313,6 @@ struct PGPROC
|
|
|
313
313
|
|
|
314
314
|
extern PGDLLIMPORT PGPROC *MyProc;
|
|
315
315
|
|
|
316
|
-
/* Proc number of this backend. Equal to GetNumberFromPGProc(MyProc). */
|
|
317
|
-
extern PGDLLIMPORT ProcNumber MyProcNumber;
|
|
318
|
-
|
|
319
|
-
/* Our parallel session leader, or INVALID_PROC_NUMBER if none */
|
|
320
|
-
extern PGDLLIMPORT ProcNumber ParallelLeaderProcNumber;
|
|
321
|
-
|
|
322
|
-
/*
|
|
323
|
-
* The proc number to use for our session's temp relations is normally our own,
|
|
324
|
-
* but parallel workers should use their leader's ID.
|
|
325
|
-
*/
|
|
326
|
-
#define ProcNumberForTempRelations() \
|
|
327
|
-
(ParallelLeaderProcNumber == INVALID_PROC_NUMBER ? MyProcNumber : ParallelLeaderProcNumber)
|
|
328
|
-
|
|
329
316
|
/*
|
|
330
317
|
* There is one ProcGlobal struct for the whole database cluster.
|
|
331
318
|
*
|
|
@@ -404,7 +391,7 @@ typedef struct PROC_HDR
|
|
|
404
391
|
uint32 allProcCount;
|
|
405
392
|
/* Head of list of free PGPROC structures */
|
|
406
393
|
dlist_head freeProcs;
|
|
407
|
-
/* Head of list of autovacuum
|
|
394
|
+
/* Head of list of autovacuum & special worker free PGPROC structures */
|
|
408
395
|
dlist_head autovacFreeProcs;
|
|
409
396
|
/* Head of list of bgworker free PGPROC structures */
|
|
410
397
|
dlist_head bgworkerFreeProcs;
|
|
@@ -434,9 +421,19 @@ extern PGDLLIMPORT PGPROC *PreparedXactProcs;
|
|
|
434
421
|
#define GetPGProcByNumber(n) (&ProcGlobal->allProcs[(n)])
|
|
435
422
|
#define GetNumberFromPGProc(proc) ((proc) - &ProcGlobal->allProcs[0])
|
|
436
423
|
|
|
424
|
+
/*
|
|
425
|
+
* We set aside some extra PGPROC structures for "special worker" processes,
|
|
426
|
+
* which are full-fledged backends (they can run transactions)
|
|
427
|
+
* but are unique animals that there's never more than one of.
|
|
428
|
+
* Currently there are two such processes: the autovacuum launcher
|
|
429
|
+
* and the slotsync worker.
|
|
430
|
+
*/
|
|
431
|
+
#define NUM_SPECIAL_WORKER_PROCS 2
|
|
432
|
+
|
|
437
433
|
/*
|
|
438
434
|
* We set aside some extra PGPROC structures for auxiliary processes,
|
|
439
|
-
* ie things that aren't full-fledged backends
|
|
435
|
+
* ie things that aren't full-fledged backends (they cannot run transactions
|
|
436
|
+
* or take heavyweight locks) but need shmem access.
|
|
440
437
|
*
|
|
441
438
|
* Background writer, checkpointer, WAL writer, WAL summarizer, and archiver
|
|
442
439
|
* run during normal operation. Startup process and WAL receiver also consume
|
|
@@ -103,8 +103,11 @@ extern void smgrwriteback(SMgrRelation reln, ForkNumber forknum,
|
|
|
103
103
|
BlockNumber blocknum, BlockNumber nblocks);
|
|
104
104
|
extern BlockNumber smgrnblocks(SMgrRelation reln, ForkNumber forknum);
|
|
105
105
|
extern BlockNumber smgrnblocks_cached(SMgrRelation reln, ForkNumber forknum);
|
|
106
|
-
extern void smgrtruncate(SMgrRelation reln, ForkNumber *forknum,
|
|
107
|
-
|
|
106
|
+
extern void smgrtruncate(SMgrRelation reln, ForkNumber *forknum, int nforks,
|
|
107
|
+
BlockNumber *nblocks);
|
|
108
|
+
extern void smgrtruncate2(SMgrRelation reln, ForkNumber *forknum, int nforks,
|
|
109
|
+
BlockNumber *old_nblocks,
|
|
110
|
+
BlockNumber *nblocks);
|
|
108
111
|
extern void smgrimmedsync(SMgrRelation reln, ForkNumber forknum);
|
|
109
112
|
extern void smgrregistersync(SMgrRelation reln, ForkNumber forknum);
|
|
110
113
|
extern void AtEOXact_SMgr(void);
|
|
@@ -220,6 +220,7 @@ extern CatCList *SearchCatCacheList(CatCache *cache, int nkeys,
|
|
|
220
220
|
extern void ReleaseCatCacheList(CatCList *list);
|
|
221
221
|
|
|
222
222
|
extern void ResetCatalogCaches(void);
|
|
223
|
+
extern void ResetCatalogCachesExt(bool debug_discard);
|
|
223
224
|
extern void CatalogCacheFlushCatalog(Oid catId);
|
|
224
225
|
extern void CatCacheInvalidate(CatCache *cache, uint32 hashValue);
|
|
225
226
|
extern void PrepareToInvalidateCacheTuple(Relation relation,
|
|
@@ -536,5 +536,6 @@ extern void write_jsonlog(ErrorData *edata);
|
|
|
536
536
|
* safely (memory context, GUC load etc)
|
|
537
537
|
*/
|
|
538
538
|
extern void write_stderr(const char *fmt,...) pg_attribute_printf(1, 2);
|
|
539
|
+
extern void vwrite_stderr(const char *fmt, va_list ap) pg_attribute_printf(1, 0);
|
|
539
540
|
|
|
540
541
|
#endif /* ELOG_H */
|
|
@@ -102,7 +102,7 @@ typedef enum
|
|
|
102
102
|
* will show as "default" in pg_settings. If there is a specific reason not
|
|
103
103
|
* to want that, use source == PGC_S_OVERRIDE.
|
|
104
104
|
*
|
|
105
|
-
* NB: see GucSource_Names in
|
|
105
|
+
* NB: see GucSource_Names in guc_tables.c if you change this.
|
|
106
106
|
*/
|
|
107
107
|
typedef enum
|
|
108
108
|
{
|
|
@@ -86,8 +86,6 @@ extern bool check_maintenance_io_concurrency(int *newval, void **extra,
|
|
|
86
86
|
extern void assign_maintenance_io_concurrency(int newval, void *extra);
|
|
87
87
|
extern bool check_max_connections(int *newval, void **extra, GucSource source);
|
|
88
88
|
extern bool check_max_wal_senders(int *newval, void **extra, GucSource source);
|
|
89
|
-
extern bool check_max_slot_wal_keep_size(int *newval, void **extra,
|
|
90
|
-
GucSource source);
|
|
91
89
|
extern void assign_max_wal_size(int newval, void *extra);
|
|
92
90
|
extern bool check_max_worker_processes(int *newval, void **extra,
|
|
93
91
|
GucSource source);
|
|
@@ -16,6 +16,11 @@
|
|
|
16
16
|
#include <xlocale.h>
|
|
17
17
|
#endif
|
|
18
18
|
#ifdef USE_ICU
|
|
19
|
+
/* only include the C APIs, to avoid errors in cpluspluscheck */
|
|
20
|
+
#undef U_SHOW_CPLUSPLUS_API
|
|
21
|
+
#define U_SHOW_CPLUSPLUS_API 0
|
|
22
|
+
#undef U_SHOW_CPLUSPLUS_HEADER_API
|
|
23
|
+
#define U_SHOW_CPLUSPLUS_HEADER_API 0
|
|
19
24
|
#include <unicode/ucol.h>
|
|
20
25
|
#endif
|
|
21
26
|
|
|
@@ -93,6 +93,19 @@ typedef struct PgStatShared_HashEntry
|
|
|
93
93
|
*/
|
|
94
94
|
pg_atomic_uint32 refcount;
|
|
95
95
|
|
|
96
|
+
/*
|
|
97
|
+
* Counter tracking the number of times the entry has been reused.
|
|
98
|
+
*
|
|
99
|
+
* Set to 0 when the entry is created, and incremented by one each time
|
|
100
|
+
* the shared entry is reinitialized with pgstat_reinit_entry().
|
|
101
|
+
*
|
|
102
|
+
* May only be incremented / decremented while holding at least a shared
|
|
103
|
+
* lock on the dshash partition containing the entry. Like refcount, it
|
|
104
|
+
* needs to be an atomic variable because multiple backends can increment
|
|
105
|
+
* the generation with just a shared lock.
|
|
106
|
+
*/
|
|
107
|
+
pg_atomic_uint32 generation;
|
|
108
|
+
|
|
96
109
|
/*
|
|
97
110
|
* Pointer to shared stats. The stats entry always starts with
|
|
98
111
|
* PgStatShared_Common, embedded in a larger struct containing the
|
|
@@ -132,6 +145,12 @@ typedef struct PgStat_EntryRef
|
|
|
132
145
|
*/
|
|
133
146
|
PgStatShared_Common *shared_stats;
|
|
134
147
|
|
|
148
|
+
/*
|
|
149
|
+
* Copy of PgStatShared_HashEntry->generation, keeping locally track of
|
|
150
|
+
* the shared stats entry "generation" retrieved (number of times reused).
|
|
151
|
+
*/
|
|
152
|
+
uint32 generation;
|
|
153
|
+
|
|
135
154
|
/*
|
|
136
155
|
* Pending statistics data that will need to be flushed to shared memory
|
|
137
156
|
* stats eventually. Each stats kind utilizing pending data defines what
|
|
@@ -145,7 +145,7 @@ typedef struct PortalData
|
|
|
145
145
|
/* Features/options */
|
|
146
146
|
PortalStrategy strategy; /* see above */
|
|
147
147
|
int cursorOptions; /* DECLARE CURSOR option bits */
|
|
148
|
-
bool run_once; /*
|
|
148
|
+
bool run_once; /* unused */
|
|
149
149
|
|
|
150
150
|
/* Status data */
|
|
151
151
|
PortalStatus status; /* see above */
|
|
@@ -43,9 +43,14 @@ extern HeapTuple SearchSysCache4(int cacheId,
|
|
|
43
43
|
|
|
44
44
|
extern void ReleaseSysCache(HeapTuple tuple);
|
|
45
45
|
|
|
46
|
+
extern HeapTuple SearchSysCacheLocked1(int cacheId,
|
|
47
|
+
Datum key1);
|
|
48
|
+
|
|
46
49
|
/* convenience routines */
|
|
47
50
|
extern HeapTuple SearchSysCacheCopy(int cacheId,
|
|
48
51
|
Datum key1, Datum key2, Datum key3, Datum key4);
|
|
52
|
+
extern HeapTuple SearchSysCacheLockedCopy1(int cacheId,
|
|
53
|
+
Datum key1);
|
|
49
54
|
extern bool SearchSysCacheExists(int cacheId,
|
|
50
55
|
Datum key1, Datum key2, Datum key3, Datum key4);
|
|
51
56
|
extern Oid GetSysCacheOid(int cacheId, AttrNumber oidcol,
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
#ifndef POSTGRES_DEPARSE_H
|
|
2
|
+
#define POSTGRES_DEPARSE_H
|
|
3
|
+
|
|
4
|
+
#include <stdbool.h>
|
|
5
|
+
#include <sys/types.h>
|
|
6
|
+
|
|
7
|
+
typedef struct PostgresDeparseComment {
|
|
8
|
+
int match_location; // Insert comment before a node, once we find a node whose location field is equal-or-higher than this location
|
|
9
|
+
int newlines_before_comment; // Insert newlines before inserting the comment (set to non-zero if the source comment was separated from the prior token by at least one newline)
|
|
10
|
+
int newlines_after_comment; // Insert newlines after inserting the comment (set to non-zero if the source comment was separated from the next token by at least one newline)
|
|
11
|
+
char *str; // The actual comment string, including comment start/end tokens, and newline characters in comment (if any)
|
|
12
|
+
} PostgresDeparseComment;
|
|
13
|
+
|
|
14
|
+
typedef struct PostgresDeparseOpts {
|
|
15
|
+
PostgresDeparseComment **comments;
|
|
16
|
+
size_t comment_count;
|
|
17
|
+
|
|
18
|
+
// Pretty print options
|
|
19
|
+
bool pretty_print;
|
|
20
|
+
int indent_size; // Indentation size (Default 4 spaces)
|
|
21
|
+
int max_line_length; // Restricts the line length of certain lists of items (Default 80 characters)
|
|
22
|
+
bool trailing_newline; // Whether to add a trailing newline at the end of the output (Default off)
|
|
23
|
+
bool commas_start_of_line; // Place separating commas at start of line (Default off)
|
|
24
|
+
} PostgresDeparseOpts;
|
|
25
|
+
|
|
26
|
+
/* Forward declarations to allow referencing the structs in this include file without needing Postgres includes */
|
|
27
|
+
struct StringInfoData;
|
|
28
|
+
typedef struct StringInfoData *StringInfo;
|
|
29
|
+
struct RawStmt;
|
|
30
|
+
|
|
31
|
+
extern void deparseRawStmt(StringInfo str, struct RawStmt *raw_stmt);
|
|
32
|
+
extern void deparseRawStmtOpts(StringInfo str, struct RawStmt *raw_stmt, PostgresDeparseOpts opts);
|
|
33
|
+
|
|
34
|
+
#endif
|