Skip to content

Commit

Permalink
Release 5.0.0, update to Postgres 16 parser
Browse files Browse the repository at this point in the history
  • Loading branch information
lfittl committed Dec 23, 2023
1 parent 18682bd commit 1ac278e
Show file tree
Hide file tree
Showing 484 changed files with 224,155 additions and 184,791 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@

* ...

## 5.0.0 2023-12-22

* Upgrade to libpg_query 16-5.0.0
- Updates to the Postgres 16 parser
- Multiple deparser improvements


## 4.2.3 2023-08-04

Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
pg_query (4.2.3)
pg_query (5.0.0)
google-protobuf (>= 3.22.3)

GEM
Expand Down
6 changes: 3 additions & 3 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 = '15-4.2.3'.freeze
LIB_PG_QUERY_SHA256SUM = '8b820d63442b1677ce4f0df2a95b3fafdbc520a82901def81217559ec4df9e6b'.freeze
LIB_PG_QUERY_TAG = '16-5.0.0'.freeze
LIB_PG_QUERY_SHA256SUM = '7cf26922cbc41668fa79332504f2d5638339baa9411912b8df4526ccd1d7029e'.freeze

Rake::ExtensionTask.new 'pg_query' do |ext|
ext.lib_dir = 'lib/pg_query'
Expand Down Expand Up @@ -66,7 +66,7 @@ task :update_source do
system("rmdir #{extdir}/postgres")
system("cp -a #{libdir}/pg_query.h #{extdir}/include")
# Make sure every .c file in the top-level directory is its own translation unit
system("mv #{extdir}/*{_conds,_defs,_helper}.c #{extdir}/include")
system("mv #{extdir}/*{_conds,_defs,_helper,.funcs}.c #{extdir}/include")
# Protobuf definitions
system("protoc --proto_path=#{libdir}/protobuf --ruby_out=#{File.join(__dir__, 'lib/pg_query')} #{libdir}/protobuf/pg_query.proto")
system("mkdir -p #{extdir}/include/protobuf")
Expand Down
4 changes: 1 addition & 3 deletions ext/pg_query/extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@

$objs = Dir.glob(File.join(__dir__, '*.c')).map { |f| Pathname.new(f).sub_ext('.o').to_s }

# -Wno-deprecated-non-prototype avoids warnings on Clang 15.0+, this can be removed in Postgres 16:
# https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=1c27d16e6e5c1f463bbe1e9ece88dda811235165
$CFLAGS << " -fvisibility=hidden -O3 -Wall -fno-strict-aliasing -fwrapv -fstack-protector -Wno-unused-function -Wno-unused-variable -Wno-clobbered -Wno-sign-compare -Wno-discarded-qualifiers -Wno-deprecated-non-prototype -Wno-unknown-warning-option -g"
$CFLAGS << " -fvisibility=hidden -O3 -Wall -fno-strict-aliasing -fwrapv -fstack-protector -Wno-unused-function -Wno-unused-variable -Wno-clobbered -Wno-sign-compare -Wno-discarded-qualifiers -Wno-unknown-warning-option -g"

$INCFLAGS = "-I#{File.join(__dir__, 'include')} " + $INCFLAGS

Expand Down
4 changes: 3 additions & 1 deletion ext/pg_query/include/access/amapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* amapi.h
* API for Postgres index access methods.
*
* Copyright (c) 2015-2022, PostgreSQL Global Development Group
* Copyright (c) 2015-2023, PostgreSQL Global Development Group
*
* src/include/access/amapi.h
*
Expand Down Expand Up @@ -244,6 +244,8 @@ typedef struct IndexAmRoutine
bool amcaninclude;
/* does AM use maintenance_work_mem? */
bool amusemaintenanceworkmem;
/* does AM store tuple information only at block granularity? */
bool amsummarizing;
/* OR of parallel vacuum flags. See vacuum.h for flags. */
uint8 amparallelvacuumoptions;
/* type of data stored in index, or InvalidOid if variable */
Expand Down
8 changes: 5 additions & 3 deletions ext/pg_query/include/access/attmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Definitions for PostgreSQL attribute mappings
*
*
* Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
* Portions Copyright (c) 1996-2023, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* src/include/access/attmap.h
Expand Down Expand Up @@ -42,9 +42,11 @@ extern void free_attrmap(AttrMap *map);

