Skip to content

Commit

Permalink
Update libpg_query to 13-2.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
lfittl committed Nov 3, 2022
1 parent 6274182 commit 6eae7d4
Show file tree
Hide file tree
Showing 81 changed files with 1,476 additions and 775 deletions.
4 changes: 2 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ require 'rspec/core/rake_task'
require 'rubocop/rake_task'
require 'open-uri'

LIB_PG_QUERY_TAG = '13-2.1.0'.freeze
LIB_PG_QUERY_SHA256SUM = 'a01329ae5bac19b10b8ddf8012bd663a20f85f180d6d7b900c1a1ca8444d19a5'.freeze
LIB_PG_QUERY_TAG = '13-2.2.0'.freeze
LIB_PG_QUERY_SHA256SUM = '07916be1a2b780dee6feed936aaa04ccee2a3afde8570a6920c3a839c87539c6'.freeze

Rake::ExtensionTask.new 'pg_query' do |ext|
ext.lib_dir = 'lib/pg_query'
Expand Down
2 changes: 2 additions & 0 deletions ext/pg_query/include/access/twophase.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ extern void TwoPhaseShmemInit(void);
extern void AtAbort_Twophase(void);
extern void PostPrepare_Twophase(void);

extern TransactionId TwoPhaseGetXidByVirtualXID(VirtualTransactionId vxid,
bool *have_more);
extern PGPROC *TwoPhaseGetDummyProc(TransactionId xid, bool lock_held);
extern BackendId TwoPhaseGetDummyBackendId(TransactionId xid, bool lock_held);

Expand Down
6 changes: 6 additions & 0 deletions ext/pg_query/include/access/xact.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@ extern int MyXactFlags;
*/
#define XACT_FLAGS_ACQUIREDACCESSEXCLUSIVELOCK (1U << 1)

/*
* XACT_FLAGS_NEEDIMMEDIATECOMMIT - records whether the top level statement
* is one that requires immediate commit, such as CREATE DATABASE.
*/
#define XACT_FLAGS_NEEDIMMEDIATECOMMIT (1U << 2)

/*
* start- and end-of-transaction callbacks for dynamically loaded modules
*/
Expand Down
11 changes: 10 additions & 1 deletion ext/pg_query/include/access/xlog_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,10 @@ typedef XLogLongPageHeaderData *XLogLongPageHeader;
#define XLP_LONG_HEADER 0x0002
/* This flag indicates backup blocks starting in this page are optional */
#define XLP_BKP_REMOVABLE 0x0004
/* Replaces a missing contrecord; see CreateOverwriteContrecordRecord */
#define XLP_FIRST_IS_OVERWRITE_CONTRECORD 0x0008
/* All defined flag bits in xlp_info (used for validity checking of header) */
#define XLP_ALL_FLAGS 0x0007
#define XLP_ALL_FLAGS 0x000F

#define XLogPageHeaderSize(hdr) \
(((hdr)->xlp_info & XLP_LONG_HEADER) ? SizeOfXLogLongPHD : SizeOfXLogShortPHD)
Expand Down Expand Up @@ -252,6 +254,13 @@ typedef struct xl_restore_point
char rp_name[MAXFNAMELEN];
} xl_restore_point;

/* Overwrite of prior contrecord */
typedef struct xl_overwrite_contrecord
{
XLogRecPtr overwritten_lsn;
TimestampTz overwrite_time;
} xl_overwrite_contrecord;

/* End of recovery mark, when we don't do an END_OF_RECOVERY checkpoint */
typedef struct xl_end_of_recovery
{
Expand Down
10 changes: 10 additions & 0 deletions ext/pg_query/include/access/xlogreader.h
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,16 @@ struct XLogReaderState

/* Buffer to hold error message */
char *errormsg_buf;

/*
* Set at the end of recovery: the start point of a partial record at the
* end of WAL (InvalidXLogRecPtr if there wasn't one), and the start
* location of its first contrecord that went missing.
*/
XLogRecPtr abortedRecPtr;
XLogRecPtr missingContrecPtr;
/* Set when XLP_FIRST_IS_OVERWRITE_CONTRECORD is found */
XLogRecPtr overwrittenRecPtr;
};

