Skip to content
Snippets Groups Projects
user avatar
Alvaro Herrera authored
psql was already accepting conninfo strings as the first parameter in
\connect, but the way it worked wasn't sane; some of the other
parameters would get the previous connection's values, causing it to
connect to a completely unexpected server or, more likely, not finding
any server at all because of completely wrong combinations of
parameters.

Fix by explicitely checking for a conninfo-looking parameter in the
dbname position; if one is found, use its complete specification rather
than mix with the other arguments.  Also, change tab-completion to not
try to complete conninfo/URI-looking "dbnames" and document that
conninfos are accepted as first argument.

There was a weak consensus to backpatch this, because while the behavior
of using the dbname as a conninfo is nowhere documented for \connect, it
is reasonable to expect that it works because it does work in many other
contexts.  Therefore this is backpatched all the way back to 9.0.

To implement this, routines previously private to libpq have been
duplicated so that psql can decide what looks like a conninfo/URI
string.  In back branches, just duplicate the same code all the way back
to 9.2, where URIs where introduced; 9.0 and 9.1 have a simpler version.
In master, the routines are moved to src/common and renamed.

Author: David Fetter, Andrew Dunstan.  Some editorialization by me
(probably earning a Gierth's "Sloppy" badge in the process.)
Reviewers: Andrew Gierth, Erik Rijkers, Pavel Stěhule, Stephen Frost,
Robert Haas, Andrew Dunstan.
d4bacdcb
History
Name Last commit Last update
..
abort.sgml
allfiles.sgml
alter_aggregate.sgml
alter_collation.sgml
alter_conversion.sgml
alter_database.sgml
alter_default_privileges.sgml
alter_domain.sgml
alter_extension.sgml
alter_foreign_data_wrapper.sgml
alter_foreign_table.sgml
alter_function.sgml
alter_group.sgml
alter_index.sgml
alter_language.sgml
alter_large_object.sgml
alter_opclass.sgml
alter_operator.sgml
alter_opfamily.sgml
alter_role.sgml
alter_schema.sgml
alter_sequence.sgml
alter_server.sgml
alter_table.sgml
alter_tablespace.sgml
alter_trigger.sgml
alter_tsconfig.sgml
alter_tsdictionary.sgml
alter_tsparser.sgml
alter_tstemplate.sgml
alter_type.sgml
alter_user.sgml
alter_user_mapping.sgml
alter_view.sgml
analyze.sgml
begin.sgml
checkpoint.sgml
close.sgml
cluster.sgml
clusterdb.sgml
comment.sgml
commit.sgml
commit_prepared.sgml
copy.sgml
create_aggregate.sgml
create_cast.sgml
create_collation.sgml
create_conversion.sgml
create_database.sgml
create_domain.sgml
create_extension.sgml
create_foreign_data_wrapper.sgml
create_foreign_table.sgml
create_function.sgml
create_group.sgml
create_index.sgml
create_language.sgml
create_opclass.sgml
create_operator.sgml
create_opfamily.sgml
create_role.sgml
create_rule.sgml
create_schema.sgml
create_sequence.sgml
create_server.sgml
create_table.sgml
create_table_as.sgml
create_tablespace.sgml
create_trigger.sgml
create_tsconfig.sgml
create_tsdictionary.sgml
create_tsparser.sgml
create_tstemplate.sgml
create_type.sgml
create_user.sgml
create_user_mapping.sgml
create_view.sgml
createdb.sgml
createlang.sgml
createuser.sgml
deallocate.sgml
declare.sgml
delete.sgml
discard.sgml
do.sgml
drop_aggregate.sgml
drop_cast.sgml
drop_collation.sgml
drop_conversion.sgml
drop_database.sgml
drop_domain.sgml
drop_extension.sgml
drop_foreign_data_wrapper.sgml
drop_foreign_table.sgml
drop_function.sgml
drop_group.sgml
drop_index.sgml
drop_language.sgml
drop_opclass.sgml
drop_operator.sgml