summaryrefslogtreecommitdiff
path: root/contrib/dblink/sql
diff options
context:
space:
mode:
authorNoah Misch2014-07-22 15:01:03 +0000
committerNoah Misch2014-07-22 15:01:03 +0000
commitd7cdf6ee36adeac9233678fb8f2a112e6678a770 (patch)
tree1f2c0717280027b904f6bfa92569ce0534b7e157 /contrib/dblink/sql
parent24e786f056c0bf009815813de1d7f58ee09f554e (diff)
Diagnose incompatible OpenLDAP versions during build and test.
With OpenLDAP versions 2.4.24 through 2.4.31, inclusive, PostgreSQL backends can crash at exit. Raise a warning during "configure" based on the compile-time OpenLDAP version number, and test the crash scenario in the dblink test suite. Back-patch to 9.0 (all supported versions).
Diffstat (limited to 'contrib/dblink/sql')
-rw-r--r--contrib/dblink/sql/.gitignore1
-rw-r--r--contrib/dblink/sql/dblink.sql28
2 files changed, 29 insertions, 0 deletions
diff --git a/contrib/dblink/sql/.gitignore b/contrib/dblink/sql/.gitignore
new file mode 100644
index 00000000000..d17507846d0
--- /dev/null
+++ b/contrib/dblink/sql/.gitignore
@@ -0,0 +1 @@
+/paths.sql
diff --git a/contrib/dblink/sql/dblink.sql b/contrib/dblink/sql/dblink.sql
index 30396ed9844..500c684a91c 100644
--- a/contrib/dblink/sql/dblink.sql
+++ b/contrib/dblink/sql/dblink.sql
@@ -65,6 +65,34 @@ SELECT *
FROM dblink('SELECT * FROM foo') AS t(a int, b text, c text[])
WHERE t.a > 7;
+-- The first-level connection's backend will crash on exit given OpenLDAP
+-- [2.4.24, 2.4.31]. We won't see evidence of any crash until the victim
+-- process terminates and the postmaster responds. If process termination
+-- entails writing a core dump, that can take awhile. Wait for the process to
+-- vanish. At that point, the postmaster has called waitpid() on the crashed
+-- process, and it will accept no new connections until it has reinitialized
+-- the cluster. (We can't exploit pg_stat_activity, because the crash happens
+-- after the backend updates shared memory to reflect its impending exit.)
+DO $pl$
+DECLARE
+ detail text;
+BEGIN
+ PERFORM wait_pid(crash_pid)
+ FROM dblink('dbname=contrib_regression', $$
+ SELECT pg_backend_pid() FROM dblink(
+ 'service=test_ldap dbname=contrib_regression',
+ -- This string concatenation is a hack to shoehorn a
+ -- set_pgservicefile call into the SQL statement.
+ 'SELECT 1' || set_pgservicefile('pg_service.conf')
+ ) t(c int)
+ $$) AS t(crash_pid int);
+EXCEPTION WHEN OTHERS THEN
+ GET STACKED DIAGNOSTICS detail = PG_EXCEPTION_DETAIL;
+ -- Expected error in a non-LDAP build.
+ IF NOT detail LIKE 'syntax error in service file%' THEN RAISE; END IF;
+END
+$pl$;
+
-- create a persistent connection
SELECT dblink_connect('dbname=contrib_regression');