mtxr / vscode-sqltools

Database management for VSCode
https://vscode-sqltools.mteixeira.dev?utm_source=github&utm_medium=homepage-link
MIT License
1.43k stars 290 forks source link

SQLITE_MISUSE error only when using "run on active connection" because of comments #1324

Open Albro3459 opened 2 months ago

Albro3459 commented 2 months ago

Describe the bug Simply clicking "run on active connection" with sqltools and sqtools sqllite gives SQLITE_MISUSE error in the SQL console. Also in Output tab for SQL Tools: [1713520001212] INFO (ext): EXECUTING COMMAND => sqltools.executeQuery [1713520001212] INFO (ext): EXECUTING COMMAND => sqltools.getConnections [1713520001213] INFO (ls): REQUEST RECEIVED => connection/GetConnectionsRequest [1713520001213] INFO (ext): EXECUTING COMMAND => sqltools.getConnections [1713520001213] INFO (ls): REQUEST RECEIVED => connection/GetConnectionsRequest [1713520001716] INFO (ext): EXECUTING COMMAND => sqltools.getConnections [1713520001717] INFO (ls): REQUEST RECEIVED => connection/GetConnectionsRequest [1713520001719] INFO (ls): REQUEST RECEIVED => connection/RunCommandRequest [1713520001722] ERROR (ls): {"code":-32001,"data":{"driver":"SQLite","driverOptions":{}},"name":"Error"} ns: "conn"

To Reproduce Literally just have comments in your .sql file. That's it. When you "run on active connection" You get SQL Misuse

Expected behavior Ignore the comments and give the correct output

Screenshots

Comments

image

No Comments

image

Another No comments example

image

MaxBook Air M3 24 gb ram 1tb disk:

SQLTools Version v0.28.3 SQLite Version v0.5.1 VS Code Version: 1.88.1 OS: Mac Sonoma 14.4.1 Driver: SQLite v0.5.1 Database version: Sqlite idk what version

Albro3459 commented 2 months ago

From Sqlite's documentation: link

(21) SQLITE_MISUSE The SQLITE_MISUSE return code might be returned if the application uses any SQLite interface in a way that is undefined or unsupported. For example, using a prepared statement after that prepared statement has been finalized might result in an SQLITE_MISUSE error.

SQLite tries to detect misuse and report the misuse using this result code. However, there is no guarantee that the detection of misuse will be successful. Misuse detection is probabilistic. Applications should never depend on an SQLITE_MISUSE return value.

If SQLite ever returns SQLITE_MISUSE from any interface, that means that the application is incorrectly coded and needs to be fixed. Do not ship an application that sometimes returns SQLITE_MISUSE from a standard SQLite interface because that application contains potentially serious bugs.