From 0d107e7efcbe191ce7f16d9f79cb16344566bbb8 Mon Sep 17 00:00:00 2001 From: Amul Sul Date: Thu, 16 Nov 2017 19:11:18 +0530 Subject: [PATCH 2/3] WIP-regression-tests --- src/test/regress/expected/func_sanity.out | 35 +++++++++++++++++++++++++++++++ src/test/regress/parallel_schedule | 3 +++ src/test/regress/sql/func_sanity.sql | 28 +++++++++++++++++++++++++ 3 files changed, 66 insertions(+) create mode 100644 src/test/regress/expected/func_sanity.out create mode 100644 src/test/regress/sql/func_sanity.sql diff --git a/src/test/regress/expected/func_sanity.out b/src/test/regress/expected/func_sanity.out new file mode 100644 index 0000000000..0f85e4a1a1 --- /dev/null +++ b/src/test/regress/expected/func_sanity.out @@ -0,0 +1,35 @@ +-- +-- FUNC_SANITY +-- Sanity checks for common errors in making error +-- in function argument handling. +-- +-- **************** satisfies_hash_partition **************** +CREATE TABLE hash_parted(a int, b int) PARTITION BY HASH(a, b); +CREATE TABLE list_parted(a int, b int) PARTITION BY LIST(a); +-- Parent relation id, modulus and the remainder should not be null +SELECT satisfies_hash_partition(NULL, NULL, NULL, NULL, NULL); +ERROR: parent relation id, modulus and the remainder cannot be null +SELECT satisfies_hash_partition('hash_parted'::regclass, NULL, NULL, NULL, NULL); +ERROR: parent relation id, modulus and the remainder cannot be null +SELECT satisfies_hash_partition('hash_parted'::regclass, 5, NULL, NULL, NULL); +ERROR: parent relation id, modulus and the remainder cannot be null +-- Remainder is greater than modulus +SELECT satisfies_hash_partition('hash_parted'::regclass, 5, 6, NULL, NULL); +ERROR: invalid hash partition bound +-- Invalid modulus +SELECT satisfies_hash_partition('hash_parted'::regclass, 0, 0, NULL, NULL); +ERROR: invalid hash partition bound +-- Invalid parent relation id +SELECT satisfies_hash_partition(0, 6, 0, NULL, NULL); +ERROR: invalid hash partition bound +-- Parent is not a hash partitioned table. +SELECT satisfies_hash_partition('pg_class'::regclass, 7, 6, NULL, NULL); +ERROR: "pg_class" is not a hash partitioned table +SELECT satisfies_hash_partition('list_parted'::regclass, 6, 2, NULL, NULL); +ERROR: "list_parted" is not a hash partitioned table +-- Less column values than partition column +SELECT satisfies_hash_partition('hash_parted'::regclass, 6, 2, NULL); +ERROR: value missing for partition column 2 +-- Clean up. +DROP TABLE hash_parted; +DROP TABLE list_parted; diff --git a/src/test/regress/parallel_schedule b/src/test/regress/parallel_schedule index aa5e6af621..4786bb0895 100644 --- a/src/test/regress/parallel_schedule +++ b/src/test/regress/parallel_schedule @@ -123,3 +123,6 @@ test: event_trigger # run stats by itself because its delay may be insufficient under heavy load test: stats + +# sanity check for catalog functions +test: func_sanity diff --git a/src/test/regress/sql/func_sanity.sql b/src/test/regress/sql/func_sanity.sql new file mode 100644 index 0000000000..803dbdd691 --- /dev/null +++ b/src/test/regress/sql/func_sanity.sql @@ -0,0 +1,28 @@ +-- +-- FUNC_SANITY +-- Sanity checks for common errors in making error +-- in function argument handling. +-- + +-- **************** satisfies_hash_partition **************** +CREATE TABLE hash_parted(a int, b int) PARTITION BY HASH(a, b); +CREATE TABLE list_parted(a int, b int) PARTITION BY LIST(a); +-- Parent relation id, modulus and the remainder should not be null +SELECT satisfies_hash_partition(NULL, NULL, NULL, NULL, NULL); +SELECT satisfies_hash_partition('hash_parted'::regclass, NULL, NULL, NULL, NULL); +SELECT satisfies_hash_partition('hash_parted'::regclass, 5, NULL, NULL, NULL); +-- Remainder is greater than modulus +SELECT satisfies_hash_partition('hash_parted'::regclass, 5, 6, NULL, NULL); +-- Invalid modulus +SELECT satisfies_hash_partition('hash_parted'::regclass, 0, 0, NULL, NULL); +-- Invalid parent relation id +SELECT satisfies_hash_partition(0, 6, 0, NULL, NULL); +-- Parent is not a hash partitioned table. +SELECT satisfies_hash_partition('pg_class'::regclass, 7, 6, NULL, NULL); +SELECT satisfies_hash_partition('list_parted'::regclass, 6, 2, NULL, NULL); +-- Less column values than partition column +SELECT satisfies_hash_partition('hash_parted'::regclass, 6, 2, NULL); + +-- Clean up. +DROP TABLE hash_parted; +DROP TABLE list_parted; -- 2.14.1