Skip to content

Commit

Permalink
Update to latest Postgres 10 patch release (10.14)
Browse files Browse the repository at this point in the history
  • Loading branch information
lfittl committed Nov 8, 2020
1 parent 0ce3454 commit 1753b27
Show file tree
Hide file tree
Showing 70 changed files with 20,849 additions and 20,152 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ARLIB = lib$(TARGET).a
PGDIR = $(root_dir)/tmp/postgres
PGDIRBZ2 = $(root_dir)/tmp/postgres.tar.bz2

PG_VERSION = 10.5
PG_VERSION = 10.14

SRC_FILES := $(wildcard src/*.c src/postgres/*.c)
OBJ_FILES := $(SRC_FILES:.c=.o)
Expand Down
4 changes: 2 additions & 2 deletions pg_query.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ void pg_query_free_plpgsql_parse_result(PgQueryPlpgsqlParseResult result);
void pg_query_free_fingerprint_result(PgQueryFingerprintResult result);

// Postgres version information
#define PG_VERSION "10.5"
#define PG_VERSION "10.14"
#define PG_MAJORVERSION "10"
#define PG_VERSION_NUM 100005
#define PG_VERSION_NUM 100014

// Deprecated APIs below

Expand Down
7 changes: 7 additions & 0 deletions src/postgres/include/access/genam.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,13 @@ typedef enum IndexUniqueCheck
} IndexUniqueCheck;


/* Nullable "ORDER BY col op const" distance */
typedef struct IndexOrderByDistance
{
double value;
bool isnull;
} IndexOrderByDistance;

/*
* generalized index_ interface routines (in indexam.c)
*/
Expand Down
7 changes: 5 additions & 2 deletions src/postgres/include/access/hash.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,12 @@ typedef HashScanOpaqueData *HashScanOpaque;
*
* There is no particular upper limit on the size of mapp[], other than
* needing to fit into the metapage. (With 8K block size, 1024 bitmaps
* limit us to 256 GB of overflow space...)
* limit us to 256 GB of overflow space...). For smaller block size we
* can not use 1024 bitmaps as it will lead to the meta page data crossing
* the block size boundary. So we use BLCKSZ to determine the maximum number
* of bitmaps.
*/
#define HASH_MAX_BITMAPS 1024
#define HASH_MAX_BITMAPS Min(BLCKSZ / 8, 1024)

#define HASH_SPLITPOINT_PHASE_BITS 2
#define HASH_SPLITPOINT_PHASES_PER_GRP (1 << HASH_SPLITPOINT_PHASE_BITS)
Expand Down
1 change: 1 addition & 0 deletions src/postgres/include/access/heapam.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#define HEAP_INSERT_SKIP_FSM 0x0002
#define HEAP_INSERT_FROZEN 0x0004
#define HEAP_INSERT_SPECULATIVE 0x0008
#define HEAP_INSERT_NO_LOGICAL 0x0010

typedef struct BulkInsertStateData *BulkInsertState;

Expand Down
4 changes: 2 additions & 2 deletions src/postgres/include/access/parallel.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ typedef struct ParallelContext
} ParallelContext;

extern volatile bool ParallelMessagePending;
extern int ParallelWorkerNumber;
extern bool InitializingParallelWorker;
extern PGDLLIMPORT int ParallelWorkerNumber;
extern PGDLLIMPORT bool InitializingParallelWorker;

#define IsParallelWorker() (ParallelWorkerNumber >= 0)

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

/*
* XACT_FLAGS_ACCESSEDTEMPNAMESPACE - set when a temporary namespace is
* accessed. We don't allow PREPARE TRANSACTION in that case.
*/
#define XACT_FLAGS_ACCESSEDTEMPNAMESPACE (1U << 2)

/*
* start- and end-of-transaction callbacks for dynamically loaded modules
Expand Down Expand Up @@ -337,6 +342,7 @@ extern SubTransactionId GetCurrentSubTransactionId(void);
extern void MarkCurrentTransactionIdLoggedIfAny(void);
extern bool SubTransactionIsActive(SubTransactionId subxid);
extern CommandId GetCurrentCommandId(bool used);
extern void SetParallelStartTimestamps(TimestampTz xact_ts, TimestampTz stmt_ts);
extern TimestampTz GetCurrentTransactionStartTimestamp(void);
extern TimestampTz GetCurrentStatementStartTimestamp(void);
extern TimestampTz GetCurrentTransactionStopTimestamp(void);
Expand Down
11 changes: 11 additions & 0 deletions src/postgres/include/access/xlog.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,14 @@ typedef enum WalLevel
WAL_LEVEL_LOGICAL
} WalLevel;

/* Recovery states */
typedef enum RecoveryState
{
RECOVERY_STATE_CRASH = 0, /* crash recovery */
RECOVERY_STATE_ARCHIVE, /* archive recovery */
RECOVERY_STATE_DONE /* currently in production */
} RecoveryState;

