0002-Tests-for-dblink-with-covering-indexes.patch
application/octet-stream
Filename: 0002-Tests-for-dblink-with-covering-indexes.patch
Type: application/octet-stream
Part: 1
Message:
Re: WIP: Covering + unique indexes.
Patch
Format: format-patch
Series: patch 0002
Subject: Tests for dblink with covering indexes
| File | + | − |
|---|---|---|
| contrib/dblink/expected/dblink.out | 14 | 0 |
| contrib/dblink/sql/dblink.sql | 10 | 0 |
From 1da6e4e871d3a29999a1cb1f96c136e0b796b276 Mon Sep 17 00:00:00 2001
From: Andrey Borodin <amborodin@acm.org>
Date: Wed, 28 Mar 2018 14:04:11 +0500
Subject: [PATCH 2/3] Tests for dblink with covering indexes
---
contrib/dblink/expected/dblink.out | 14 ++++++++++++++
contrib/dblink/sql/dblink.sql | 10 ++++++++++
2 files changed, 24 insertions(+)
diff --git a/contrib/dblink/expected/dblink.out b/contrib/dblink/expected/dblink.out
index 511691e57f..76e922c9f3 100644
--- a/contrib/dblink/expected/dblink.out
+++ b/contrib/dblink/expected/dblink.out
@@ -22,6 +22,20 @@ FROM dblink_get_pkey('foo');
2 | f2
(2 rows)
+-- list the primary key fields with covering index
+CREATE TABLE foo_covering(f1 int, f2 text, f3 text[]);
+CREATE UNIQUE INDEX foo_covering_index on foo_covering (f1,f2) INCLUDE(f3);
+ALTER TABLE foo_covering ADD CONSTRAINT covering_pkey PRIMARY KEY USING INDEX foo_covering_index;
+NOTICE: ALTER TABLE / ADD CONSTRAINT USING INDEX will rename index "foo_covering_index" to "covering_pkey"
+SELECT *
+FROM dblink_get_pkey('foo_covering');
+ position | colname
+----------+---------
+ 1 | f1
+ 2 | f2
+(2 rows)
+
+DROP TABLE foo_covering;
-- build an insert statement based on a local tuple,
-- replacing the primary key values with new ones
SELECT dblink_build_sql_insert('foo','1 2',2,'{"0", "a"}','{"99", "xyz"}');
diff --git a/contrib/dblink/sql/dblink.sql b/contrib/dblink/sql/dblink.sql
index b093fa6722..b31912a312 100644
--- a/contrib/dblink/sql/dblink.sql
+++ b/contrib/dblink/sql/dblink.sql
@@ -21,6 +21,16 @@ INSERT INTO foo VALUES (9,'j','{"a9","b9","c9"}');
SELECT *
FROM dblink_get_pkey('foo');
+-- list the primary key fields with covering index
+CREATE TABLE foo_covering(f1 int, f2 text, f3 text[]);
+CREATE UNIQUE INDEX foo_covering_index on foo_covering (f1,f2) INCLUDE(f3);
+ALTER TABLE foo_covering ADD CONSTRAINT covering_pkey PRIMARY KEY USING INDEX foo_covering_index;
+
+SELECT *
+FROM dblink_get_pkey('foo_covering');
+
+DROP TABLE foo_covering;
+
-- build an insert statement based on a local tuple,
-- replacing the primary key values with new ones
SELECT dblink_build_sql_insert('foo','1 2',2,'{"0", "a"}','{"99", "xyz"}');
--
2.14.3 (Apple Git-98)