zap fastmode as IN =OBJECT_ID_CONDITION does not work

This commit is contained in:
Rinie Kervel 2022-10-13 12:05:08 +02:00
parent 51952ecfdd
commit 64168577ab
3 changed files with 28 additions and 52 deletions

View File

@ -221,6 +221,8 @@ class Analyser extends DatabaseAnalyser {
}
async _getFastSnapshot() {
return null;
const tableModificationsQueryData = this.driver.dialect.stringAgg
? await this.driver.query(this.pool, this.createQuery('tableModifications'))
: null;
@ -239,12 +241,14 @@ class Analyser extends DatabaseAnalyser {
contentHash: `${x.hash_code_columns}-${x.hash_code_constraints}`,
}))
: null,
views: viewModificationsQueryData.rows.map(x => ({
views: viewModificationsQueryData
? viewModificationsQueryData.rows.map(x => ({
objectId: `views:${x.schema_name}.${x.pure_name}`,
pureName: x.pure_name,
schemaName: x.schema_name,
contentHash: x.hash_code,
})),
}))
: undefined,
matviews: matviewModificationsQueryData
? matviewModificationsQueryData.rows.map(x => ({
objectId: `matviews:${x.schema_name}.${x.pure_name}`,

View File

@ -14,11 +14,6 @@ pg.types.setTypeParser(1184, 'text', val => val); // timestamp
*/
function extractOracleColumns(result) {
console.log('result', result);
//console.log('result.name', result[0].name);
console.log('result.map', result.map(fld => ({
columnName: fld.name.toLowerCase(),
})));
if (!result /*|| !result.fields */) return [];
const res = result.map(fld => ({
columnName: fld.name.toLowerCase(),
@ -113,18 +108,18 @@ const drivers = driverBases.map(driverBase => ({
};
}
try {
console.log('sql', sql);
//console.log('sql', sql);
const res = await client.execute(sql);
console.log('res', res);
//console.log('res', res);
const columns = extractOracleColumns(res.metaData);
console.log('columns', columns);
//console.log('columns', columns);
return { rows: (res.rows || []).map(row => zipDataRow(row, columns)), columns };
}
catch(err) {
console.log('Error query', err);
console.log('Error query', err, sql);
}
finally {
console.log('finally', sql);
//console.log('finally', sql);
}
},
@ -135,14 +130,14 @@ finally {
rowMode: 'array',
});
*/
console.log('queryStream', sql);
//console.log('queryStream', sql);
const query = client.queryStream(sql);
// const consumeStream = new Promise((resolve, reject) => {
let rowcount = 0;
let wasHeader = false;
query.on('metadata', row => {
console.log('metadata', row);
//console.log('metadata', row);
if (!wasHeader) {
columns = extractOracleColumns(row);
if (columns && columns.length > 0) {
@ -155,7 +150,7 @@ finally {
});
query.on('data', row => {
console.log('DATA', row);
//console.log('DATA', row);
options.row(zipDataRow(row, columns));
});
@ -194,16 +189,17 @@ finally {
options.done();
});
query.on('close', function() {
// console.log("stream 'close' event");
//console.log("stream 'close' event");
// The underlying ResultSet has been closed, so the connection can now
// be closed, if desired. Note: do not close connections on 'end'.
resolve(rowcount);
//resolve(rowcount);
;
});
//});
//const numrows = await consumeStream;
//console.log('Rows selected: ' + numrows);
client.query(query);
//client.query(query);
},
async getVersion(client) {
//const { rows } = await this.query(client, "SELECT banner as version FROM v$version WHERE banner LIKE 'Oracle%'");
@ -243,7 +239,7 @@ finally {
rowMode: 'array',
});
*/
console.log('readQuery', sql, structure);
//console.log('readQuery', sql, structure);
const query = await client.queryStream(sql);
let wasHeader = false;

View File

@ -1,36 +1,12 @@
module.exports = `
select
table_name as "pure_name",
table_schema as "schema_name",
table_name as "create_sql",
ora_hash(view_definition, 3768421) as "hash_code" -- fixme
select avv.*,
ora_hash("create_sql") as "hash_code"
from (select
sys_context('userenv', 'DB_NAME') table_catalog,
owner table_schema,
view_name table_name,
text view_definition,
'VIEW' table_type,
(select max( case when uuc.updatable = 'YES' or
uuc.deletable = 'YES' or
uuc.insertable = 'YES' then 'YES' else 'NO' end
)
from
user_updatable_columns uuc
where
uuc.owner = av.owner and
uuc.table_name = av.view_name
) is_updatable,
decode(
(select 1
from
all_constraints ac
where
ac.owner = av.owner and
ac.table_name = av.view_name and
ac.constraint_type = 'V'), 1, 'CASCADE', 'NONE') check_option
from
all_views av
where text is not null
) views
where table_name =OBJECT_ID_CONDITION
view_name as "pure_name",
owner as "schema_name",
SUBSTR(text_vc, 1, 3900) AS "create_sql"
from all_views av
where text_vc is not null
) avv
where "pure_name" =OBJECT_ID_CONDITION
`;