/* Get a new XLogReader */
Expand Down
2 changes: 2 additions & 0 deletions ext/pg_query/include/catalog/dependency.h
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,8 @@ extern void recordMultipleDependencies(const ObjectAddress *depender,
extern void recordDependencyOnCurrentExtension(const ObjectAddress *object,
bool isReplace);

extern void checkMembershipInCurrentExtension(const ObjectAddress *object);

extern long deleteDependencyRecordsFor(Oid classId, Oid objectId,
bool skipExtensionDeps);

Expand Down
2 changes: 1 addition & 1 deletion ext/pg_query/include/catalog/pg_class.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ typedef FormData_pg_class *Form_pg_class;
/*
* an explicitly chosen candidate key's columns are used as replica identity.
* Note this will still be set if the index has been dropped; in that case it
* has the same meaning as 'd'.
* has the same meaning as 'n'.
*/
#define REPLICA_IDENTITY_INDEX 'i'

Expand Down
2 changes: 1 addition & 1 deletion ext/pg_query/include/catalog/pg_class_d.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
/*
* an explicitly chosen candidate key's columns are used as replica identity.
* Note this will still be set if the index has been dropped; in that case it
* has the same meaning as 'd'.
* has the same meaning as 'n'.
*/
#define REPLICA_IDENTITY_INDEX 'i'

Expand Down
2 changes: 2 additions & 0 deletions ext/pg_query/include/catalog/pg_control.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ typedef struct CheckPoint
#define XLOG_END_OF_RECOVERY 0x90
#define XLOG_FPI_FOR_HINT 0xA0
#define XLOG_FPI 0xB0
/* 0xC0 is used in Postgres 9.5-11 */
#define XLOG_OVERWRITE_CONTRECORD 0xD0


/*
Expand Down
4 changes: 3 additions & 1 deletion ext/pg_query/include/catalog/pg_operator.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@ extern ObjectAddress OperatorCreate(const char *operatorName,
bool canMerge,
bool canHash);

extern ObjectAddress makeOperatorDependencies(HeapTuple tuple, bool isUpdate);
extern ObjectAddress makeOperatorDependencies(HeapTuple tuple,
bool makeExtensionDep,
bool isUpdate);

extern void OperatorUpd(Oid baseId, Oid commId, Oid negId, bool isDelete);

Expand Down
3 changes: 3 additions & 0 deletions ext/pg_query/include/catalog/pg_publication.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ extern List *GetAllTablesPublicationRelations(bool pubviaroot);
extern bool is_publishable_relation(Relation rel);
extern ObjectAddress publication_add_relation(Oid pubid, Relation targetrel,
bool if_not_exists);
extern List *GetPubPartitionOptionRelations(List *result,
PublicationPartOpt pub_partopt,
Oid relid);

extern Oid get_publication_oid(const char *pubname, bool missing_ok);
extern char *get_publication_name(Oid pubid, bool missing_ok);
Expand Down
1 change: 1 addition & 0 deletions ext/pg_query/include/catalog/pg_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ extern void GenerateTypeDependencies(HeapTuple typeTuple,
* rowtypes */
bool isImplicitArray,
bool isDependentType,
bool makeExtensionDep,
bool rebuild);