extern PGDLLIMPORT int wal_level;

/* Is WAL archiving enabled (always or only while server is running normally)? */
Expand Down Expand Up @@ -184,6 +192,8 @@ extern bool XLOG_DEBUG;
/* These indicate the cause of a checkpoint request */
#define CHECKPOINT_CAUSE_XLOG 0x0040 /* XLOG consumption */
#define CHECKPOINT_CAUSE_TIME 0x0080 /* Elapsed time */
/* We set this to ensure that ckpt_flags is not 0 if a request has been made */
#define CHECKPOINT_REQUESTED 0x0100 /* Checkpoint request has been made */

/*
* Flag bits for the record being inserted, set using XLogSetRecordFlags().
Expand Down Expand Up @@ -240,6 +250,7 @@ extern const char *xlog_identify(uint8 info);
extern void issue_xlog_fsync(int fd, XLogSegNo segno);

extern bool RecoveryInProgress(void);
extern RecoveryState GetRecoveryState(void);
extern bool HotStandbyActive(void);
extern bool HotStandbyActiveInReplay(void);
extern bool XLogInsertAllowed(void);
Expand Down
3 changes: 3 additions & 0 deletions src/postgres/include/access/xloginsert.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "storage/block.h"
#include "storage/buf.h"
#include "storage/relfilenode.h"
#include "utils/relcache.h"

/*
* The minimum size of the WAL construction working area. If you need to
Expand Down Expand Up @@ -54,6 +55,8 @@ extern bool XLogCheckBufferNeedsBackup(Buffer buffer);
extern XLogRecPtr log_newpage(RelFileNode *rnode, ForkNumber forkNum,
BlockNumber blk, char *page, bool page_std);
extern XLogRecPtr log_newpage_buffer(Buffer buffer, bool page_std);
extern void log_newpage_range(Relation rel, ForkNumber forkNum,
BlockNumber startblk, BlockNumber endblk, bool page_std);
extern XLogRecPtr XLogSaveBufferForHint(Buffer buffer, bool buffer_std);

extern void InitXLogInsert(void);
Expand Down
58 changes: 58 additions & 0 deletions src/postgres/include/c.h
Original file line number Diff line number Diff line change
Expand Up @@ -963,12 +963,70 @@ typedef NameData *Name;
*_start++ = 0; \
} while (0)

/*
* Macros for range-checking float values before converting to integer.
* We must be careful here that the boundary values are expressed exactly
* in the float domain. PG_INTnn_MIN is an exact power of 2, so it will
* be represented exactly; but PG_INTnn_MAX isn't, and might get rounded
* off, so avoid using that.
* The input must be rounded to an integer beforehand, typically with rint(),
* else we might draw the wrong conclusion about close-to-the-limit values.
* These macros will do the right thing for Inf, but not necessarily for NaN,
* so check isnan(num) first if that's a possibility.
*/
#define FLOAT4_FITS_IN_INT16(num) \
((num) >= (float4) PG_INT16_MIN && (num) < -((float4) PG_INT16_MIN))
#define FLOAT4_FITS_IN_INT32(num) \
((num) >= (float4) PG_INT32_MIN && (num) < -((float4) PG_INT32_MIN))
#define FLOAT4_FITS_IN_INT64(num) \
((num) >= (float4) PG_INT64_MIN && (num) < -((float4) PG_INT64_MIN))
#define FLOAT8_FITS_IN_INT16(num) \
((num) >= (float8) PG_INT16_MIN && (num) < -((float8) PG_INT16_MIN))
#define FLOAT8_FITS_IN_INT32(num) \
((num) >= (float8) PG_INT32_MIN && (num) < -((float8) PG_INT32_MIN))
#define FLOAT8_FITS_IN_INT64(num) \
((num) >= (float8) PG_INT64_MIN && (num) < -((float8) PG_INT64_MIN))


