Skip to content
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

Pasting multiple statements into the CLI can cause strange behaviour. #845

Open
fake-name opened this issue Feb 25, 2018 · 8 comments
Open

Comments

@fake-name
Copy link

fake-name commented Feb 25, 2018

I pretty often compose a set of queries I want to enter in psql/pgcli in a notepad, and then paste them into the terminal as a single block.

In psql, the entire block of queries executes normally. However, in pgcli, generally only one of the queries gets executed, and which query it is that gets run doesn't seem to make sense.

For instance, the following queries:


DROP TABLE  manga_releases;
DROP TABLE  manga_tags;
DROP TABLE  pg_stat_statements;
DROP TABLE  release_files;

Causes only the second query to be executed (DROP TABLE manga_tags;). The other queries show up on the console, but appear to be ignored.

image

Multi-line is on, otherwise I'm mostly running the defaults.

image

I'd expect pgcli to not simply drop statements on the floor. Ideally, every statement I enter should either result in a success output, or an error report.

This seems to be an effect of the fact that I'm pasting newlines into the console. if I remove the newlines in the SQL, it seems to function normally.

The SSH terminal I'm using is Cygwin minitty.exe x64, if it's somehow relevant.

Environment

  • Os: Ubuntu 14.04
  • Python 3.4.3
  • pgcli version: 1.8.2
durr@postgres-server ~> pip freeze
backports.csv==1.0.5
cli-helpers==1.0.1
click==6.7
configobj==5.0.6
humanize==0.5.1
pgcli==1.8.2
pgspecial==1.9.0
pgxnclient==1.2.1
prompt-toolkit==1.0.15
psycopg2==2.7.4
pycurl==7.19.3
Pygments==2.2.0
pygobject==3.12.0
python-apt===0.9.3.5ubuntu2
setproctitle==1.1.10
six==1.11.0
sqlparse==0.2.4
tabulate==0.8.2
terminaltables==3.1.0
unattended-upgrades==0.1
wcwidth==0.1.7
@amjith
Copy link
Member

amjith commented Mar 2, 2018

Hi. I just tried this on pgcli v1.8.2 in Fedora Linux, gnome-terminal. It works just fine.

I suspect that this is some incompatible behavior in cygwin. I understand that it works fine in psql. We are using prompt-tookit to render our shell which handles all our copy/paste for us.

It might be worthwhile to file a bug with prompt-toolkit about this.

@fraoustin
Copy link
Contributor

Hi, i use pgcli v1.8.2 on Debian (no Ubuntu) and it work fine. Can you indicate the name of your soft console, please? I use gnome-terminal

@fake-name
Copy link
Author

fake-name commented Mar 4, 2018

@fraoustin:

From the original report:

The SSH terminal I'm using is Cygwin minitty.exe x64, if it's somehow relevant.

@fraoustin
Copy link
Contributor

you can tested with putty client ?

@fpietka
Copy link
Member

fpietka commented Mar 5, 2018

I tested it with PuTTY without reproducing the issue.

@fake-name is the client you are using this one: https://mintty.github.io/ ?

@fake-name
Copy link
Author

@fpietka - It sounds like it. From https://mintty.github.io/ :

In Cygwin, it is installed as the default "Cygwin Terminal".

@fake-name
Copy link
Author

fake-name commented Mar 6, 2018

you can tested with putty client ?

putty.exe is worse. It actually only ever even shows one of the 4 queries I tried to paste into the console.

Everything after the first newline in the clipboard input is completely discarded. If my clipboard starts with a newline, nothing whatsoever gets entered, aside from that one newline.

psql via putty.exe works fine.

@fake-name
Copy link
Author

Heh, looking at python-prompt-toolkit:

prompt-toolkit/python-prompt-toolkit#602, dbcli/mycli#579

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

No branches or pull requests

4 participants