diff --git a/integration-tests/engines.js b/integration-tests/engines.js index c2dd972f5..be09a4f43 100644 --- a/integration-tests/engines.js +++ b/integration-tests/engines.js @@ -418,20 +418,29 @@ end;$$`, dbSnapshotBySeconds: true, setNullDefaultInsteadOfDrop: true, skipIncrementalAnalysis: true, - objects: [views], + objects: [ + views, + { + type: 'procedures', + create1: 'CREATE PROCEDURE ~obj1 AS BEGIN SELECT ~id FROM ~t1 END', + create2: 'CREATE PROCEDURE ~obj2 AS BEGIN SELECT ~id FROM ~t2 END', + drop1: 'DROP PROCEDURE ~obj1', + drop2: 'DROP PROCEDURE ~obj2', + }, + ], }, ]; const filterLocal = [ // filter local testing - 'MySQL', + '-MySQL', '-MariaDB', '-PostgreSQL', '-SQL Server', '-SQLite', '-CockroachDB', '-ClickHouse', - '-Oracle', + 'Oracle', ]; const enginesPostgre = engines.filter(x => x.label == 'PostgreSQL'); diff --git a/plugins/dbgate-plugin-oracle/src/backend/Analyser.js b/plugins/dbgate-plugin-oracle/src/backend/Analyser.js index 223364e4c..bee40d641 100644 --- a/plugins/dbgate-plugin-oracle/src/backend/Analyser.js +++ b/plugins/dbgate-plugin-oracle/src/backend/Analyser.js @@ -171,14 +171,14 @@ class Analyser extends DatabaseAnalyser { objectId: `procedures:${proc.pure_name}`, pureName: proc.pure_name, // schemaName: proc.schema_name, - createSql: `CREATE PROCEDURE "${proc.pure_name}"() LANGUAGE ${proc.language}\nAS\n$$\n${proc.definition}\n$$`, + createSql: `CREATE ${proc.source_code}`, contentHash: proc.hash_code, })), functions: routines.rows .filter(x => x.object_type == 'FUNCTION') .map(func => ({ objectId: `functions:${func.pure_name}`, - createSql: `CREATE FUNCTION "${func.pure_name}"() RETURNS ${func.data_type} LANGUAGE ${func.language}\nAS\n$$\n${func.definition}\n$$`, + createSql: `CREATE ${func.source_code}`, pureName: func.pure_name, // schemaName: func.schema_name, contentHash: func.hash_code, diff --git a/plugins/dbgate-plugin-oracle/src/backend/sql/routines.js b/plugins/dbgate-plugin-oracle/src/backend/sql/routines.js index 2f290386c..a16f21dee 100644 --- a/plugins/dbgate-plugin-oracle/src/backend/sql/routines.js +++ b/plugins/dbgate-plugin-oracle/src/backend/sql/routines.js @@ -1,41 +1,10 @@ module.exports = ` -select - routine_name as "pure_name", - -- routine_schema as "schema_name", - routine_definition as "definition", - ora_hash(routine_definition) as "hash_code", - routine_type as "object_type", - 'fixme_data_type' as "data_type", - 'fixme_external_language' as "language" -from (select - sys_context('userenv', 'DB_NAME') routine_catalog, - sys_context('userenv', 'DB_NAME') specific_catalog, - ap.owner specific_schema, - ap.owner routine_schema, - decode( ap.procedure_name, null, ap.object_name || ap.procedure_name, ap.procedure_name ) specific_name, - decode( ap.procedure_name, null, ap.object_name || ap.procedure_name, ap.procedure_name ) routine_name, - ao.object_type routine_type, - decode(impltypeowner, null, to_char(null), SYS_CONTEXT('userenv', 'DB_NAME')) type_udt_catalog, - --to_clob(get_proc_text(ap.owner, ap.object_name, ao.object_type, 32767)) routine_body, - 'fixme_routine_body.' || ap.owner || '.' || decode( ap.procedure_name, null, ap.object_name || ap.procedure_name, ap.procedure_name ) routine_body, - --to_clob(get_proc_text(ap.owner, ap.object_name, ao.object_type, 4000)) routine_definition, - 'fixme_routine_definition.' || ap.owner || '.' || decode( ap.procedure_name, null, ap.object_name || ap.procedure_name, ap.procedure_name ) routine_definition, - sys_context('userenv', 'DB_NAME') character_set_catalog, - 'SYS' character_set_schema, - sys_context('userenv', 'DB_NAME') collation_catalog, - 'SYS' collation_schema, - deterministic is_deterministic, - pipelined is_pipelined , - aggregate is_aggregate, - authid is_definer - from - all_procedures ap, - all_objects ao - where - ap.owner = '$owner' and - ap.owner = ao.owner and - ap.object_name = ao.object_name and - ao.object_type in ('PACKAGE', 'PROCEDURE', 'FUNCTION') - and ao.object_name =OBJECT_ID_CONDITION - ) routines +SELECT + name as "pure_name", + type as "object_type", + LISTAGG(text, '') WITHIN GROUP (ORDER BY line) AS "source_code", + ora_hash(LISTAGG(text, '') WITHIN GROUP (ORDER BY line)) AS "hash_code" +FROM all_source +WHERE type in ('FUNCTION', 'PROCEDURE') AND OWNER = '$owner' +GROUP BY name, type `;