pg_query 6.0.0 → 6.1.0
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 +12 -0
- data/Rakefile +4 -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 +20 -6
- data/ext/pg_query/include/pg_query.h +2 -2
- data/ext/pg_query/include/postgres/access/amapi.h +4 -0
- data/ext/pg_query/include/postgres/access/genam.h +9 -0
- data/ext/pg_query/include/postgres/access/slru.h +3 -6
- data/ext/pg_query/include/postgres/access/tableam.h +2 -1
- data/ext/pg_query/include/postgres/access/transam.h +43 -0
- 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/event_trigger.h +6 -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/libpq/libpq-be.h +6 -3
- data/ext/pg_query/include/postgres/mb/pg_wchar.h +1 -0
- data/ext/pg_query/include/postgres/miscadmin.h +10 -2
- data/ext/pg_query/include/postgres/nodes/execnodes.h +3 -0
- data/ext/pg_query/include/postgres/nodes/pathnodes.h +4 -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 +28 -20
- data/ext/pg_query/include/postgres/port/pg_iovec.h +2 -2
- 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 +9 -18
- data/ext/pg_query/include/postgres/replication/slot.h +5 -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/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/postgres_deparse.c +197 -156
- data/ext/pg_query/src_backend_parser_gram.c +1 -1
- data/ext/pg_query/src_common_wchar.c +47 -1
- data/ext/pg_query/src_port_snprintf.c +14 -17
- data/lib/pg_query/fingerprint.rb +3 -5
- data/lib/pg_query/param_refs.rb +1 -1
- data/lib/pg_query/parse.rb +5 -7
- data/lib/pg_query/parse_error.rb +1 -0
- data/lib/pg_query/pg_query_pb.rb +1 -22
- data/lib/pg_query/scan.rb +1 -0
- data/lib/pg_query/treewalker.rb +2 -6
- data/lib/pg_query/truncate.rb +17 -19
- data/lib/pg_query/version.rb +1 -1
- metadata +15 -80
- /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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6b36a06556f82152c5dbf59f614d17ace5e6b796f47e392e9db0cb8a9b673df2
|
4
|
+
data.tar.gz: db1624f7783f496ecdcba756d4d3d0d2c2d87efbaf2a175d580041c28c1e3e5f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0fc23f15402fd98ca1768ea81cb31fbac2bbac488640d4af38bcb20b388ea57f395156ca8bd89192eb89736f721a9e6502e8891c2bd2c0774e38d17034e89ddc
|
7
|
+
data.tar.gz: 385424fe6139048a0fccb5d0ecc1df1f3f4a66aca59032137faad5ce86a5ec43ec28b1db77f43a2b816e9bde1c61fd219a0dd46b88cfd630b9a0b68fef05364f
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,18 @@
|
|
4
4
|
|
5
5
|
* ...
|
6
6
|
|
7
|
+
## 6.1.0 2025-04-02
|
8
|
+
|
9
|
+
* Upgrade to libpg_query 17-6.1.0
|
10
|
+
- Update to Postgres 17.4, and add recent patches scheduled for Postgres 17.5 (not yet released)
|
11
|
+
- Notably, this pulls in support for macOS 15.4 which defines strchrnul
|
12
|
+
in its standard library, fixing builds on up-to-date macOS versions.
|
13
|
+
- Deparser improvements
|
14
|
+
- Add parenthesis around AT LOCAL / AT TIMEZONE if needed
|
15
|
+
- Correctness improvements related to expressions and function calls
|
16
|
+
- Fixes to support newer Rubocop version linting of the codebase
|
17
|
+
- Add support for OpenBSD
|
18
|
+
|
7
19
|
## 6.0.0 2024-11-26
|
8
20
|
|
9
21
|
* Upgrade to libpg_query 17-6.0.0
|
data/Rakefile
CHANGED
@@ -5,8 +5,8 @@ require 'rspec/core/rake_task'
|
|
5
5
|
require 'rubocop/rake_task'
|
6
6
|
require 'open-uri'
|
7
7
|
|
8
|
-
LIB_PG_QUERY_TAG = '17-6.
|
9
|
-
LIB_PG_QUERY_SHA256SUM = '
|
8
|
+
LIB_PG_QUERY_TAG = '17-6.1.0'.freeze
|
9
|
+
LIB_PG_QUERY_SHA256SUM = 'a3dc0e4084a23da35128d4e9809ff27241c29a44fde74ba40a378b33d2cdefe2'.freeze
|
10
10
|
|
11
11
|
Rake::ExtensionTask.new 'pg_query' do |ext|
|
12
12
|
ext.lib_dir = 'lib/pg_query'
|
@@ -55,7 +55,7 @@ task :update_source do
|
|
55
55
|
# Backup important files from ext dir
|
56
56
|
system("rm -fr #{extbakdir}")
|
57
57
|
system("mkdir -p #{extbakdir}")
|
58
|
-
system("cp -a #{extdir}/pg_query_ruby
|
58
|
+
system("cp -a #{extdir}/pg_query_ruby.c #{extdir}/ext_symbols*.sym #{extdir}/extconf.rb #{extbakdir}")
|
59
59
|
|
60
60
|
FileUtils.rm_rf extdir
|
61
61
|
|
@@ -84,5 +84,5 @@ task :update_source do
|
|
84
84
|
# Other support files
|
85
85
|
system("cp -a #{libdir}/testdata/* #{testfilesdir}")
|
86
86
|
# Copy back the custom ext files
|
87
|
-
system("cp -a #{extbakdir}/pg_query_ruby
|
87
|
+
system("cp -a #{extbakdir}/pg_query_ruby.c #{extbakdir}/ext_symbols*.sym #{extbakdir}/extconf.rb #{extdir}")
|
88
88
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
Init_pg_query
|
data/ext/pg_query/extconf.rb
CHANGED
@@ -21,12 +21,26 @@ if RUBY_PLATFORM =~ /mswin/
|
|
21
21
|
$INCFLAGS = "-I#{File.join(__dir__, 'include', 'postgres', 'port', 'win32_msvc')} " + $INCFLAGS
|
22
22
|
end
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
24
|
+
# "ruby_abi_version" is a required symbol to be exported on Ruby 3.2+ development releases
|
25
|
+
# See https://github.com/ruby/ruby/pull/5474 and https://github.com/ruby/ruby/pull/6231
|
26
|
+
def export_ruby_abi_version
|
27
|
+
return false if RUBY_PATCHLEVEL >= 0 # Not a development release
|
28
|
+
m = /(\d+)\.(\d+)/.match(RUBY_VERSION)
|
29
|
+
return false if m.nil?
|
30
|
+
major = m[1].to_i
|
31
|
+
minor = m[2].to_i
|
32
|
+
major >= 3 && minor >= 2
|
33
|
+
end
|
34
|
+
|
35
|
+
def ext_symbols_filename
|
36
|
+
name = 'ext_symbols'
|
37
|
+
name += '_freebsd' if RUBY_PLATFORM =~ /freebsd/
|
38
|
+
name += '_openbsd' if RUBY_PLATFORM =~ /openbsd/
|
39
|
+
name += '_with_ruby_abi_version' if export_ruby_abi_version
|
40
|
+
"#{name}.sym"
|
41
|
+
end
|
42
|
+
|
43
|
+
SYMFILE = File.join(__dir__, ext_symbols_filename)
|
30
44
|
|
31
45
|
if RUBY_PLATFORM =~ /darwin/
|
32
46
|
$DLDFLAGS << " -Wl,-exported_symbols_list #{SYMFILE}" unless defined?(::Rubinius)
|
@@ -133,8 +133,8 @@ void pg_query_exit(void);
|
|
133
133
|
|
134
134
|
// Postgres version information
|
135
135
|
#define PG_MAJORVERSION "17"
|
136
|
-
#define PG_VERSION "17.
|
137
|
-
#define PG_VERSION_NUM
|
136
|
+
#define PG_VERSION "17.4"
|
137
|
+
#define PG_VERSION_NUM 170004
|
138
138
|
|
139
139
|
// Deprecated APIs below
|
140
140
|
|
@@ -76,6 +76,10 @@ typedef enum IndexAMProperty
|
|
76
76
|
* opfamily. This allows ALTER OPERATOR FAMILY DROP, and causes that to
|
77
77
|
* happen automatically if the operator or support func is dropped. This
|
78
78
|
* is the right behavior for inessential ("loose") objects.
|
79
|
+
*
|
80
|
+
* We also make dependencies on lefttype/righttype, of the same strength as
|
81
|
+
* the dependency on the operator or support func, unless these dependencies
|
82
|
+
* are redundant with the dependency on the operator or support func.
|
79
83
|
*/
|
80
84
|
typedef struct OpFamilyMember
|
81
85
|
{
|
@@ -233,5 +233,14 @@ extern SysScanDesc systable_beginscan_ordered(Relation heapRelation,
|
|
233
233
|
extern HeapTuple systable_getnext_ordered(SysScanDesc sysscan,
|
234
234
|
ScanDirection direction);
|
235
235
|
extern void systable_endscan_ordered(SysScanDesc sysscan);
|
236
|
+
extern void systable_inplace_update_begin(Relation relation,
|
237
|
+
Oid indexId,
|
238
|
+
bool indexOK,
|
239
|
+
Snapshot snapshot,
|
240
|
+
int nkeys, const ScanKeyData *key,
|
241
|
+
HeapTuple *oldtupcopy,
|
242
|
+
void **state);
|
243
|
+
extern void systable_inplace_update_finish(void *state, HeapTuple tuple);
|
244
|
+
extern void systable_inplace_update_cancel(void *state);
|
236
245
|
|
237
246
|
#endif /* GENAM_H */
|
@@ -128,10 +128,8 @@ typedef struct SlruCtlData
|
|
128
128
|
{
|
129
129
|
SlruShared shared;
|
130
130
|
|
131
|
-
/*
|
132
|
-
|
133
|
-
*/
|
134
|
-
bits16 bank_mask;
|
131
|
+
/* Number of banks in this SLRU. */
|
132
|
+
uint16 nbanks;
|
135
133
|
|
136
134
|
/*
|
137
135
|
* If true, use long segment file names. Otherwise, use short file names.
|
@@ -163,7 +161,6 @@ typedef struct SlruCtlData
|
|
163
161
|
* it's always the same, it doesn't need to be in shared memory.
|
164
162
|
*/
|
165
163
|
char Dir[64];
|
166
|
-
|
167
164
|
} SlruCtlData;
|
168
165
|
|
169
166
|
typedef SlruCtlData *SlruCtl;
|
@@ -179,7 +176,7 @@ SimpleLruGetBankLock(SlruCtl ctl, int64 pageno)
|
|
179
176
|
{
|
180
177
|
int bankno;
|
181
178
|
|
182
|
-
bankno = pageno
|
179
|
+
bankno = pageno % ctl->nbanks;
|
183
180
|
return &(ctl->shared->bank_locks[bankno].lock);
|
184
181
|
}
|
185
182
|
|
@@ -137,7 +137,8 @@ typedef enum TU_UpdateIndexes
|
|
137
137
|
*
|
138
138
|
* xmax is the outdating transaction's XID. If the caller wants to visit the
|
139
139
|
* replacement tuple, it must check that this matches before believing the
|
140
|
-
* replacement is really a match.
|
140
|
+
* replacement is really a match. This is InvalidTransactionId if the target
|
141
|
+
* was !LP_NORMAL (expected only for a TID retrieved from syscache).
|
141
142
|
*
|
142
143
|
* cmax is the outdating command's CID, but only when the failure code is
|
143
144
|
* TM_SelfModified (i.e., something in the current transaction outdated the
|
@@ -370,6 +370,49 @@ FullTransactionIdNewer(FullTransactionId a, FullTransactionId b)
|
|
370
370
|
return b;
|
371
371
|
}
|
372
372
|
|
373
|
+
/*
|
374
|
+
* Compute FullTransactionId for the given TransactionId, assuming xid was
|
375
|
+
* between [oldestXid, nextXid] at the time when TransamVariables->nextXid was
|
376
|
+
* nextFullXid. When adding calls, evaluate what prevents xid from preceding
|
377
|
+
* oldestXid if SetTransactionIdLimit() runs between the collection of xid and
|
378
|
+
* the collection of nextFullXid.
|
379
|
+
*/
|
380
|
+
static inline FullTransactionId
|
381
|
+
FullTransactionIdFromAllowableAt(FullTransactionId nextFullXid,
|
382
|
+
TransactionId xid)
|
383
|
+
{
|
384
|
+
uint32 epoch;
|
385
|
+
|
386
|
+
/* Special transaction ID. */
|
387
|
+
if (!TransactionIdIsNormal(xid))
|
388
|
+
return FullTransactionIdFromEpochAndXid(0, xid);
|
389
|
+
|
390
|
+
Assert(TransactionIdPrecedesOrEquals(xid,
|
391
|
+
XidFromFullTransactionId(nextFullXid)));
|
392
|
+
|
393
|
+
/*
|
394
|
+
* The 64 bit result must be <= nextFullXid, since nextFullXid hadn't been
|
395
|
+
* issued yet when xid was in the past. The xid must therefore be from
|
396
|
+
* the epoch of nextFullXid or the epoch before. We know this because we
|
397
|
+
* must remove (by freezing) an XID before assigning the XID half an epoch
|
398
|
+
* ahead of it.
|
399
|
+
*
|
400
|
+
* The unlikely() branch hint is dubious. It's perfect for the first 2^32
|
401
|
+
* XIDs of a cluster's life. Right at 2^32 XIDs, misprediction shoots to
|
402
|
+
* 100%, then improves until perfection returns 2^31 XIDs later. Since
|
403
|
+
* current callers pass relatively-recent XIDs, expect >90% prediction
|
404
|
+
* accuracy overall. This favors average latency over tail latency.
|
405
|
+
*/
|
406
|
+
epoch = EpochFromFullTransactionId(nextFullXid);
|
407
|
+
if (unlikely(xid > XidFromFullTransactionId(nextFullXid)))
|
408
|
+
{
|
409
|
+
Assert(epoch != 0);
|
410
|
+
epoch--;
|
411
|
+
}
|
412
|
+
|
413
|
+
return FullTransactionIdFromEpochAndXid(epoch, xid);
|
414
|
+
}
|
415
|
+
|
373
416
|
#endif /* FRONTEND */
|
374
417
|
|
375
418
|
#endif /* TRANSAM_H */
|
@@ -435,7 +435,7 @@ typedef void (*pg_funcptr_t) (void);
|
|
435
435
|
* bool
|
436
436
|
* Boolean value, either true or false.
|
437
437
|
*
|
438
|
-
* We use stdbool.h if
|
438
|
+
* We use stdbool.h if bool has size 1 after including it. That's useful for
|
439
439
|
* better compiler and debugger output and for compatibility with third-party
|
440
440
|
* libraries. But PostgreSQL currently cannot deal with bool of other sizes;
|
441
441
|
* there are static assertions around the code to prevent that.
|
@@ -69,6 +69,10 @@ extern bool get_object_namensp_unique(Oid class_id);
|
|
69
69
|
|
70
70
|
extern HeapTuple get_catalog_object_by_oid(Relation catalog,
|
71
71
|
AttrNumber oidcol, Oid objectId);
|
72
|
+
extern HeapTuple get_catalog_object_by_oid_extended(Relation catalog,
|
73
|
+
AttrNumber oidcol,
|
74
|
+
Oid objectId,
|
75
|
+
bool locktup);
|
72
76
|
|
73
77
|
extern char *getObjectDescription(const ObjectAddress *object,
|
74
78
|
bool missing_ok);
|
@@ -31,6 +31,12 @@ typedef struct EventTriggerData
|
|
31
31
|
|
32
32
|
extern PGDLLIMPORT bool event_triggers;
|
33
33
|
|
34
|
+
/*
|
35
|
+
* Reasons for relation rewrites.
|
36
|
+
*
|
37
|
+
* pg_event_trigger_table_rewrite_reason() uses these values, so make sure to
|
38
|
+
* update the documentation when changing this list.
|
39
|
+
*/
|
34
40
|
#define AT_REWRITE_ALTER_PERSISTENCE 0x01
|
35
41
|
#define AT_REWRITE_DEFAULT_VAL 0x02
|
36
42
|
#define AT_REWRITE_COLUMN_REWRITE 0x04
|
@@ -14,8 +14,6 @@
|
|
14
14
|
#ifndef HASHFN_UNSTABLE_H
|
15
15
|
#define HASHFN_UNSTABLE_H
|
16
16
|
|
17
|
-
#include "port/pg_bitutils.h"
|
18
|
-
#include "port/pg_bswap.h"
|
19
17
|
|
20
18
|
/*
|
21
19
|
* fasthash is a modification of code taken from
|
@@ -219,13 +217,6 @@ fasthash_accum(fasthash_state *hs, const char *k, size_t len)
|
|
219
217
|
#define haszero64(v) \
|
220
218
|
(((v) - 0x0101010101010101) & ~(v) & 0x8080808080808080)
|
221
219
|
|
222
|
-
/* get first byte in memory order */
|
223
|
-
#ifdef WORDS_BIGENDIAN
|
224
|
-
#define firstbyte64(v) ((v) >> 56)
|
225
|
-
#else
|
226
|
-
#define firstbyte64(v) ((v) & 0xFF)
|
227
|
-
#endif
|
228
|
-
|
229
220
|
/*
|
230
221
|
* all-purpose workhorse for fasthash_accum_cstring
|
231
222
|
*/
|
@@ -262,33 +253,20 @@ static inline size_t
|
|
262
253
|
fasthash_accum_cstring_aligned(fasthash_state *hs, const char *str)
|
263
254
|
{
|
264
255
|
const char *const start = str;
|
265
|
-
|
256
|
+
size_t remainder;
|
266
257
|
uint64 zero_byte_low;
|
267
258
|
|
268
259
|
Assert(PointerIsAligned(start, uint64));
|
269
260
|
|
270
261
|
/*
|
271
262
|
* For every chunk of input, check for zero bytes before mixing into the
|
272
|
-
* hash. The chunk with zeros must contain the NUL terminator.
|
273
|
-
* so that zero_byte_low tells us not only that a zero exists, but also
|
274
|
-
* where it is, so we can hash the remainder of the string.
|
275
|
-
*
|
276
|
-
* The haszero64 calculation will set bits corresponding to the lowest
|
277
|
-
* byte where a zero exists, so that suffices for little-endian machines.
|
278
|
-
* For big-endian machines, we would need bits set for the highest zero
|
279
|
-
* byte in the chunk, since the trailing junk past the terminator could
|
280
|
-
* contain additional zeros. haszero64 does not give us that, so we
|
281
|
-
* byteswap the chunk first.
|
263
|
+
* hash. The chunk with zeros must contain the NUL terminator.
|
282
264
|
*/
|
283
265
|
for (;;)
|
284
266
|
{
|
285
|
-
chunk = *(uint64 *) str;
|
267
|
+
uint64 chunk = *(uint64 *) str;
|
286
268
|
|
287
|
-
#ifdef WORDS_BIGENDIAN
|
288
|
-
zero_byte_low = haszero64(pg_bswap64(chunk));
|
289
|
-
#else
|
290
269
|
zero_byte_low = haszero64(chunk);
|
291
|
-
#endif
|
292
270
|
if (zero_byte_low)
|
293
271
|
break;
|
294
272
|
|
@@ -297,33 +275,9 @@ fasthash_accum_cstring_aligned(fasthash_state *hs, const char *str)
|
|
297
275
|
str += FH_SIZEOF_ACCUM;
|
298
276
|
}
|
299
277
|
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
uint64 mask;
|
304
|
-
|
305
|
-
/*
|
306
|
-
* The byte corresponding to the NUL will be 0x80, so the rightmost
|
307
|
-
* bit position will be in the range 15, 23, ..., 63. Turn this into
|
308
|
-
* byte position by dividing by 8.
|
309
|
-
*/
|
310
|
-
remainder = pg_rightmost_one_pos64(zero_byte_low) / BITS_PER_BYTE;
|
311
|
-
|
312
|
-
/*
|
313
|
-
* Create a mask for the remaining bytes so we can combine them into
|
314
|
-
* the hash. This must have the same result as mixing the remaining
|
315
|
-
* bytes with fasthash_accum().
|
316
|
-
*/
|
317
|
-
#ifdef WORDS_BIGENDIAN
|
318
|
-
mask = ~UINT64CONST(0) << BITS_PER_BYTE * (FH_SIZEOF_ACCUM - remainder);
|
319
|
-
#else
|
320
|
-
mask = ~UINT64CONST(0) >> BITS_PER_BYTE * (FH_SIZEOF_ACCUM - remainder);
|
321
|
-
#endif
|
322
|
-
hs->accum = chunk & mask;
|
323
|
-
fasthash_combine(hs);
|
324
|
-
|
325
|
-
str += remainder;
|
326
|
-
}
|
278
|
+
/* mix in remaining bytes */
|
279
|
+
remainder = fasthash_accum_cstring_unaligned(hs, str);
|
280
|
+
str += remainder;
|
327
281
|
|
328
282
|
return str - start;
|
329
283
|
}
|
@@ -136,7 +136,7 @@ struct pg_itm_in
|
|
136
136
|
/*
|
137
137
|
* We allow numeric timezone offsets up to 15:59:59 either way from Greenwich.
|
138
138
|
* Currently, the record holders for wackiest offsets in actual use are zones
|
139
|
-
* Asia/Manila, at -15:56:
|
139
|
+
* Asia/Manila, at -15:56:08 until 1844, and America/Metlakatla, at +15:13:42
|
140
140
|
* until 1867. If we were to reject such values we would fail to dump and
|
141
141
|
* restore old timestamptz values with these zone settings.
|
142
142
|
*/
|
@@ -48,7 +48,7 @@ typedef struct QueryDesc
|
|
48
48
|
EState *estate; /* executor's query-wide state */
|
49
49
|
PlanState *planstate; /* tree of per-plan-node state */
|
50
50
|
|
51
|
-
/* This field is set by
|
51
|
+
/* This field is set by ExecutePlan */
|
52
52
|
bool already_executed; /* true if previously executed */
|
53
53
|
|
54
54
|
/* This is always set NULL by the core system, but plugins can change it */
|
@@ -189,7 +189,8 @@ typedef struct Port
|
|
189
189
|
/*
|
190
190
|
* If GSSAPI is supported and used on this connection, store GSSAPI
|
191
191
|
* information. Even when GSSAPI is not compiled in, store a NULL pointer
|
192
|
-
* to keep struct offsets the same (for
|
192
|
+
* to keep struct offsets of the "SSL structures" below the same (for
|
193
|
+
* extension ABI compatibility).
|
193
194
|
*/
|
194
195
|
pg_gssinfo *gss;
|
195
196
|
#else
|
@@ -206,8 +207,7 @@ typedef struct Port
|
|
206
207
|
bool alpn_used;
|
207
208
|
|
208
209
|
/*
|
209
|
-
* OpenSSL structures.
|
210
|
-
* fields are the same whether or not you build with SSL enabled.)
|
210
|
+
* OpenSSL structures.
|
211
211
|
*/
|
212
212
|
#ifdef USE_OPENSSL
|
213
213
|
SSL *ssl;
|
@@ -222,6 +222,9 @@ typedef struct Port
|
|
222
222
|
* There's no API to "unread", the upper layer just places the data in the
|
223
223
|
* Port structure in raw_buf and sets raw_buf_remaining to the amount of
|
224
224
|
* bytes unread and raw_buf_consumed to 0.
|
225
|
+
*
|
226
|
+
* NB: the offsets of these fields depend on USE_OPENSSL. These should
|
227
|
+
* not be accessed in an extension because of the ABI incompatibility.
|
225
228
|
*/
|
226
229
|
char *raw_buf;
|
227
230
|
ssize_t raw_buf_consumed,
|
@@ -662,6 +662,7 @@ extern int pg_valid_server_encoding_id(int encoding);
|
|
662
662
|
* (in addition to the ones just above). The constant tables declared
|
663
663
|
* earlier in this file are also available from libpgcommon.
|
664
664
|
*/
|
665
|
+
extern void pg_encoding_set_invalid(int encoding, char *dst);
|
665
666
|
extern int pg_encoding_mblen(int encoding, const char *mbstr);
|
666
667
|
extern int pg_encoding_mblen_bounded(int encoding, const char *mbstr);
|
667
668
|
extern int pg_encoding_dsplen(int encoding, const char *mbstr);
|
@@ -346,8 +346,9 @@ typedef enum BackendType
|
|
346
346
|
|
347
347
|
/*
|
348
348
|
* Auxiliary processes. These have PGPROC entries, but they are not
|
349
|
-
* attached to any particular database
|
350
|
-
*
|
349
|
+
* attached to any particular database, and cannot run transactions or
|
350
|
+
* even take heavyweight locks. There can be only one of each of these
|
351
|
+
* running at a time.
|
351
352
|
*
|
352
353
|
* If you modify these, make sure to update NUM_AUXILIARY_PROCS and the
|
353
354
|
* glossary in the docs.
|
@@ -371,6 +372,7 @@ typedef enum BackendType
|
|
371
372
|
|
372
373
|
extern PGDLLIMPORT BackendType MyBackendType;
|
373
374
|
|
375
|
+
#define AmRegularBackendProcess() (MyBackendType == B_BACKEND)
|
374
376
|
#define AmAutoVacuumLauncherProcess() (MyBackendType == B_AUTOVAC_LAUNCHER)
|
375
377
|
#define AmAutoVacuumWorkerProcess() (MyBackendType == B_AUTOVAC_WORKER)
|
376
378
|
#define AmBackgroundWorkerProcess() (MyBackendType == B_BG_WORKER)
|
@@ -384,6 +386,10 @@ extern PGDLLIMPORT BackendType MyBackendType;
|
|
384
386
|
#define AmWalSummarizerProcess() (MyBackendType == B_WAL_SUMMARIZER)
|
385
387
|
#define AmWalWriterProcess() (MyBackendType == B_WAL_WRITER)
|
386
388
|
|
389
|
+
#define AmSpecialWorkerProcess() \
|
390
|
+
(AmAutoVacuumLauncherProcess() || \
|
391
|
+
AmLogicalSlotSyncWorkerProcess())
|
392
|
+
|
387
393
|
extern const char *GetBackendTypeDesc(BackendType backendType);
|
388
394
|
|
389
395
|
extern void SetDatabasePath(const char *path);
|
@@ -395,7 +401,9 @@ extern char *GetUserNameFromId(Oid roleid, bool noerr);
|
|
395
401
|
extern Oid GetUserId(void);
|
396
402
|
extern Oid GetOuterUserId(void);
|
397
403
|
extern Oid GetSessionUserId(void);
|
404
|
+
extern bool GetSessionUserIsSuperuser(void);
|
398
405
|
extern Oid GetAuthenticatedUserId(void);
|
406
|
+
extern void SetAuthenticatedUserId(Oid userid);
|
399
407
|
extern void GetUserIdAndSecContext(Oid *userid, int *sec_context);
|
400
408
|
extern void SetUserIdAndSecContext(Oid userid, int sec_context);
|
401
409
|
extern bool InLocalUserIdChange(void);
|
@@ -484,6 +484,9 @@ typedef struct ResultRelInfo
|
|
484
484
|
/* Have the projection and the slots above been initialized? */
|
485
485
|
bool ri_projectNewInfoValid;
|
486
486
|
|
487
|
+
/* updates do LockTuple() before oldtup read; see README.tuplock */
|
488
|
+
bool ri_needLockTagTuple;
|
489
|
+
|
487
490
|
/* triggers to be fired, if any */
|
488
491
|
TriggerDesc *ri_TrigDesc;
|
489
492
|
|
@@ -1101,6 +1101,9 @@ typedef struct IndexOptInfo IndexOptInfo;
|
|
1101
1101
|
#define HAVE_INDEXOPTINFO_TYPEDEF 1
|
1102
1102
|
#endif
|
1103
1103
|
|
1104
|
+
struct IndexPath; /* avoid including pathnodes.h here */
|
1105
|
+
struct PlannerInfo; /* avoid including pathnodes.h here */
|
1106
|
+
|
1104
1107
|
struct IndexOptInfo
|
1105
1108
|
{
|
1106
1109
|
pg_node_attr(no_copy_equal, no_read, no_query_jumble)
|
@@ -1200,7 +1203,7 @@ struct IndexOptInfo
|
|
1200
1203
|
bool amcanmarkpos;
|
1201
1204
|
/* AM's cost estimator */
|
1202
1205
|
/* Rather than include amapi.h here, we declare amcostestimate like this */
|
1203
|
-
void (*amcostestimate) () pg_node_attr(read_write_ignore);
|
1206
|
+
void (*amcostestimate) (struct PlannerInfo *, struct IndexPath *, double, Cost *, Cost *, Selectivity *, double *, double *) pg_node_attr(read_write_ignore);
|
1204
1207
|
};
|
1205
1208
|
|
1206
1209
|
/*
|
@@ -485,7 +485,7 @@ for_each_cell_setup(const List *lst, const ListCell *initcell)
|
|
485
485
|
for (ForEachState var##__state = {(lst), 0}; \
|
486
486
|
(var##__state.l != NIL && \
|
487
487
|
var##__state.i < var##__state.l->length && \
|
488
|
-
(var = func(&var##__state.l->elements[var##__state.i]), true)); \
|
488
|
+
(var = (type pointer) func(&var##__state.l->elements[var##__state.i]), true)); \
|
489
489
|
var##__state.i++)
|
490
490
|
|
491
491
|
/*
|
@@ -1669,15 +1669,19 @@ typedef struct JsonReturning
|
|
1669
1669
|
* JsonValueExpr -
|
1670
1670
|
* representation of JSON value expression (expr [FORMAT JsonFormat])
|
1671
1671
|
*
|
1672
|
-
*
|
1673
|
-
*
|
1674
|
-
*
|
1672
|
+
* raw_expr is the user-specified value, while formatted_expr is the value
|
1673
|
+
* obtained by coercing raw_expr to the type required by either the FORMAT
|
1674
|
+
* clause or an enclosing node's RETURNING clause.
|
1675
|
+
*
|
1676
|
+
* When deparsing a JsonValueExpr, get_rule_expr() prints raw_expr. However,
|
1677
|
+
* during the evaluation of a JsonValueExpr, the value of formatted_expr
|
1678
|
+
* takes precedence over that of raw_expr.
|
1675
1679
|
*/
|
1676
1680
|
typedef struct JsonValueExpr
|
1677
1681
|
{
|
1678
1682
|
NodeTag type;
|
1679
|
-
Expr *raw_expr; /*
|
1680
|
-
Expr *formatted_expr; /* formatted expression */
|
1683
|
+
Expr *raw_expr; /* user-specified expression */
|
1684
|
+
Expr *formatted_expr; /* coerced formatted expression */
|
1681
1685
|
JsonFormat *format; /* FORMAT clause, if specified */
|
1682
1686
|
} JsonValueExpr;
|
1683
1687
|
|
@@ -63,6 +63,9 @@ extern Node *coerce_to_specific_type_typmod(ParseState *pstate, Node *node,
|
|
63
63
|
Oid targetTypeId, int32 targetTypmod,
|
64
64
|
const char *constructName);
|
65
65
|
|
66
|
+
extern Node *coerce_null_to_domain(Oid typid, int32 typmod, Oid collation,
|
67
|
+
int typlen, bool typbyval);
|
68
|
+
|
66
69
|
extern int parser_coercion_errposition(ParseState *pstate,
|
67
70
|
int coerce_location,
|
68
71
|
Node *input_expr);
|