Re: [HACKERS] psql \conninfo command (was: Patch: psql \whoami option)
On Wed, Jul 21, 2010 at 11:13 PM, Fujii Masao masao.fu...@gmail.com wrote: On Thu, Jul 22, 2010 at 11:57 AM, Robert Haas robertmh...@gmail.com wrote: Should we be using is_absolute_path() here instead, as libpq does? Yes. The attached patch does that. On Wed, Jul 21, 2010 at 10:09 PM, David Christensen da...@endpoint.com wrote: If we print the local socket when it's been explicitly set via the host= param, why not display the actual socket path in the general local socket case? Patch? Done. DEFAULT_PGSOCKET_DIR (i.e., /tmp) should be displayed in that case, I think. $ psql -c\conninfo You are connected to database postgres via local socket on /tmp at port 5432 as user postgres. Sorry for the slow response, I've been slightly buried. I've committed this with some kibitzing, the most relevant bit of which is that I changed via local socket on to via local socket in, which I think reads better. -- Robert Haas EnterpriseDB: http://www.enterprisedb.com The Enterprise Postgres Company -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] psql \conninfo command (was: Patch: psql \whoami option)
On Wed, Jul 21, 2010 at 1:07 AM, Fujii Masao masao.fu...@gmail.com wrote: On Tue, Jul 20, 2010 at 11:14 PM, Robert Haas robertmh...@gmail.com wrote: OK, committed. When I specify the path of the directory for the Unix-domain socket as the host, \conninfo doesn't mention that this connection is based on the Unix-domain socket. Is this intentional? $ psql -h/tmp -c\conninfo You are connected to database postgres on host /tmp at port 5432 as user postgres. I expected that something like You are connected to database postgres via local socket on /tmp at port 5432 as user postgres. :-( No, I didn't realize the host field could be used that way. It's true that you get a fairly similar message from \c, but that's not exactly intuitive either. rhaas=# \c - - /tmp - You are now connected to database rhaas on host /tmp. -- Robert Haas EnterpriseDB: http://www.enterprisedb.com The Enterprise Postgres Company -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] psql \conninfo command (was: Patch: psql \whoami option)
On Wed, Jul 21, 2010 at 7:29 PM, Robert Haas robertmh...@gmail.com wrote: On Wed, Jul 21, 2010 at 1:07 AM, Fujii Masao masao.fu...@gmail.com wrote: On Tue, Jul 20, 2010 at 11:14 PM, Robert Haas robertmh...@gmail.com wrote: OK, committed. When I specify the path of the directory for the Unix-domain socket as the host, \conninfo doesn't mention that this connection is based on the Unix-domain socket. Is this intentional? $ psql -h/tmp -c\conninfo You are connected to database postgres on host /tmp at port 5432 as user postgres. I expected that something like You are connected to database postgres via local socket on /tmp at port 5432 as user postgres. :-( No, I didn't realize the host field could be used that way. It's true that you get a fairly similar message from \c, but that's not exactly intuitive either. rhaas=# \c - - /tmp - You are now connected to database rhaas on host /tmp. OK. The attached patch makes \conninfo command emit the following message if the host begins with a slash: $ psql -h/tmp -c\conninfo You are connected to database postgres via local socket on /tmp at port 5432 as user postgres. Similarly, it makes \c command emit the following message in that case: $ psql -hlocalhost -c\c - - /tmp - You are now connected to database postgres via local socket on /tmp. Comments? Regards, -- Fujii Masao NIPPON TELEGRAPH AND TELEPHONE CORPORATION NTT Open Source Software Center conninfo_local_socket_v1.patch Description: Binary data -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] psql \conninfo command (was: Patch: psql \whoami option)
On Jul 21, 2010, at 8:48 PM, Fujii Masao wrote: On Wed, Jul 21, 2010 at 7:29 PM, Robert Haas robertmh...@gmail.com wrote: On Wed, Jul 21, 2010 at 1:07 AM, Fujii Masao masao.fu...@gmail.com wrote: On Tue, Jul 20, 2010 at 11:14 PM, Robert Haas robertmh...@gmail.com wrote: OK, committed. When I specify the path of the directory for the Unix-domain socket as the host, \conninfo doesn't mention that this connection is based on the Unix-domain socket. Is this intentional? $ psql -h/tmp -c\conninfo You are connected to database postgres on host /tmp at port 5432 as user postgres. I expected that something like You are connected to database postgres via local socket on /tmp at port 5432 as user postgres. :-( No, I didn't realize the host field could be used that way. It's true that you get a fairly similar message from \c, but that's not exactly intuitive either. rhaas=# \c - - /tmp - You are now connected to database rhaas on host /tmp. OK. The attached patch makes \conninfo command emit the following message if the host begins with a slash: $ psql -h/tmp -c\conninfo You are connected to database postgres via local socket on /tmp at port 5432 as user postgres. Similarly, it makes \c command emit the following message in that case: $ psql -hlocalhost -c\c - - /tmp - You are now connected to database postgres via local socket on /tmp. If we print the local socket when it's been explicitly set via the host= param, why not display the actual socket path in the general local socket case? Also, while we're still tweaking this patch, I've had a couple requests for the SSL status of the connection as well; does this seem like a generally useful parameter to display as well? Regards, David -- David Christensen End Point Corporation da...@endpoint.com -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] psql \conninfo command (was: Patch: psql \whoami option)
On Wed, Jul 21, 2010 at 9:48 PM, Fujii Masao masao.fu...@gmail.com wrote: On Wed, Jul 21, 2010 at 7:29 PM, Robert Haas robertmh...@gmail.com wrote: On Wed, Jul 21, 2010 at 1:07 AM, Fujii Masao masao.fu...@gmail.com wrote: On Tue, Jul 20, 2010 at 11:14 PM, Robert Haas robertmh...@gmail.com wrote: OK, committed. When I specify the path of the directory for the Unix-domain socket as the host, \conninfo doesn't mention that this connection is based on the Unix-domain socket. Is this intentional? $ psql -h/tmp -c\conninfo You are connected to database postgres on host /tmp at port 5432 as user postgres. I expected that something like You are connected to database postgres via local socket on /tmp at port 5432 as user postgres. :-( No, I didn't realize the host field could be used that way. It's true that you get a fairly similar message from \c, but that's not exactly intuitive either. rhaas=# \c - - /tmp - You are now connected to database rhaas on host /tmp. OK. The attached patch makes \conninfo command emit the following message if the host begins with a slash: $ psql -h/tmp -c\conninfo You are connected to database postgres via local socket on /tmp at port 5432 as user postgres. Similarly, it makes \c command emit the following message in that case: $ psql -hlocalhost -c\c - - /tmp - You are now connected to database postgres via local socket on /tmp. Comments? Should we be using is_absolute_path() here instead, as libpq does? -- Robert Haas EnterpriseDB: http://www.enterprisedb.com The Enterprise Postgres Company -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] psql \conninfo command (was: Patch: psql \whoami option)
On Wed, Jul 21, 2010 at 10:09 PM, David Christensen da...@endpoint.com wrote: On Jul 21, 2010, at 8:48 PM, Fujii Masao wrote: On Wed, Jul 21, 2010 at 7:29 PM, Robert Haas robertmh...@gmail.com wrote: On Wed, Jul 21, 2010 at 1:07 AM, Fujii Masao masao.fu...@gmail.com wrote: On Tue, Jul 20, 2010 at 11:14 PM, Robert Haas robertmh...@gmail.com wrote: OK, committed. When I specify the path of the directory for the Unix-domain socket as the host, \conninfo doesn't mention that this connection is based on the Unix-domain socket. Is this intentional? $ psql -h/tmp -c\conninfo You are connected to database postgres on host /tmp at port 5432 as user postgres. I expected that something like You are connected to database postgres via local socket on /tmp at port 5432 as user postgres. :-( No, I didn't realize the host field could be used that way. It's true that you get a fairly similar message from \c, but that's not exactly intuitive either. rhaas=# \c - - /tmp - You are now connected to database rhaas on host /tmp. OK. The attached patch makes \conninfo command emit the following message if the host begins with a slash: $ psql -h/tmp -c\conninfo You are connected to database postgres via local socket on /tmp at port 5432 as user postgres. Similarly, it makes \c command emit the following message in that case: $ psql -hlocalhost -c\c - - /tmp - You are now connected to database postgres via local socket on /tmp. If we print the local socket when it's been explicitly set via the host= param, why not display the actual socket path in the general local socket case? Patch? Also, while we're still tweaking this patch, I've had a couple requests for the SSL status of the connection as well; does this seem like a generally useful parameter to display as well? Yes. If we're going to have the command, we might as well get as much mileage out of it as we reasonably can. -- Robert Haas EnterpriseDB: http://www.enterprisedb.com The Enterprise Postgres Company -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] psql \conninfo command (was: Patch: psql \whoami option)
On Thu, Jul 22, 2010 at 11:57 AM, Robert Haas robertmh...@gmail.com wrote: Should we be using is_absolute_path() here instead, as libpq does? Yes. The attached patch does that. On Wed, Jul 21, 2010 at 10:09 PM, David Christensen da...@endpoint.com wrote: If we print the local socket when it's been explicitly set via the host= param, why not display the actual socket path in the general local socket case? Patch? Done. DEFAULT_PGSOCKET_DIR (i.e., /tmp) should be displayed in that case, I think. $ psql -c\conninfo You are connected to database postgres via local socket on /tmp at port 5432 as user postgres. Regards, -- Fujii Masao NIPPON TELEGRAPH AND TELEPHONE CORPORATION NTT Open Source Software Center conninfo_local_socket_v2.patch Description: Binary data -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] psql \conninfo command (was: Patch: psql \whoami option)
On Tue, Jul 20, 2010 at 12:16 AM, David Christensen da...@endpoint.com wrote: On Jul 19, 2010, at 11:10 PM, Robert Haas wrote: On Tue, Jul 20, 2010 at 12:07 AM, Robert Haas robertmh...@gmail.com wrote: On Tue, Jul 20, 2010 at 12:02 AM, David Christensen da...@endpoint.com wrote: I would propose to print instead: You are connected to database rhaas via local socket as user rhaas. One minor quibble here; you lose the ability to see which pg instance you're running on if there are multiple ones running on different local sockets, so maybe either the port or the socket path should show up here still. Doh. Will fix. Something like the attached? Looks good to me. OK, committed. Thanks for the patch! -- Robert Haas EnterpriseDB: http://www.enterprisedb.com The Enterprise Postgres Company -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] psql \conninfo command (was: Patch: psql \whoami option)
On Tue, Jul 20, 2010 at 11:14 PM, Robert Haas robertmh...@gmail.com wrote: OK, committed. When I specify the path of the directory for the Unix-domain socket as the host, \conninfo doesn't mention that this connection is based on the Unix-domain socket. Is this intentional? $ psql -h/tmp -c\conninfo You are connected to database postgres on host /tmp at port 5432 as user postgres. I expected that something like You are connected to database postgres via local socket on /tmp at port 5432 as user postgres. is output. Regards, -- Fujii Masao NIPPON TELEGRAPH AND TELEPHONE CORPORATION NTT Open Source Software Center -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] psql \conninfo command (was: Patch: psql \whoami option)
On Sun, Jul 18, 2010 at 2:00 PM, David Christensen da...@endpoint.com wrote: Updated the commitfest entry with the patch, updated the title to reflect the actual name of the command, and marked as ready for committer. I took a look at this patch. One problem is that it doesn't handle the case where there is no database connection (for example, shut down the database with pg_ctl, then do select 1, then do \conninfo). I've fixed that in the attached version. However, I'm also wondering about the output format. I feel like it would make sense to use a format similar to what we do for \c, which looks like this: You are now connected to database %s. It prints out more parameters if they've changed. The longest possible version is: You are now connected to database %s on host %s at port %s as user %s. My suggestion is that we use the same format, except (1) always include all the components, since that's the point; (2) don't include the word now; and (3) if there is no host, then print via local socket rather than on host...port So where the current patch prints: Connected to database: rhaas, user: rhaas, port: 5432 via local domain socket I would propose to print instead: You are connected to database rhaas via local socket as user rhaas. If people strongly prefer the way the patch does it now, I don't think it's horrible... but it seems like it would be nicer to be somewhat consistent with the existing message. Thoughts? -- Robert Haas EnterpriseDB: http://www.enterprisedb.com The Enterprise Postgres Company psql-conninfo-v3.patch Description: Binary data -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] psql \conninfo command (was: Patch: psql \whoami option)
On Jul 19, 2010, at 10:34 PM, Robert Haas wrote: On Sun, Jul 18, 2010 at 2:00 PM, David Christensen da...@endpoint.com wrote: Updated the commitfest entry with the patch, updated the title to reflect the actual name of the command, and marked as ready for committer. I took a look at this patch. One problem is that it doesn't handle the case where there is no database connection (for example, shut down the database with pg_ctl, then do select 1, then do \conninfo). I've fixed that in the attached version. Thanks, I hadn't considered that case. However, I'm also wondering about the output format. I feel like it would make sense to use a format similar to what we do for \c, which looks like this: You are now connected to database %s. It prints out more parameters if they've changed. The longest possible version is: You are now connected to database %s on host %s at port %s as user %s. My suggestion is that we use the same format, except (1) always include all the components, since that's the point; (2) don't include the word now; and (3) if there is no host, then print via local socket rather than on host...port So where the current patch prints: Connected to database: rhaas, user: rhaas, port: 5432 via local domain socket I would propose to print instead: You are connected to database rhaas via local socket as user rhaas. If people strongly prefer the way the patch does it now, I don't think it's horrible... but it seems like it would be nicer to be somewhat consistent with the existing message. Thoughts? +1 from me; I don't care what color the bikeshed is, as long as it gets the point across, which this does, and is consistent to boot. Regards, David -- David Christensen End Point Corporation da...@endpoint.com -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] psql \conninfo command (was: Patch: psql \whoami option)
On Mon, Jul 19, 2010 at 11:41 PM, David Christensen da...@endpoint.com wrote: I took a look at this patch. One problem is that it doesn't handle the case where there is no database connection (for example, shut down the database with pg_ctl, then do select 1, then do \conninfo). I've fixed that in the attached version. Thanks, I hadn't considered that case. For some reason, I end up crashing a lot of databases during development (must be my lousy coding). So I've had occasion to run across this, ahem, a few times... +1 from me; I don't care what color the bikeshed is, as long as it gets the point across, which this does, and is consistent to boot. Great, committed that way. -- Robert Haas EnterpriseDB: http://www.enterprisedb.com The Enterprise Postgres Company -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] psql \conninfo command (was: Patch: psql \whoami option)
I would propose to print instead: You are connected to database rhaas via local socket as user rhaas. One minor quibble here; you lose the ability to see which pg instance you're running on if there are multiple ones running on different local sockets, so maybe either the port or the socket path should show up here still. Regards, David -- David Christensen End Point Corporation da...@endpoint.com -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] psql \conninfo command (was: Patch: psql \whoami option)
On Tue, Jul 20, 2010 at 12:02 AM, David Christensen da...@endpoint.com wrote: I would propose to print instead: You are connected to database rhaas via local socket as user rhaas. One minor quibble here; you lose the ability to see which pg instance you're running on if there are multiple ones running on different local sockets, so maybe either the port or the socket path should show up here still. Doh. Will fix. -- Robert Haas EnterpriseDB: http://www.enterprisedb.com The Enterprise Postgres Company -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] psql \conninfo command (was: Patch: psql \whoami option)
On Tue, Jul 20, 2010 at 12:07 AM, Robert Haas robertmh...@gmail.com wrote: On Tue, Jul 20, 2010 at 12:02 AM, David Christensen da...@endpoint.com wrote: I would propose to print instead: You are connected to database rhaas via local socket as user rhaas. One minor quibble here; you lose the ability to see which pg instance you're running on if there are multiple ones running on different local sockets, so maybe either the port or the socket path should show up here still. Doh. Will fix. Something like the attached? -- Robert Haas EnterpriseDB: http://www.enterprisedb.com The Enterprise Postgres Company psql-conninfo-fix.patch Description: Binary data -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] psql \conninfo command (was: Patch: psql \whoami option)
On Jul 19, 2010, at 11:10 PM, Robert Haas wrote: On Tue, Jul 20, 2010 at 12:07 AM, Robert Haas robertmh...@gmail.com wrote: On Tue, Jul 20, 2010 at 12:02 AM, David Christensen da...@endpoint.com wrote: I would propose to print instead: You are connected to database rhaas via local socket as user rhaas. One minor quibble here; you lose the ability to see which pg instance you're running on if there are multiple ones running on different local sockets, so maybe either the port or the socket path should show up here still. Doh. Will fix. Something like the attached? Looks good to me. Regards, David -- David Christensen End Point Corporation da...@endpoint.com -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
[HACKERS] psql \conninfo command (was: Patch: psql \whoami option)
On Jul 18, 2010, at 12:33 PM, David Christensen wrote: On Jul 18, 2010, at 12:30 PM, Tom Lane wrote: David Christensen da...@endpoint.com writes: machack:machack:5432=# \c foobar You are now connected to database foobar. What this is reflecting is that backslash commands have their own weird rules for processing double quotes. What I was concerned about was that double quotes in SQL are normally used for protecting mixed case, and you don't need that for \c: regression=# create database FooBar; CREATE DATABASE regression=# \c foobar FATAL: database foobar does not exist Previous connection kept regression=# \c FooBar You are now connected to database FooBar. FooBar=# The fact that there are double quotes around the database name in the You are now connected... message is *not* meant to imply that that is a valid double-quoted SQL identifier, either. It's just an artifact of how we set off names in English-language message style. In another language it might look like FooBar or some such. My opinion remains that you should just print the user and database names as-is, without trying to inject any quoting into the mix. You're more likely to confuse people than help them if you do that. Okay, understood. Then consider my updated patch (just sent attached to a recent message) to reflect the desired behavior. (I'll update the commitfest patch entry when it shows up in the archives.) Updated the commitfest entry with the patch, updated the title to reflect the actual name of the command, and marked as ready for committer. Regards, David -- David Christensen End Point Corporation da...@endpoint.com -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers