mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-26 17:55:59 +00:00
postgre function analyser
This commit is contained in:
@@ -54,6 +54,13 @@ const engines = [
|
|||||||
drop1: 'DROP PROCEDURE obj1',
|
drop1: 'DROP PROCEDURE obj1',
|
||||||
drop2: 'DROP PROCEDURE obj2',
|
drop2: 'DROP PROCEDURE obj2',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
type: 'functions',
|
||||||
|
create1: 'CREATE FUNCTION obj1() returns int LANGUAGE plpgsql AS $$ declare res integer; begin select count(*) into res from t1; return res; end; $$',
|
||||||
|
create2: 'CREATE FUNCTION obj2() returns int LANGUAGE plpgsql AS $$ declare res integer; begin select count(*) into res from t2; return res; end; $$',
|
||||||
|
drop1: 'DROP FUNCTION obj1',
|
||||||
|
drop2: 'DROP FUNCTION obj2',
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -139,6 +139,7 @@ class Analyser extends DatabaseAnalyser {
|
|||||||
.filter(x => x.object_type == 'FUNCTION')
|
.filter(x => x.object_type == 'FUNCTION')
|
||||||
.map(func => ({
|
.map(func => ({
|
||||||
objectId: `functions:${func.schema_name}.${func.pure_name}`,
|
objectId: `functions:${func.schema_name}.${func.pure_name}`,
|
||||||
|
createSql: `CREATE FUNCTION "${func.schema_name}"."${func.pure_name}"() RETURNS ${func.data_type} LANGUAGE ${func.language}\nAS\n$$\n${func.definition}\n$$`,
|
||||||
pureName: func.pure_name,
|
pureName: func.pure_name,
|
||||||
schemaName: func.schema_name,
|
schemaName: func.schema_name,
|
||||||
contentHash: func.hash_code,
|
contentHash: func.hash_code,
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ select
|
|||||||
routine_definition as "definition",
|
routine_definition as "definition",
|
||||||
md5(routine_definition) as "hash_code",
|
md5(routine_definition) as "hash_code",
|
||||||
routine_type as "object_type",
|
routine_type as "object_type",
|
||||||
|
data_type as "data_type",
|
||||||
external_language as "language"
|
external_language as "language"
|
||||||
from
|
from
|
||||||
information_schema.routines where routine_schema != 'information_schema' and routine_schema != 'pg_catalog'
|
information_schema.routines where routine_schema != 'information_schema' and routine_schema != 'pg_catalog'
|
||||||
|
|||||||
Reference in New Issue
Block a user