gooderp18绿色标准版
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

82 lines
2.5KB

  1. DO $do$
  2. declare
  3. isedb bool;
  4. createstmt text;
  5. begin
  6. isedb = (SELECT version() LIKE '%EnterpriseDB%');
  7. createstmt := $create_stmt$
  8. CREATE OR REPLACE FUNCTION pldbg_get_target_info(signature text, targetType "char") returns targetinfo AS $$
  9. SELECT p.oid AS target,
  10. pronamespace AS schema,
  11. pronargs::int4 AS nargs,
  12. -- The returned argtypes column is of type oidvector, but unlike
  13. -- proargtypes, it's supposed to include OUT params. So we
  14. -- essentially have to return proallargtypes, converted to an
  15. -- oidvector. There is no oid[] -> oidvector cast, so we have to
  16. -- do it via text.
  17. CASE WHEN proallargtypes IS NOT NULL THEN
  18. translate(proallargtypes::text, ',{}', ' ')::oidvector
  19. ELSE
  20. proargtypes
  21. END AS argtypes,
  22. proname AS targetname,
  23. proargmodes AS argmodes,
  24. proargnames AS proargnames,
  25. prolang AS targetlang,
  26. quote_ident(nspname) || '.' || quote_ident(proname) AS fqname,
  27. proretset AS returnsset,
  28. prorettype AS returntype,
  29. $create_stmt$;
  30. -- Add the three EDB-columns to the query (as dummies if we're installing
  31. -- to PostgreSQL)
  32. IF isedb THEN
  33. createstmt := createstmt ||
  34. $create_stmt$
  35. p.protype='0' AS isfunc,
  36. CASE WHEN n.nspparent <> 0 THEN n.oid ELSE 0 END AS pkg,
  37. edb_get_func_defvals(p.oid) AS argdefvals
  38. $create_stmt$;
  39. ELSE
  40. createstmt := createstmt ||
  41. $create_stmt$
  42. 't'::bool AS isfunc,
  43. 0::oid AS pkg,
  44. NULL::text[] AS argdefvals
  45. $create_stmt$;
  46. END IF;
  47. -- End of conditional part
  48. createstmt := createstmt ||
  49. $create_stmt$
  50. FROM pg_proc p, pg_namespace n
  51. WHERE p.pronamespace = n.oid
  52. AND p.oid = $1::oid
  53. -- We used to support querying by function name or trigger name/oid as well,
  54. -- but that was never used in the client, so the support for that has been
  55. -- removed. The targeType argument remains as a legacy of that. You're
  56. -- expected to pass 'o' as target type, but it doesn't do anything.
  57. AND $2 = 'o'
  58. $$ LANGUAGE SQL;
  59. $create_stmt$;
  60. execute createstmt;
  61. -- Add a couple of EDB specific functions
  62. IF isedb THEN
  63. CREATE OR REPLACE FUNCTION edb_oid_debug(functionOID oid) RETURNS integer AS $$
  64. select pldbg_oid_debug($1);
  65. $$ LANGUAGE SQL;
  66. CREATE OR REPLACE FUNCTION pldbg_get_pkg_cons(packageOID oid) RETURNS oid AS $$
  67. select oid from pg_proc where pronamespace=$1 and proname='cons';
  68. $$ LANGUAGE SQL;
  69. END IF;
  70. end;
  71. $do$;
上海开阖软件有限公司 沪ICP备12045867号-1