Hyyy6 Hyyy6 - 29 days ago 9
SQL Question

SQL Shell stops taking commands

I'm learning some psql and currently ran into a problem when command line cursor changes from =# to '# after a long command. Shell then completely ignores all commands.
Could someone please explain what is this problem and how to avoid/solve it?

Active code page: 1251
Server [localhost]:
Database [postgres]:
Port [5432]:
Username [postgres]:
Password for user postgres:
psql (9.6.5)
WARNING: Console code page (1251) differs from Windows code page (1252)
8-bit characters might not work correctly. See psql reference
page "Notes for Windows users" for details.
Type "help" for help.

postgres=# insert into manuf values (3, 'manuf3', 'city2');
INSERT 0 1
postgres=# insert into manuf values (1, 'manuf1', 'city1')
postgres-# ;
INSERT 0 1
postgres=# insert into manuf values (2, 'manuf2', 'city2');
INSERT 0 1
postgres=# insert into product values (6, 'product6', 54, 34, 4), (5, 'product5', 34, 16, 5), (10, 'product10', 57, 4, 5), (9, 'product9', 66, 6, 2), (8, 'product8), 43, 16, 5), (7, 'product7', 76, 14, 3);
postgres'# \h
postgres'# WTF
postgres'# \q
postgres'#


I've notices that if a particular request does that in the first time, it will always cause that problem. But not all request with a similar length cause the problem.

UPD:

(8, 'product8', 43, 16, 5)


fixed this line. Still wondering, why does shell act in this way, not giving out any error messages, just sort of freezes.

Answer Source

Question already addressed in comments, but just to re-iterate: In the original list of values there is a typo: (8, 'product8), 43, 16, 5) - parenthesis instead of quote, so console is waiting for the closing string literal, and that's what it is indicating with the prompt '#. This is standard behavior of many console implementations, allowing you to enter multiline strings or blocks of code line by line