Module: ArSchemaFunctions::Extensions::PostgreSQLAdapter

Defined in:
lib/ar_schema_functions/extensions.rb

Instance Method Summary collapse

Instance Method Details

#functionsObject



41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/ar_schema_functions/extensions.rb', line 41

def functions
  # From https://dataedo.com/kb/query/postgresql/list-user-defined-functions
  exec_query(<<~SQL.squish, 'SCHEMA').cast_values
    select case when l.lanname = 'internal' then p.prosrc
                else pg_get_functiondef(p.oid)
                end as definition
    from pg_proc p
    left join pg_namespace n on p.pronamespace = n.oid
    left join pg_language l on p.prolang = l.oid
    where n.nspname not in ('pg_catalog', 'information_schema')#{' '}
      and l.lanname != 'c'
    order by definition;
  SQL
end