Routine privilege restoration fixes

This commit is contained in:
Juan Ferrer 2021-10-27 12:56:25 +02:00
parent 8c83e79bd7
commit f1f1f00b5d
2 changed files with 12 additions and 8 deletions

View File

@ -185,7 +185,11 @@ class Push {
const routines = []; const routines = [];
for (const change of changes) for (const change of changes)
if (change.isRoutine) if (change.isRoutine)
routines.push([change.schema, change.name]); routines.push([
change.schema,
change.name,
change.type.name
]);
if (routines.length) { if (routines.length) {
await conn.query( await conn.query(
@ -195,7 +199,7 @@ class Push {
`CREATE TEMPORARY TABLE tProcsPriv `CREATE TEMPORARY TABLE tProcsPriv
ENGINE = MEMORY ENGINE = MEMORY
SELECT * FROM mysql.procs_priv SELECT * FROM mysql.procs_priv
WHERE (Db, Routine_name) IN (?)`, WHERE (Db, Routine_name, Routine_type) IN (?)`,
[routines] [routines]
); );
} }
@ -212,7 +216,7 @@ class Push {
const scapedSchema = pushConn.escapeId(change.schema, true); const scapedSchema = pushConn.escapeId(change.schema, true);
if (exists) { if (exists) {
if (change.type.name = 'VIEW') if (change.type.name === 'VIEW')
await pushConn.query(`USE ${scapedSchema}`); await pushConn.query(`USE ${scapedSchema}`);
await this.queryFromFile(pushConn, `routines/${change.path}.sql`); await this.queryFromFile(pushConn, `routines/${change.path}.sql`);
@ -221,9 +225,9 @@ class Push {
await conn.query( await conn.query(
`INSERT IGNORE INTO mysql.procs_priv `INSERT IGNORE INTO mysql.procs_priv
SELECT * FROM tProcsPriv SELECT * FROM tProcsPriv
WHERE Db = ? WHERE Db = ?
AND Routine_name = ? AND Routine_name = ?
AND Routine_type = ?`, AND Routine_type = ?`,
[change.schema, change.name, change.type.name] [change.schema, change.name, change.type.name]
); );
} }
@ -456,7 +460,7 @@ class Routine {
schema, schema,
name, name,
fullName: `${schema}.${name}`, fullName: `${schema}.${name}`,
isRoutine: routineTypes.has(type.abbr) isRoutine: routineTypes.has(type.name)
}); });
} }
} }

View File

@ -1,6 +1,6 @@
{ {
"name": "myvc", "name": "myvc",
"version": "1.2.2", "version": "1.2.3",
"author": "Verdnatura Levante SL", "author": "Verdnatura Levante SL",
"description": "MySQL Version Control", "description": "MySQL Version Control",
"license": "GPL-3.0", "license": "GPL-3.0",