extern void RenameTypeInternal(Oid typeOid, const char *newTypeName,
Expand Down
2 changes: 1 addition & 1 deletion ext/pg_query/include/commands/async.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,6 @@ extern void ProcessCompletedNotifies(void);
extern void HandleNotifyInterrupt(void);

/* process interrupts */
extern void ProcessNotifyInterrupt(void);
extern void ProcessNotifyInterrupt(bool flush);

#endif /* ASYNC_H */
2 changes: 2 additions & 0 deletions ext/pg_query/include/commands/tablespace.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
#include "lib/stringinfo.h"
#include "nodes/parsenodes.h"

extern bool allow_in_place_tablespaces;

/* XLOG stuff */
#define XLOG_TBLSPC_CREATE 0x00
#define XLOG_TBLSPC_DROP 0x10
Expand Down
8 changes: 8 additions & 0 deletions ext/pg_query/include/commands/trigger.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,20 @@ extern ObjectAddress CreateTrigger(CreateTrigStmt *stmt, const char *queryString
Oid relOid, Oid refRelOid, Oid constraintOid, Oid indexOid,
Oid funcoid, Oid parentTriggerOid, Node *whenClause,
bool isInternal, bool in_partition);
extern ObjectAddress CreateTriggerFiringOn(CreateTrigStmt *stmt, const char *queryString,
Oid relOid, Oid refRelOid, Oid constraintOid,
Oid indexOid, Oid funcoid, Oid parentTriggerOid,
Node *whenClause, bool isInternal, bool in_partition,
char trigger_fires_when);

extern void RemoveTriggerById(Oid trigOid);
extern Oid get_trigger_oid(Oid relid, const char *name, bool missing_ok);

extern ObjectAddress renametrig(RenameStmt *stmt);

extern void EnableDisableTriggerNew(Relation rel, const char *tgname,
char fires_when, bool skip_system, bool recurse,
LOCKMODE lockmode);
extern void EnableDisableTrigger(Relation rel, const char *tgname,
char fires_when, bool skip_system, LOCKMODE lockmode);

Expand Down
26 changes: 13 additions & 13 deletions ext/pg_query/include/lib/simplehash.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@
* presence is relevant to determine whether a lookup needs to continue
* looking or is done - buckets following a deleted element are shifted
* backwards, unless they're empty or already at their optimal position.
*
* Portions Copyright (c) 1996-2021, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* src/include/lib/simplehash.h
*/

#include "port/pg_bitutils.h"
Expand Down Expand Up @@ -156,7 +161,7 @@ SH_SCOPE SH_TYPE *SH_CREATE(MemoryContext ctx, uint32 nelements,
#endif
SH_SCOPE void SH_DESTROY(SH_TYPE * tb);
SH_SCOPE void SH_RESET(SH_TYPE * tb);
SH_SCOPE void SH_GROW(SH_TYPE * tb, uint32 newsize);
SH_SCOPE void SH_GROW(SH_TYPE * tb, uint64 newsize);
SH_SCOPE SH_ELEMENT_TYPE *SH_INSERT(SH_TYPE * tb, SH_KEY_TYPE key, bool *found);
SH_SCOPE SH_ELEMENT_TYPE *SH_INSERT_HASH(SH_TYPE * tb, SH_KEY_TYPE key,
uint32 hash, bool *found);
Expand Down Expand Up @@ -218,7 +223,8 @@ SH_SCOPE void SH_STAT(SH_TYPE * tb);
#define SIMPLEHASH_H

#ifdef FRONTEND
#define sh_error(...) pg_log_error(__VA_ARGS__)
#define sh_error(...) \
do { pg_log_fatal(__VA_ARGS__); exit(1); } while(0)
#define sh_log(...) pg_log_info(__VA_ARGS__)
#else
#define sh_error(...) elog(ERROR, __VA_ARGS__)
Expand All @@ -232,7 +238,7 @@ SH_SCOPE void SH_STAT(SH_TYPE * tb);
* the hashtable.
*/
static inline void
SH_COMPUTE_PARAMETERS(SH_TYPE * tb, uint32 newsize)
SH_COMPUTE_PARAMETERS(SH_TYPE * tb, uint64 newsize)
{
uint64 size;

Expand All @@ -247,16 +253,12 @@ SH_COMPUTE_PARAMETERS(SH_TYPE * tb, uint32 newsize)
* Verify that allocation of ->data is possible on this platform, without
* overflowing Size.
*/
if ((((uint64) sizeof(SH_ELEMENT_TYPE)) * size) >= SIZE_MAX / 2)
if (unlikely((((uint64) sizeof(SH_ELEMENT_TYPE)) * size) >= SIZE_MAX / 2))
sh_error("hash table too large");

/* now set size */
tb->size = size;

if (tb->size == SH_MAX_SIZE)
tb->sizemask = 0;
else
tb->sizemask = tb->size - 1;
tb->sizemask = (uint32) (size - 1);

/*
* Compute the next threshold at which we need to grow the hash table
Expand Down Expand Up @@ -406,7 +408,7 @@ SH_RESET(SH_TYPE * tb)
* performance-wise, when known at some point.
*/
SH_SCOPE void
SH_GROW(SH_TYPE * tb, uint32 newsize)
SH_GROW(SH_TYPE * tb, uint64 newsize)
{
uint64 oldsize = tb->size;
SH_ELEMENT_TYPE *olddata = tb->data;
Expand Down Expand Up @@ -536,10 +538,8 @@ SH_INSERT_HASH_INTERNAL(SH_TYPE * tb, SH_KEY_TYPE key, uint32 hash, bool *found)
*/
if (unlikely(tb->members >= tb->grow_threshold))
{
if (tb->size == SH_MAX_SIZE)
{
if (unlikely(tb->size == SH_MAX_SIZE))
sh_error("hash table size exceeded");
}

/*
* When optimizing, it can be very useful to print these out.
Expand Down
1 change: 1 addition & 0 deletions ext/pg_query/include/libpq/libpq.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ extern int pq_getmessage(StringInfo s, int maxlen);
extern int pq_getbyte(void);
extern int pq_peekbyte(void);
extern int pq_getbyte_if_available(unsigned char *c);
extern bool pq_buffer_has_data(void);
extern int pq_putbytes(const char *s, size_t len);

/*
Expand Down
1 change: 1 addition & 0 deletions ext/pg_query/include/mb/pg_wchar.h
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,7 @@ extern int pg_valid_server_encoding_id(int encoding);
* earlier in this file are also available from libpgcommon.
*/
extern int pg_encoding_mblen(int encoding, const char *mbstr);
extern int pg_encoding_mblen_bounded(int encoding, const char *mbstr);
extern int pg_encoding_dsplen(int encoding, const char *mbstr);
extern int pg_encoding_verifymb(int encoding, const char *mbstr, int len);
extern int pg_encoding_max_length(int encoding);
Expand Down
35 changes: 24 additions & 11 deletions ext/pg_query/include/miscadmin.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,15 @@
* allowing die interrupts: HOLD_CANCEL_INTERRUPTS() and
* RESUME_CANCEL_INTERRUPTS().
*
* Note that ProcessInterrupts() has also acquired a number of tasks that
* do not necessarily cause a query-cancel-or-die response. Hence, it's
* possible that it will just clear InterruptPending and return.
*
* INTERRUPTS_PENDING_CONDITION() can be checked to see whether an
* interrupt needs to be serviced, without trying to do so immediately.
* Some callers are also interested in INTERRUPTS_CAN_BE_PROCESSED(),
* which tells whether ProcessInterrupts is sure to clear the interrupt.
*
* Special mechanisms are used to let an interrupt be accepted when we are
* waiting for a lock or when we are waiting for command input (but, of
* course, only if the interrupt holdoff counter is zero). See the
Expand Down Expand Up @@ -94,24 +103,27 @@ extern PGDLLIMPORT __thread volatile uint32 CritSectionCount;
/* in tcop/postgres.c */
extern void ProcessInterrupts(void);

/* Test whether an interrupt is pending */
#ifndef WIN32
#define INTERRUPTS_PENDING_CONDITION() \
(unlikely(InterruptPending))
#else
#define INTERRUPTS_PENDING_CONDITION() \
(unlikely(UNBLOCKED_SIGNAL_QUEUE()) ? pgwin32_dispatch_queued_signals() : 0, \
unlikely(InterruptPending))
#endif

/* Service interrupt, if one is pending and it's safe to service it now */
#define CHECK_FOR_INTERRUPTS() \
do { \
if (unlikely(InterruptPending)) \
ProcessInterrupts(); \
} while(0)
#else /* WIN32 */

#define CHECK_FOR_INTERRUPTS() \
do { \
if (unlikely(UNBLOCKED_SIGNAL_QUEUE())) \
pgwin32_dispatch_queued_signals(); \
if (unlikely(InterruptPending)) \
if (INTERRUPTS_PENDING_CONDITION()) \
ProcessInterrupts(); \
} while(0)
#endif /* WIN32 */

/* Is ProcessInterrupts() guaranteed to clear InterruptPending? */
#define INTERRUPTS_CAN_BE_PROCESSED() \
(InterruptHoldoffCount == 0 && CritSectionCount == 0 && \
QueryCancelHoldoffCount == 0)

#define HOLD_INTERRUPTS() (InterruptHoldoffCount++)

Expand Down Expand Up @@ -471,6 +483,7 @@ extern bool BackupInProgress(void);
extern void CancelBackup(void);

/* in executor/nodeHash.c */
extern size_t get_hash_memory_limit(void);
extern int get_hash_mem(void);

#endif /* MISCADMIN_H */
4 changes: 2 additions & 2 deletions ext/pg_query/include/nodes/execnodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -1454,7 +1454,7 @@ typedef struct IndexScanState
/* ----------------
* IndexOnlyScanState information
*
* indexqual execution state for indexqual expressions
* recheckqual execution state for recheckqual expressions
* ScanKeys Skey structures for index quals
* NumScanKeys number of ScanKeys
* OrderByKeys Skey structures for index ordering operators
Expand All @@ -1473,7 +1473,7 @@ typedef struct IndexScanState
typedef struct IndexOnlyScanState
{
ScanState ss; /* its first field is NodeTag */
ExprState *indexqual;
ExprState *recheckqual;
struct ScanKeyData *ioss_ScanKeys;
int ioss_NumScanKeys;
struct ScanKeyData *ioss_OrderByKeys;
Expand Down
9 changes: 5 additions & 4 deletions ext/pg_query/include/nodes/parsenodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -915,10 +915,10 @@ typedef struct PartitionCmd
* inFromCl marks those range variables that are listed in the FROM clause.
* It's false for RTEs that are added to a query behind the scenes, such
* as the NEW and OLD variables for a rule, or the subqueries of a UNION.
* This flag is not used anymore during parsing, since the parser now uses
* a separate "namespace" data structure to control visibility, but it is
* needed by ruleutils.c to determine whether RTEs should be shown in
* decompiled queries.
* This flag is not used during parsing (except in transformLockingClause,
* q.v.); the parser now uses a separate "namespace" data structure to
* control visibility. But it is needed by ruleutils.c to determine
* whether RTEs should be shown in decompiled queries.
*
* requiredPerms and checkAsUser specify run-time access permissions
* checks to be performed at query startup. The user must have *all*
Expand Down Expand Up @@ -1876,6 +1876,7 @@ typedef struct AlterTableCmd /* one subcommand of an ALTER TABLE */
* constraint, or parent table */
DropBehavior behavior; /* RESTRICT or CASCADE for DROP cases */
bool missing_ok; /* skip error if missing? */
bool recurse; /* exec-time recursion */
} AlterTableCmd;


Expand Down
3 changes: 2 additions & 1 deletion ext/pg_query/include/nodes/pathnodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,8 @@ struct PlannerInfo

List *init_plans; /* init SubPlans for query */

List *cte_plan_ids; /* per-CTE-item list of subplan IDs */
List *cte_plan_ids; /* per-CTE-item list of subplan IDs (or -1 if
* no subplan was made for that CTE) */

List *multiexpr_params; /* List of Lists of Params for MULTIEXPR
* subquery outputs */
Expand Down
1 change: 1 addition & 0 deletions ext/pg_query/include/nodes/pg_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,7 @@ extern List *list_delete_int(List *list, int datum);
extern List *list_delete_oid(List *list, Oid datum);
extern List *list_delete_first(List *list);
extern List *list_delete_last(List *list);
extern List *list_delete_first_n(List *list, int n);
extern List *list_delete_nth_cell(List *list, int n);
extern List *list_delete_cell(List *list, ListCell *cell);

Expand Down
Loading

0 comments on commit 6eae7d4

Please sign in to comment.