/* ----------------------------------------------------------------
* Section 8: random stuff
* ----------------------------------------------------------------
*/

/*
* Invert the sign of a qsort-style comparison result, ie, exchange negative
* and positive integer values, being careful not to get the wrong answer
* for INT_MIN. The argument should be an integral variable.
*/
#define INVERT_COMPARE_RESULT(var) \
((var) = ((var) < 0) ? 1 : -(var))

/*
* Use this, not "char buf[BLCKSZ]", to declare a field or local variable
* holding a page buffer, if that page might be accessed as a page and not
* just a string of bytes. Otherwise the variable might be under-aligned,
* causing problems on alignment-picky hardware. (In some places, we use
* this to declare buffers even though we only pass them to read() and
* write(), because copying to/from aligned buffers is usually faster than
* using unaligned buffers.) We include both "double" and "int64" in the
* union to ensure that the compiler knows the value must be MAXALIGN'ed
* (cf. configure's computation of MAXIMUM_ALIGNOF).
*/
typedef union PGAlignedBlock
{
char data[BLCKSZ];
double force_align_d;
int64 force_align_i64;
} PGAlignedBlock;

/* Same, but for an XLOG_BLCKSZ-sized buffer */
typedef union PGAlignedXLogBlock
{
char data[XLOG_BLCKSZ];
double force_align_d;
int64 force_align_i64;
} PGAlignedXLogBlock;

/* msb for char */
#define HIGHBIT (0x80)
#define IS_HIGHBIT_SET(ch) ((unsigned char)(ch) & HIGHBIT)
Expand Down
7 changes: 6 additions & 1 deletion src/postgres/include/catalog/dependency.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,10 @@ typedef enum ObjectClass

/* in dependency.c */

extern void AcquireDeletionLock(const ObjectAddress *object, int flags);

extern void ReleaseDeletionLock(const ObjectAddress *object);

extern void performDeletion(const ObjectAddress *object,
DropBehavior behavior, int flags);

Expand All @@ -194,7 +198,7 @@ extern void recordDependencyOnSingleRelExpr(const ObjectAddress *depender,
Node *expr, Oid relId,
DependencyType behavior,
DependencyType self_behavior,
bool ignore_self);
bool reverse_self);

extern ObjectClass getObjectClass(const ObjectAddress *object);

Expand Down Expand Up @@ -237,6 +241,7 @@ extern long changeDependencyFor(Oid classId, Oid objectId,
Oid newRefObjectId);

extern Oid getExtensionOfObject(Oid classId, Oid objectId);
extern List *getAutoExtensionsOfObject(Oid classId, Oid objectId);

extern bool sequenceIsOwned(Oid seqId, char deptype, Oid *tableId, int32 *colId);
extern List *getOwnedSequences(Oid relid, AttrNumber attnum);
Expand Down
10 changes: 8 additions & 2 deletions src/postgres/include/catalog/index.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ typedef enum

extern void index_check_primary_key(Relation heapRel,
IndexInfo *indexInfo,
bool is_alter_table);
bool is_alter_table,
IndexStmt *stmt);

