gooderp18绿色标准版
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

54 lines
1.6KB

  1. /* contrib/hstore/hstore--1.1--1.2.sql */
  2. -- complain if script is sourced in psql, rather than via ALTER EXTENSION
  3. \echo Use "ALTER EXTENSION hstore UPDATE TO '1.2'" to load this file. \quit
  4. -- A version of 1.1 was shipped with these objects mistakenly in 9.3.0.
  5. -- Therefore we only add them if we detect that they aren't already there and
  6. -- dependent on the extension.
  7. DO LANGUAGE plpgsql
  8. $$
  9. DECLARE
  10. my_schema pg_catalog.text := pg_catalog.quote_ident(pg_catalog.current_schema());
  11. old_path pg_catalog.text := pg_catalog.current_setting('search_path');
  12. BEGIN
  13. -- for safety, transiently set search_path to just pg_catalog+pg_temp
  14. PERFORM pg_catalog.set_config('search_path', 'pg_catalog, pg_temp', true);
  15. PERFORM 1
  16. FROM pg_proc p
  17. JOIN pg_depend d
  18. ON p.proname = 'hstore_to_json_loose'
  19. AND d.classid = 'pg_proc'::regclass
  20. AND d.objid = p.oid
  21. AND d.refclassid = 'pg_extension'::regclass
  22. JOIN pg_extension x
  23. ON d.refobjid = x.oid
  24. AND x.extname = 'hstore';
  25. IF NOT FOUND
  26. THEN
  27. PERFORM pg_catalog.set_config('search_path', old_path, true);
  28. CREATE FUNCTION hstore_to_json(hstore)
  29. RETURNS json
  30. AS 'MODULE_PATHNAME', 'hstore_to_json'
  31. LANGUAGE C IMMUTABLE STRICT;
  32. CREATE CAST (hstore AS json)
  33. WITH FUNCTION hstore_to_json(hstore);
  34. CREATE FUNCTION hstore_to_json_loose(hstore)
  35. RETURNS json
  36. AS 'MODULE_PATHNAME', 'hstore_to_json_loose'
  37. LANGUAGE C IMMUTABLE STRICT;
  38. END IF;
  39. PERFORM pg_catalog.set_config('search_path', old_path, true);
  40. END;
  41. $$;
上海开阖软件有限公司 沪ICP备12045867号-1