0003-lo-Add-test-suite.patch
text/plain
Filename: 0003-lo-Add-test-suite.patch
Type: text/plain
Part: 2
Message:
additional contrib test suites
Patch
Format: format-patch
Series: patch 0003
Subject: lo: Add test suite
| File | + | − |
|---|---|---|
| contrib/lo/expected/lo.out | 42 | 0 |
| contrib/lo/.gitignore | 4 | 0 |
| contrib/lo/Makefile | 2 | 0 |
| contrib/lo/sql/lo.sql | 25 | 0 |
| doc/src/sgml/lo.sgml | 1 | 1 |
From fb23fda4933b5b78fbfc9a834fdd5e7352d96ae7 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter_e@gmx.net>
Date: Fri, 11 Aug 2017 21:04:04 -0400
Subject: [PATCH 3/7] lo: Add test suite
---
contrib/lo/.gitignore | 4 ++++
contrib/lo/Makefile | 2 ++
contrib/lo/expected/lo.out | 42 ++++++++++++++++++++++++++++++++++++++++++
contrib/lo/sql/lo.sql | 25 +++++++++++++++++++++++++
doc/src/sgml/lo.sgml | 2 +-
5 files changed, 74 insertions(+), 1 deletion(-)
create mode 100644 contrib/lo/.gitignore
create mode 100644 contrib/lo/expected/lo.out
create mode 100644 contrib/lo/sql/lo.sql
diff --git a/contrib/lo/.gitignore b/contrib/lo/.gitignore
new file mode 100644
index 0000000000..5dcb3ff972
--- /dev/null
+++ b/contrib/lo/.gitignore
@@ -0,0 +1,4 @@
+# Generated subdirectories
+/log/
+/results/
+/tmp_check/
diff --git a/contrib/lo/Makefile b/contrib/lo/Makefile
index 71f0cb0d24..bd4fd6b72d 100644
--- a/contrib/lo/Makefile
+++ b/contrib/lo/Makefile
@@ -6,6 +6,8 @@ EXTENSION = lo
DATA = lo--1.1.sql lo--1.0--1.1.sql lo--unpackaged--1.0.sql
PGFILEDESC = "lo - management for large objects"
+REGRESS = lo
+
ifdef USE_PGXS
PG_CONFIG = pg_config
PGXS := $(shell $(PG_CONFIG) --pgxs)
diff --git a/contrib/lo/expected/lo.out b/contrib/lo/expected/lo.out
new file mode 100644
index 0000000000..f7104aee3f
--- /dev/null
+++ b/contrib/lo/expected/lo.out
@@ -0,0 +1,42 @@
+CREATE EXTENSION lo;
+CREATE TABLE image (title text, raster lo);
+CREATE TRIGGER t_raster BEFORE UPDATE OR DELETE ON image
+ FOR EACH ROW EXECUTE PROCEDURE lo_manage(raster);
+SELECT lo_create(43213);
+ lo_create
+-----------
+ 43213
+(1 row)
+
+SELECT lo_create(43214);
+ lo_create
+-----------
+ 43214
+(1 row)
+
+INSERT INTO image (title, raster) VALUES ('beautiful image', 43213);
+SELECT lo_get(43213);
+ lo_get
+--------
+ \x
+(1 row)
+
+SELECT lo_get(43214);
+ lo_get
+--------
+ \x
+(1 row)
+
+UPDATE image SET raster = 43214 WHERE title = 'beautiful image';
+SELECT lo_get(43213);
+ERROR: large object 43213 does not exist
+SELECT lo_get(43214);
+ lo_get
+--------
+ \x
+(1 row)
+
+DELETE FROM image;
+SELECT lo_get(43214);
+ERROR: large object 43214 does not exist
+DROP TABLE image;
diff --git a/contrib/lo/sql/lo.sql b/contrib/lo/sql/lo.sql
new file mode 100644
index 0000000000..34ba6f00ec
--- /dev/null
+++ b/contrib/lo/sql/lo.sql
@@ -0,0 +1,25 @@
+CREATE EXTENSION lo;
+
+CREATE TABLE image (title text, raster lo);
+
+CREATE TRIGGER t_raster BEFORE UPDATE OR DELETE ON image
+ FOR EACH ROW EXECUTE PROCEDURE lo_manage(raster);
+
+SELECT lo_create(43213);
+SELECT lo_create(43214);
+
+INSERT INTO image (title, raster) VALUES ('beautiful image', 43213);
+
+SELECT lo_get(43213);
+SELECT lo_get(43214);
+
+UPDATE image SET raster = 43214 WHERE title = 'beautiful image';
+
+SELECT lo_get(43213);
+SELECT lo_get(43214);
+
+DELETE FROM image;
+
+SELECT lo_get(43214);
+
+DROP TABLE image;
diff --git a/doc/src/sgml/lo.sgml b/doc/src/sgml/lo.sgml
index cd4ed6030b..9c318f1c98 100644
--- a/doc/src/sgml/lo.sgml
+++ b/doc/src/sgml/lo.sgml
@@ -67,7 +67,7 @@ <title>How to Use It</title>
</para>
<programlisting>
-CREATE TABLE image (title TEXT, raster lo);
+CREATE TABLE image (title text, raster lo);
CREATE TRIGGER t_raster BEFORE UPDATE OR DELETE ON image
FOR EACH ROW EXECUTE PROCEDURE lo_manage(raster);
--
2.14.0