From 3df4de6a915fb1ff3247a5f322bef2752fa9b227 Mon Sep 17 00:00:00 2001 From: martinko Date: Mon, 17 Mar 2014 16:21:50 +0100 Subject: [PATCH] londiste.upgrade_schema: fixed condition_timing vs action_timing --- .../functions/londiste.upgrade_schema.sql | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/sql/londiste/functions/londiste.upgrade_schema.sql b/sql/londiste/functions/londiste.upgrade_schema.sql index 508daea2..c0cf2986 100644 --- a/sql/londiste/functions/londiste.upgrade_schema.sql +++ b/sql/londiste/functions/londiste.upgrade_schema.sql @@ -3,8 +3,10 @@ create or replace function londiste.upgrade_schema() returns int4 as $$ -- updates table structure if necessary declare + pgversion int; cnt int4 = 0; begin + show server_version_num into pgversion; -- table_info: check (dropped_ddl is null or merge_state in ('in-copy', 'catching-up')) perform 1 from information_schema.check_constraints @@ -29,11 +31,19 @@ begin end if; -- table_info: change trigger timing - perform 1 from information_schema.triggers - where event_object_schema = 'londiste' - and event_object_table = 'table_info' - and trigger_name = 'table_info_trigger_sync' - and condition_timing = 'AFTER'; + if pgversion >= 90100 then + perform 1 from information_schema.triggers + where event_object_schema = 'londiste' + and event_object_table = 'table_info' + and trigger_name = 'table_info_trigger_sync' + and action_timing = 'AFTER'; + else + perform 1 from information_schema.triggers + where event_object_schema = 'londiste' + and event_object_table = 'table_info' + and trigger_name = 'table_info_trigger_sync' + and condition_timing = 'AFTER'; + end if; if found then drop trigger table_info_trigger_sync on londiste.table_info; create trigger table_info_trigger_sync before delete on londiste.table_info -- 2.39.5