summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'src/test')
-rw-r--r--src/test/regress/expected/misc_functions.out11
-rw-r--r--src/test/regress/regress.c29
-rw-r--r--src/test/regress/sql/misc_functions.sql8
3 files changed, 48 insertions, 0 deletions
diff --git a/src/test/regress/expected/misc_functions.out b/src/test/regress/expected/misc_functions.out
index 106dedb519a..543fbbe09c5 100644
--- a/src/test/regress/expected/misc_functions.out
+++ b/src/test/regress/expected/misc_functions.out
@@ -903,3 +903,14 @@ SELECT gist_stratnum_common(3);
18
(1 row)
+-- relpath tests
+CREATE FUNCTION test_relpath()
+ RETURNS void
+ AS :'regresslib'
+ LANGUAGE C;
+SELECT test_relpath();
+ test_relpath
+--------------
+
+(1 row)
+
diff --git a/src/test/regress/regress.c b/src/test/regress/regress.c
index 667d9835148..ed4a7937331 100644
--- a/src/test/regress/regress.c
+++ b/src/test/regress/regress.c
@@ -36,6 +36,7 @@
#include "optimizer/plancat.h"
#include "parser/parse_coerce.h"
#include "port/atomics.h"
+#include "postmaster/postmaster.h" /* for MAX_BACKENDS */
#include "storage/spin.h"
#include "utils/array.h"
#include "utils/builtins.h"
@@ -1208,3 +1209,31 @@ binary_coercible(PG_FUNCTION_ARGS)
PG_RETURN_BOOL(IsBinaryCoercible(srctype, targettype));
}
+
+/*
+ * Sanity checks for functions in relpath.h
+ */
+PG_FUNCTION_INFO_V1(test_relpath);
+Datum
+test_relpath(PG_FUNCTION_ARGS)
+{
+ RelPathStr rpath;
+
+ /*
+ * Verify that PROCNUMBER_CHARS and MAX_BACKENDS stay in sync.
+ * Unfortunately I don't know how to express that in a way suitable for a
+ * static assert.
+ */
+ if ((int) ceil(log10(MAX_BACKENDS)) != PROCNUMBER_CHARS)
+ elog(WARNING, "mismatch between MAX_BACKENDS and PROCNUMBER_CHARS");
+
+ /* verify that the max-length relpath is generated ok */
+ rpath = GetRelationPath(OID_MAX, OID_MAX, OID_MAX, MAX_BACKENDS - 1,
+ INIT_FORKNUM);
+
+ if (strlen(rpath.str) != REL_PATH_STR_MAXLEN)
+ elog(WARNING, "maximum length relpath is if length %zu instead of %zu",
+ strlen(rpath.str), REL_PATH_STR_MAXLEN);
+
+ PG_RETURN_VOID();
+}
diff --git a/src/test/regress/sql/misc_functions.sql b/src/test/regress/sql/misc_functions.sql
index 753a0f41c03..aaebb298330 100644
--- a/src/test/regress/sql/misc_functions.sql
+++ b/src/test/regress/sql/misc_functions.sql
@@ -403,3 +403,11 @@ DROP FUNCTION explain_mask_costs(text, bool, bool, bool, bool);
-- test stratnum support functions
SELECT gist_stratnum_common(7);
SELECT gist_stratnum_common(3);
+
+
+-- relpath tests
+CREATE FUNCTION test_relpath()
+ RETURNS void
+ AS :'regresslib'
+ LANGUAGE C;
+SELECT test_relpath();