Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add workflow to test PG14 #3349

Merged
merged 3 commits into from Jun 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
108 changes: 108 additions & 0 deletions .github/workflows/postgres_dev.yaml
@@ -0,0 +1,108 @@
name: PostgreSQL bleeding edge
on:
pull_request:
jobs:
regress:
name: PG14
runs-on: ubuntu-20.04
env:
PG_SRC_DIR: pgbuild
PG_INSTALL_DIR: postgresql
MAKE_JOBS: 2
# postgres version to build against this can either be commit hash, branch or tag
PG_COMMIT: 5028981923
svenklemm marked this conversation as resolved.
Show resolved Hide resolved
CLANG: clang-9
LLVM_CONFIG: llvm-config-9
CC: gcc
CXX: g++
svenklemm marked this conversation as resolved.
Show resolved Hide resolved

steps:
- name: Install Linux Dependencies
run: |
sudo apt-get update
sudo apt-get install flex bison lcov systemd-coredump gdb libipc-run-perl libtest-most-perl clang-9 llvm-9 llvm-9-dev llvm-9-tools

# we cache the build directory instead of the install directory here
# because extension installation will write files to install directory
# leading to a tainted cache
- name: Cache PostgreSQL
id: cache-postgresql
uses: actions/cache@v2
with:
path: ~/${{ env.PG_SRC_DIR }}
key: ${{ runner.os }}-postgresql-dev-${{ env.PG_COMMIT }}

- name: Build PostgreSQL
if: steps.cache-postgresql.outputs.cache-hit != 'true'
run: |
mkdir -p ~/$PG_SRC_DIR
cd ~/$PG_SRC_DIR
git clone https://github.com/postgres/postgres .
git checkout $PG_COMMIT
./configure --prefix=$HOME/$PG_INSTALL_DIR --enable-debug --enable-cassert --with-llvm --with-openssl --without-readline --without-libxml
make -j $MAKE_JOBS
make -j $MAKE_JOBS -C src/test/isolation
make -j $MAKE_JOBS -C contrib/postgres_fdw

- name: Install PostgreSQL
run: |
make -C ~/$PG_SRC_DIR install
make -C ~/$PG_SRC_DIR/contrib/postgres_fdw install

- name: Checkout TimescaleDB
uses: actions/checkout@v2

- name: Build TimescaleDB
run: |
./bootstrap -DCMAKE_BUILD_TYPE=Debug -DEXPERIMENTAL=ON -DPG_SOURCE_DIR=~/$PG_SRC_DIR -DPG_PATH=~/$PG_INSTALL_DIR -DWARNINGS_AS_ERRORS=OFF
make -C build
make -C build install

# this is more for informational purposes as we don't yet have pg14 test output files and treat them as being the same as PG13
- name: Run tests
run: |
find . -name '*-13.out' | xargs -IFILE bash -c 'cp FILE $(echo FILE| sed -e "s!-13.out!-14.out!")'
make -C build installcheck || true

- name: Show regression diffs
if: always()
id: collectlogs
run: |
find . -name regression.diffs -exec cat {} + > regression.log
find . -name postmaster.log -exec cat {} + > postgres.log
if [[ "${{ runner.os }}" == "Linux" ]] ; then
# wait in case there are in-progress coredumps
sleep 10
if coredumpctl -q list >/dev/null; then echo "::set-output name=coredumps::true"; fi
fi
if [[ -s regression.log ]]; then echo "::set-output name=regression_diff::true"; fi
grep -e 'FAILED' -e 'failed (ignored)' installcheck.log || true
cat regression.log

- name: Save regression diffs
if: always() && steps.collectlogs.outputs.regression_diff == 'true'
uses: actions/upload-artifact@v2
with:
name: Regression diff PG ${{ env.PG_COMMIT }}
path: regression.log

- name: Save postmaster.log
if: always()
uses: actions/upload-artifact@v2
with:
name: PostgreSQL log PG ${{ env.PG_COMMIT }}
path: postgres.log

- name: Stack trace
if: always() && steps.collectlogs.outputs.coredumps == 'true'
run: |
echo "bt full" | sudo coredumpctl gdb
./scripts/bundle_coredumps.sh
false

- name: Coredumps
if: always() && steps.collectlogs.outputs.coredumps == 'true'
uses: actions/upload-artifact@v2
with:
name: Coredumps PG ${{ env.PG_COMMIT }}
path: coredumps
7 changes: 5 additions & 2 deletions CMakeLists.txt
Expand Up @@ -101,6 +101,7 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

# Code coverage is optional and OFF by default
option(CODECOVERAGE "Enable code coverage for the build" OFF)
option(EXPERIMENTAL "Skip postgres version compatibility check" OFF)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... or DEVELOPMENT. No opinion, just offering alternatives.


