mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-22 04:06:00 +00:00
fixed load postgres schema on Azure #906
This commit is contained in:
@@ -56,7 +56,12 @@ class Analyser extends DatabaseAnalyser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
createQuery(resFileName, typeFields, replacements = {}) {
|
createQuery(resFileName, typeFields, replacements = {}) {
|
||||||
const query = super.createQuery(sql[resFileName], typeFields, replacements);
|
const query = super.createQuery(sql[resFileName], typeFields, {
|
||||||
|
...replacements,
|
||||||
|
$typeAggFunc: this.driver.dialect.stringAgg ? 'string_agg' : 'max',
|
||||||
|
$typeAggParam: this.driver.dialect.stringAgg ? ", '|'" : '',
|
||||||
|
$md5Function: this.dialect?.isFipsComplianceOn ? 'LENGTH' : 'MD5',
|
||||||
|
});
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -138,10 +143,7 @@ class Analyser extends DatabaseAnalyser {
|
|||||||
: null;
|
: null;
|
||||||
|
|
||||||
this.feedback({ analysingMessage: 'Loading routines' });
|
this.feedback({ analysingMessage: 'Loading routines' });
|
||||||
const routines = await this.analyserQuery('routines', ['procedures', 'functions'], {
|
const routines = await this.analyserQuery('routines', ['procedures', 'functions']);
|
||||||
$typeAggFunc: this.driver.dialect.stringAgg ? 'string_agg' : 'max',
|
|
||||||
$typeAggParam: this.driver.dialect.stringAgg ? ", '|'" : '',
|
|
||||||
});
|
|
||||||
|
|
||||||
this.feedback({ analysingMessage: 'Loading indexes' });
|
this.feedback({ analysingMessage: 'Loading indexes' });
|
||||||
const indexes = this.driver.__analyserInternals.skipIndexes
|
const indexes = this.driver.__analyserInternals.skipIndexes
|
||||||
|
|||||||
@@ -182,6 +182,13 @@ const drivers = driverBases.map(driverBase => ({
|
|||||||
const { rows } = await this.query(dbhan, 'SELECT version()');
|
const { rows } = await this.query(dbhan, 'SELECT version()');
|
||||||
const { version } = rows[0];
|
const { version } = rows[0];
|
||||||
|
|
||||||
|
let isFipsComplianceOn = false;
|
||||||
|
try {
|
||||||
|
await this.query(dbhan, "SELECT MD5('test')");
|
||||||
|
} catch (err) {
|
||||||
|
isFipsComplianceOn = true;
|
||||||
|
}
|
||||||
|
|
||||||
const isCockroach = version.toLowerCase().includes('cockroachdb');
|
const isCockroach = version.toLowerCase().includes('cockroachdb');
|
||||||
const isRedshift = version.toLowerCase().includes('redshift');
|
const isRedshift = version.toLowerCase().includes('redshift');
|
||||||
const isPostgres = !isCockroach && !isRedshift;
|
const isPostgres = !isCockroach && !isRedshift;
|
||||||
@@ -207,6 +214,7 @@ const drivers = driverBases.map(driverBase => ({
|
|||||||
isRedshift,
|
isRedshift,
|
||||||
versionMajor,
|
versionMajor,
|
||||||
versionMinor,
|
versionMinor,
|
||||||
|
isFipsComplianceOn,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
async readQuery(dbhan, sql, structure) {
|
async readQuery(dbhan, sql, structure) {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ module.exports = `
|
|||||||
select
|
select
|
||||||
matviewname as "pure_name",
|
matviewname as "pure_name",
|
||||||
schemaname as "schema_name",
|
schemaname as "schema_name",
|
||||||
md5(definition) as "hash_code"
|
$md5Function(definition) as "hash_code"
|
||||||
from
|
from
|
||||||
pg_catalog.pg_matviews WHERE schemaname NOT LIKE 'pg_%' AND schemaname =SCHEMA_NAME_CONDITION
|
pg_catalog.pg_matviews WHERE schemaname NOT LIKE 'pg_%' AND schemaname =SCHEMA_NAME_CONDITION
|
||||||
`;
|
`;
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ select
|
|||||||
matviewname as "pure_name",
|
matviewname as "pure_name",
|
||||||
schemaname as "schema_name",
|
schemaname as "schema_name",
|
||||||
definition as "definition",
|
definition as "definition",
|
||||||
md5(definition) as "hash_code"
|
$md5Function(definition) as "hash_code"
|
||||||
from
|
from
|
||||||
pg_catalog.pg_matviews WHERE schemaname NOT LIKE 'pg_%'
|
pg_catalog.pg_matviews WHERE schemaname NOT LIKE 'pg_%'
|
||||||
and ('matviews:' || schemaname || '.' || matviewname) =OBJECT_ID_CONDITION
|
and ('matviews:' || schemaname || '.' || matviewname) =OBJECT_ID_CONDITION
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ module.exports = `
|
|||||||
select
|
select
|
||||||
routine_name as "pure_name",
|
routine_name as "pure_name",
|
||||||
routine_schema as "schema_name",
|
routine_schema as "schema_name",
|
||||||
md5(routine_definition) as "hash_code",
|
$md5Function(routine_definition) as "hash_code",
|
||||||
routine_type as "object_type"
|
routine_type as "object_type"
|
||||||
from
|
from
|
||||||
information_schema.routines where routine_schema !~ '^_timescaledb_'
|
information_schema.routines where routine_schema !~ '^_timescaledb_'
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ select
|
|||||||
routine_name as "pure_name",
|
routine_name as "pure_name",
|
||||||
routine_schema as "schema_name",
|
routine_schema as "schema_name",
|
||||||
max(routine_definition) as "definition",
|
max(routine_definition) as "definition",
|
||||||
max(md5(routine_definition)) as "hash_code",
|
max($md5Function(routine_definition)) as "hash_code",
|
||||||
routine_type as "object_type",
|
routine_type as "object_type",
|
||||||
$typeAggFunc(data_type $typeAggParam) as "data_type",
|
$typeAggFunc(data_type $typeAggParam) as "data_type",
|
||||||
max(external_language) as "language"
|
max(external_language) as "language"
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
module.exports = `
|
module.exports = `
|
||||||
select infoTables.table_schema as "schema_name", infoTables.table_name as "pure_name",
|
select infoTables.table_schema as "schema_name", infoTables.table_name as "pure_name",
|
||||||
(
|
(
|
||||||
select md5(string_agg(
|
select $md5Function(string_agg(
|
||||||
infoColumns.column_name || '|' || infoColumns.data_type || '|' || infoColumns.is_nullable::varchar(255) || '|' || coalesce(infoColumns.character_maximum_length, -1)::varchar(255)
|
infoColumns.column_name || '|' || infoColumns.data_type || '|' || infoColumns.is_nullable::varchar(255) || '|' || coalesce(infoColumns.character_maximum_length, -1)::varchar(255)
|
||||||
|| '|' || coalesce(infoColumns.numeric_precision, -1)::varchar(255) ,
|
|| '|' || coalesce(infoColumns.numeric_precision, -1)::varchar(255) ,
|
||||||
',' order by infoColumns.ordinal_position
|
',' order by infoColumns.ordinal_position
|
||||||
@@ -10,7 +10,7 @@ select infoTables.table_schema as "schema_name", infoTables.table_name as "pure_
|
|||||||
where infoColumns.table_schema = infoTables.table_schema and infoColumns.table_name = infoTables.table_name
|
where infoColumns.table_schema = infoTables.table_schema and infoColumns.table_name = infoTables.table_name
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
select md5(string_agg(
|
select $md5Function(string_agg(
|
||||||
infoConstraints.constraint_name || '|' || infoConstraints.constraint_type ,
|
infoConstraints.constraint_name || '|' || infoConstraints.constraint_type ,
|
||||||
',' order by infoConstraints.constraint_name
|
',' order by infoConstraints.constraint_name
|
||||||
)) as "hash_code_constraints"
|
)) as "hash_code_constraints"
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ module.exports = `
|
|||||||
select
|
select
|
||||||
table_name as "pure_name",
|
table_name as "pure_name",
|
||||||
table_schema as "schema_name",
|
table_schema as "schema_name",
|
||||||
md5(view_definition) as "hash_code"
|
$md5Function(view_definition) as "hash_code"
|
||||||
from
|
from
|
||||||
information_schema.views where table_schema != 'information_schema' and table_schema != 'pg_catalog' and table_schema !~ '^_timescaledb_' and table_schema =SCHEMA_NAME_CONDITION
|
information_schema.views where table_schema != 'information_schema' and table_schema != 'pg_catalog' and table_schema !~ '^_timescaledb_' and table_schema =SCHEMA_NAME_CONDITION
|
||||||
`;
|
`;
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ select
|
|||||||
table_name as "pure_name",
|
table_name as "pure_name",
|
||||||
table_schema as "schema_name",
|
table_schema as "schema_name",
|
||||||
view_definition as "create_sql",
|
view_definition as "create_sql",
|
||||||
md5(view_definition) as "hash_code"
|
$md5Function(view_definition) as "hash_code"
|
||||||
from
|
from
|
||||||
information_schema.views
|
information_schema.views
|
||||||
where table_schema !~ '^_timescaledb_' and table_schema =SCHEMA_NAME_CONDITION
|
where table_schema !~ '^_timescaledb_' and table_schema =SCHEMA_NAME_CONDITION
|
||||||
|
|||||||
@@ -220,6 +220,7 @@ const postgresDriver = {
|
|||||||
version.versionMajor != null &&
|
version.versionMajor != null &&
|
||||||
version.versionMinor != null &&
|
version.versionMinor != null &&
|
||||||
(version.versionMajor > 9 || version.versionMajor == 9 || version.versionMinor >= 3),
|
(version.versionMajor > 9 || version.versionMajor == 9 || version.versionMinor >= 3),
|
||||||
|
isFipsComplianceOn: version.isFipsComplianceOn,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
return dialect;
|
return dialect;
|
||||||
|
|||||||
Reference in New Issue
Block a user