/* Conversion routines to build mappings */
extern AttrMap *build_attrmap_by_name(TupleDesc indesc,
TupleDesc outdesc);
TupleDesc outdesc,
bool missing_ok);
extern AttrMap *build_attrmap_by_name_if_req(TupleDesc indesc,
TupleDesc outdesc);
TupleDesc outdesc,
bool missing_ok);
extern AttrMap *build_attrmap_by_position(TupleDesc indesc,
TupleDesc outdesc,
const char *msg);
Expand Down
2 changes: 1 addition & 1 deletion ext/pg_query/include/access/attnum.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* POSTGRES attribute number definitions.
*
*
* Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
* Portions Copyright (c) 1996-2023, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* src/include/access/attnum.h
Expand Down
2 changes: 1 addition & 1 deletion ext/pg_query/include/access/clog.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* PostgreSQL transaction-commit-log manager
*
* Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
* Portions Copyright (c) 1996-2023, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* src/include/access/clog.h
Expand Down
2 changes: 1 addition & 1 deletion ext/pg_query/include/access/commit_ts.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* PostgreSQL commit timestamp manager
*
* Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
* Portions Copyright (c) 1996-2023, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* src/include/access/commit_ts.h
Expand Down
2 changes: 1 addition & 1 deletion ext/pg_query/include/access/detoast.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* detoast.h
* Access to compressed and external varlena values.
*
* Copyright (c) 2000-2022, PostgreSQL Global Development Group
* Copyright (c) 2000-2023, PostgreSQL Global Development Group
*
* src/include/access/detoast.h
*
Expand Down
12 changes: 7 additions & 5 deletions ext/pg_query/include/access/genam.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* POSTGRES generalized index access method definitions.
*
*
* Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
* Portions Copyright (c) 1996-2023, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* src/include/access/genam.h
Expand Down Expand Up @@ -44,6 +44,7 @@ typedef struct IndexBuildResult
typedef struct IndexVacuumInfo
{
Relation index; /* the index being vacuumed */
Relation heaprel; /* the heap relation the index belongs to */
bool analyze_only; /* ANALYZE (without any actual vacuum) */
bool report_progress; /* emit progress.h status reports */
bool estimated_count; /* num_heap_tuples is an estimate */
Expand Down Expand Up @@ -161,9 +162,10 @@ extern void index_rescan(IndexScanDesc scan,
extern void index_endscan(IndexScanDesc scan);
extern void index_markpos(IndexScanDesc scan);
extern void index_restrpos(IndexScanDesc scan);
extern Size index_parallelscan_estimate(Relation indexrel, Snapshot snapshot);
extern void index_parallelscan_initialize(Relation heaprel, Relation indexrel,
Snapshot snapshot, ParallelIndexScanDesc target);
extern Size index_parallelscan_estimate(Relation indexRelation, Snapshot snapshot);
extern void index_parallelscan_initialize(Relation heapRelation,
Relation indexRelation, Snapshot snapshot,
ParallelIndexScanDesc target);
extern void index_parallelrescan(IndexScanDesc scan);
extern IndexScanDesc index_beginscan_parallel(Relation heaprel,
Relation indexrel, int nkeys, int norderbys,
Expand Down Expand Up @@ -191,7 +193,7 @@ extern void index_store_float8_orderby_distances(IndexScanDesc scan,
Oid *orderByTypes,
IndexOrderByDistance *distances,
bool recheckOrderBy);
extern bytea *index_opclass_options(Relation relation, AttrNumber attnum,
extern bytea *index_opclass_options(Relation indrel, AttrNumber attnum,
Datum attoptions, bool validate);


Expand Down
19 changes: 16 additions & 3 deletions ext/pg_query/include/access/gin.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* gin.h
* Public header file for Generalized Inverted Index access method.
*
* Copyright (c) 2006-2022, PostgreSQL Global Development Group
* Copyright (c) 2006-2023, PostgreSQL Global Development Group
*
* src/include/access/gin.h
*--------------------------------------------------------------------------
Expand Down Expand Up @@ -57,13 +57,26 @@ typedef struct GinStatsData
*/
typedef char GinTernaryValue;

StaticAssertDecl(sizeof(GinTernaryValue) == sizeof(bool),
"sizes of GinTernaryValue and bool are not equal");

#define GIN_FALSE 0 /* item is not present / does not match */
#define GIN_TRUE 1 /* item is present / matches */
#define GIN_MAYBE 2 /* don't know if item is present / don't know
* if matches */

#define DatumGetGinTernaryValue(X) ((GinTernaryValue)(X))
#define GinTernaryValueGetDatum(X) ((Datum)(X))
static inline GinTernaryValue
DatumGetGinTernaryValue(Datum X)
{
return (GinTernaryValue) X;
}

static inline Datum
GinTernaryValueGetDatum(GinTernaryValue X)
{
return (Datum) X;
}

#define PG_RETURN_GIN_TERNARY_VALUE(x) return GinTernaryValueGetDatum(x)

/* GUC parameters */
Expand Down
2 changes: 1 addition & 1 deletion ext/pg_query/include/access/htup.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* POSTGRES heap tuple definitions.
*
*
* Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
* Portions Copyright (c) 1996-2023, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* src/include/access/htup.h
Expand Down
8 changes: 6 additions & 2 deletions ext/pg_query/include/access/htup_details.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* POSTGRES heap tuple header definitions.
*
*
* Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
* Portions Copyright (c) 1996-2023, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* src/include/access/htup_details.h
Expand All @@ -19,6 +19,7 @@
#include "access/tupdesc.h"
#include "access/tupmacs.h"
#include "storage/bufpage.h"
#include "varatt.h"

/*
* MaxTupleAttributeNumber limits the number of (user) columns in a tuple.
Expand Down Expand Up @@ -426,6 +427,9 @@ do { \
(tup)->t_choice.t_heap.t_field3.t_xvac = (xid); \
} while (0)

StaticAssertDecl(MaxOffsetNumber < SpecTokenOffsetNumber,
"invalid speculative token constant");

#define HeapTupleHeaderIsSpeculative(tup) \
( \
(ItemPointerGetOffsetNumberNoCheck(&(tup)->t_ctid) == SpecTokenOffsetNumber) \
Expand Down Expand Up @@ -699,7 +703,7 @@ extern void heap_fill_tuple(TupleDesc tupleDesc,
uint16 *infomask, bits8 *bit);
extern bool heap_attisnull(HeapTuple tup, int attnum, TupleDesc tupleDesc);
extern Datum nocachegetattr(HeapTuple tup, int attnum,
TupleDesc att);
TupleDesc tupleDesc);
extern Datum heap_getsysattr(HeapTuple tup, int attnum, TupleDesc tupleDesc,
bool *isnull);
extern Datum getmissingattr(TupleDesc tupleDesc,
Expand Down
Loading

0 comments on commit 1ac278e

Please sign in to comment.