extern Oid index_create(Relation heapRelation,
const char *indexRelationName,
Expand Down Expand Up @@ -81,6 +82,8 @@ extern void index_drop(Oid indexId, bool concurrent);

extern IndexInfo *BuildIndexInfo(Relation index);

extern IndexInfo *BuildDummyIndexInfo(Relation index);

extern void BuildSpeculativeIndexInfo(Relation index, IndexInfo *ii);

extern void FormIndexDatum(IndexInfo *indexInfo,
Expand Down Expand Up @@ -115,6 +118,8 @@ extern void validate_index(Oid heapId, Oid indexId, Snapshot snapshot);

extern void index_set_state_flags(Oid indexId, IndexStateFlagsAction action);

extern Oid IndexGetRelation(Oid indexId, bool missing_ok);

extern void reindex_index(Oid indexId, bool skip_constraint_checks,
char relpersistence, int options);

Expand All @@ -129,6 +134,7 @@ extern bool reindex_relation(Oid relid, int flags, int options);

extern bool ReindexIsProcessingHeap(Oid heapOid);
extern bool ReindexIsProcessingIndex(Oid indexOid);
extern Oid IndexGetRelation(Oid indexId, bool missing_ok);

extern void ResetReindexState(int nestLevel);

#endif /* INDEX_H */
1 change: 1 addition & 0 deletions src/postgres/include/catalog/namespace.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ extern Oid RelnameGetRelid(const char *relname);
extern bool RelationIsVisible(Oid relid);

extern Oid TypenameGetTypid(const char *typname);
extern Oid TypenameGetTypidExtended(const char *typname, bool temp_ok);
extern bool TypeIsVisible(Oid typid);

extern FuncCandidateList FuncnameGetCandidates(List *names,
Expand Down
1 change: 1 addition & 0 deletions src/postgres/include/catalog/pg_control.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ typedef struct CheckPoint
#define XLOG_END_OF_RECOVERY 0x90
#define XLOG_FPI_FOR_HINT 0xA0
#define XLOG_FPI 0xB0
#define XLOG_FPI_MULTI 0xC0


/*
Expand Down
2 changes: 1 addition & 1 deletion src/postgres/include/catalog/pg_proc.h
Original file line number Diff line number Diff line change
Expand Up @@ -5425,7 +5425,7 @@ DATA(insert OID = 6011 ( pg_replication_origin_xact_reset PGNSP PGUID 12 1 0 0 0
DESCR("reset the transaction's origin lsn and timestamp");

DATA(insert OID = 6012 ( pg_replication_origin_advance PGNSP PGUID 12 1 0 0 0 f f f f t f v u 2 0 2278 "25 3220" _null_ _null_ _null_ _null_ _null_ pg_replication_origin_advance _null_ _null_ _null_ ));
DESCR("advance replication identifier to specific location");
DESCR("advance replication origin to specific location");

DATA(insert OID = 6013 ( pg_replication_origin_progress PGNSP PGUID 12 1 0 0 0 f f f f t f v u 2 0 3220 "25 16" _null_ _null_ _null_ _null_ _null_ pg_replication_origin_progress _null_ _null_ _null_ ));
DESCR("get an individual replication origin's replication progress");
Expand Down
5 changes: 5 additions & 0 deletions src/postgres/include/fmgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,11 @@ extern void fmgr_info_copy(FmgrInfo *dstinfo, FmgrInfo *srcinfo,
* caller must still check fcinfo->isnull! Also, if function is strict,
* it is caller's responsibility to verify that no null arguments are present
* before calling.
*
* Some code performs multiple calls without redoing InitFunctionCallInfoData,
* possibly altering the argument values. This is okay, but be sure to reset
* the fcinfo->isnull flag before each call, since callees are permitted to
* assume that starts out false.
*/
#define FunctionCallInvoke(fcinfo) ((* (fcinfo)->flinfo->fn_addr) (fcinfo))

Expand Down
13 changes: 12 additions & 1 deletion src/postgres/include/funcapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ extern TupleTableSlot *TupleDescGetSlot(TupleDesc tupdesc);
/*----------
* Support for Set Returning Functions (SRFs)
*
* The basic API for SRFs looks something like:
* The basic API for SRFs using ValuePerCall mode looks something like this:
*
* Datum
* my_Set_Returning_Function(PG_FUNCTION_ARGS)
Expand Down Expand Up @@ -275,6 +275,17 @@ extern TupleTableSlot *TupleDescGetSlot(TupleDesc tupdesc);
* SRF_RETURN_DONE(funcctx);
* }
*
* NOTE: there is no guarantee that a SRF using ValuePerCall mode will be
* run to completion; for example, a query with LIMIT might stop short of
* fetching all the rows. Therefore, do not expect that you can do resource
* cleanup just before SRF_RETURN_DONE(). You need not worry about releasing
* memory allocated in multi_call_memory_ctx, but holding file descriptors or
* other non-memory resources open across calls is a bug. SRFs that need
* such resources should not use these macros, but instead populate a
* tuplestore during a single call, and return that using SFRM_Materialize
* mode (see fmgr/README). Alternatively, set up a callback to release
* resources at query shutdown, using RegisterExprContextCallback().
*
*----------
*/

Expand Down
6 changes: 3 additions & 3 deletions src/postgres/include/miscadmin.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,16 +97,16 @@ extern void ProcessInterrupts(void);

#define CHECK_FOR_INTERRUPTS() \
do { \
if (InterruptPending) \
if (unlikely(InterruptPending)) \
ProcessInterrupts(); \
} while(0)
#else /* WIN32 */

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

0 comments on commit 1753b27

Please sign in to comment.