diff options
author | Dick Marinus <dick@mrns.nl> | 2019-03-17 07:04:29 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-17 07:04:29 +0100 |
commit | 72f6b6a5611c08ae22ee72d320995a35b6e45998 (patch) | |
tree | a25fe9a3f116a56febb809471270ac80ce4b47fc | |
parent | 80f440e91c1276f98463dd66007bfd9a7a59a878 (diff) | |
parent | 3652134bc57007fc29344456e212d5c85a71cb2b (diff) |
Merge pull request #1022 from dbcli/system-error
Catch and ignore the system interrupt.
-rw-r--r-- | changelog.rst | 1 | ||||
-rw-r--r-- | pgcli/pgexecute.py | 25 |
2 files changed, 15 insertions, 11 deletions
diff --git a/changelog.rst b/changelog.rst index 2a3e446f..069d782e 100644 --- a/changelog.rst +++ b/changelog.rst @@ -11,6 +11,7 @@ Bug fixes: ---------- * Avoid error message on the server side if hstore extension is not installed in the current database (#991). (Thanks: `Marcin Cieślak`_) * All pexpect submodules have been moved into the pexpect package as of version 3.0. Use pexpect.TIMEOUT (Thanks: `Marcin Cieślak`_) +* Resizing pgcli terminal kills the connection to postgres in python 2.7 (Thanks: `Amjith Ramanujam`_) * Fix crash retrieving server version with ``--single-connection``. (Thanks: `Irina Truong`_) Internal: diff --git a/pgcli/pgexecute.py b/pgcli/pgexecute.py index c7d204f0..4deaf279 100644 --- a/pgcli/pgexecute.py +++ b/pgcli/pgexecute.py @@ -50,7 +50,10 @@ def _wait_select(conn): conn.cancel() # the loop will be broken by a server error continue - + except select.error as e: + errno = e.args[0] + if errno != 4: + raise # When running a query, make pressing CTRL+C raise a KeyboardInterrupt # See http://initd.org/psycopg/articles/2014/07/20/cancelling-postgresql-statements-python/ @@ -165,21 +168,21 @@ class PGExecute(object): view_definition_query = ''' WITH v AS (SELECT %s::pg_catalog.regclass::pg_catalog.oid AS v_oid) - SELECT nspname, relname, relkind, - pg_catalog.pg_get_viewdef(c.oid, true), + SELECT nspname, relname, relkind, + pg_catalog.pg_get_viewdef(c.oid, true), array_remove(array_remove(c.reloptions,'check_option=local'), - 'check_option=cascaded') AS reloptions, - CASE - WHEN 'check_option=local' = ANY (c.reloptions) THEN 'LOCAL'::text - WHEN 'check_option=cascaded' = ANY (c.reloptions) THEN 'CASCADED'::text - ELSE NULL - END AS checkoption - FROM pg_catalog.pg_class c + 'check_option=cascaded') AS reloptions, + CASE + WHEN 'check_option=local' = ANY (c.reloptions) THEN 'LOCAL'::text + WHEN 'check_option=cascaded' = ANY (c.reloptions) THEN 'CASCADED'::text + ELSE NULL + END AS checkoption + FROM pg_catalog.pg_class c LEFT JOIN pg_catalog.pg_namespace n ON (c.relnamespace = n.oid) JOIN v ON (c.oid = v.v_oid)''' function_definition_query = ''' - WITH f AS + WITH f AS (SELECT %s::pg_catalog.regproc::pg_catalog.oid AS f_oid) SELECT pg_catalog.pg_get_functiondef(f.f_oid) FROM f''' |