Skip to content

Special commands inside source inside --execute are not supported, but the error is not handled correctly. #2148

Description

@your-diary

Setup

$ mycli --execute 'source 1.sql' test_database

where 1.sql contains a special command (source, \T, etc.):

SELECT 1;
\T ascii; -- In addition to `\T`, I also confirmed with a nested `source`
SELECT 2;

Expected Behavior

  • An error message is printed.

  • The command returns a non-zero exit status.

Actual Behavior

  • Processing the file is aborted right after encountering a special command (this is preferable).

    • In other words, SELECT 1 is executed while SELECT 2 is not executed.
  • No error message is printed.

  • The command returns 0 as the exit status.

System

  • mycli version: v2.13.2
  • OS/version: Alpine Linux

Cause (AI-generated, unverified)

The problem is that the rejection is returned as an SQLResult.status.
The --execute path does not render that status and treats the completed
run_query() call as success, causing silent partial execution with exit
status 0.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions