From 12cf8c372d80e38fd11c4c30b141bd51282053b7 Mon Sep 17 00:00:00 2001
From: Nicolas Williams <nico@cryptonector.com>
Date: Tue, 3 Oct 2017 12:25:05 -0500
Subject: [PATCH 4/4] Add always_deferred to information_schema??

---
 src/backend/catalog/information_schema.sql | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/backend/catalog/information_schema.sql b/src/backend/catalog/information_schema.sql
index 4fa230c..5b05843 100644
--- a/src/backend/catalog/information_schema.sql
+++ b/src/backend/catalog/information_schema.sql
@@ -894,11 +894,13 @@ CREATE VIEW domain_constraints AS
            CAST(CASE WHEN condeferrable THEN 'YES' ELSE 'NO' END
              AS yes_or_no) AS is_deferrable,
            CAST(CASE WHEN condeferred THEN 'YES' ELSE 'NO' END
-             AS yes_or_no) AS initially_deferred
+             AS yes_or_no) AS initially_deferred,
 	   /*
 	    * XXX Can we add is_always_deferred here?  Are there
 	    * standards considerations?
 	    */
+           CAST(CASE WHEN conalwaysdeferred THEN 'YES' ELSE 'NO' END
+             AS yes_or_no) AS always_deferred
     FROM pg_namespace rs, pg_namespace n, pg_constraint con, pg_type t
     WHERE rs.oid = con.connamespace
           AND n.oid = t.typnamespace
@@ -1782,11 +1784,13 @@ CREATE VIEW table_constraints AS
            CAST(CASE WHEN c.condeferrable THEN 'YES' ELSE 'NO' END AS yes_or_no)
              AS is_deferrable,
            CAST(CASE WHEN c.condeferred THEN 'YES' ELSE 'NO' END AS yes_or_no)
-             AS initially_deferred
+             AS initially_deferred,
 	   /*
 	    * XXX Can we add is_always_deferred here?  Are there
 	    * standards considerations?
 	    */
+           CAST(CASE WHEN c.conalwaysdeferred THEN 'YES' ELSE 'NO' END AS yes_or_no)
+             AS always_deferred
 
     FROM pg_namespace nc,
          pg_namespace nr,
@@ -1815,7 +1819,8 @@ CREATE VIEW table_constraints AS
            CAST(r.relname AS sql_identifier) AS table_name,
            CAST('CHECK' AS character_data) AS constraint_type,
            CAST('NO' AS yes_or_no) AS is_deferrable,
-           CAST('NO' AS yes_or_no) AS initially_deferred
+           CAST('NO' AS yes_or_no) AS initially_deferred,
+           CAST('NO' AS yes_or_no) AS always_deferred
 
     FROM pg_namespace nr,
          pg_class r,
-- 
2.7.4

