Skip to content

gh-133439: Fix dot commands with trailing spaces are mistaken for multi-line sqlite statements in the sqlite3 command-line interface #133440

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
May 9, 2025

Conversation

tanloong
Copy link
Contributor

@tanloong tanloong commented May 5, 2025

Copy link
Member

@serhiy-storchaka serhiy-storchaka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The sqlite3 CLI supports also space after dot:

sqlite> . version
SQLite 3.45.1 2024-01-30 16:01:20 e876e51a0ed5c5b3126f52e532044363a014bc594cfefa87ffb5b82257ccalt1
zlib version 1.3
gcc-13.3.0 (64-bit)

But not before dot:

sqlite>  .version
   ...> 

To be conforming with it, we should check if the first character is a dot, and if it is, use source[1:].strip() as the command. No stripping is needed for the SQL statement.

@tanloong tanloong force-pushed the sqlite3-cli-strip-whitespaces branch from 0d89da8 to 3543c33 Compare May 9, 2025 08:19
@tanloong
Copy link
Contributor Author

tanloong commented May 9, 2025

Thank you for your review! I have modified the code to use source[1:].strip() as dot command, no stripping for SQL statement.

@tanloong tanloong force-pushed the sqlite3-cli-strip-whitespaces branch from 3543c33 to a4498ab Compare May 9, 2025 08:24
@tanloong tanloong force-pushed the sqlite3-cli-strip-whitespaces branch from cbea2b1 to 487aafc Compare May 9, 2025 09:50
@tanloong tanloong force-pushed the sqlite3-cli-strip-whitespaces branch from 487aafc to b473fe9 Compare May 9, 2025 09:52
@tanloong
Copy link
Contributor Author

tanloong commented May 9, 2025

Sorry for the overlook, now the empty source and unknown dot commands are handled. I have improved the news entry.

@tanloong tanloong force-pushed the sqlite3-cli-strip-whitespaces branch from 36b4a16 to caf47bc Compare May 9, 2025 11:07
Copy link
Member

@serhiy-storchaka serhiy-storchaka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. 👍

@serhiy-storchaka serhiy-storchaka enabled auto-merge (squash) May 9, 2025 11:11
@serhiy-storchaka serhiy-storchaka added the needs backport to 3.14 bugs and security fixes label May 9, 2025
auto-merge was automatically disabled May 9, 2025 11:13

Head branch was pushed to by a user without write access

@serhiy-storchaka serhiy-storchaka enabled auto-merge (squash) May 9, 2025 11:15
@serhiy-storchaka serhiy-storchaka merged commit ebd4881 into python:main May 9, 2025
39 checks passed
@miss-islington-app
Copy link

Thanks @tanloong for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request May 9, 2025
…or multi-line sqlite statements in the sqlite3 command-line interface (pythonGH-133440)

(cherry picked from commit ebd4881)

Co-authored-by: Tan Long <tanloong@foxmail.com>
@bedevere-app
Copy link

bedevere-app bot commented May 9, 2025

GH-133738 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.14 bugs and security fixes label May 9, 2025
@picnixz
Copy link
Member

picnixz commented May 9, 2025

@serhiy-storchaka no 3.13 backports?

serhiy-storchaka pushed a commit that referenced this pull request May 9, 2025
…for multi-line sqlite statements in the sqlite3 command-line interface (GH-133440) (GH-133738)

(cherry picked from commit ebd4881)

Co-authored-by: Tan Long <tanloong@foxmail.com>
@serhiy-storchaka
Copy link
Member

This is borderline between minor bug fix and minor feature. It improves the quality of life a little, but most people won't notice anything. If anyone wants to backport to 3.13, please do. If not, no problem either.

@tanloong
Copy link
Contributor Author

tanloong commented May 9, 2025

I will do that.

@bedevere-app
Copy link

bedevere-app bot commented May 9, 2025

GH-133765 is a backport of this pull request to the 3.13 branch.

@serhiy-storchaka
Copy link
Member

@tanloong, I meant any of the core developers. It's as simple as adding a label. Someone just has to want to do it.

@tanloong
Copy link
Contributor Author

tanloong commented May 9, 2025

Ah, sorry, I misunderstood.

tanloong added a commit to tanloong/cpython that referenced this pull request May 9, 2025
…or multi-line sqlite statements in the sqlite3 command-line interface (pythonGH-133440)

(cherry picked from commit ebd4881)
pass
case _ as unknown:
self.write("Error: unknown command or invalid arguments:"
f' "{unknown}".\n')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error messages do not end with a '.' e.g.:

Python 3.15.0a0 (heads/main:c81fa2b9cd1, May  8 2025, 16:38:25) [GCC 15.1.1 20250425 (Red Hat 15.1.1-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> test
Traceback (most recent call last):
  File "<python-input-0>", line 1, in <module>
    test
NameError: name 'test' is not defined

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants