Skip to content

Commit

Permalink
Support PostgreSQL 14
Browse files Browse the repository at this point in the history
In PostgreSQL 14, planner was restructured in regard to query string
passing.  This change allows us to remove fair amount of lines and
complexity that had been added as a struggle for retrieving proper
query string.

Two callbacks, post_parse_analyze_hook and ProcessUtility_hook are no
longer used.  get_query_string is removed altogether.  Also
current_hint_retrieved juggling, which was complex and fragile,
disappears. Now pg_hint_plan_planner alone can retrieve hint string by
looking into the given string.

In PostgreSQL 14, a new optimization item "memoize" is added. It is
not handled in this commit and leave it for a later commit.
  • Loading branch information
horiguti committed Oct 6, 2021
1 parent 4ffa97e commit 454f72a
Show file tree
Hide file tree
Showing 14 changed files with 551 additions and 1,271 deletions.
12 changes: 6 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#

MODULES = pg_hint_plan
HINTPLANVER = 1.3.7
HINTPLANVER = 1.4

REGRESS = init base_plan pg_hint_plan ut-init ut-A ut-S ut-J ut-L ut-G ut-R ut-fdw ut-W ut-T ut-fini

Expand All @@ -22,8 +22,8 @@ PG_CONFIG = pg_config
PGXS := $(shell $(PG_CONFIG) --pgxs)
include $(PGXS)

STARBALL13 = pg_hint_plan13-$(HINTPLANVER).tar.gz
STARBALLS = $(STARBALL13)
STARBALL14 = pg_hint_plan14-$(HINTPLANVER).tar.gz
STARBALLS = $(STARBALL14)

TARSOURCES = Makefile *.c *.h COPYRIGHT* \
pg_hint_plan--*.sql \
Expand All @@ -37,7 +37,7 @@ endif

installcheck: $(REGRESSION_EXPECTED)

rpms: rpm13
rpms: rpm14

# pg_hint_plan.c includes core.c and make_join_rel.c
pg_hint_plan.o: core.c make_join_rel.c # pg_stat_statements.c
Expand All @@ -52,5 +52,5 @@ $(STARBALLS): $(TARSOURCES)
tar -chzf $@ $(addprefix $(subst .tar.gz,,$@)/, $^)
rm $(subst .tar.gz,,$@)

rpm13: $(STARBALL13)
MAKE_ROOT=`pwd` rpmbuild -bb SPECS/pg_hint_plan13.spec
rpm14: $(STARBALL14)
MAKE_ROOT=`pwd` rpmbuild -bb SPECS/pg_hint_plan14.spec
30 changes: 15 additions & 15 deletions SPECS/pg_hint_plan13.spec → SPECS/pg_hint_plan14.spec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# SPEC file for pg_store_plans
# Copyright(C) 2020 NIPPON TELEGRAPH AND TELEPHONE CORPORATION

%define _pgdir /usr/pgsql-13
%define _pgdir /usr/pgsql-14
%define _bindir %{_pgdir}/bin
%define _libdir %{_pgdir}/lib
%define _datadir %{_pgdir}/share
Expand All @@ -15,8 +15,8 @@

## Set general information for pg_store_plans.
Summary: Optimizer hint on PostgreSQL 12
Name: pg_hint_plan13
Version: 1.3.7
Name: pg_hint_plan14
Version: 1.4
Release: 1%{?dist}
License: BSD
Group: Applications/Databases
Expand All @@ -26,28 +26,28 @@ BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-%(%{__id_u} -n)
Vendor: NIPPON TELEGRAPH AND TELEPHONE CORPORATION

## We use postgresql-devel package
BuildRequires: postgresql13-devel
Requires: postgresql13-server
BuildRequires: postgresql14-devel
Requires: postgresql14-server

## Description for "pg_hint_plan"
%description

pg_hint_plan provides capability to tweak execution plans to be
executed on PostgreSQL.

Note that this package is available for only PostgreSQL 13.
Note that this package is available for only PostgreSQL 14.

%package llvmjit
Requires: postgresql13-server, postgresql13-llvmjit
Requires: pg_hint_plan13 = 1.3.7
Summary: Just-in-time compilation support for pg_hint_plan13
Requires: postgresql14-server, postgresql14-llvmjit
Requires: pg_hint_plan14 = 1.4
Summary: Just-in-time compilation support for pg_hint_plan14

%description llvmjit
Just-in-time compilation support for pg_hint_plan13
Just-in-time compilation support for pg_hint_plan14

## pre work for build pg_hint_plan
%prep
PATH=/usr/pgsql-13/bin:$PATH
PATH=/usr/pgsql-14/bin:$PATH
if [ "${MAKE_ROOT}" != "" ]; then
pushd ${MAKE_ROOT}
make clean %{name}-%{version}.tar.gz
Expand All @@ -58,7 +58,7 @@ if [ ! -d %{_rpmdir} ]; then mkdir -p %{_rpmdir}; fi

## Set variables for build environment
%build
PATH=/usr/pgsql-13/bin:$PATH
PATH=/usr/pgsql-14/bin:$PATH
make USE_PGXS=1 %{?_smp_mflags}

## Set variables for install
Expand All @@ -73,7 +73,7 @@ rm -rf %{buildroot}
%defattr(0755,root,root)
%{_libdir}/pg_hint_plan.so
%defattr(0644,root,root)
%{_datadir}/extension/pg_hint_plan--1.3.7.sql
%{_datadir}/extension/pg_hint_plan--1.4.sql
%{_datadir}/extension/pg_hint_plan.control

%files llvmjit
Expand All @@ -85,5 +85,5 @@ rm -rf %{buildroot}

# History of pg_hint_plan.
%changelog
* Thu Oct 29 2020 Kyotaro Horiguchi
- First release of pg_hint_plan13.
* Tue Oct 05 2021 Kyotaro Horiguchi
- Support PostgreSQL 14.
Loading

0 comments on commit 454f72a

Please sign in to comment.