diff --git a/.github/workflows/psp-matrix.yml b/.github/workflows/psp-matrix.yml new file mode 100644 index 0000000000000..837677ca20c8f --- /dev/null +++ b/.github/workflows/psp-matrix.yml @@ -0,0 +1,19 @@ +name: PSP +on: + pull_request: + workflow_dispatch: + +jobs: + build: + name: PSP + strategy: + matrix: + os: ['ubuntu-22.04'] + build_type: [debug,debugoptimized] + build_script: [make, meson] + uses: ./.github/workflows/psp-reusable.yml + with: + os: ${{ matrix.os }} + build_type: ${{ matrix.build_type }} + build_script: ${{ matrix.build_script }} + secrets: inherit \ No newline at end of file diff --git a/.github/workflows/psp-reusable.yml b/.github/workflows/psp-reusable.yml new file mode 100644 index 0000000000000..f23c3790cea32 --- /dev/null +++ b/.github/workflows/psp-reusable.yml @@ -0,0 +1,123 @@ +name: PSP-Reusable +on: + workflow_call: + inputs: + os: + type: string + required: true + build_type: + type: string + required: true + build_script: + type: string + required: true + +env: + artifact_name: build-${{ inputs.os }}-${{ inputs.build_script }}-${{ inputs.build_type }} + +jobs: + build: + name: Build PSP + runs-on: ${{ inputs.os }} + steps: + + - name: Clone repository + uses: actions/checkout@v4 + with: + path: 'src' + submodules: recursive + ref: ${{ github.ref }} + + - name: Install dependencies + run: src/ci_scripts/ubuntu-deps.sh + + - name: Build postgres + run: src/ci_scripts/${{ inputs.build_script }}-build.sh ${{ inputs.build_type }} + + - name: 'Tar files' + run: tar -czf artifacts.tar src pginst + + - name: Upload build artifacts + uses: actions/upload-artifact@v4 + with: + name: ${{ env.artifact_name }} + overwrite: true + path: | + artifacts.tar + retention-days: 1 + + test: + name: Test PSP + runs-on: ${{ inputs.os }} + needs: build + + steps: + - name: Download build artifacts + uses: actions/download-artifact@v4 + with: + name: ${{ env.artifact_name }} + path: . + + - name: 'Untar files' + run: tar -xzf artifacts.tar + + - name: Install dependencies + run: src/ci_scripts/ubuntu-deps.sh + + - name: Setup kmip and vault + run: src/ci_scripts/setup-keyring-servers.sh + + - name: Test postgres + run: src/ci_scripts/${{ inputs.build_script }}-test.sh + + - name: Report on test fail + uses: actions/upload-artifact@v4 + if: ${{ failure() }} + with: + name: testlog-ubuntu-${{ inputs.ubuntu_version }}.04-meson-${{ inputs.build_type }} + path: | + src/build/testrun/ + src/contrib/*/t/ + src/contrib/*/results + src/contrib/*/regression.diffs + src/contrib/*/regression.out + retention-days: 3 + + test_tde: + name: Test PSP with TDE + runs-on: ${{ inputs.os }} + if: inputs.build_script == 'make' + needs: build + + steps: + + - name: Download build artifacts + uses: actions/download-artifact@v4 + with: + name: ${{ env.artifact_name }} + path: . + + - name: 'Untar files' + run: tar -xzf artifacts.tar + + - name: Install dependencies + run: src/ci_scripts/ubuntu-deps.sh + + - name: Setup kmip and vault + run: src/ci_scripts/setup-keyring-servers.sh + + - name: Test postgres with TDE + run: src/ci_scripts/${{ inputs.build_script }}-test-tde.sh + + - name: Report on test fail + uses: actions/upload-artifact@v4 + if: ${{ failure() }} + with: + name: testlog-tde-${{ inputs.os }}-${{ inputs.build_script }}-${{ inputs.build_type }} + path: | + src/build/testrun/ + src/contrib/*/t/ + src/contrib/*/results + src/contrib/*/regression.diffs + src/contrib/*/regression.out + retention-days: 3 \ No newline at end of file diff --git a/.github/workflows/psp.yml b/.github/workflows/psp.yml deleted file mode 100644 index 2a1b48eb74675..0000000000000 --- a/.github/workflows/psp.yml +++ /dev/null @@ -1,44 +0,0 @@ -name: PSP -on: - pull_request: - workflow_dispatch: - -jobs: - build: - name: Percona Postgres - strategy: - matrix: - ubuntu_version: [22] - build_type: [debug,debugoptimized] - build_script: [make, meson] - runs-on: ubuntu-${{ matrix.ubuntu_version }}.04 - steps: - - - name: Clone repository - uses: actions/checkout@v4 - with: - path: 'src' - submodules: recursive - ref: ${{ github.ref }} - - - name: Install dependencies - run: src/.scripts/ubuntu-deps.sh - - - name: Setup kmip and vault - run: src/.scripts/setup-keyring-servers.sh - - - name: Build and test postgres - run: src/.scripts/${{ matrix.build_script }}-build.sh ${{ matrix.build_type }} - - - name: Test postgres - run: src/.scripts/${{ matrix.build_script }}-test.sh - - - name: Report on test fail - uses: actions/upload-artifact@v4 - if: ${{ failure() }} - with: - name: testlog-ubuntu-${{ matrix.ubuntu_version }}.04-meson-${{ matrix.build_type }} - path: | - src/build/testrun/ - src/contrib/pg_tde/t/ - retention-days: 3 diff --git a/.gitignore b/.gitignore index 4e911395fe3ba..a880c1e3838db 100644 --- a/.gitignore +++ b/.gitignore @@ -31,6 +31,7 @@ win32ver.rc *.exe lib*dll.def lib*.pc +.vscode # Local excludes in root directory /GNUmakefile diff --git a/.scripts/make-build.sh b/ci_scripts/make-build.sh similarity index 54% rename from .scripts/make-build.sh rename to ci_scripts/make-build.sh index ebf3d38c73061..9450e115c52b8 100755 --- a/.scripts/make-build.sh +++ b/ci_scripts/make-build.sh @@ -1,6 +1,10 @@ #!/bin/bash +export TDE_MODE=1 + SCRIPT_DIR="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" +INSTALL_DIR="$SCRIPT_DIR/../../pginst" + cd "$SCRIPT_DIR/../" @@ -9,5 +13,5 @@ if [ "$1" = "debugoptimized" ]; then export CXXFLAGS="-O2" fi -./configure --enable-debug --enable-cassert --enable-tap-tests -make \ No newline at end of file +./configure --enable-debug --enable-cassert --enable-tap-tests --prefix=$INSTALL_DIR +make install-world -j \ No newline at end of file diff --git a/ci_scripts/make-test-tde.sh b/ci_scripts/make-test-tde.sh new file mode 100755 index 0000000000000..00e3c48c34880 --- /dev/null +++ b/ci_scripts/make-test-tde.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +export TDE_MODE=1 + +SCRIPT_DIR="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" +INSTALL_DIR="$SCRIPT_DIR/../../pginst" + +cd "$SCRIPT_DIR/../" + +export PATH=$INSTALL_DIR/bin:$PATH +export PGDATA=$INSTALL_DIR/data + +initdb -D $PGDATA + +echo "shared_preload_libraries ='pg_tde'" >> $PGDATA/postgresql.conf +echo "pg_tde.wal_encrypt = on" >> $PGDATA/postgresql.conf + +pg_ctl -D $PGDATA start + +EXTRA_REGRESS_OPTS="--extra-setup=$SCRIPT_DIR/tde_setup.sql --load-extension=pg_tde" make installcheck-world -k \ No newline at end of file diff --git a/.scripts/make-test.sh b/ci_scripts/make-test.sh similarity index 67% rename from .scripts/make-test.sh rename to ci_scripts/make-test.sh index d7541a58b0ed1..4477175139dc2 100755 --- a/.scripts/make-test.sh +++ b/ci_scripts/make-test.sh @@ -1,6 +1,9 @@ #!/bin/bash +export TDE_MODE=1 + SCRIPT_DIR="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" +INSTALL_DIR="$SCRIPT_DIR/../../pginst" cd "$SCRIPT_DIR/../" diff --git a/.scripts/meson-build.sh b/ci_scripts/meson-build.sh similarity index 59% rename from .scripts/meson-build.sh rename to ci_scripts/meson-build.sh index 19885014ed61b..ed00033453138 100755 --- a/.scripts/meson-build.sh +++ b/ci_scripts/meson-build.sh @@ -4,5 +4,5 @@ SCRIPT_DIR="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" cd "$SCRIPT_DIR/../" -meson setup build --prefix `pwd`/../inst --buildtype=$1 -Dcassert=true -Dtap_tests=enabled +meson setup build --prefix `pwd`/../pginst --buildtype=$1 -Dcassert=true -Dtap_tests=enabled cd build && ninja && ninja install \ No newline at end of file diff --git a/ci_scripts/meson-test-tde.sh b/ci_scripts/meson-test-tde.sh new file mode 100755 index 0000000000000..d8f66e5788d9f --- /dev/null +++ b/ci_scripts/meson-test-tde.sh @@ -0,0 +1 @@ +# Nop for now: meson doesn't have EXTRA_REGRESS_OPTS \ No newline at end of file diff --git a/.scripts/meson-test.sh b/ci_scripts/meson-test.sh similarity index 100% rename from .scripts/meson-test.sh rename to ci_scripts/meson-test.sh diff --git a/.scripts/setup-keyring-servers.sh b/ci_scripts/setup-keyring-servers.sh similarity index 100% rename from .scripts/setup-keyring-servers.sh rename to ci_scripts/setup-keyring-servers.sh diff --git a/ci_scripts/tde_setup.sql b/ci_scripts/tde_setup.sql new file mode 100644 index 0000000000000..0b00e6fe56f22 --- /dev/null +++ b/ci_scripts/tde_setup.sql @@ -0,0 +1,6 @@ +CREATE EXTENSION IF NOT EXISTS pg_tde; +SELECT pg_tde_add_key_provider_file('reg_file-vault', '/tmp/pg_tde_test_keyring.per'); +SELECT pg_tde_set_principal_key('test-db-principal-key', 'reg_file-vault'); +ALTER SYSTEM SET default_table_access_method='tde_heap'; +SET default_table_access_method='tde_heap'; +SELECT pg_reload_conf(); \ No newline at end of file diff --git a/.scripts/ubuntu-deps.sh b/ci_scripts/ubuntu-deps.sh similarity index 95% rename from .scripts/ubuntu-deps.sh rename to ci_scripts/ubuntu-deps.sh index 7d9b0f34d5090..f2d1aa5e78237 100755 --- a/.scripts/ubuntu-deps.sh +++ b/ci_scripts/ubuntu-deps.sh @@ -2,7 +2,7 @@ sudo apt update -sudo apt install -y libreadline6-dev systemtap-sdt-dev zlib1g-dev libssl-dev libpam0g-dev bison flex libxml2 libxml2-utils libxml2-dev libxslt-dev xsltproc libkrb5-dev libldap2-dev libsystemd-dev gettext tcl-dev libperl-dev pkg-config libselinux1-dev python3-dev uuid-dev liblz4-dev meson ninja-build gpg wget libcurl4-openssl-dev +sudo apt install -y libreadline6-dev systemtap-sdt-dev zlib1g-dev libssl-dev libpam0g-dev bison flex libxml2 libxml2-utils libxml2-dev libxslt-dev xsltproc libkrb5-dev libldap2-dev libsystemd-dev gettext tcl-dev libperl-dev pkg-config libselinux1-dev python3-dev uuid-dev liblz4-dev meson ninja-build gpg wget libcurl4-openssl-dev libxml2-utils docbook-xsl xsltproc bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)" diff --git a/contrib/amcheck/verify_heapam.c b/contrib/amcheck/verify_heapam.c index f2526ed63a284..dd91492a0ee85 100644 --- a/contrib/amcheck/verify_heapam.c +++ b/contrib/amcheck/verify_heapam.c @@ -305,7 +305,7 @@ verify_heapam(PG_FUNCTION_ARGS) * Other relkinds might be using a different AM, so check. */ if (ctx.rel->rd_rel->relkind != RELKIND_SEQUENCE && - ctx.rel->rd_rel->relam != HEAP_TABLE_AM_OID) + ctx.rel->rd_rel->relam != HEAP_TABLE_AM_OID && ctx.rel->rd_rel->relam != get_tde_table_am_oid()) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("only heap AM is supported"))); diff --git a/contrib/earthdistance/expected/earthdistance_1.out b/contrib/earthdistance/expected/earthdistance_1.out new file mode 100644 index 0000000000000..687971531f508 --- /dev/null +++ b/contrib/earthdistance/expected/earthdistance_1.out @@ -0,0 +1,1220 @@ +-- +-- Test earthdistance extension +-- +-- In this file we also do some testing of extension create/drop scenarios. +-- That's really exercising the core database's dependency logic, so ideally +-- we'd do it in the core regression tests, but we can't for lack of suitable +-- guaranteed-available extensions. earthdistance is a good test case because +-- it has a dependency on the cube extension. +-- +CREATE EXTENSION earthdistance; -- fail, must install cube first +ERROR: required extension "cube" is not installed +HINT: Use CREATE EXTENSION ... CASCADE to install required extensions too. +CREATE EXTENSION cube; +CREATE EXTENSION earthdistance; +-- +-- The radius of the Earth we are using. +-- +SELECT earth()::numeric(20,5); + earth +--------------- + 6378168.00000 +(1 row) + +-- +-- Convert straight line distances to great circle distances. +-- +SELECT (pi()*earth())::numeric(20,5); + numeric +---------------- + 20037605.73216 +(1 row) + +SELECT sec_to_gc(0)::numeric(20,5); + sec_to_gc +----------- + 0.00000 +(1 row) + +SELECT sec_to_gc(2*earth())::numeric(20,5); + sec_to_gc +---------------- + 20037605.73216 +(1 row) + +SELECT sec_to_gc(10*earth())::numeric(20,5); + sec_to_gc +---------------- + 20037605.73216 +(1 row) + +SELECT sec_to_gc(-earth())::numeric(20,5); + sec_to_gc +----------- + 0.00000 +(1 row) + +SELECT sec_to_gc(1000)::numeric(20,5); + sec_to_gc +------------ + 1000.00000 +(1 row) + +SELECT sec_to_gc(10000)::numeric(20,5); + sec_to_gc +------------- + 10000.00102 +(1 row) + +SELECT sec_to_gc(100000)::numeric(20,5); + sec_to_gc +-------------- + 100001.02426 +(1 row) + +SELECT sec_to_gc(1000000)::numeric(20,5); + sec_to_gc +--------------- + 1001027.07131 +(1 row) + +-- +-- Convert great circle distances to straight line distances. +-- +SELECT gc_to_sec(0)::numeric(20,5); + gc_to_sec +----------- + 0.00000 +(1 row) + +SELECT gc_to_sec(sec_to_gc(2*earth()))::numeric(20,5); + gc_to_sec +---------------- + 12756336.00000 +(1 row) + +SELECT gc_to_sec(10*earth())::numeric(20,5); + gc_to_sec +---------------- + 12756336.00000 +(1 row) + +SELECT gc_to_sec(pi()*earth())::numeric(20,5); + gc_to_sec +---------------- + 12756336.00000 +(1 row) + +SELECT gc_to_sec(-1000)::numeric(20,5); + gc_to_sec +----------- + 0.00000 +(1 row) + +SELECT gc_to_sec(1000)::numeric(20,5); + gc_to_sec +------------ + 1000.00000 +(1 row) + +SELECT gc_to_sec(10000)::numeric(20,5); + gc_to_sec +------------ + 9999.99898 +(1 row) + +SELECT gc_to_sec(100000)::numeric(20,5); + gc_to_sec +------------- + 99998.97577 +(1 row) + +SELECT gc_to_sec(1000000)::numeric(20,5); + gc_to_sec +-------------- + 998976.08618 +(1 row) + +-- +-- Set coordinates using latitude and longitude. +-- Extract each coordinate separately so we can round them. +-- +SELECT cube_ll_coord(ll_to_earth(0,0),1)::numeric(20,5), + cube_ll_coord(ll_to_earth(0,0),2)::numeric(20,5), + cube_ll_coord(ll_to_earth(0,0),3)::numeric(20,5); + cube_ll_coord | cube_ll_coord | cube_ll_coord +---------------+---------------+--------------- + 6378168.00000 | 0.00000 | 0.00000 +(1 row) + +SELECT cube_ll_coord(ll_to_earth(360,360),1)::numeric(20,5), + cube_ll_coord(ll_to_earth(360,360),2)::numeric(20,5), + cube_ll_coord(ll_to_earth(360,360),3)::numeric(20,5); + cube_ll_coord | cube_ll_coord | cube_ll_coord +---------------+---------------+--------------- + 6378168.00000 | 0.00000 | 0.00000 +(1 row) + +SELECT cube_ll_coord(ll_to_earth(180,180),1)::numeric(20,5), + cube_ll_coord(ll_to_earth(180,180),2)::numeric(20,5), + cube_ll_coord(ll_to_earth(180,180),3)::numeric(20,5); + cube_ll_coord | cube_ll_coord | cube_ll_coord +---------------+---------------+--------------- + 6378168.00000 | 0.00000 | 0.00000 +(1 row) + +SELECT cube_ll_coord(ll_to_earth(180,360),1)::numeric(20,5), + cube_ll_coord(ll_to_earth(180,360),2)::numeric(20,5), + cube_ll_coord(ll_to_earth(180,360),3)::numeric(20,5); + cube_ll_coord | cube_ll_coord | cube_ll_coord +----------------+---------------+--------------- + -6378168.00000 | 0.00000 | 0.00000 +(1 row) + +SELECT cube_ll_coord(ll_to_earth(-180,-360),1)::numeric(20,5), + cube_ll_coord(ll_to_earth(-180,-360),2)::numeric(20,5), + cube_ll_coord(ll_to_earth(-180,-360),3)::numeric(20,5); + cube_ll_coord | cube_ll_coord | cube_ll_coord +----------------+---------------+--------------- + -6378168.00000 | 0.00000 | 0.00000 +(1 row) + +SELECT cube_ll_coord(ll_to_earth(0,180),1)::numeric(20,5), + cube_ll_coord(ll_to_earth(0,180),2)::numeric(20,5), + cube_ll_coord(ll_to_earth(0,180),3)::numeric(20,5); + cube_ll_coord | cube_ll_coord | cube_ll_coord +----------------+---------------+--------------- + -6378168.00000 | 0.00000 | 0.00000 +(1 row) + +SELECT cube_ll_coord(ll_to_earth(0,-180),1)::numeric(20,5), + cube_ll_coord(ll_to_earth(0,-180),2)::numeric(20,5), + cube_ll_coord(ll_to_earth(0,-180),3)::numeric(20,5); + cube_ll_coord | cube_ll_coord | cube_ll_coord +----------------+---------------+--------------- + -6378168.00000 | 0.00000 | 0.00000 +(1 row) + +SELECT cube_ll_coord(ll_to_earth(90,0),1)::numeric(20,5), + cube_ll_coord(ll_to_earth(90,0),2)::numeric(20,5), + cube_ll_coord(ll_to_earth(90,0),3)::numeric(20,5); + cube_ll_coord | cube_ll_coord | cube_ll_coord +---------------+---------------+--------------- + 0.00000 | 0.00000 | 6378168.00000 +(1 row) + +SELECT cube_ll_coord(ll_to_earth(90,180),1)::numeric(20,5), + cube_ll_coord(ll_to_earth(90,180),2)::numeric(20,5), + cube_ll_coord(ll_to_earth(90,180),3)::numeric(20,5); + cube_ll_coord | cube_ll_coord | cube_ll_coord +---------------+---------------+--------------- + 0.00000 | 0.00000 | 6378168.00000 +(1 row) + +SELECT cube_ll_coord(ll_to_earth(-90,0),1)::numeric(20,5), + cube_ll_coord(ll_to_earth(-90,0),2)::numeric(20,5), + cube_ll_coord(ll_to_earth(-90,0),3)::numeric(20,5); + cube_ll_coord | cube_ll_coord | cube_ll_coord +---------------+---------------+---------------- + 0.00000 | 0.00000 | -6378168.00000 +(1 row) + +SELECT cube_ll_coord(ll_to_earth(-90,180),1)::numeric(20,5), + cube_ll_coord(ll_to_earth(-90,180),2)::numeric(20,5), + cube_ll_coord(ll_to_earth(-90,180),3)::numeric(20,5); + cube_ll_coord | cube_ll_coord | cube_ll_coord +---------------+---------------+---------------- + 0.00000 | 0.00000 | -6378168.00000 +(1 row) + +-- +-- Test getting the latitude of a location. +-- +SELECT latitude(ll_to_earth(0,0))::numeric(20,10); + latitude +-------------- + 0.0000000000 +(1 row) + +SELECT latitude(ll_to_earth(45,0))::numeric(20,10); + latitude +--------------- + 45.0000000000 +(1 row) + +SELECT latitude(ll_to_earth(90,0))::numeric(20,10); + latitude +--------------- + 90.0000000000 +(1 row) + +SELECT latitude(ll_to_earth(-45,0))::numeric(20,10); + latitude +---------------- + -45.0000000000 +(1 row) + +SELECT latitude(ll_to_earth(-90,0))::numeric(20,10); + latitude +---------------- + -90.0000000000 +(1 row) + +SELECT latitude(ll_to_earth(0,90))::numeric(20,10); + latitude +-------------- + 0.0000000000 +(1 row) + +SELECT latitude(ll_to_earth(45,90))::numeric(20,10); + latitude +--------------- + 45.0000000000 +(1 row) + +SELECT latitude(ll_to_earth(90,90))::numeric(20,10); + latitude +--------------- + 90.0000000000 +(1 row) + +SELECT latitude(ll_to_earth(-45,90))::numeric(20,10); + latitude +---------------- + -45.0000000000 +(1 row) + +SELECT latitude(ll_to_earth(-90,90))::numeric(20,10); + latitude +---------------- + -90.0000000000 +(1 row) + +SELECT latitude(ll_to_earth(0,180))::numeric(20,10); + latitude +-------------- + 0.0000000000 +(1 row) + +SELECT latitude(ll_to_earth(45,180))::numeric(20,10); + latitude +--------------- + 45.0000000000 +(1 row) + +SELECT latitude(ll_to_earth(90,180))::numeric(20,10); + latitude +--------------- + 90.0000000000 +(1 row) + +SELECT latitude(ll_to_earth(-45,180))::numeric(20,10); + latitude +---------------- + -45.0000000000 +(1 row) + +SELECT latitude(ll_to_earth(-90,180))::numeric(20,10); + latitude +---------------- + -90.0000000000 +(1 row) + +SELECT latitude(ll_to_earth(0,-90))::numeric(20,10); + latitude +-------------- + 0.0000000000 +(1 row) + +SELECT latitude(ll_to_earth(45,-90))::numeric(20,10); + latitude +--------------- + 45.0000000000 +(1 row) + +SELECT latitude(ll_to_earth(90,-90))::numeric(20,10); + latitude +--------------- + 90.0000000000 +(1 row) + +SELECT latitude(ll_to_earth(-45,-90))::numeric(20,10); + latitude +---------------- + -45.0000000000 +(1 row) + +SELECT latitude(ll_to_earth(-90,-90))::numeric(20,10); + latitude +---------------- + -90.0000000000 +(1 row) + +-- +-- Test getting the longitude of a location. +-- +SELECT longitude(ll_to_earth(0,0))::numeric(20,10); + longitude +-------------- + 0.0000000000 +(1 row) + +SELECT longitude(ll_to_earth(45,0))::numeric(20,10); + longitude +-------------- + 0.0000000000 +(1 row) + +SELECT longitude(ll_to_earth(90,0))::numeric(20,10); + longitude +-------------- + 0.0000000000 +(1 row) + +SELECT longitude(ll_to_earth(-45,0))::numeric(20,10); + longitude +-------------- + 0.0000000000 +(1 row) + +SELECT longitude(ll_to_earth(-90,0))::numeric(20,10); + longitude +-------------- + 0.0000000000 +(1 row) + +SELECT longitude(ll_to_earth(0,90))::numeric(20,10); + longitude +--------------- + 90.0000000000 +(1 row) + +SELECT longitude(ll_to_earth(45,90))::numeric(20,10); + longitude +--------------- + 90.0000000000 +(1 row) + +SELECT longitude(ll_to_earth(90,90))::numeric(20,10); + longitude +--------------- + 90.0000000000 +(1 row) + +SELECT longitude(ll_to_earth(-45,90))::numeric(20,10); + longitude +--------------- + 90.0000000000 +(1 row) + +SELECT longitude(ll_to_earth(-90,90))::numeric(20,10); + longitude +--------------- + 90.0000000000 +(1 row) + +SELECT longitude(ll_to_earth(0,180))::numeric(20,10); + longitude +---------------- + 180.0000000000 +(1 row) + +SELECT longitude(ll_to_earth(45,180))::numeric(20,10); + longitude +---------------- + 180.0000000000 +(1 row) + +SELECT longitude(ll_to_earth(90,180))::numeric(20,10); + longitude +---------------- + 180.0000000000 +(1 row) + +SELECT longitude(ll_to_earth(-45,180))::numeric(20,10); + longitude +---------------- + 180.0000000000 +(1 row) + +SELECT longitude(ll_to_earth(-90,180))::numeric(20,10); + longitude +---------------- + 180.0000000000 +(1 row) + +SELECT longitude(ll_to_earth(0,-90))::numeric(20,10); + longitude +---------------- + -90.0000000000 +(1 row) + +SELECT longitude(ll_to_earth(45,-90))::numeric(20,10); + longitude +---------------- + -90.0000000000 +(1 row) + +SELECT longitude(ll_to_earth(90,-90))::numeric(20,10); + longitude +---------------- + -90.0000000000 +(1 row) + +SELECT longitude(ll_to_earth(-45,-90))::numeric(20,10); + longitude +---------------- + -90.0000000000 +(1 row) + +SELECT longitude(ll_to_earth(-90,-90))::numeric(20,10); + longitude +---------------- + -90.0000000000 +(1 row) + +-- +-- For the distance tests the following is some real life data. +-- +-- Chicago has a latitude of 41.8 and a longitude of 87.6. +-- Albuquerque has a latitude of 35.1 and a longitude of 106.7. +-- (Note that latitude and longitude are specified differently +-- in the cube based functions than for the point based functions.) +-- +-- +-- Test getting the distance between two points using earth_distance. +-- +SELECT earth_distance(ll_to_earth(0,0),ll_to_earth(0,0))::numeric(20,5); + earth_distance +---------------- + 0.00000 +(1 row) + +SELECT earth_distance(ll_to_earth(0,0),ll_to_earth(0,180))::numeric(20,5); + earth_distance +---------------- + 20037605.73216 +(1 row) + +SELECT earth_distance(ll_to_earth(0,0),ll_to_earth(90,0))::numeric(20,5); + earth_distance +---------------- + 10018802.86608 +(1 row) + +SELECT earth_distance(ll_to_earth(0,0),ll_to_earth(0,90))::numeric(20,5); + earth_distance +---------------- + 10018802.86608 +(1 row) + +SELECT earth_distance(ll_to_earth(0,0),ll_to_earth(0,1))::numeric(20,5); + earth_distance +---------------- + 111320.03185 +(1 row) + +SELECT earth_distance(ll_to_earth(0,0),ll_to_earth(1,0))::numeric(20,5); + earth_distance +---------------- + 111320.03185 +(1 row) + +SELECT earth_distance(ll_to_earth(30,0),ll_to_earth(30,1))::numeric(20,5); + earth_distance +---------------- + 96405.66962 +(1 row) + +SELECT earth_distance(ll_to_earth(30,0),ll_to_earth(31,0))::numeric(20,5); + earth_distance +---------------- + 111320.03185 +(1 row) + +SELECT earth_distance(ll_to_earth(60,0),ll_to_earth(60,1))::numeric(20,5); + earth_distance +---------------- + 55659.48608 +(1 row) + +SELECT earth_distance(ll_to_earth(60,0),ll_to_earth(61,0))::numeric(20,5); + earth_distance +---------------- + 111320.03185 +(1 row) + +SELECT earth_distance(ll_to_earth(41.8,87.6),ll_to_earth(35.1,106.7))::numeric(20,5); + earth_distance +---------------- + 1819303.21265 +(1 row) + +SELECT (earth_distance(ll_to_earth(41.8,87.6),ll_to_earth(35.1,106.7))* + 100./2.54/12./5280.)::numeric(20,5); + numeric +------------ + 1130.46261 +(1 row) + +-- +-- Test getting the distance between two points using geo_distance. +-- +SELECT geo_distance('(0,0)'::point,'(0,0)'::point)::numeric(20,5); + geo_distance +-------------- + 0.00000 +(1 row) + +SELECT geo_distance('(0,0)'::point,'(180,0)'::point)::numeric(20,5); + geo_distance +-------------- + 12436.77274 +(1 row) + +SELECT geo_distance('(0,0)'::point,'(0,90)'::point)::numeric(20,5); + geo_distance +-------------- + 6218.38637 +(1 row) + +SELECT geo_distance('(0,0)'::point,'(90,0)'::point)::numeric(20,5); + geo_distance +-------------- + 6218.38637 +(1 row) + +SELECT geo_distance('(0,0)'::point,'(1,0)'::point)::numeric(20,5); + geo_distance +-------------- + 69.09318 +(1 row) + +SELECT geo_distance('(0,0)'::point,'(0,1)'::point)::numeric(20,5); + geo_distance +-------------- + 69.09318 +(1 row) + +SELECT geo_distance('(0,30)'::point,'(1,30)'::point)::numeric(20,5); + geo_distance +-------------- + 59.83626 +(1 row) + +SELECT geo_distance('(0,30)'::point,'(0,31)'::point)::numeric(20,5); + geo_distance +-------------- + 69.09318 +(1 row) + +SELECT geo_distance('(0,60)'::point,'(1,60)'::point)::numeric(20,5); + geo_distance +-------------- + 34.54626 +(1 row) + +SELECT geo_distance('(0,60)'::point,'(0,61)'::point)::numeric(20,5); + geo_distance +-------------- + 69.09318 +(1 row) + +SELECT geo_distance('(87.6,41.8)'::point,'(106.7,35.1)'::point)::numeric(20,5); + geo_distance +-------------- + 1129.18983 +(1 row) + +SELECT (geo_distance('(87.6,41.8)'::point,'(106.7,35.1)'::point)*5280.*12.*2.54/100.)::numeric(20,5); + numeric +--------------- + 1817254.87730 +(1 row) + +-- +-- Test getting the distance between two points using the <@> operator. +-- +SELECT ('(0,0)'::point <@> '(0,0)'::point)::numeric(20,5); + numeric +--------- + 0.00000 +(1 row) + +SELECT ('(0,0)'::point <@> '(180,0)'::point)::numeric(20,5); + numeric +------------- + 12436.77274 +(1 row) + +SELECT ('(0,0)'::point <@> '(0,90)'::point)::numeric(20,5); + numeric +------------ + 6218.38637 +(1 row) + +SELECT ('(0,0)'::point <@> '(90,0)'::point)::numeric(20,5); + numeric +------------ + 6218.38637 +(1 row) + +SELECT ('(0,0)'::point <@> '(1,0)'::point)::numeric(20,5); + numeric +---------- + 69.09318 +(1 row) + +SELECT ('(0,0)'::point <@> '(0,1)'::point)::numeric(20,5); + numeric +---------- + 69.09318 +(1 row) + +SELECT ('(0,30)'::point <@> '(1,30)'::point)::numeric(20,5); + numeric +---------- + 59.83626 +(1 row) + +SELECT ('(0,30)'::point <@> '(0,31)'::point)::numeric(20,5); + numeric +---------- + 69.09318 +(1 row) + +SELECT ('(0,60)'::point <@> '(1,60)'::point)::numeric(20,5); + numeric +---------- + 34.54626 +(1 row) + +SELECT ('(0,60)'::point <@> '(0,61)'::point)::numeric(20,5); + numeric +---------- + 69.09318 +(1 row) + +SELECT ('(87.6,41.8)'::point <@> '(106.7,35.1)'::point)::numeric(20,5); + numeric +------------ + 1129.18983 +(1 row) + +SELECT (('(87.6,41.8)'::point <@> '(106.7,35.1)'::point)*5280.*12.*2.54/100.)::numeric(20,5); + numeric +--------------- + 1817254.87730 +(1 row) + +-- +-- Test getting a bounding box around points. +-- +SELECT cube_ll_coord(earth_box(ll_to_earth(0,0),112000),1)::numeric(20,5), + cube_ll_coord(earth_box(ll_to_earth(0,0),112000),2)::numeric(20,5), + cube_ll_coord(earth_box(ll_to_earth(0,0),112000),3)::numeric(20,5), + cube_ur_coord(earth_box(ll_to_earth(0,0),112000),1)::numeric(20,5), + cube_ur_coord(earth_box(ll_to_earth(0,0),112000),2)::numeric(20,5), + cube_ur_coord(earth_box(ll_to_earth(0,0),112000),3)::numeric(20,5); + cube_ll_coord | cube_ll_coord | cube_ll_coord | cube_ur_coord | cube_ur_coord | cube_ur_coord +---------------+---------------+---------------+---------------+---------------+--------------- + 6266169.43896 | -111998.56104 | -111998.56104 | 6490166.56104 | 111998.56104 | 111998.56104 +(1 row) + +SELECT cube_ll_coord(earth_box(ll_to_earth(0,0),pi()*earth()),1)::numeric(20,5), + cube_ll_coord(earth_box(ll_to_earth(0,0),pi()*earth()),2)::numeric(20,5), + cube_ll_coord(earth_box(ll_to_earth(0,0),pi()*earth()),3)::numeric(20,5), + cube_ur_coord(earth_box(ll_to_earth(0,0),pi()*earth()),1)::numeric(20,5), + cube_ur_coord(earth_box(ll_to_earth(0,0),pi()*earth()),2)::numeric(20,5), + cube_ur_coord(earth_box(ll_to_earth(0,0),pi()*earth()),3)::numeric(20,5); + cube_ll_coord | cube_ll_coord | cube_ll_coord | cube_ur_coord | cube_ur_coord | cube_ur_coord +----------------+-----------------+-----------------+----------------+----------------+---------------- + -6378168.00000 | -12756336.00000 | -12756336.00000 | 19134504.00000 | 12756336.00000 | 12756336.00000 +(1 row) + +SELECT cube_ll_coord(earth_box(ll_to_earth(0,0),10*earth()),1)::numeric(20,5), + cube_ll_coord(earth_box(ll_to_earth(0,0),10*earth()),2)::numeric(20,5), + cube_ll_coord(earth_box(ll_to_earth(0,0),10*earth()),3)::numeric(20,5), + cube_ur_coord(earth_box(ll_to_earth(0,0),10*earth()),1)::numeric(20,5), + cube_ur_coord(earth_box(ll_to_earth(0,0),10*earth()),2)::numeric(20,5), + cube_ur_coord(earth_box(ll_to_earth(0,0),10*earth()),3)::numeric(20,5); + cube_ll_coord | cube_ll_coord | cube_ll_coord | cube_ur_coord | cube_ur_coord | cube_ur_coord +----------------+-----------------+-----------------+----------------+----------------+---------------- + -6378168.00000 | -12756336.00000 | -12756336.00000 | 19134504.00000 | 12756336.00000 | 12756336.00000 +(1 row) + +-- +-- Test for points that should be in bounding boxes. +-- +SELECT earth_box(ll_to_earth(0,0), + earth_distance(ll_to_earth(0,0),ll_to_earth(0,1))*1.00001) @> + ll_to_earth(0,1); + ?column? +---------- + t +(1 row) + +SELECT earth_box(ll_to_earth(0,0), + earth_distance(ll_to_earth(0,0),ll_to_earth(0,0.1))*1.00001) @> + ll_to_earth(0,0.1); + ?column? +---------- + t +(1 row) + +SELECT earth_box(ll_to_earth(0,0), + earth_distance(ll_to_earth(0,0),ll_to_earth(0,0.01))*1.00001) @> + ll_to_earth(0,0.01); + ?column? +---------- + t +(1 row) + +SELECT earth_box(ll_to_earth(0,0), + earth_distance(ll_to_earth(0,0),ll_to_earth(0,0.001))*1.00001) @> + ll_to_earth(0,0.001); + ?column? +---------- + t +(1 row) + +SELECT earth_box(ll_to_earth(0,0), + earth_distance(ll_to_earth(0,0),ll_to_earth(0,0.0001))*1.00001) @> + ll_to_earth(0,0.0001); + ?column? +---------- + t +(1 row) + +SELECT earth_box(ll_to_earth(0,0), + earth_distance(ll_to_earth(0,0),ll_to_earth(0.0001,0.0001))*1.00001) @> + ll_to_earth(0.0001,0.0001); + ?column? +---------- + t +(1 row) + +SELECT earth_box(ll_to_earth(45,45), + earth_distance(ll_to_earth(45,45),ll_to_earth(45.0001,45.0001))*1.00001) @> + ll_to_earth(45.0001,45.0001); + ?column? +---------- + t +(1 row) + +SELECT earth_box(ll_to_earth(90,180), + earth_distance(ll_to_earth(90,180),ll_to_earth(90.0001,180.0001))*1.00001) @> + ll_to_earth(90.0001,180.0001); + ?column? +---------- + t +(1 row) + +-- +-- Test for points that shouldn't be in bounding boxes. Note that we need +-- to make points way outside, since some points close may be in the box +-- but further away than the distance we are testing. +-- +SELECT earth_box(ll_to_earth(0,0), + earth_distance(ll_to_earth(0,0),ll_to_earth(0,1))*.57735) @> + ll_to_earth(0,1); + ?column? +---------- + f +(1 row) + +SELECT earth_box(ll_to_earth(0,0), + earth_distance(ll_to_earth(0,0),ll_to_earth(0,0.1))*.57735) @> + ll_to_earth(0,0.1); + ?column? +---------- + f +(1 row) + +SELECT earth_box(ll_to_earth(0,0), + earth_distance(ll_to_earth(0,0),ll_to_earth(0,0.01))*.57735) @> + ll_to_earth(0,0.01); + ?column? +---------- + f +(1 row) + +SELECT earth_box(ll_to_earth(0,0), + earth_distance(ll_to_earth(0,0),ll_to_earth(0,0.001))*.57735) @> + ll_to_earth(0,0.001); + ?column? +---------- + f +(1 row) + +SELECT earth_box(ll_to_earth(0,0), + earth_distance(ll_to_earth(0,0),ll_to_earth(0,0.0001))*.57735) @> + ll_to_earth(0,0.0001); + ?column? +---------- + f +(1 row) + +SELECT earth_box(ll_to_earth(0,0), + earth_distance(ll_to_earth(0,0),ll_to_earth(0.0001,0.0001))*.57735) @> + ll_to_earth(0.0001,0.0001); + ?column? +---------- + f +(1 row) + +SELECT earth_box(ll_to_earth(45,45), + earth_distance(ll_to_earth(45,45),ll_to_earth(45.0001,45.0001))*.57735) @> + ll_to_earth(45.0001,45.0001); + ?column? +---------- + f +(1 row) + +SELECT earth_box(ll_to_earth(90,180), + earth_distance(ll_to_earth(90,180),ll_to_earth(90.0001,180.0001))*.57735) @> + ll_to_earth(90.0001,180.0001); + ?column? +---------- + f +(1 row) + +-- +-- Test the recommended constraints. +-- +SELECT cube_is_point(ll_to_earth(0,0)); + cube_is_point +--------------- + t +(1 row) + +SELECT cube_dim(ll_to_earth(0,0)) <= 3; + ?column? +---------- + t +(1 row) + +SELECT abs(cube_distance(ll_to_earth(0,0), '(0)'::cube) / earth() - 1) < + '10e-12'::float8; + ?column? +---------- + t +(1 row) + +SELECT cube_is_point(ll_to_earth(30,60)); + cube_is_point +--------------- + t +(1 row) + +SELECT cube_dim(ll_to_earth(30,60)) <= 3; + ?column? +---------- + t +(1 row) + +SELECT abs(cube_distance(ll_to_earth(30,60), '(0)'::cube) / earth() - 1) < + '10e-12'::float8; + ?column? +---------- + t +(1 row) + +SELECT cube_is_point(ll_to_earth(60,90)); + cube_is_point +--------------- + t +(1 row) + +SELECT cube_dim(ll_to_earth(60,90)) <= 3; + ?column? +---------- + t +(1 row) + +SELECT abs(cube_distance(ll_to_earth(60,90), '(0)'::cube) / earth() - 1) < + '10e-12'::float8; + ?column? +---------- + t +(1 row) + +SELECT cube_is_point(ll_to_earth(-30,-90)); + cube_is_point +--------------- + t +(1 row) + +SELECT cube_dim(ll_to_earth(-30,-90)) <= 3; + ?column? +---------- + t +(1 row) + +SELECT abs(cube_distance(ll_to_earth(-30,-90), '(0)'::cube) / earth() - 1) < + '10e-12'::float8; + ?column? +---------- + t +(1 row) + +-- +-- Now we are going to test extension create/drop scenarios. +-- +-- list what's installed +\dT + List of data types + Schema | Name | Description +--------+---------------+--------------------------------------------------------------------------------------------- + public | cube | multi-dimensional cube '(FLOAT-1, FLOAT-2, ..., FLOAT-N), (FLOAT-1, FLOAT-2, ..., FLOAT-N)' + public | earth | + public | pg_tde_global | +(3 rows) + +drop extension cube; -- fail, earthdistance requires it +ERROR: cannot drop extension cube because other objects depend on it +DETAIL: extension earthdistance depends on extension cube +HINT: Use DROP ... CASCADE to drop the dependent objects too. +drop extension earthdistance; +drop type cube; -- fail, extension cube requires it +ERROR: cannot drop type cube because extension cube requires it +HINT: You can drop extension cube instead. +-- list what's installed +\dT + List of data types + Schema | Name | Description +--------+---------------+--------------------------------------------------------------------------------------------- + public | cube | multi-dimensional cube '(FLOAT-1, FLOAT-2, ..., FLOAT-N), (FLOAT-1, FLOAT-2, ..., FLOAT-N)' + public | pg_tde_global | +(2 rows) + +create table foo (f1 cube, f2 int); +drop extension cube; -- fail, foo.f1 requires it +ERROR: cannot drop extension cube because other objects depend on it +DETAIL: column f1 of table foo depends on type cube +HINT: Use DROP ... CASCADE to drop the dependent objects too. +drop table foo; +drop extension cube; +-- list what's installed +\dT + List of data types + Schema | Name | Description +--------+---------------+------------- + public | pg_tde_global | +(1 row) + +\df + List of functions + Schema | Name | Result data type | Argument data types | Type +--------+---------------------------------------------+------------------------------------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+------ + public | pg_tde_add_key_provider | integer | pg_tde_global, provider_type character varying, provider_name character varying, options json | func + public | pg_tde_add_key_provider | integer | provider_type character varying, provider_name character varying, options json | func + public | pg_tde_add_key_provider_file | integer | pg_tde_global, provider_name character varying, file_path json | func + public | pg_tde_add_key_provider_file | integer | pg_tde_global, provider_name character varying, file_path text | func + public | pg_tde_add_key_provider_file | integer | provider_name character varying, file_path json | func + public | pg_tde_add_key_provider_file | integer | provider_name character varying, file_path text | func + public | pg_tde_add_key_provider_internal | integer | provider_type character varying, provider_name character varying, options json, is_global boolean | func + public | pg_tde_add_key_provider_kmip | integer | pg_tde_global, provider_name character varying, kmip_host json, kmip_port json, kmip_ca_path json, kmip_cert_path json | func + public | pg_tde_add_key_provider_kmip | integer | pg_tde_global, provider_name character varying, kmip_host text, kmip_port integer, kmip_ca_path text, kmip_cert_path text | func + public | pg_tde_add_key_provider_kmip | integer | provider_name character varying, kmip_host json, kmip_port json, kmip_ca_path json, kmip_cert_path json | func + public | pg_tde_add_key_provider_kmip | integer | provider_name character varying, kmip_host text, kmip_port integer, kmip_ca_path text, kmip_cert_path text | func + public | pg_tde_add_key_provider_vault_v2 | integer | pg_tde_global, provider_name character varying, vault_token json, vault_url json, vault_mount_path json, vault_ca_path json | func + public | pg_tde_add_key_provider_vault_v2 | integer | pg_tde_global, provider_name character varying, vault_token text, vault_url text, vault_mount_path text, vault_ca_path text | func + public | pg_tde_add_key_provider_vault_v2 | integer | provider_name character varying, vault_token json, vault_url json, vault_mount_path json, vault_ca_path json | func + public | pg_tde_add_key_provider_vault_v2 | integer | provider_name character varying, vault_token text, vault_url text, vault_mount_path text, vault_ca_path text | func + public | pg_tde_alter_principal_key_keyring | boolean | new_provider_name character varying | func + public | pg_tde_ddl_command_end_capture | event_trigger | | func + public | pg_tde_ddl_command_start_capture | event_trigger | | func + public | pg_tde_extension_initialize | void | | func + public | pg_tde_grant_execute_privilege_on_function | boolean | target_user_or_role text, target_function_name text, target_function_args text | func + public | pg_tde_grant_key_management_to_role | boolean | target_user_or_role text | func + public | pg_tde_grant_key_viewer_to_role | boolean | target_user_or_role text | func + public | pg_tde_internal_has_key | boolean | oid oid | func + public | pg_tde_is_encrypted | boolean | table_name character varying | func + public | pg_tde_list_all_key_providers | SETOF record | OUT id integer, OUT provider_name character varying, OUT provider_type character varying, OUT options json | func + public | pg_tde_list_all_key_providers | SETOF record | pg_tde_global, OUT id integer, OUT provider_name character varying, OUT provider_type character varying, OUT options json | func + public | pg_tde_principal_key_info | TABLE(principal_key_name text, key_provider_name text, key_provider_id integer, key_createion_time timestamp with time zone) | | func + public | pg_tde_principal_key_info | TABLE(principal_key_name text, key_provider_name text, key_provider_id integer, key_createion_time timestamp with time zone) | pg_tde_global | func + public | pg_tde_principal_key_info_internal | TABLE(principal_key_name text, key_provider_name text, key_provider_id integer, key_createion_time timestamp with time zone) | is_global boolean | func + public | pg_tde_revoke_execute_privilege_on_function | boolean | target_user_or_role text, target_function_name text, argument_types text | func + public | pg_tde_revoke_key_management_from_role | boolean | target_user_or_role text | func + public | pg_tde_revoke_key_viewer_from_role | boolean | target_user_or_role text | func + public | pg_tde_set_principal_key | boolean | principal_key_name character varying, pg_tde_global, provider_name character varying DEFAULT NULL::character varying, ensure_new_key boolean DEFAULT false | func + public | pg_tde_set_principal_key | boolean | principal_key_name character varying, provider_name character varying DEFAULT NULL::character varying, ensure_new_key boolean DEFAULT false | func + public | pg_tde_set_principal_key_internal | boolean | principal_key_name character varying, is_global integer, provider_name character varying, ensure_new_key boolean DEFAULT false | func + public | pg_tde_set_server_principal_key | boolean | principal_key_name character varying, pg_tde_global, provider_name character varying DEFAULT NULL::character varying, ensure_new_key boolean DEFAULT false | func + public | pg_tde_version | text | | func + public | pg_tdeam_basic_handler | table_am_handler | internal | func + public | pg_tdeam_handler | table_am_handler | internal | func +(39 rows) + +\do + List of operators + Schema | Name | Left arg type | Right arg type | Result type | Description +--------+------+---------------+----------------+-------------+------------- +(0 rows) + +create schema c; +create extension cube with schema c; +-- list what's installed +\dT public.* + List of data types + Schema | Name | Description +--------+---------------+------------- + public | pg_tde_global | +(1 row) + +\df public.* + List of functions + Schema | Name | Result data type | Argument data types | Type +--------+---------------------------------------------+------------------------------------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+------ + public | pg_tde_add_key_provider | integer | pg_tde_global, provider_type character varying, provider_name character varying, options json | func + public | pg_tde_add_key_provider | integer | provider_type character varying, provider_name character varying, options json | func + public | pg_tde_add_key_provider_file | integer | pg_tde_global, provider_name character varying, file_path json | func + public | pg_tde_add_key_provider_file | integer | pg_tde_global, provider_name character varying, file_path text | func + public | pg_tde_add_key_provider_file | integer | provider_name character varying, file_path json | func + public | pg_tde_add_key_provider_file | integer | provider_name character varying, file_path text | func + public | pg_tde_add_key_provider_internal | integer | provider_type character varying, provider_name character varying, options json, is_global boolean | func + public | pg_tde_add_key_provider_kmip | integer | pg_tde_global, provider_name character varying, kmip_host json, kmip_port json, kmip_ca_path json, kmip_cert_path json | func + public | pg_tde_add_key_provider_kmip | integer | pg_tde_global, provider_name character varying, kmip_host text, kmip_port integer, kmip_ca_path text, kmip_cert_path text | func + public | pg_tde_add_key_provider_kmip | integer | provider_name character varying, kmip_host json, kmip_port json, kmip_ca_path json, kmip_cert_path json | func + public | pg_tde_add_key_provider_kmip | integer | provider_name character varying, kmip_host text, kmip_port integer, kmip_ca_path text, kmip_cert_path text | func + public | pg_tde_add_key_provider_vault_v2 | integer | pg_tde_global, provider_name character varying, vault_token json, vault_url json, vault_mount_path json, vault_ca_path json | func + public | pg_tde_add_key_provider_vault_v2 | integer | pg_tde_global, provider_name character varying, vault_token text, vault_url text, vault_mount_path text, vault_ca_path text | func + public | pg_tde_add_key_provider_vault_v2 | integer | provider_name character varying, vault_token json, vault_url json, vault_mount_path json, vault_ca_path json | func + public | pg_tde_add_key_provider_vault_v2 | integer | provider_name character varying, vault_token text, vault_url text, vault_mount_path text, vault_ca_path text | func + public | pg_tde_alter_principal_key_keyring | boolean | new_provider_name character varying | func + public | pg_tde_ddl_command_end_capture | event_trigger | | func + public | pg_tde_ddl_command_start_capture | event_trigger | | func + public | pg_tde_extension_initialize | void | | func + public | pg_tde_grant_execute_privilege_on_function | boolean | target_user_or_role text, target_function_name text, target_function_args text | func + public | pg_tde_grant_key_management_to_role | boolean | target_user_or_role text | func + public | pg_tde_grant_key_viewer_to_role | boolean | target_user_or_role text | func + public | pg_tde_internal_has_key | boolean | oid oid | func + public | pg_tde_is_encrypted | boolean | table_name character varying | func + public | pg_tde_list_all_key_providers | SETOF record | OUT id integer, OUT provider_name character varying, OUT provider_type character varying, OUT options json | func + public | pg_tde_list_all_key_providers | SETOF record | pg_tde_global, OUT id integer, OUT provider_name character varying, OUT provider_type character varying, OUT options json | func + public | pg_tde_principal_key_info | TABLE(principal_key_name text, key_provider_name text, key_provider_id integer, key_createion_time timestamp with time zone) | | func + public | pg_tde_principal_key_info | TABLE(principal_key_name text, key_provider_name text, key_provider_id integer, key_createion_time timestamp with time zone) | pg_tde_global | func + public | pg_tde_principal_key_info_internal | TABLE(principal_key_name text, key_provider_name text, key_provider_id integer, key_createion_time timestamp with time zone) | is_global boolean | func + public | pg_tde_revoke_execute_privilege_on_function | boolean | target_user_or_role text, target_function_name text, argument_types text | func + public | pg_tde_revoke_key_management_from_role | boolean | target_user_or_role text | func + public | pg_tde_revoke_key_viewer_from_role | boolean | target_user_or_role text | func + public | pg_tde_set_principal_key | boolean | principal_key_name character varying, pg_tde_global, provider_name character varying DEFAULT NULL::character varying, ensure_new_key boolean DEFAULT false | func + public | pg_tde_set_principal_key | boolean | principal_key_name character varying, provider_name character varying DEFAULT NULL::character varying, ensure_new_key boolean DEFAULT false | func + public | pg_tde_set_principal_key_internal | boolean | principal_key_name character varying, is_global integer, provider_name character varying, ensure_new_key boolean DEFAULT false | func + public | pg_tde_set_server_principal_key | boolean | principal_key_name character varying, pg_tde_global, provider_name character varying DEFAULT NULL::character varying, ensure_new_key boolean DEFAULT false | func + public | pg_tde_version | text | | func + public | pg_tdeam_basic_handler | table_am_handler | internal | func + public | pg_tdeam_handler | table_am_handler | internal | func +(39 rows) + +\do public.* + List of operators + Schema | Name | Left arg type | Right arg type | Result type | Description +--------+------+---------------+----------------+-------------+------------- +(0 rows) + +\dT c.* + List of data types + Schema | Name | Description +--------+--------+--------------------------------------------------------------------------------------------- + c | c.cube | multi-dimensional cube '(FLOAT-1, FLOAT-2, ..., FLOAT-N), (FLOAT-1, FLOAT-2, ..., FLOAT-N)' +(1 row) + +create table foo (f1 c.cube, f2 int); +drop extension cube; -- fail, foo.f1 requires it +ERROR: cannot drop extension cube because other objects depend on it +DETAIL: column f1 of table foo depends on type c.cube +HINT: Use DROP ... CASCADE to drop the dependent objects too. +drop schema c; -- fail, cube requires it +ERROR: cannot drop schema c because other objects depend on it +DETAIL: extension cube depends on schema c +column f1 of table foo depends on type c.cube +HINT: Use DROP ... CASCADE to drop the dependent objects too. +drop extension cube cascade; +NOTICE: drop cascades to column f1 of table foo +\d foo + Table "public.foo" + Column | Type | Collation | Nullable | Default +--------+---------+-----------+----------+--------- + f2 | integer | | | + +-- list what's installed +\dT public.* + List of data types + Schema | Name | Description +--------+---------------+------------- + public | pg_tde_global | +(1 row) + +\df public.* + List of functions + Schema | Name | Result data type | Argument data types | Type +--------+---------------------------------------------+------------------------------------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+------ + public | pg_tde_add_key_provider | integer | pg_tde_global, provider_type character varying, provider_name character varying, options json | func + public | pg_tde_add_key_provider | integer | provider_type character varying, provider_name character varying, options json | func + public | pg_tde_add_key_provider_file | integer | pg_tde_global, provider_name character varying, file_path json | func + public | pg_tde_add_key_provider_file | integer | pg_tde_global, provider_name character varying, file_path text | func + public | pg_tde_add_key_provider_file | integer | provider_name character varying, file_path json | func + public | pg_tde_add_key_provider_file | integer | provider_name character varying, file_path text | func + public | pg_tde_add_key_provider_internal | integer | provider_type character varying, provider_name character varying, options json, is_global boolean | func + public | pg_tde_add_key_provider_kmip | integer | pg_tde_global, provider_name character varying, kmip_host json, kmip_port json, kmip_ca_path json, kmip_cert_path json | func + public | pg_tde_add_key_provider_kmip | integer | pg_tde_global, provider_name character varying, kmip_host text, kmip_port integer, kmip_ca_path text, kmip_cert_path text | func + public | pg_tde_add_key_provider_kmip | integer | provider_name character varying, kmip_host json, kmip_port json, kmip_ca_path json, kmip_cert_path json | func + public | pg_tde_add_key_provider_kmip | integer | provider_name character varying, kmip_host text, kmip_port integer, kmip_ca_path text, kmip_cert_path text | func + public | pg_tde_add_key_provider_vault_v2 | integer | pg_tde_global, provider_name character varying, vault_token json, vault_url json, vault_mount_path json, vault_ca_path json | func + public | pg_tde_add_key_provider_vault_v2 | integer | pg_tde_global, provider_name character varying, vault_token text, vault_url text, vault_mount_path text, vault_ca_path text | func + public | pg_tde_add_key_provider_vault_v2 | integer | provider_name character varying, vault_token json, vault_url json, vault_mount_path json, vault_ca_path json | func + public | pg_tde_add_key_provider_vault_v2 | integer | provider_name character varying, vault_token text, vault_url text, vault_mount_path text, vault_ca_path text | func + public | pg_tde_alter_principal_key_keyring | boolean | new_provider_name character varying | func + public | pg_tde_ddl_command_end_capture | event_trigger | | func + public | pg_tde_ddl_command_start_capture | event_trigger | | func + public | pg_tde_extension_initialize | void | | func + public | pg_tde_grant_execute_privilege_on_function | boolean | target_user_or_role text, target_function_name text, target_function_args text | func + public | pg_tde_grant_key_management_to_role | boolean | target_user_or_role text | func + public | pg_tde_grant_key_viewer_to_role | boolean | target_user_or_role text | func + public | pg_tde_internal_has_key | boolean | oid oid | func + public | pg_tde_is_encrypted | boolean | table_name character varying | func + public | pg_tde_list_all_key_providers | SETOF record | OUT id integer, OUT provider_name character varying, OUT provider_type character varying, OUT options json | func + public | pg_tde_list_all_key_providers | SETOF record | pg_tde_global, OUT id integer, OUT provider_name character varying, OUT provider_type character varying, OUT options json | func + public | pg_tde_principal_key_info | TABLE(principal_key_name text, key_provider_name text, key_provider_id integer, key_createion_time timestamp with time zone) | | func + public | pg_tde_principal_key_info | TABLE(principal_key_name text, key_provider_name text, key_provider_id integer, key_createion_time timestamp with time zone) | pg_tde_global | func + public | pg_tde_principal_key_info_internal | TABLE(principal_key_name text, key_provider_name text, key_provider_id integer, key_createion_time timestamp with time zone) | is_global boolean | func + public | pg_tde_revoke_execute_privilege_on_function | boolean | target_user_or_role text, target_function_name text, argument_types text | func + public | pg_tde_revoke_key_management_from_role | boolean | target_user_or_role text | func + public | pg_tde_revoke_key_viewer_from_role | boolean | target_user_or_role text | func + public | pg_tde_set_principal_key | boolean | principal_key_name character varying, pg_tde_global, provider_name character varying DEFAULT NULL::character varying, ensure_new_key boolean DEFAULT false | func + public | pg_tde_set_principal_key | boolean | principal_key_name character varying, provider_name character varying DEFAULT NULL::character varying, ensure_new_key boolean DEFAULT false | func + public | pg_tde_set_principal_key_internal | boolean | principal_key_name character varying, is_global integer, provider_name character varying, ensure_new_key boolean DEFAULT false | func + public | pg_tde_set_server_principal_key | boolean | principal_key_name character varying, pg_tde_global, provider_name character varying DEFAULT NULL::character varying, ensure_new_key boolean DEFAULT false | func + public | pg_tde_version | text | | func + public | pg_tdeam_basic_handler | table_am_handler | internal | func + public | pg_tdeam_handler | table_am_handler | internal | func +(39 rows) + +\do public.* + List of operators + Schema | Name | Left arg type | Right arg type | Result type | Description +--------+------+---------------+----------------+-------------+------------- +(0 rows) + +\dT c.* + List of data types + Schema | Name | Description +--------+------+------------- +(0 rows) + +\df c.* + List of functions + Schema | Name | Result data type | Argument data types | Type +--------+------+------------------+---------------------+------ +(0 rows) + +\do c.* + List of operators + Schema | Name | Left arg type | Right arg type | Result type | Description +--------+------+---------------+----------------+-------------+------------- +(0 rows) + +drop schema c; diff --git a/contrib/pageinspect/heapfuncs.c b/contrib/pageinspect/heapfuncs.c index 38a539dad1be0..6bbfe5f789f63 100644 --- a/contrib/pageinspect/heapfuncs.c +++ b/contrib/pageinspect/heapfuncs.c @@ -27,6 +27,7 @@ #include "access/htup_details.h" #include "access/relation.h" +#include "access/tableam.h" #include "catalog/pg_am_d.h" #include "catalog/pg_type.h" #include "funcapi.h" @@ -324,7 +325,7 @@ tuple_data_split_internal(Oid relid, char *tupdata, * Sequences always use heap AM, but they don't show that in the catalogs. */ if (rel->rd_rel->relkind != RELKIND_SEQUENCE && - rel->rd_rel->relam != HEAP_TABLE_AM_OID) + rel->rd_rel->relam != HEAP_TABLE_AM_OID && rel->rd_rel->relam != get_tde_table_am_oid()) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("only heap AM is supported"))); diff --git a/contrib/pg_surgery/heap_surgery.c b/contrib/pg_surgery/heap_surgery.c index 37dffe3f7d57a..4d405f79db5f0 100644 --- a/contrib/pg_surgery/heap_surgery.c +++ b/contrib/pg_surgery/heap_surgery.c @@ -112,7 +112,7 @@ heap_force_common(FunctionCallInfo fcinfo, HeapTupleForceOption heap_force_opt) RelationGetRelationName(rel)), errdetail_relkind_not_supported(rel->rd_rel->relkind))); - if (rel->rd_rel->relam != HEAP_TABLE_AM_OID) + if (rel->rd_rel->relam != HEAP_TABLE_AM_OID && rel->rd_rel->relam != get_tde_table_am_oid()) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("only heap AM is supported"))); diff --git a/contrib/pg_tde/expected/alter_index.out b/contrib/pg_tde/expected/alter_index.out index 59baff38822ea..6996e1b8620e4 100644 --- a/contrib/pg_tde/expected/alter_index.out +++ b/contrib/pg_tde/expected/alter_index.out @@ -1,6 +1,6 @@ \set tde_am tde_heap \i sql/alter_index.inc -CREATE EXTENSION pg_tde; +CREATE EXTENSION IF NOT EXISTS pg_tde; SELECT pg_tde_add_key_provider_file('file-vault','/tmp/pg_tde_test_keyring.per'); pg_tde_add_key_provider_file ------------------------------ diff --git a/contrib/pg_tde/expected/alter_index_basic.out b/contrib/pg_tde/expected/alter_index_basic.out index 953cd268d6bf7..487bde74d7711 100644 --- a/contrib/pg_tde/expected/alter_index_basic.out +++ b/contrib/pg_tde/expected/alter_index_basic.out @@ -1,6 +1,6 @@ \set tde_am tde_heap_basic \i sql/alter_index.inc -CREATE EXTENSION pg_tde; +CREATE EXTENSION IF NOT EXISTS pg_tde; SELECT pg_tde_add_key_provider_file('file-vault','/tmp/pg_tde_test_keyring.per'); pg_tde_add_key_provider_file ------------------------------ diff --git a/contrib/pg_tde/expected/cache_alloc.out b/contrib/pg_tde/expected/cache_alloc.out index 7b6bf20127fbe..44d04187f85c0 100644 --- a/contrib/pg_tde/expected/cache_alloc.out +++ b/contrib/pg_tde/expected/cache_alloc.out @@ -1,6 +1,6 @@ -- We test cache so AM doesn't matter -- Just checking there are no mem debug WARNINGs during the cache population -CREATE EXTENSION pg_tde; +CREATE EXTENSION IF NOT EXISTS pg_tde; SELECT pg_tde_add_key_provider_file('file-vault','/tmp/pg_tde_test_keyring.per'); pg_tde_add_key_provider_file ------------------------------ diff --git a/contrib/pg_tde/expected/change_access_method.out b/contrib/pg_tde/expected/change_access_method.out index 9e86ebf2f7019..e995bd2debc87 100644 --- a/contrib/pg_tde/expected/change_access_method.out +++ b/contrib/pg_tde/expected/change_access_method.out @@ -1,6 +1,6 @@ \set tde_am tde_heap \i sql/change_access_method.inc -CREATE EXTENSION pg_tde; +CREATE EXTENSION IF NOT EXISTS pg_tde; SELECT pg_tde_add_key_provider_file('file-vault','/tmp/pg_tde_test_keyring.per'); pg_tde_add_key_provider_file ------------------------------ diff --git a/contrib/pg_tde/expected/change_access_method_basic.out b/contrib/pg_tde/expected/change_access_method_basic.out index e5c0bb7f6fc89..c1dfa98ff637f 100644 --- a/contrib/pg_tde/expected/change_access_method_basic.out +++ b/contrib/pg_tde/expected/change_access_method_basic.out @@ -1,6 +1,6 @@ \set tde_am tde_heap_basic \i sql/change_access_method.inc -CREATE EXTENSION pg_tde; +CREATE EXTENSION IF NOT EXISTS pg_tde; SELECT pg_tde_add_key_provider_file('file-vault','/tmp/pg_tde_test_keyring.per'); pg_tde_add_key_provider_file ------------------------------ diff --git a/contrib/pg_tde/expected/insert_update_delete.out b/contrib/pg_tde/expected/insert_update_delete.out index 0a363b677c489..b85fbefda3c53 100644 --- a/contrib/pg_tde/expected/insert_update_delete.out +++ b/contrib/pg_tde/expected/insert_update_delete.out @@ -1,6 +1,6 @@ \set tde_am tde_heap \i sql/insert_update_delete.inc -CREATE EXTENSION pg_tde; +CREATE EXTENSION IF NOT EXISTS pg_tde; SELECT pg_tde_add_key_provider_file('file-vault','/tmp/pg_tde_test_keyring.per'); pg_tde_add_key_provider_file ------------------------------ diff --git a/contrib/pg_tde/expected/insert_update_delete_basic.out b/contrib/pg_tde/expected/insert_update_delete_basic.out index 6ca59cae9f18d..38611a2fae799 100644 --- a/contrib/pg_tde/expected/insert_update_delete_basic.out +++ b/contrib/pg_tde/expected/insert_update_delete_basic.out @@ -1,6 +1,6 @@ \set tde_am tde_heap_basic \i sql/insert_update_delete.inc -CREATE EXTENSION pg_tde; +CREATE EXTENSION IF NOT EXISTS pg_tde; SELECT pg_tde_add_key_provider_file('file-vault','/tmp/pg_tde_test_keyring.per'); pg_tde_add_key_provider_file ------------------------------ diff --git a/contrib/pg_tde/expected/keyprovider_dependency.out b/contrib/pg_tde/expected/keyprovider_dependency.out index 7254b08d8fe6d..9b9b9755568e4 100644 --- a/contrib/pg_tde/expected/keyprovider_dependency.out +++ b/contrib/pg_tde/expected/keyprovider_dependency.out @@ -1,6 +1,6 @@ \set tde_am tde_heap \i sql/keyprovider_dependency.inc -CREATE EXTENSION pg_tde; +CREATE EXTENSION IF NOT EXISTS pg_tde; SELECT pg_tde_add_key_provider_file('mk-file','/tmp/pg_tde_test_keyring.per'); pg_tde_add_key_provider_file ------------------------------ diff --git a/contrib/pg_tde/expected/keyprovider_dependency_basic.out b/contrib/pg_tde/expected/keyprovider_dependency_basic.out index f0613a83448d8..ff41fec245a55 100644 --- a/contrib/pg_tde/expected/keyprovider_dependency_basic.out +++ b/contrib/pg_tde/expected/keyprovider_dependency_basic.out @@ -1,6 +1,6 @@ \set tde_am tde_heap_basic \i sql/keyprovider_dependency.inc -CREATE EXTENSION pg_tde; +CREATE EXTENSION IF NOT EXISTS pg_tde; SELECT pg_tde_add_key_provider_file('mk-file','/tmp/pg_tde_test_keyring.per'); pg_tde_add_key_provider_file ------------------------------ diff --git a/contrib/pg_tde/expected/merge_join.out b/contrib/pg_tde/expected/merge_join.out index 2d28d3ff4ac5c..3dfdafb300d26 100644 --- a/contrib/pg_tde/expected/merge_join.out +++ b/contrib/pg_tde/expected/merge_join.out @@ -1,6 +1,6 @@ \set tde_am tde_heap \i sql/merge_join.inc -CREATE EXTENSION pg_tde; +CREATE EXTENSION IF NOT EXISTS pg_tde; SELECT pg_tde_add_key_provider_file('file-vault','/tmp/pg_tde_test_keyring.per'); pg_tde_add_key_provider_file ------------------------------ diff --git a/contrib/pg_tde/expected/merge_join_basic.out b/contrib/pg_tde/expected/merge_join_basic.out index 648bbc1266301..38b5a3856cbe9 100644 --- a/contrib/pg_tde/expected/merge_join_basic.out +++ b/contrib/pg_tde/expected/merge_join_basic.out @@ -1,6 +1,6 @@ \set tde_am tde_heap_basic \i sql/merge_join.inc -CREATE EXTENSION pg_tde; +CREATE EXTENSION IF NOT EXISTS pg_tde; SELECT pg_tde_add_key_provider_file('file-vault','/tmp/pg_tde_test_keyring.per'); pg_tde_add_key_provider_file ------------------------------ diff --git a/contrib/pg_tde/expected/move_large_tuples.out b/contrib/pg_tde/expected/move_large_tuples.out index 9ffac997b7656..36a369ea6fbde 100644 --- a/contrib/pg_tde/expected/move_large_tuples.out +++ b/contrib/pg_tde/expected/move_large_tuples.out @@ -1,7 +1,7 @@ \set tde_am tde_heap \i sql/move_large_tuples.inc -- test pg_tde_move_encrypted_data() -CREATE EXTENSION pg_tde; +CREATE EXTENSION IF NOT EXISTS pg_tde; SELECT pg_tde_add_key_provider_file('file-vault','/tmp/pg_tde_test_keyring.per'); pg_tde_add_key_provider_file ------------------------------ diff --git a/contrib/pg_tde/expected/move_large_tuples_basic.out b/contrib/pg_tde/expected/move_large_tuples_basic.out index 6d1e235ee4c7b..41eaf5e63d738 100644 --- a/contrib/pg_tde/expected/move_large_tuples_basic.out +++ b/contrib/pg_tde/expected/move_large_tuples_basic.out @@ -1,7 +1,7 @@ \set tde_am tde_heap_basic \i sql/move_large_tuples.inc -- test pg_tde_move_encrypted_data() -CREATE EXTENSION pg_tde; +CREATE EXTENSION IF NOT EXISTS pg_tde; SELECT pg_tde_add_key_provider_file('file-vault','/tmp/pg_tde_test_keyring.per'); pg_tde_add_key_provider_file ------------------------------ diff --git a/contrib/pg_tde/expected/multi_insert.out b/contrib/pg_tde/expected/multi_insert.out index feb9ad35ad3ac..327c051358be1 100644 --- a/contrib/pg_tde/expected/multi_insert.out +++ b/contrib/pg_tde/expected/multi_insert.out @@ -2,7 +2,7 @@ \i sql/multi_insert.inc -- trigger multi_insert path -- -CREATE EXTENSION pg_tde; +CREATE EXTENSION IF NOT EXISTS pg_tde; SELECT pg_tde_add_key_provider_file('file-vault','/tmp/pg_tde_test_keyring.per'); pg_tde_add_key_provider_file ------------------------------ diff --git a/contrib/pg_tde/expected/multi_insert_basic.out b/contrib/pg_tde/expected/multi_insert_basic.out index 6662449e32f2d..e6d29188f7dea 100644 --- a/contrib/pg_tde/expected/multi_insert_basic.out +++ b/contrib/pg_tde/expected/multi_insert_basic.out @@ -2,7 +2,7 @@ \i sql/multi_insert.inc -- trigger multi_insert path -- -CREATE EXTENSION pg_tde; +CREATE EXTENSION IF NOT EXISTS pg_tde; SELECT pg_tde_add_key_provider_file('file-vault','/tmp/pg_tde_test_keyring.per'); pg_tde_add_key_provider_file ------------------------------ diff --git a/contrib/pg_tde/expected/non_sorted_off_compact.out b/contrib/pg_tde/expected/non_sorted_off_compact.out index bd1d9fc0115d8..26e2976b6ca70 100644 --- a/contrib/pg_tde/expected/non_sorted_off_compact.out +++ b/contrib/pg_tde/expected/non_sorted_off_compact.out @@ -2,7 +2,7 @@ \i sql/non_sorted_off_compact.inc -- A test case for https://github.com/percona/pg_tde/pull/21 -- -CREATE EXTENSION pg_tde; +CREATE EXTENSION IF NOT EXISTS pg_tde; SELECT pg_tde_add_key_provider_file('file-vault','/tmp/pg_tde_test_keyring.per'); pg_tde_add_key_provider_file ------------------------------ @@ -40,7 +40,7 @@ INSERT INTO sbtest1(k) VALUES (12), (13); -- Line pointers (lp) point to non-sorted offsets (lp_off): --- CREATE EXTENSION pageinspect; +-- CREATE EXTENSION IF NOT EXISTS pageinspect; -- SELECT lp, lp_off, t_ctid FROM heap_page_items(get_raw_page('sbtest1', 0)); -- lp | lp_off | t_ctid -- ----+--------+-------- diff --git a/contrib/pg_tde/expected/non_sorted_off_compact_basic.out b/contrib/pg_tde/expected/non_sorted_off_compact_basic.out index 6801740c86d59..6739869921caa 100644 --- a/contrib/pg_tde/expected/non_sorted_off_compact_basic.out +++ b/contrib/pg_tde/expected/non_sorted_off_compact_basic.out @@ -2,7 +2,7 @@ \i sql/non_sorted_off_compact.inc -- A test case for https://github.com/percona/pg_tde/pull/21 -- -CREATE EXTENSION pg_tde; +CREATE EXTENSION IF NOT EXISTS pg_tde; SELECT pg_tde_add_key_provider_file('file-vault','/tmp/pg_tde_test_keyring.per'); pg_tde_add_key_provider_file ------------------------------ @@ -40,7 +40,7 @@ INSERT INTO sbtest1(k) VALUES (12), (13); -- Line pointers (lp) point to non-sorted offsets (lp_off): --- CREATE EXTENSION pageinspect; +-- CREATE EXTENSION IF NOT EXISTS pageinspect; -- SELECT lp, lp_off, t_ctid FROM heap_page_items(get_raw_page('sbtest1', 0)); -- lp | lp_off | t_ctid -- ----+--------+-------- diff --git a/contrib/pg_tde/expected/pg_tde_is_encrypted.out b/contrib/pg_tde/expected/pg_tde_is_encrypted.out index fd7f0b1a56563..f5ed1faf6db39 100644 --- a/contrib/pg_tde/expected/pg_tde_is_encrypted.out +++ b/contrib/pg_tde/expected/pg_tde_is_encrypted.out @@ -1,6 +1,6 @@ \set tde_am tde_heap \i sql/pg_tde_is_encrypted.inc -CREATE EXTENSION pg_tde; +CREATE EXTENSION IF NOT EXISTS pg_tde; SELECT * FROM pg_tde_principal_key_info(); psql:sql/pg_tde_is_encrypted.inc:3: ERROR: Principal key does not exists for the database HINT: Use set_principal_key interface to set the principal key diff --git a/contrib/pg_tde/expected/pg_tde_is_encrypted_basic.out b/contrib/pg_tde/expected/pg_tde_is_encrypted_basic.out index 1c573f90f7328..36b7eaf12a9be 100644 --- a/contrib/pg_tde/expected/pg_tde_is_encrypted_basic.out +++ b/contrib/pg_tde/expected/pg_tde_is_encrypted_basic.out @@ -1,6 +1,6 @@ \set tde_am tde_heap_basic \i sql/pg_tde_is_encrypted.inc -CREATE EXTENSION pg_tde; +CREATE EXTENSION IF NOT EXISTS pg_tde; SELECT * FROM pg_tde_principal_key_info(); psql:sql/pg_tde_is_encrypted.inc:3: ERROR: Principal key does not exists for the database HINT: Use set_principal_key interface to set the principal key diff --git a/contrib/pg_tde/expected/subtransaction.out b/contrib/pg_tde/expected/subtransaction.out index 731382a251366..3dd80be731d79 100644 --- a/contrib/pg_tde/expected/subtransaction.out +++ b/contrib/pg_tde/expected/subtransaction.out @@ -1,6 +1,6 @@ \set tde_am tde_heap \i sql/subtransaction.inc -CREATE EXTENSION pg_tde; +CREATE EXTENSION IF NOT EXISTS pg_tde; SELECT pg_tde_add_key_provider_file('file-vault','/tmp/pg_tde_test_keyring.per'); pg_tde_add_key_provider_file ------------------------------ diff --git a/contrib/pg_tde/expected/subtransaction_basic.out b/contrib/pg_tde/expected/subtransaction_basic.out index d84651efba9d0..9d213ee44e25f 100644 --- a/contrib/pg_tde/expected/subtransaction_basic.out +++ b/contrib/pg_tde/expected/subtransaction_basic.out @@ -1,6 +1,6 @@ \set tde_am tde_heap_basic \i sql/subtransaction.inc -CREATE EXTENSION pg_tde; +CREATE EXTENSION IF NOT EXISTS pg_tde; SELECT pg_tde_add_key_provider_file('file-vault','/tmp/pg_tde_test_keyring.per'); pg_tde_add_key_provider_file ------------------------------ diff --git a/contrib/pg_tde/expected/tablespace.out b/contrib/pg_tde/expected/tablespace.out index 52448e20ee944..d4f80568eb78c 100644 --- a/contrib/pg_tde/expected/tablespace.out +++ b/contrib/pg_tde/expected/tablespace.out @@ -1,6 +1,6 @@ \set tde_am tde_heap \i sql/tablespace.inc -CREATE EXTENSION pg_tde; +CREATE EXTENSION IF NOT EXISTS pg_tde; SELECT pg_tde_add_key_provider_file('file-vault','/tmp/pg_tde_test_keyring.per'); pg_tde_add_key_provider_file ------------------------------ diff --git a/contrib/pg_tde/expected/tablespace_basic.out b/contrib/pg_tde/expected/tablespace_basic.out index 6718dc5a5beec..5d64aed93e79b 100644 --- a/contrib/pg_tde/expected/tablespace_basic.out +++ b/contrib/pg_tde/expected/tablespace_basic.out @@ -1,6 +1,6 @@ \set tde_am tde_heap_basic \i sql/tablespace.inc -CREATE EXTENSION pg_tde; +CREATE EXTENSION IF NOT EXISTS pg_tde; SELECT pg_tde_add_key_provider_file('file-vault','/tmp/pg_tde_test_keyring.per'); pg_tde_add_key_provider_file ------------------------------ diff --git a/contrib/pg_tde/expected/test_issue_153_fix.out b/contrib/pg_tde/expected/test_issue_153_fix.out index bcbb15a172e9d..8ff45cdbd3adf 100644 --- a/contrib/pg_tde/expected/test_issue_153_fix.out +++ b/contrib/pg_tde/expected/test_issue_153_fix.out @@ -1,6 +1,6 @@ \set tde_am tde_heap \i sql/test_issue_153_fix.inc -CREATE EXTENSION pg_tde; +CREATE EXTENSION IF NOT EXISTS pg_tde; SET datestyle TO 'iso, dmy'; SELECT * FROM pg_tde_principal_key_info(); psql:sql/test_issue_153_fix.inc:4: ERROR: Principal key does not exists for the database diff --git a/contrib/pg_tde/expected/test_issue_153_fix_basic.out b/contrib/pg_tde/expected/test_issue_153_fix_basic.out index 66f293e94a497..74a6354843683 100644 --- a/contrib/pg_tde/expected/test_issue_153_fix_basic.out +++ b/contrib/pg_tde/expected/test_issue_153_fix_basic.out @@ -1,6 +1,6 @@ \set tde_am tde_heap_basic \i sql/test_issue_153_fix.inc -CREATE EXTENSION pg_tde; +CREATE EXTENSION IF NOT EXISTS pg_tde; SET datestyle TO 'iso, dmy'; SELECT * FROM pg_tde_principal_key_info(); psql:sql/test_issue_153_fix.inc:4: ERROR: Principal key does not exists for the database diff --git a/contrib/pg_tde/expected/toast_decrypt.out b/contrib/pg_tde/expected/toast_decrypt.out index ac47626f09d21..184179f700bfb 100644 --- a/contrib/pg_tde/expected/toast_decrypt.out +++ b/contrib/pg_tde/expected/toast_decrypt.out @@ -1,6 +1,6 @@ \set tde_am tde_heap \i sql/toast_decrypt.inc -CREATE EXTENSION pg_tde; +CREATE EXTENSION IF NOT EXISTS pg_tde; SELECT pg_tde_add_key_provider_file('file-vault','/tmp/pg_tde_test_keyring.per'); pg_tde_add_key_provider_file ------------------------------ diff --git a/contrib/pg_tde/expected/toast_decrypt_basic.out b/contrib/pg_tde/expected/toast_decrypt_basic.out index 1e273d44f1751..356c03f12ce4f 100644 --- a/contrib/pg_tde/expected/toast_decrypt_basic.out +++ b/contrib/pg_tde/expected/toast_decrypt_basic.out @@ -1,6 +1,6 @@ \set tde_am tde_heap_basic \i sql/toast_decrypt.inc -CREATE EXTENSION pg_tde; +CREATE EXTENSION IF NOT EXISTS pg_tde; SELECT pg_tde_add_key_provider_file('file-vault','/tmp/pg_tde_test_keyring.per'); pg_tde_add_key_provider_file ------------------------------ diff --git a/contrib/pg_tde/expected/toast_decrypt_basic_1.out b/contrib/pg_tde/expected/toast_decrypt_basic_1.out new file mode 100644 index 0000000000000..67287083cf3f1 --- /dev/null +++ b/contrib/pg_tde/expected/toast_decrypt_basic_1.out @@ -0,0 +1,26 @@ +\set tde_am tde_heap_basic +\i sql/toast_decrypt.inc +CREATE EXTENSION IF NOT EXISTS pg_tde; +psql:sql/toast_decrypt.inc:1: NOTICE: extension "pg_tde" already exists, skipping +SELECT pg_tde_add_key_provider_file('file-vault','/tmp/pg_tde_test_keyring.per'); + pg_tde_add_key_provider_file +------------------------------ + 2 +(1 row) + +SELECT pg_tde_set_principal_key('test-db-principal-key','file-vault'); + pg_tde_set_principal_key +-------------------------- + t +(1 row) + +CREATE TABLE src (f1 TEXT STORAGE EXTERNAL) USING :tde_am; +INSERT INTO src VALUES(repeat('abcdeF',1000)); +SELECT * FROM src; + f1 +-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + abcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeFabcdeF +(1 row) + +DROP TABLE src; +DROP EXTENSION pg_tde; diff --git a/contrib/pg_tde/expected/toast_extended_storage.out b/contrib/pg_tde/expected/toast_extended_storage.out index ce59afeeaa132..7446960d27f86 100644 --- a/contrib/pg_tde/expected/toast_extended_storage.out +++ b/contrib/pg_tde/expected/toast_extended_storage.out @@ -1,7 +1,7 @@ \set tde_am tde_heap \i sql/toast_extended_storage.inc -- test https://github.com/percona/pg_tde/issues/63 -CREATE EXTENSION pg_tde; +CREATE EXTENSION IF NOT EXISTS pg_tde; SELECT pg_tde_add_key_provider_file('file-vault','/tmp/pg_tde_test_keyring.per'); pg_tde_add_key_provider_file ------------------------------ diff --git a/contrib/pg_tde/expected/toast_extended_storage_basic.out b/contrib/pg_tde/expected/toast_extended_storage_basic.out index b04a32983ca6f..d3cf3bf763be4 100644 --- a/contrib/pg_tde/expected/toast_extended_storage_basic.out +++ b/contrib/pg_tde/expected/toast_extended_storage_basic.out @@ -1,7 +1,7 @@ \set tde_am tde_heap_basic \i sql/toast_extended_storage.inc -- test https://github.com/percona/pg_tde/issues/63 -CREATE EXTENSION pg_tde; +CREATE EXTENSION IF NOT EXISTS pg_tde; SELECT pg_tde_add_key_provider_file('file-vault','/tmp/pg_tde_test_keyring.per'); pg_tde_add_key_provider_file ------------------------------ diff --git a/contrib/pg_tde/expected/trigger_on_view.out b/contrib/pg_tde/expected/trigger_on_view.out index 33cdc5f1b36eb..63b0e6fb5599e 100644 --- a/contrib/pg_tde/expected/trigger_on_view.out +++ b/contrib/pg_tde/expected/trigger_on_view.out @@ -1,6 +1,6 @@ \set tde_am tde_heap \i sql/trigger_on_view.inc -CREATE extension pg_tde; +CREATE EXTENSION IF NOT EXISTS pg_tde; SELECT pg_tde_add_key_provider_file('file-vault','/tmp/pg_tde_test_keyring.per'); pg_tde_add_key_provider_file ------------------------------ diff --git a/contrib/pg_tde/expected/trigger_on_view_basic.out b/contrib/pg_tde/expected/trigger_on_view_basic.out index e01bd0e9f1a0e..83ea7bfca4bfb 100644 --- a/contrib/pg_tde/expected/trigger_on_view_basic.out +++ b/contrib/pg_tde/expected/trigger_on_view_basic.out @@ -1,6 +1,6 @@ \set tde_am tde_heap_basic \i sql/trigger_on_view.inc -CREATE extension pg_tde; +CREATE EXTENSION IF NOT EXISTS pg_tde; SELECT pg_tde_add_key_provider_file('file-vault','/tmp/pg_tde_test_keyring.per'); pg_tde_add_key_provider_file ------------------------------ diff --git a/contrib/pg_tde/expected/update.out b/contrib/pg_tde/expected/update.out index 2eadadf27ffcf..cde5f4e6cb45c 100644 --- a/contrib/pg_tde/expected/update.out +++ b/contrib/pg_tde/expected/update.out @@ -1,6 +1,6 @@ \set tde_am tde_heap \i sql/update.inc -CREATE EXTENSION pg_tde; +CREATE EXTENSION IF NOT EXISTS pg_tde; SELECT pg_tde_add_key_provider_file('file-vault','/tmp/pg_tde_test_keyring.per'); pg_tde_add_key_provider_file ------------------------------ diff --git a/contrib/pg_tde/expected/update_basic.out b/contrib/pg_tde/expected/update_basic.out index 46e84dabe3e3d..1bf0e2dd69a20 100644 --- a/contrib/pg_tde/expected/update_basic.out +++ b/contrib/pg_tde/expected/update_basic.out @@ -1,6 +1,6 @@ \set tde_am tde_heap_basic \i sql/update.inc -CREATE EXTENSION pg_tde; +CREATE EXTENSION IF NOT EXISTS pg_tde; SELECT pg_tde_add_key_provider_file('file-vault','/tmp/pg_tde_test_keyring.per'); pg_tde_add_key_provider_file ------------------------------ diff --git a/contrib/pg_tde/expected/update_compare_indexes.out b/contrib/pg_tde/expected/update_compare_indexes.out index 3e21417f50c64..870635309fde7 100644 --- a/contrib/pg_tde/expected/update_compare_indexes.out +++ b/contrib/pg_tde/expected/update_compare_indexes.out @@ -1,6 +1,6 @@ \set tde_am tde_heap \i sql/update_compare_indexes.inc -CREATE EXTENSION pg_tde; +CREATE EXTENSION IF NOT EXISTS pg_tde; SELECT pg_tde_add_key_provider_file('file-vault','/tmp/pg_tde_test_keyring.per'); pg_tde_add_key_provider_file ------------------------------ diff --git a/contrib/pg_tde/expected/update_compare_indexes_basic.out b/contrib/pg_tde/expected/update_compare_indexes_basic.out index 0840810e21825..d6a17197f6898 100644 --- a/contrib/pg_tde/expected/update_compare_indexes_basic.out +++ b/contrib/pg_tde/expected/update_compare_indexes_basic.out @@ -1,6 +1,6 @@ \set tde_am tde_heap_basic \i sql/update_compare_indexes.inc -CREATE EXTENSION pg_tde; +CREATE EXTENSION IF NOT EXISTS pg_tde; SELECT pg_tde_add_key_provider_file('file-vault','/tmp/pg_tde_test_keyring.per'); pg_tde_add_key_provider_file ------------------------------ diff --git a/contrib/pg_tde/expected/vault_v2_test.out b/contrib/pg_tde/expected/vault_v2_test.out index b1037d7290a64..08f395fc86a05 100644 --- a/contrib/pg_tde/expected/vault_v2_test.out +++ b/contrib/pg_tde/expected/vault_v2_test.out @@ -1,6 +1,6 @@ \set tde_am tde_heap \i sql/vault_v2_test.inc -CREATE EXTENSION pg_tde; +CREATE EXTENSION IF NOT EXISTS pg_tde; \getenv root_token ROOT_TOKEN SELECT pg_tde_add_key_provider_vault_v2('vault-incorrect',:'root_token','http://127.0.0.1:8200','DUMMY-TOKEN',NULL); pg_tde_add_key_provider_vault_v2 diff --git a/contrib/pg_tde/expected/vault_v2_test_basic.out b/contrib/pg_tde/expected/vault_v2_test_basic.out index 5fcedd36748b6..f2b4f1b235dfe 100644 --- a/contrib/pg_tde/expected/vault_v2_test_basic.out +++ b/contrib/pg_tde/expected/vault_v2_test_basic.out @@ -1,6 +1,6 @@ \set tde_am tde_heap_basic \i sql/vault_v2_test.inc -CREATE EXTENSION pg_tde; +CREATE EXTENSION IF NOT EXISTS pg_tde; \getenv root_token ROOT_TOKEN SELECT pg_tde_add_key_provider_vault_v2('vault-incorrect',:'root_token','http://127.0.0.1:8200','DUMMY-TOKEN',NULL); pg_tde_add_key_provider_vault_v2 diff --git a/contrib/pg_tde/sql/alter_index.inc b/contrib/pg_tde/sql/alter_index.inc index d7f1a7f7157d3..c96e8904efc77 100644 --- a/contrib/pg_tde/sql/alter_index.inc +++ b/contrib/pg_tde/sql/alter_index.inc @@ -1,4 +1,4 @@ -CREATE EXTENSION pg_tde; +CREATE EXTENSION IF NOT EXISTS pg_tde; SELECT pg_tde_add_key_provider_file('file-vault','/tmp/pg_tde_test_keyring.per'); SELECT pg_tde_set_principal_key('test-db-principal-key','file-vault'); diff --git a/contrib/pg_tde/sql/cache_alloc.sql b/contrib/pg_tde/sql/cache_alloc.sql index de791ec13dcfe..7c0ca429b5d39 100644 --- a/contrib/pg_tde/sql/cache_alloc.sql +++ b/contrib/pg_tde/sql/cache_alloc.sql @@ -1,7 +1,7 @@ -- We test cache so AM doesn't matter -- Just checking there are no mem debug WARNINGs during the cache population -CREATE EXTENSION pg_tde; +CREATE EXTENSION IF NOT EXISTS pg_tde; SELECT pg_tde_add_key_provider_file('file-vault','/tmp/pg_tde_test_keyring.per'); SELECT pg_tde_set_principal_key('test-db-principal-key','file-vault'); diff --git a/contrib/pg_tde/sql/change_access_method.inc b/contrib/pg_tde/sql/change_access_method.inc index 0849e681c6d2a..b82a4d5a67ffd 100644 --- a/contrib/pg_tde/sql/change_access_method.inc +++ b/contrib/pg_tde/sql/change_access_method.inc @@ -1,4 +1,4 @@ -CREATE EXTENSION pg_tde; +CREATE EXTENSION IF NOT EXISTS pg_tde; SELECT pg_tde_add_key_provider_file('file-vault','/tmp/pg_tde_test_keyring.per'); SELECT pg_tde_set_principal_key('test-db-principal-key','file-vault'); diff --git a/contrib/pg_tde/sql/insert_update_delete.inc b/contrib/pg_tde/sql/insert_update_delete.inc index 23acc27991fd5..e362b6dacd53c 100644 --- a/contrib/pg_tde/sql/insert_update_delete.inc +++ b/contrib/pg_tde/sql/insert_update_delete.inc @@ -1,4 +1,4 @@ -CREATE EXTENSION pg_tde; +CREATE EXTENSION IF NOT EXISTS pg_tde; SELECT pg_tde_add_key_provider_file('file-vault','/tmp/pg_tde_test_keyring.per'); SELECT pg_tde_set_principal_key('test-db-principal-key','file-vault'); diff --git a/contrib/pg_tde/sql/keyprovider_dependency.inc b/contrib/pg_tde/sql/keyprovider_dependency.inc index 26575ecdb8520..2c56d2d9e38e2 100644 --- a/contrib/pg_tde/sql/keyprovider_dependency.inc +++ b/contrib/pg_tde/sql/keyprovider_dependency.inc @@ -1,4 +1,4 @@ -CREATE EXTENSION pg_tde; +CREATE EXTENSION IF NOT EXISTS pg_tde; SELECT pg_tde_add_key_provider_file('mk-file','/tmp/pg_tde_test_keyring.per'); SELECT pg_tde_add_key_provider_file('free-file','/tmp/pg_tde_test_keyring_2.per'); diff --git a/contrib/pg_tde/sql/merge_join.inc b/contrib/pg_tde/sql/merge_join.inc index 8fc4211b47d19..af8cf8cfde44f 100644 --- a/contrib/pg_tde/sql/merge_join.inc +++ b/contrib/pg_tde/sql/merge_join.inc @@ -1,4 +1,4 @@ -CREATE EXTENSION pg_tde; +CREATE EXTENSION IF NOT EXISTS pg_tde; SELECT pg_tde_add_key_provider_file('file-vault','/tmp/pg_tde_test_keyring.per'); SELECT pg_tde_set_principal_key('test-db-principal-key','file-vault'); diff --git a/contrib/pg_tde/sql/move_large_tuples.inc b/contrib/pg_tde/sql/move_large_tuples.inc index 36d090776c38c..f8ae5b0b0c03d 100644 --- a/contrib/pg_tde/sql/move_large_tuples.inc +++ b/contrib/pg_tde/sql/move_large_tuples.inc @@ -1,5 +1,5 @@ -- test pg_tde_move_encrypted_data() -CREATE EXTENSION pg_tde; +CREATE EXTENSION IF NOT EXISTS pg_tde; SELECT pg_tde_add_key_provider_file('file-vault','/tmp/pg_tde_test_keyring.per'); SELECT pg_tde_set_principal_key('test-db-principal-key','file-vault'); diff --git a/contrib/pg_tde/sql/multi_insert.inc b/contrib/pg_tde/sql/multi_insert.inc index 88b9206070058..39896d990b890 100644 --- a/contrib/pg_tde/sql/multi_insert.inc +++ b/contrib/pg_tde/sql/multi_insert.inc @@ -1,6 +1,6 @@ -- trigger multi_insert path -- -CREATE EXTENSION pg_tde; +CREATE EXTENSION IF NOT EXISTS pg_tde; SELECT pg_tde_add_key_provider_file('file-vault','/tmp/pg_tde_test_keyring.per'); SELECT pg_tde_set_principal_key('test-db-principal-key','file-vault'); diff --git a/contrib/pg_tde/sql/non_sorted_off_compact.inc b/contrib/pg_tde/sql/non_sorted_off_compact.inc index 3b6ac2a81b7e4..d739a05af1a61 100644 --- a/contrib/pg_tde/sql/non_sorted_off_compact.inc +++ b/contrib/pg_tde/sql/non_sorted_off_compact.inc @@ -1,6 +1,6 @@ -- A test case for https://github.com/percona/pg_tde/pull/21 -- -CREATE EXTENSION pg_tde; +CREATE EXTENSION IF NOT EXISTS pg_tde; SELECT pg_tde_add_key_provider_file('file-vault','/tmp/pg_tde_test_keyring.per'); SELECT pg_tde_set_principal_key('test-db-principal-key','file-vault'); @@ -33,7 +33,7 @@ INSERT INTO sbtest1(k) VALUES (13); -- Line pointers (lp) point to non-sorted offsets (lp_off): --- CREATE EXTENSION pageinspect; +-- CREATE EXTENSION IF NOT EXISTS pageinspect; -- SELECT lp, lp_off, t_ctid FROM heap_page_items(get_raw_page('sbtest1', 0)); -- lp | lp_off | t_ctid -- ----+--------+-------- diff --git a/contrib/pg_tde/sql/pg_tde_is_encrypted.inc b/contrib/pg_tde/sql/pg_tde_is_encrypted.inc index 00054e0d1cca5..cc96888c256f0 100644 --- a/contrib/pg_tde/sql/pg_tde_is_encrypted.inc +++ b/contrib/pg_tde/sql/pg_tde_is_encrypted.inc @@ -1,4 +1,4 @@ -CREATE EXTENSION pg_tde; +CREATE EXTENSION IF NOT EXISTS pg_tde; SELECT * FROM pg_tde_principal_key_info(); diff --git a/contrib/pg_tde/sql/subtransaction.inc b/contrib/pg_tde/sql/subtransaction.inc index 3446d44ea764d..681d505092a7f 100644 --- a/contrib/pg_tde/sql/subtransaction.inc +++ b/contrib/pg_tde/sql/subtransaction.inc @@ -1,4 +1,4 @@ -CREATE EXTENSION pg_tde; +CREATE EXTENSION IF NOT EXISTS pg_tde; SELECT pg_tde_add_key_provider_file('file-vault','/tmp/pg_tde_test_keyring.per'); SELECT pg_tde_set_principal_key('test-db-principal-key','file-vault'); diff --git a/contrib/pg_tde/sql/tablespace.inc b/contrib/pg_tde/sql/tablespace.inc index b2f7ebddc77d5..fe517e1184489 100644 --- a/contrib/pg_tde/sql/tablespace.inc +++ b/contrib/pg_tde/sql/tablespace.inc @@ -1,4 +1,4 @@ -CREATE EXTENSION pg_tde; +CREATE EXTENSION IF NOT EXISTS pg_tde; SELECT pg_tde_add_key_provider_file('file-vault','/tmp/pg_tde_test_keyring.per'); SELECT pg_tde_set_principal_key('test-db-principal-key','file-vault'); diff --git a/contrib/pg_tde/sql/test_issue_153_fix.inc b/contrib/pg_tde/sql/test_issue_153_fix.inc index 72eb4497e1b41..c83035945717f 100644 --- a/contrib/pg_tde/sql/test_issue_153_fix.inc +++ b/contrib/pg_tde/sql/test_issue_153_fix.inc @@ -1,4 +1,4 @@ -CREATE EXTENSION pg_tde; +CREATE EXTENSION IF NOT EXISTS pg_tde; SET datestyle TO 'iso, dmy'; SELECT * FROM pg_tde_principal_key_info(); diff --git a/contrib/pg_tde/sql/toast_decrypt.inc b/contrib/pg_tde/sql/toast_decrypt.inc index b41a27314649e..8d6e9f3e1df94 100644 --- a/contrib/pg_tde/sql/toast_decrypt.inc +++ b/contrib/pg_tde/sql/toast_decrypt.inc @@ -1,4 +1,4 @@ -CREATE EXTENSION pg_tde; +CREATE EXTENSION IF NOT EXISTS pg_tde; SELECT pg_tde_add_key_provider_file('file-vault','/tmp/pg_tde_test_keyring.per'); SELECT pg_tde_set_principal_key('test-db-principal-key','file-vault'); diff --git a/contrib/pg_tde/sql/toast_extended_storage.inc b/contrib/pg_tde/sql/toast_extended_storage.inc index 2311e8038ab85..eb1554789ecc2 100644 --- a/contrib/pg_tde/sql/toast_extended_storage.inc +++ b/contrib/pg_tde/sql/toast_extended_storage.inc @@ -1,5 +1,5 @@ -- test https://github.com/percona/pg_tde/issues/63 -CREATE EXTENSION pg_tde; +CREATE EXTENSION IF NOT EXISTS pg_tde; SELECT pg_tde_add_key_provider_file('file-vault','/tmp/pg_tde_test_keyring.per'); SELECT pg_tde_set_principal_key('test-db-principal-key','file-vault'); diff --git a/contrib/pg_tde/sql/trigger_on_view.inc b/contrib/pg_tde/sql/trigger_on_view.inc index b229d1b9449c7..954bb220793f2 100644 --- a/contrib/pg_tde/sql/trigger_on_view.inc +++ b/contrib/pg_tde/sql/trigger_on_view.inc @@ -1,4 +1,4 @@ -CREATE extension pg_tde; +CREATE EXTENSION IF NOT EXISTS pg_tde; SELECT pg_tde_add_key_provider_file('file-vault','/tmp/pg_tde_test_keyring.per'); SELECT pg_tde_set_principal_key('test-db-principal-key','file-vault'); diff --git a/contrib/pg_tde/sql/update.inc b/contrib/pg_tde/sql/update.inc index 2702940b0137e..04a46a9505150 100644 --- a/contrib/pg_tde/sql/update.inc +++ b/contrib/pg_tde/sql/update.inc @@ -1,4 +1,4 @@ -CREATE EXTENSION pg_tde; +CREATE EXTENSION IF NOT EXISTS pg_tde; SELECT pg_tde_add_key_provider_file('file-vault','/tmp/pg_tde_test_keyring.per'); SELECT pg_tde_set_principal_key('test-db-principal-key','file-vault'); diff --git a/contrib/pg_tde/sql/update_compare_indexes.inc b/contrib/pg_tde/sql/update_compare_indexes.inc index 6cc54ac602711..f43a9dea50074 100644 --- a/contrib/pg_tde/sql/update_compare_indexes.inc +++ b/contrib/pg_tde/sql/update_compare_indexes.inc @@ -1,4 +1,4 @@ -CREATE EXTENSION pg_tde; +CREATE EXTENSION IF NOT EXISTS pg_tde; SELECT pg_tde_add_key_provider_file('file-vault','/tmp/pg_tde_test_keyring.per'); SELECT pg_tde_set_principal_key('test-db-principal-key','file-vault'); diff --git a/contrib/pg_tde/sql/vault_v2_test.inc b/contrib/pg_tde/sql/vault_v2_test.inc index 70c7190690a6f..0c715592875fa 100644 --- a/contrib/pg_tde/sql/vault_v2_test.inc +++ b/contrib/pg_tde/sql/vault_v2_test.inc @@ -1,4 +1,4 @@ -CREATE EXTENSION pg_tde; +CREATE EXTENSION IF NOT EXISTS pg_tde; \getenv root_token ROOT_TOKEN diff --git a/contrib/pg_tde/src/common/pg_tde_utils.c b/contrib/pg_tde/src/common/pg_tde_utils.c index 8c211ea8b4b38..a41209c7e7972 100644 --- a/contrib/pg_tde/src/common/pg_tde_utils.c +++ b/contrib/pg_tde/src/common/pg_tde_utils.c @@ -29,12 +29,6 @@ get_tde_basic_table_am_oid(void) return get_table_am_oid("tde_heap_basic", false); } -Oid -get_tde_table_am_oid(void) -{ - return get_table_am_oid("tde_heap", false); -} - PG_FUNCTION_INFO_V1(pg_tde_internal_has_key); Datum pg_tde_internal_has_key(PG_FUNCTION_ARGS) diff --git a/contrib/pg_tde/t/001_basic.pl b/contrib/pg_tde/t/001_basic.pl index 914f4af9ca7e4..2543ec8d890a4 100644 --- a/contrib/pg_tde/t/001_basic.pl +++ b/contrib/pg_tde/t/001_basic.pl @@ -25,8 +25,8 @@ my $rt_value = $node->start; ok($rt_value == 1, "Start Server"); -# CREATE EXTENSION and change out file permissions -my ($cmdret, $stdout, $stderr) = $node->psql('postgres', 'CREATE EXTENSION pg_tde;', extra_params => ['-a']); +# CREATE EXTENSION IF NOT EXISTS and change out file permissions +my ($cmdret, $stdout, $stderr) = $node->psql('postgres', 'CREATE EXTENSION IF NOT EXISTS pg_tde;', extra_params => ['-a']); ok($cmdret == 0, "CREATE PGTDE EXTENSION"); PGTDE::append_to_file($stdout); diff --git a/contrib/pg_tde/t/002_rotate_key.pl b/contrib/pg_tde/t/002_rotate_key.pl index 894529b2e3d4a..7700449e559f7 100644 --- a/contrib/pg_tde/t/002_rotate_key.pl +++ b/contrib/pg_tde/t/002_rotate_key.pl @@ -25,8 +25,8 @@ my $rt_value = $node->start; ok($rt_value == 1, "Start Server"); -# CREATE EXTENSION and change out file permissions -my ($cmdret, $stdout, $stderr) = $node->psql('postgres', 'CREATE EXTENSION pg_tde;', extra_params => ['-a']); +# CREATE EXTENSION IF NOT EXISTS and change out file permissions +my ($cmdret, $stdout, $stderr) = $node->psql('postgres', 'CREATE EXTENSION IF NOT EXISTS pg_tde;', extra_params => ['-a']); ok($cmdret == 0, "CREATE PGTDE EXTENSION"); PGTDE::append_to_file($stdout); diff --git a/contrib/pg_tde/t/003_remote_config.pl b/contrib/pg_tde/t/003_remote_config.pl index aa22c1bacc44a..3480e45fd49a8 100644 --- a/contrib/pg_tde/t/003_remote_config.pl +++ b/contrib/pg_tde/t/003_remote_config.pl @@ -66,7 +66,7 @@ sub resp_hello { $rt_value = $node->start(); ok($rt_value == 1, "Restart Server"); -my ($cmdret, $stdout, $stderr) = $node->psql('postgres', 'CREATE EXTENSION pg_tde;', extra_params => ['-a']); +my ($cmdret, $stdout, $stderr) = $node->psql('postgres', 'CREATE EXTENSION IF NOT EXISTS pg_tde;', extra_params => ['-a']); ok($cmdret == 0, "CREATE PGTDE EXTENSION"); PGTDE::append_to_file($stdout); diff --git a/contrib/pg_tde/t/004_file_config.pl b/contrib/pg_tde/t/004_file_config.pl index 411aa7f3f0485..c0bc75272251f 100644 --- a/contrib/pg_tde/t/004_file_config.pl +++ b/contrib/pg_tde/t/004_file_config.pl @@ -30,7 +30,7 @@ my $rt_value = $node->start(); ok($rt_value == 1, "Start Server"); -my ($cmdret, $stdout, $stderr) = $node->psql('postgres', 'CREATE EXTENSION pg_tde;', extra_params => ['-a']); +my ($cmdret, $stdout, $stderr) = $node->psql('postgres', 'CREATE EXTENSION IF NOT EXISTS pg_tde;', extra_params => ['-a']); ok($cmdret == 0, "CREATE PGTDE EXTENSION"); PGTDE::append_to_file($stdout); diff --git a/contrib/pg_tde/t/005_multiple_extensions.pl b/contrib/pg_tde/t/005_multiple_extensions.pl index e8b499e3ba6ad..63d8c788013c4 100644 --- a/contrib/pg_tde/t/005_multiple_extensions.pl +++ b/contrib/pg_tde/t/005_multiple_extensions.pl @@ -41,7 +41,7 @@ ok($rt_value == 1, "Start Server"); # Create PGSM extension -my ($cmdret, $stdout, $stderr) = $node->psql('postgres', 'CREATE EXTENSION pg_stat_monitor;', extra_params => ['-a']); +my ($cmdret, $stdout, $stderr) = $node->psql('postgres', 'CREATE EXTENSION IF NOT EXISTS pg_stat_monitor;', extra_params => ['-a']); ok($cmdret == 0, "CREATE PGSM EXTENSION"); PGTDE::append_to_debug_file($stdout); @@ -50,39 +50,39 @@ PGTDE::append_to_debug_file($stdout); # Create pg_tde extension -($cmdret, $stdout, $stderr) = $node->psql('postgres', 'CREATE EXTENSION pg_tde;', extra_params => ['-a']); +($cmdret, $stdout, $stderr) = $node->psql('postgres', 'CREATE EXTENSION IF NOT EXISTS pg_tde;', extra_params => ['-a']); ok($cmdret == 0, "CREATE PGTDE EXTENSION"); PGTDE::append_to_file($stdout); # Create Other extensions -($cmdret, $stdout, $stderr) = $node->psql('postgres', 'CREATE EXTENSION IF NOT EXISTS pgaudit;', extra_params => ['-a']); +($cmdret, $stdout, $stderr) = $node->psql('postgres', 'CREATE EXTENSION IF NOT EXISTS IF NOT EXISTS pgaudit;', extra_params => ['-a']); ok($cmdret == 0, "CREATE pgaudit EXTENSION"); PGTDE::append_to_debug_file($stdout); -($cmdret, $stdout, $stderr) = $node->psql('postgres', 'CREATE EXTENSION IF NOT EXISTS set_user;', extra_params => ['-a']); +($cmdret, $stdout, $stderr) = $node->psql('postgres', 'CREATE EXTENSION IF NOT EXISTS IF NOT EXISTS set_user;', extra_params => ['-a']); ok($cmdret == 0, "CREATE set_user EXTENSION"); PGTDE::append_to_debug_file($stdout); -($cmdret, $stdout, $stderr) = $node->psql('postgres', 'CREATE EXTENSION IF NOT EXISTS pg_repack;', extra_params => ['-a']); +($cmdret, $stdout, $stderr) = $node->psql('postgres', 'CREATE EXTENSION IF NOT EXISTS IF NOT EXISTS pg_repack;', extra_params => ['-a']); ok($cmdret == 0, "CREATE pg_repack EXTENSION"); PGTDE::append_to_debug_file($stdout); -($cmdret, $stdout, $stderr) = $node->psql('postgres', "SET pgaudit.log = 'none'; CREATE EXTENSION IF NOT EXISTS postgis; SET pgaudit.log = 'all';", extra_params => ['-a']); +($cmdret, $stdout, $stderr) = $node->psql('postgres', "SET pgaudit.log = 'none'; CREATE EXTENSION IF NOT EXISTS IF NOT EXISTS postgis; SET pgaudit.log = 'all';", extra_params => ['-a']); ok($cmdret == 0, "CREATE postgis EXTENSION"); PGTDE::append_to_debug_file($stdout); -($cmdret, $stdout, $stderr) = $node->psql('postgres', 'CREATE EXTENSION IF NOT EXISTS postgis_raster;', extra_params => ['-a']); +($cmdret, $stdout, $stderr) = $node->psql('postgres', 'CREATE EXTENSION IF NOT EXISTS IF NOT EXISTS postgis_raster;', extra_params => ['-a']); ok($cmdret == 0, "CREATE postgis_raster EXTENSION"); PGTDE::append_to_debug_file($stdout); -($cmdret, $stdout, $stderr) = $node->psql('postgres', 'CREATE EXTENSION IF NOT EXISTS postgis_sfcgal;', extra_params => ['-a']); +($cmdret, $stdout, $stderr) = $node->psql('postgres', 'CREATE EXTENSION IF NOT EXISTS IF NOT EXISTS postgis_sfcgal;', extra_params => ['-a']); ok($cmdret == 0, "CREATE postgis_sfcgal EXTENSION"); PGTDE::append_to_debug_file($stdout); -($cmdret, $stdout, $stderr) = $node->psql('postgres', 'CREATE EXTENSION IF NOT EXISTS fuzzystrmatch;', extra_params => ['-a']); +($cmdret, $stdout, $stderr) = $node->psql('postgres', 'CREATE EXTENSION IF NOT EXISTS IF NOT EXISTS fuzzystrmatch;', extra_params => ['-a']); ok($cmdret == 0, "CREATE fuzzystrmatch EXTENSION"); PGTDE::append_to_debug_file($stdout); -($cmdret, $stdout, $stderr) = $node->psql('postgres', 'CREATE EXTENSION IF NOT EXISTS address_standardizer;', extra_params => ['-a']); +($cmdret, $stdout, $stderr) = $node->psql('postgres', 'CREATE EXTENSION IF NOT EXISTS IF NOT EXISTS address_standardizer;', extra_params => ['-a']); ok($cmdret == 0, "CREATE address_standardizer EXTENSION"); PGTDE::append_to_debug_file($stdout); -($cmdret, $stdout, $stderr) = $node->psql('postgres', 'CREATE EXTENSION IF NOT EXISTS address_standardizer_data_us;', extra_params => ['-a']); +($cmdret, $stdout, $stderr) = $node->psql('postgres', 'CREATE EXTENSION IF NOT EXISTS IF NOT EXISTS address_standardizer_data_us;', extra_params => ['-a']); ok($cmdret == 0, "CREATE address_standardizer_data_us EXTENSION"); PGTDE::append_to_debug_file($stdout); -($cmdret, $stdout, $stderr) = $node->psql('postgres', 'CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder;', extra_params => ['-a']); +($cmdret, $stdout, $stderr) = $node->psql('postgres', 'CREATE EXTENSION IF NOT EXISTS IF NOT EXISTS postgis_tiger_geocoder;', extra_params => ['-a']); ok($cmdret == 0, "CREATE postgis_tiger_geocoder EXTENSION"); PGTDE::append_to_debug_file($stdout); diff --git a/contrib/pg_tde/t/006_remote_vault_config.pl b/contrib/pg_tde/t/006_remote_vault_config.pl index 25d503f141190..a18ce214b5e4f 100644 --- a/contrib/pg_tde/t/006_remote_vault_config.pl +++ b/contrib/pg_tde/t/006_remote_vault_config.pl @@ -74,7 +74,7 @@ sub resp_url { $rt_value = $node->start(); ok($rt_value == 1, "Restart Server"); -my ($cmdret, $stdout, $stderr) = $node->psql('postgres', 'CREATE EXTENSION pg_tde;', extra_params => ['-a']); +my ($cmdret, $stdout, $stderr) = $node->psql('postgres', 'CREATE EXTENSION IF NOT EXISTS pg_tde;', extra_params => ['-a']); ok($cmdret == 0, "CREATE PGTDE EXTENSION"); PGTDE::append_to_file($stdout); diff --git a/contrib/pg_tde/t/007_access_control.pl b/contrib/pg_tde/t/007_access_control.pl index 2fdff8658e80f..db0410af1190d 100644 --- a/contrib/pg_tde/t/007_access_control.pl +++ b/contrib/pg_tde/t/007_access_control.pl @@ -25,8 +25,8 @@ my $rt_value = $node->start; ok($rt_value == 1, "Start Server"); -# CREATE EXTENSION and change out file permissions -my ($cmdret, $stdout, $stderr) = $node->psql('postgres', 'CREATE EXTENSION pg_tde;', extra_params => ['-a']); +# CREATE EXTENSION IF NOT EXISTS and change out file permissions +my ($cmdret, $stdout, $stderr) = $node->psql('postgres', 'CREATE EXTENSION IF NOT EXISTS pg_tde;', extra_params => ['-a']); ok($cmdret == 0, "CREATE PGTDE EXTENSION"); PGTDE::append_to_file($stdout); diff --git a/contrib/pg_tde/t/008_tde_heap.pl b/contrib/pg_tde/t/008_tde_heap.pl index 6db26aa25d35f..77b7098bcbb47 100644 --- a/contrib/pg_tde/t/008_tde_heap.pl +++ b/contrib/pg_tde/t/008_tde_heap.pl @@ -32,8 +32,8 @@ my $rt_value = $node->start; ok($rt_value == 1, "Start Server"); -# CREATE EXTENSION and change out file permissions -my ($cmdret, $stdout, $stderr) = $node->psql('postgres', 'CREATE EXTENSION pg_tde;', extra_params => ['-a']); +# CREATE EXTENSION IF NOT EXISTS and change out file permissions +my ($cmdret, $stdout, $stderr) = $node->psql('postgres', 'CREATE EXTENSION IF NOT EXISTS pg_tde;', extra_params => ['-a']); ok($cmdret == 0, "CREATE PGTDE EXTENSION"); PGTDE::append_to_file($stdout); diff --git a/contrib/pg_tde/t/009_key_rotate_tablespace.pl b/contrib/pg_tde/t/009_key_rotate_tablespace.pl index 4071f9c0103ec..5729e810b74e5 100644 --- a/contrib/pg_tde/t/009_key_rotate_tablespace.pl +++ b/contrib/pg_tde/t/009_key_rotate_tablespace.pl @@ -36,7 +36,7 @@ $stdout = $node->safe_psql('tbc', q{ -CREATE EXTENSION pg_tde; +CREATE EXTENSION IF NOT EXISTS pg_tde; SELECT pg_tde_add_key_provider_file('file-vault','/tmp/pg_tde_test_keyring.per'); SELECT pg_tde_set_principal_key('test-db-principal-key','file-vault'); diff --git a/contrib/pg_tde/t/010_alter_keyring.pl b/contrib/pg_tde/t/010_alter_keyring.pl index a6e8ea554977e..374c65c054d4b 100644 --- a/contrib/pg_tde/t/010_alter_keyring.pl +++ b/contrib/pg_tde/t/010_alter_keyring.pl @@ -25,8 +25,8 @@ my $rt_value = $node->start; ok($rt_value == 1, "Start Server"); -# CREATE EXTENSION and change out file permissions -my ($cmdret, $stdout, $stderr) = $node->psql('postgres', 'CREATE EXTENSION pg_tde;', extra_params => ['-a']); +# CREATE EXTENSION IF NOT EXISTS and change out file permissions +my ($cmdret, $stdout, $stderr) = $node->psql('postgres', 'CREATE EXTENSION IF NOT EXISTS pg_tde;', extra_params => ['-a']); ok($cmdret == 0, "CREATE PGTDE EXTENSION"); PGTDE::append_to_file($stdout); diff --git a/contrib/pg_tde/t/expected/001_basic.out b/contrib/pg_tde/t/expected/001_basic.out index ab41e680414dd..8c062b6f69795 100644 --- a/contrib/pg_tde/t/expected/001_basic.out +++ b/contrib/pg_tde/t/expected/001_basic.out @@ -1,4 +1,4 @@ -CREATE EXTENSION pg_tde; +CREATE EXTENSION IF NOT EXISTS pg_tde; SELECT extname, extversion FROM pg_extension WHERE extname = 'pg_tde'; pg_tde|1.0-beta2 -- server restart diff --git a/contrib/pg_tde/t/expected/002_rotate_key.out b/contrib/pg_tde/t/expected/002_rotate_key.out index 2f7751c3cbd43..8198586927073 100644 --- a/contrib/pg_tde/t/expected/002_rotate_key.out +++ b/contrib/pg_tde/t/expected/002_rotate_key.out @@ -1,4 +1,4 @@ -CREATE EXTENSION pg_tde; +CREATE EXTENSION IF NOT EXISTS pg_tde; -- server restart SELECT pg_tde_add_key_provider_file('file-vault','/tmp/pg_tde_test_keyring.per'); 1 diff --git a/contrib/pg_tde/t/expected/003_remote_config.out b/contrib/pg_tde/t/expected/003_remote_config.out index c6a75f18996f0..5da0a6afe3c8c 100644 --- a/contrib/pg_tde/t/expected/003_remote_config.out +++ b/contrib/pg_tde/t/expected/003_remote_config.out @@ -1,4 +1,4 @@ -CREATE EXTENSION pg_tde; +CREATE EXTENSION IF NOT EXISTS pg_tde; CREATE TABLE test_enc2(id SERIAL,k INTEGER,PRIMARY KEY (id)) USING tde_heap_basic; INSERT INTO test_enc2 (k) VALUES (5),(6); SELECT * FROM test_enc2 ORDER BY id ASC; diff --git a/contrib/pg_tde/t/expected/004_file_config.out b/contrib/pg_tde/t/expected/004_file_config.out index 7879231cdf632..57e7d2f22dfcf 100644 --- a/contrib/pg_tde/t/expected/004_file_config.out +++ b/contrib/pg_tde/t/expected/004_file_config.out @@ -1,4 +1,4 @@ -CREATE EXTENSION pg_tde; +CREATE EXTENSION IF NOT EXISTS pg_tde; CREATE TABLE test_enc1(id SERIAL,k INTEGER,PRIMARY KEY (id)) USING tde_heap_basic; INSERT INTO test_enc1 (k) VALUES (5),(6); SELECT * FROM test_enc1 ORDER BY id ASC; diff --git a/contrib/pg_tde/t/expected/005_multiple_extensions.out b/contrib/pg_tde/t/expected/005_multiple_extensions.out index 7879231cdf632..57e7d2f22dfcf 100644 --- a/contrib/pg_tde/t/expected/005_multiple_extensions.out +++ b/contrib/pg_tde/t/expected/005_multiple_extensions.out @@ -1,4 +1,4 @@ -CREATE EXTENSION pg_tde; +CREATE EXTENSION IF NOT EXISTS pg_tde; CREATE TABLE test_enc1(id SERIAL,k INTEGER,PRIMARY KEY (id)) USING tde_heap_basic; INSERT INTO test_enc1 (k) VALUES (5),(6); SELECT * FROM test_enc1 ORDER BY id ASC; diff --git a/contrib/pg_tde/t/expected/006_remote_vault_config.out b/contrib/pg_tde/t/expected/006_remote_vault_config.out index c6a75f18996f0..5da0a6afe3c8c 100644 --- a/contrib/pg_tde/t/expected/006_remote_vault_config.out +++ b/contrib/pg_tde/t/expected/006_remote_vault_config.out @@ -1,4 +1,4 @@ -CREATE EXTENSION pg_tde; +CREATE EXTENSION IF NOT EXISTS pg_tde; CREATE TABLE test_enc2(id SERIAL,k INTEGER,PRIMARY KEY (id)) USING tde_heap_basic; INSERT INTO test_enc2 (k) VALUES (5),(6); SELECT * FROM test_enc2 ORDER BY id ASC; diff --git a/contrib/pg_tde/t/expected/007_access_control.out b/contrib/pg_tde/t/expected/007_access_control.out index 6fdeed79307ec..4971cd16727aa 100644 --- a/contrib/pg_tde/t/expected/007_access_control.out +++ b/contrib/pg_tde/t/expected/007_access_control.out @@ -1,4 +1,4 @@ -CREATE EXTENSION pg_tde; +CREATE EXTENSION IF NOT EXISTS pg_tde; CREATE USER test_access; grant all ON database postgres TO test_access; -- server restart diff --git a/contrib/pg_tde/t/expected/008_tde_heap.out b/contrib/pg_tde/t/expected/008_tde_heap.out index 5b16269bd8445..867f714c9fb16 100644 --- a/contrib/pg_tde/t/expected/008_tde_heap.out +++ b/contrib/pg_tde/t/expected/008_tde_heap.out @@ -1,4 +1,4 @@ -CREATE EXTENSION pg_tde; +CREATE EXTENSION IF NOT EXISTS pg_tde; -- server restart CREATE TABLE test_enc1(id SERIAL,k VARCHAR(32),PRIMARY KEY (id)) USING tde_heap; INSERT INTO test_enc1 (k) VALUES ('foobar'),('barfoo'); diff --git a/contrib/pg_tde/t/expected/009_key_rotate_tablespace.out b/contrib/pg_tde/t/expected/009_key_rotate_tablespace.out index 463024ff021b6..8d304f04bb6b9 100644 --- a/contrib/pg_tde/t/expected/009_key_rotate_tablespace.out +++ b/contrib/pg_tde/t/expected/009_key_rotate_tablespace.out @@ -1,4 +1,4 @@ -CREATE EXTENSION pg_tde; +CREATE EXTENSION IF NOT EXISTS pg_tde; SELECT pg_tde_add_key_provider_file('file-vault','/tmp/pg_tde_test_keyring.per'); 1 SELECT pg_tde_set_principal_key('test-db-principal-key','file-vault'); @@ -16,7 +16,7 @@ SELECT * FROM country_table; 1|Japan|Asia 2|UK|Europe 3|USA|North America -CREATE EXTENSION pg_tde; +CREATE EXTENSION IF NOT EXISTS pg_tde; SELECT pg_tde_add_key_provider_file('file-vault','/tmp/pg_tde_test_keyring.per'); 1 SELECT pg_tde_set_principal_key('test-db-principal-key','file-vault'); diff --git a/contrib/pg_tde/t/expected/010_alter_keyring.out b/contrib/pg_tde/t/expected/010_alter_keyring.out index 0f6c37e058822..e64721a78c002 100644 --- a/contrib/pg_tde/t/expected/010_alter_keyring.out +++ b/contrib/pg_tde/t/expected/010_alter_keyring.out @@ -1,4 +1,4 @@ -CREATE EXTENSION pg_tde; +CREATE EXTENSION IF NOT EXISTS pg_tde; -- server restart CREATE TABLE test_enc(id SERIAL,k INTEGER,PRIMARY KEY (id)) USING tde_heap_basic; INSERT INTO test_enc (k) VALUES (5),(6); diff --git a/contrib/pgrowlocks/pgrowlocks.c b/contrib/pgrowlocks/pgrowlocks.c index adbc8279c3fdb..71af3d0d0216d 100644 --- a/contrib/pgrowlocks/pgrowlocks.c +++ b/contrib/pgrowlocks/pgrowlocks.c @@ -92,7 +92,7 @@ pgrowlocks(PG_FUNCTION_ARGS) (errcode(ERRCODE_WRONG_OBJECT_TYPE), errmsg("\"%s\" is not a table", RelationGetRelationName(rel)))); - else if (rel->rd_rel->relam != HEAP_TABLE_AM_OID) + else if (rel->rd_rel->relam != HEAP_TABLE_AM_OID && rel->rd_rel->relam != get_tde_table_am_oid()) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("only heap AM is supported"))); diff --git a/contrib/pgstattuple/pgstatapprox.c b/contrib/pgstattuple/pgstatapprox.c index c84c6423555e2..9b3946cc878e1 100644 --- a/contrib/pgstattuple/pgstatapprox.c +++ b/contrib/pgstattuple/pgstatapprox.c @@ -293,7 +293,7 @@ pgstattuple_approx_internal(Oid relid, FunctionCallInfo fcinfo) RelationGetRelationName(rel)), errdetail_relkind_not_supported(rel->rd_rel->relkind))); - if (rel->rd_rel->relam != HEAP_TABLE_AM_OID) + if (rel->rd_rel->relam != HEAP_TABLE_AM_OID && rel->rd_rel->relam != get_tde_table_am_oid()) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("only heap AM is supported"))); diff --git a/contrib/pgstattuple/pgstattuple.c b/contrib/pgstattuple/pgstattuple.c index 1d012233cbffe..be1be00404c88 100644 --- a/contrib/pgstattuple/pgstattuple.c +++ b/contrib/pgstattuple/pgstattuple.c @@ -327,7 +327,7 @@ pgstat_heap(Relation rel, FunctionCallInfo fcinfo) * Sequences always use heap AM, but they don't show that in the catalogs. */ if (rel->rd_rel->relkind != RELKIND_SEQUENCE && - rel->rd_rel->relam != HEAP_TABLE_AM_OID) + rel->rd_rel->relam != HEAP_TABLE_AM_OID && rel->rd_rel->relam != get_tde_table_am_oid()) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("only heap AM is supported"))); diff --git a/src/backend/access/table/tableam.c b/src/backend/access/table/tableam.c index e57a0b7ea310b..9242fd58dddf4 100644 --- a/src/backend/access/table/tableam.c +++ b/src/backend/access/table/tableam.c @@ -24,6 +24,7 @@ #include "access/syncscan.h" #include "access/tableam.h" #include "access/xact.h" +#include "commands/defrem.h" #include "optimizer/plancat.h" #include "port/pg_bitutils.h" #include "storage/bufmgr.h" @@ -756,3 +757,10 @@ table_block_relation_estimate_size(Relation rel, int32 *attr_widths, else *allvisfrac = (double) relallvisible / curpages; } + + +Oid +get_tde_table_am_oid(void) +{ + return get_table_am_oid("tde_heap", false); +} \ No newline at end of file diff --git a/src/bin/pg_upgrade/t/002_pg_upgrade.pl b/src/bin/pg_upgrade/t/002_pg_upgrade.pl index 17af2ce61efdc..573051c781584 100644 --- a/src/bin/pg_upgrade/t/002_pg_upgrade.pl +++ b/src/bin/pg_upgrade/t/002_pg_upgrade.pl @@ -15,6 +15,11 @@ use PostgreSQL::Test::AdjustUpgrade; use Test::More; +if (defined($ENV{TDE_MODE})) +{ + plan skip_all => "Running with TDE doesn't support special server starts yet"; +} + # Can be changed to test the other modes. my $mode = $ENV{PG_TEST_PG_UPGRADE_MODE} || '--copy'; diff --git a/src/include/access/tableam.h b/src/include/access/tableam.h index da661289c1fd4..c9bcc2cc0491c 100644 --- a/src/include/access/tableam.h +++ b/src/include/access/tableam.h @@ -2106,4 +2106,6 @@ extern const TableAmRoutine *GetTableAmRoutine(Oid amhandler); extern const TableAmRoutine *GetHeapamTableAmRoutine(void); +extern Oid get_tde_table_am_oid(void); + #endif /* TABLEAM_H */ diff --git a/src/test/recovery/t/027_stream_regress.pl b/src/test/recovery/t/027_stream_regress.pl index d1ae32d97d603..5178466fd0c4f 100644 --- a/src/test/recovery/t/027_stream_regress.pl +++ b/src/test/recovery/t/027_stream_regress.pl @@ -9,6 +9,11 @@ use Test::More; use File::Basename; +if (defined($ENV{TDE_MODE})) +{ + plan skip_all => "Running with TDE doesn't support special server starts yet"; +} + # Initialize primary node my $node_primary = PostgreSQL::Test::Cluster->new('primary'); $node_primary->init(allows_streaming => 1);