1/* contrib/cube/cube--1.3--1.4.sql */
2
3-- complain if script is sourced in psql, rather than via ALTER EXTENSION
4\echo Use "ALTER EXTENSION cube UPDATE TO '1.4'" to load this file. \quit
5
6--
7-- Get rid of unnecessary compress and decompress support functions.
8--
9-- To be allowed to drop the opclass entry for a support function,
10-- we must change the entry's dependency type from 'internal' to 'auto',
11-- as though it were a loose member of the opfamily rather than being
12-- bound into a particular opclass.  There's no SQL command for that,
13-- so fake it with a manual update on pg_depend.
14--
15DO LANGUAGE plpgsql
16$$
17DECLARE
18  my_schema pg_catalog.text := pg_catalog.quote_ident(pg_catalog.current_schema());
19  old_path pg_catalog.text := pg_catalog.current_setting('search_path');
20BEGIN
21-- for safety, transiently set search_path to just pg_catalog+pg_temp
22PERFORM pg_catalog.set_config('search_path', 'pg_catalog, pg_temp', true);
23
24UPDATE pg_catalog.pg_depend
25SET deptype = 'a'
26WHERE classid = 'pg_catalog.pg_amproc'::pg_catalog.regclass
27  AND objid =
28    (SELECT objid
29     FROM pg_catalog.pg_depend
30     WHERE classid = 'pg_catalog.pg_amproc'::pg_catalog.regclass
31       AND refclassid = 'pg_catalog.pg_proc'::pg_catalog.regclass
32       AND (refobjid = (my_schema || '.g_cube_compress(pg_catalog.internal)')::pg_catalog.regprocedure))
33  AND refclassid = 'pg_catalog.pg_opclass'::pg_catalog.regclass
34  AND deptype = 'i';
35
36UPDATE pg_catalog.pg_depend
37SET deptype = 'a'
38WHERE classid = 'pg_catalog.pg_amproc'::pg_catalog.regclass
39  AND objid =
40    (SELECT objid
41     FROM pg_catalog.pg_depend
42     WHERE classid = 'pg_catalog.pg_amproc'::pg_catalog.regclass
43       AND refclassid = 'pg_catalog.pg_proc'::pg_catalog.regclass
44       AND (refobjid = (my_schema || '.g_cube_decompress(pg_catalog.internal)')::pg_catalog.regprocedure))
45  AND refclassid = 'pg_catalog.pg_opclass'::pg_catalog.regclass
46  AND deptype = 'i';
47
48PERFORM pg_catalog.set_config('search_path', old_path, true);
49END
50$$;
51
52ALTER OPERATOR FAMILY gist_cube_ops USING gist drop function 3 (cube);
53ALTER EXTENSION cube DROP function g_cube_compress(pg_catalog.internal);
54DROP FUNCTION g_cube_compress(pg_catalog.internal);
55
56ALTER OPERATOR FAMILY gist_cube_ops USING gist drop function 4 (cube);
57ALTER EXTENSION cube DROP function g_cube_decompress(pg_catalog.internal);
58DROP FUNCTION g_cube_decompress(pg_catalog.internal);
59