2.0
[hstore.git] / hstore--1.1--1.2.sql
1 /* contrib/hstore/hstore--1.1--1.2.sql */
2
3 -- complain if script is sourced in psql, rather than via ALTER EXTENSION
4 \echo Use "ALTER EXTENSION hstore UPDATE TO '1.2'" to load this file. \quit
5
6
7 -- A version of 1.1 was shipped with these objects mistakenly in 9.3.0.
8 -- Therefore we only add them if we detect that they aren't already there and
9 -- dependent on the extension.
10
11 DO LANGUAGE plpgsql
12
13 $$
14
15 BEGIN
16
17    PERFORM 1
18    FROM pg_proc p
19        JOIN  pg_depend d
20           ON p.proname = 'hstore_to_json_loose'
21             AND d.classid = 'pg_proc'::regclass
22             AND d.objid = p.oid
23             AND d.refclassid = 'pg_extension'::regclass
24        JOIN pg_extension x
25           ON d.refobjid = x.oid
26             AND  x.extname = 'hstore';
27
28    IF NOT FOUND
29    THEN
30
31         CREATE FUNCTION hstore_to_json(hstore)
32         RETURNS json
33         AS 'MODULE_PATHNAME', 'hstore_to_json'
34         LANGUAGE C IMMUTABLE STRICT;
35
36         CREATE CAST (hstore AS json)
37           WITH FUNCTION hstore_to_json(hstore);
38
39         CREATE FUNCTION hstore_to_json_loose(hstore)
40         RETURNS json
41         AS 'MODULE_PATHNAME', 'hstore_to_json_loose'
42         LANGUAGE C IMMUTABLE STRICT;
43
44    END IF;
45
46 END;
47
48 $$;