vertica/vertica-sql-go

Honor search_path (and other connection arguments) in connection string.

ringmaster217 opened this issue · 3 comments

When connecting to databases, my organization often specifies search_path (and sometimes other session variables) as part of the connection string:

vertica://dbadmin:dbadminpass@localhost:5433/VMart?connection_load_balance=1&search_path=my_schema

vertica-sql-go doesn't currently support this (only connection_load_balance, use_prepared_statements, and backup_server_node are supported variables). Vertica does support this by simply passing the variables as part of the connection handshake.

I have a fork where I have implemented this functionality. If there is interest in having it as part of vertica-sql-go, I'll get tests written and submit a pr.

@ringmaster217 Thanks for pointing this out. However, your implementation is not a recommended way to achieve this. It lets the client to send arbitrary variables to the server, which is not a good practice. Only a couple of undocumented variables can be recognized by server during connection handshake, but we don't implement them because all these variables can be set after connection (e.g. execute query SET SEARCH_PATH TO store, public;). Please let me know if this workaround meets your needs.

I've tried your suggested SET SEARCH_PATH..., but it doesn't work with connection pooling (which go uses heavily for database connections). It ends up setting the search path for a single connection in the pool, but not for the rest, resulting in some unexpected behavior. That being said, I may have found another way forward that uses a user's default search_path setting.

I didn't realize that this handshake variable was undocumented. As such, I'll withdraw my request here. If it does ever become officially documented, I'd love to add it at that time.

@ringmaster217 You might looking for something like "Setting the User Search Path", please take a look at Vertica documentation