Closed zhangyangyu closed 7 months ago
@zhangyangyu usql
does not know anything about the server's configuration.
Please note that there are many unique commands for various SQL servers and their respective clients that are sometimes recognized/parsed/intercepted by the client, and some that are 100% delegated to the actual server. I believe set
here is the prototypical example of such -- in some SQL servers, a set
query is 100% handled by the client, and for many others it can be a hybrid, or is 100% handled by the server.
For usql
, all configuration variables/parameters are handled using \set
or \pset
.
I'll look into adding a setting that changes this on usql
, but it would be a usql
setting, not a MySQL setting. I'm also hesitant to enable something like this by default, as the user really needs to decide if they want to present the time relative to the user, or just dump/relay whatever the server says is "the time". I can see the relative merits of both, but I do think that having the server as the "source of truth" is likely always the right scenario.
Understand that one of the difficulties with this, is that if there was a usql
setting for a "timezone appearance", there would be equally challenging issues. Consider: if a user had a "timezone appearance" setting on usql
, what should the expected behavior be when a user then inserts/modifies/etc. a value? Should usql
try to intercept and change that value? As of today, usql
has no underlying understanding of SQL, and implementing such logic would require a full fledged SQL parser.
I have quite a bit of experience with the PostgreSQL code base, especially with psql
, and if I remember correctly, I believe that the server handles all of those translations from the user when using a server-side SET
. I am not sure how the mysql
command line client might treat these values, if it is modifying it on the client side before sending it off to the server or altering it before displaying it.
For mysql, if using usql to query a timestamp column, it represents the return value with timezone, but the timezone is wrong.
Note the time is changed but time_zone still not.