Super-linter: Fails for SQL files with LOCK TABLES query

Created on 9 Feb 2021  路  8Comments  路  Source: github/super-linter

Describe the bug

The following exception was thrown when running against a DB dump with LOCK TABLES

Error: Unable to categorise query: lock tables `reg_association` write;. The query must start with one of Alter,Begin,Call,Create,Declare,Delete,Delimiter,Drop,Else,End,From,Having,If,Insert,Join,Leave,Limit,Replace,Return,Select,Set,Show,Truncate,Update,Use,Where,CommentHash,CommentDash,CommentMultiLineStart,CommentMultiLineEnd,Newline,WindowsNewline
    at Object.categorise (/node_modules/sql-lint/dist/src/lexer/lexer.js:14:11)
    at /node_modules/sql-lint/dist/src/checker/checkerRunner.js:38:42
    at Array.forEach (<anonymous>)
    at CheckerRunner.run (/node_modules/sql-lint/dist/src/checker/checkerRunner.js:35:20)
    at Object.<anonymous> (/node_modules/sql-lint/dist/src/main.js:86:8)
    at Module._compile (internal/modules/cjs/loader.js:1201:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1221:10)
    at Module.load (internal/modules/cjs/loader.js:1050:32)
    at Function.Module._load (internal/modules/cjs/loader.js:938:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)

Expected behavior

Recognize LOCK TABLES query

Steps to Reproduce






  1. Scan a SQL dump which has LOCK TABLES in it

Super Linter version

super-linter:v3.14.5

Stalled bug enhancement

Most helpful comment

@withinfocus All done!
Cutting a release later today

All 8 comments

Hello! I'm the dev for sql-lint. What dialect are you using, MySQL?
Is it possible you can send me the entire query?

I've not looked at the codebase for a while but I think I'll need to add in support for this.

Hi @joereynolds

Here is a part of the file scanned by the super linter.

-- MySQL dump 10.13  Distrib 8.0.20, for macos10.15 (x86_64)
--
-- Host: 192.168.113.11    Database: AM_DB
-- ------------------------------------------------------
-- Server version   5.7.30

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!50503 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;

--
-- Table structure for table `AM_ALERT_EMAILLIST`
--

DROP TABLE IF EXISTS `AM_ALERT_EMAILLIST`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `AM_ALERT_EMAILLIST` (
  `EMAIL_LIST_ID` int(11) NOT NULL AUTO_INCREMENT,
  `USER_NAME` varchar(255) NOT NULL,
  `STAKE_HOLDER` varchar(100) NOT NULL,
  PRIMARY KEY (`EMAIL_LIST_ID`,`USER_NAME`,`STAKE_HOLDER`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `AM_ALERT_EMAILLIST`
--

LOCK TABLES `AM_ALERT_EMAILLIST` WRITE;
/*!40000 ALTER TABLE `AM_ALERT_EMAILLIST` DISABLE KEYS */;
/*!40000 ALTER TABLE `AM_ALERT_EMAILLIST` ENABLE KEYS */;
UNLOCK TABLES;

Hope this helps. Let me know if you need more info. Thank you for looking into this.

This issue has been automatically marked as stale because it has not had recent activity.
It will be closed in 14 days if no further activity occurs.
Thank you for your contributions.

If you think this issue should stay open, please remove the O: stale 馃 label or comment on the issue.

@joereynolds Did you have time to look into this?

Hey @VimukthiPerera,

There is some work ongoing in a branch to make sql-lint more intelligent for individual DB systems (postgres, Mysql etc...)
I'm hoping to continue it soon but I'm quite busy with "life things" at the moment. Sorry I can't be any more help than that!

@joereynolds @VimukthiPerera As soon as the update is pushed to the individual linter, we will pull in the newer version and all should be good. Thanks all!

@admiralAwkbar this landed yesterday: https://github.com/joereynolds/sql-lint/releases/tag/v0.0.16

Can we get this pulled in?

@withinfocus All done!
Cutting a release later today

Was this page helpful?
0 / 5 - 0 ratings

Related issues

patrick-compass picture patrick-compass  路  4Comments

IlanCosman picture IlanCosman  路  4Comments

MuhaddiMu picture MuhaddiMu  路  3Comments

thehesiod picture thehesiod  路  4Comments

sergey-muntyanu picture sergey-muntyanu  路  4Comments