# Generate downgrade script
option(GENERATE_DOWNGRADE_SCRIPT
Expand Down Expand Up @@ -307,7 +308,7 @@ execute_process(
OUTPUT_STRIP_TRAILING_WHITESPACE)

if(NOT ${PG_VERSION_STRING} MATCHES
"^PostgreSQL[ ]+([0-9]+)(\\.([0-9]+)|devel|rc[0-9]+)")
"^PostgreSQL[ ]+([0-9]+)(\\.([0-9]+)|beta|devel|rc[0-9]+)")
message(FATAL_ERROR "Could not parse PostgreSQL version ${PG_VERSION_STRING}")
endif()

Expand All @@ -323,7 +324,9 @@ message(STATUS "Compiling against PostgreSQL version ${PG_VERSION}")

# Ensure that PostgreSQL version is supported and consistent with src/compat.h
# version check
if((${PG_VERSION_MAJOR} LESS "12") OR (${PG_VERSION_MAJOR} GREATER "13"))
if((${PG_VERSION_MAJOR} LESS "12")
OR (${PG_VERSION_MAJOR} GREATER "13")
AND NOT (${EXPERIMENTAL}))
message(FATAL_ERROR "TimescaleDB only supports PostgreSQL 12 and 13")
endif()

Expand Down
9 changes: 7 additions & 2 deletions src/compat.h
Expand Up @@ -25,15 +25,20 @@

#define is_supported_pg_version_12(version) ((version >= 120000) && (version < 130000))
#define is_supported_pg_version_13(version) ((version >= 130002) && (version < 140000))
#define is_supported_pg_version_14(version) ((version >= 140000) && (version < 150000))

#define is_supported_pg_version(version) \
(is_supported_pg_version_12(version) || is_supported_pg_version_13(version))
(is_supported_pg_version_12(version) || is_supported_pg_version_13(version) || \
is_supported_pg_version_14(version))

#define PG12 is_supported_pg_version_12(PG_VERSION_NUM)
#define PG13 is_supported_pg_version_13(PG_VERSION_NUM)
#define PG14 is_supported_pg_version_14(PG_VERSION_NUM)

#define PG13_LT (PG_VERSION_NUM < 130000)
#define PG13_GE (PG_VERSION_NUM >= 130000)
#define PG14_LT (PG_VERSION_NUM < 140000)
#define PG14_GE (PG_VERSION_NUM >= 140000)

#if !(is_supported_pg_version(PG_VERSION_NUM))
#error "Unsupported PostgreSQL version"
Expand Down Expand Up @@ -78,7 +83,7 @@
* https://github.com/postgres/postgres/commit/73fc2e5bab
*/

#if (PG12 && PG_VERSION_NUM < 120006) || (PG13 && PG_VERSION_NUM < 130002)
#if (PG12 && PG_VERSION_NUM < 120006) || (PG13 && PG_VERSION_NUM < 130002) || PG14
#define pull_varnos_compat(root, expr) pull_varnos(expr)
#define make_simple_restrictinfo_compat(root, expr) make_simple_restrictinfo(expr)
#define make_restrictinfo_compat(root, a, b, c, d, e, f, g, h) \
Expand Down
26 changes: 23 additions & 3 deletions src/process_utility.c
Expand Up @@ -107,6 +107,26 @@ prev_ProcessUtility(ProcessUtilityArgs *args)
}
}

static ObjectType
get_altertable_objecttype(AlterTableStmt *stmt)
{
#if PG14_GE
return stmt->objtype;
#else
return stmt->relkind;
#endif
}

static ObjectType
get_createtableas_objecttype(CreateTableAsStmt *stmt)
{
#if PG14_GE
return stmt->objtype;
#else
return stmt->relkind;
#endif
}

static void
check_chunk_alter_table_operation_allowed(Oid relid, AlterTableStmt *stmt)
{
Expand Down Expand Up @@ -3170,7 +3190,7 @@ static DDLResult
process_altertable_start(ProcessUtilityArgs *args)
{
AlterTableStmt *stmt = (AlterTableStmt *) args->parsetree;
switch (stmt->relkind)
switch (get_altertable_objecttype(stmt))
{
case OBJECT_TABLE:
return process_altertable_start_table(args);
Expand Down Expand Up @@ -3445,7 +3465,7 @@ process_altertable_end(Node *parsetree, CollectedCommand *cmd)
{
AlterTableStmt *stmt = (AlterTableStmt *) parsetree;

switch (stmt->relkind)
switch (get_altertable_objecttype(stmt))
{
case OBJECT_TABLE:
process_altertable_end_table(parsetree, cmd);
Expand Down Expand Up @@ -3586,7 +3606,7 @@ process_create_table_as(ProcessUtilityArgs *args)
bool is_cagg = false;
List *pg_options = NIL, *cagg_options = NIL;

if (stmt->relkind == OBJECT_MATVIEW)
if (get_createtableas_objecttype(stmt) == OBJECT_MATVIEW)
{
/* Check for creation of continuous aggregate */
ts_with_clause_filter(stmt->into->options, &cagg_options, &pg_options);
Expand Down
1 change: 1 addition & 0 deletions test/src/test_utils.h
Expand Up @@ -8,6 +8,7 @@

#include <postgres.h>
#include <access/xact.h>
#include <fmgr.h>

#include "export.h"

Expand Down