1 --Upgrade Script for 3.6.2 to 3.6.3
2 \set eg_version '''3.6.3'''
4 INSERT INTO config.upgrade_log (version, applied_to) VALUES ('3.6.3', :eg_version);
6 SELECT evergreen.upgrade_deps_block_check('1248', :eg_version);
14 -- We only want to mess with gist indexes in stock Evergreen.
15 -- If you've added your own convert them or don't as you see fit.
18 JOIN pg_class cls ON cls.oid=idx.indexrelid
19 JOIN pg_namespace sc ON sc.oid = cls.relnamespace
20 JOIN pg_class tab ON tab.oid=idx.indrelid
21 JOIN pg_attribute at ON (at.attnum = ANY(idx.indkey) AND at.attrelid = tab.oid)
22 JOIN pg_am am ON am.oid=cls.relam
23 WHERE am.amname = 'gist'
25 'authority_full_rec_index_vector_idx',
26 'authority_simple_heading_index_vector_idx',
27 'metabib_identifier_field_entry_index_vector_idx',
28 'metabib_combined_identifier_field_entry_index_vector_idx',
29 'metabib_title_field_entry_index_vector_idx',
30 'metabib_combined_title_field_entry_index_vector_idx',
31 'metabib_author_field_entry_index_vector_idx',
32 'metabib_combined_author_field_entry_index_vector_idx',
33 'metabib_subject_field_entry_index_vector_idx',
34 'metabib_combined_subject_field_entry_index_vector_idx',
35 'metabib_keyword_field_entry_index_vector_idx',
36 'metabib_combined_keyword_field_entry_index_vector_idx',
37 'metabib_series_field_entry_index_vector_idx',
38 'metabib_combined_series_field_entry_index_vector_idx',
39 'metabib_full_rec_index_vector_idx'
48 RAISE NOTICE 'Converting GIST indexes into GIN indexes...';
50 FOR ind IN SELECT sc.nspname AS sch, tab.relname AS tab, cls.relname AS idx, at.attname AS col
52 JOIN pg_class cls ON cls.oid=idx.indexrelid
53 JOIN pg_namespace sc ON sc.oid = cls.relnamespace
54 JOIN pg_class tab ON tab.oid=idx.indrelid
55 JOIN pg_attribute at ON (at.attnum = ANY(idx.indkey) AND at.attrelid = tab.oid)
56 JOIN pg_am am ON am.oid=cls.relam
57 WHERE am.amname = 'gist'
59 'authority_full_rec_index_vector_idx',
60 'authority_simple_heading_index_vector_idx',
61 'metabib_identifier_field_entry_index_vector_idx',
62 'metabib_combined_identifier_field_entry_index_vector_idx',
63 'metabib_title_field_entry_index_vector_idx',
64 'metabib_combined_title_field_entry_index_vector_idx',
65 'metabib_author_field_entry_index_vector_idx',
66 'metabib_combined_author_field_entry_index_vector_idx',
67 'metabib_subject_field_entry_index_vector_idx',
68 'metabib_combined_subject_field_entry_index_vector_idx',
69 'metabib_keyword_field_entry_index_vector_idx',
70 'metabib_combined_keyword_field_entry_index_vector_idx',
71 'metabib_series_field_entry_index_vector_idx',
72 'metabib_combined_series_field_entry_index_vector_idx',
73 'metabib_full_rec_index_vector_idx'
76 -- Move existing index out of the way so there's no difference between new databases and upgraded databases
77 EXECUTE FORMAT('ALTER INDEX %I.%I RENAME TO %I_gist', ind.sch, ind.idx, ind.idx);
79 -- Meet the new index, same as the old index (almost)
80 EXECUTE FORMAT('CREATE INDEX %I ON %I.%I USING GIN (%I)', ind.idx, ind.sch, ind.tab, ind.col);
82 -- And drop the old index
83 EXECUTE FORMAT('DROP INDEX %I.%I_gist', ind.sch, ind.idx);
85 tablist := tablist || ' ' || ind.sch || '.' || ind.tab || E'\n';
89 RAISE NOTICE E'Conversion Complete.\n\n You should run a VACUUM ANALYZE on the following tables soon:\n%', tablist;
95 SELECT evergreen.upgrade_deps_block_check('1258', :eg_version);
97 UPDATE config.metabib_field
98 SET xpath = '//*[@tag=''260'' or @tag=''264''][1]'
99 WHERE id = 52 AND xpath = '//*[@tag=''260'']';
103 -- Update auditor tables to catch changes to source tables.
104 -- Can be removed/skipped if there were no schema changes.
105 SELECT auditor.update_auditors();