Skip to content

SetOptionSync and different Connect methods #156

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
anton-kotenko opened this issue Sep 5, 2012 · 4 comments
Open

SetOptionSync and different Connect methods #156

anton-kotenko opened this issue Sep 5, 2012 · 4 comments

Comments

@anton-kotenko
Copy link
Contributor

I'm working on "Load data infile" feature. It's work requires to set MYSQL_OPT_LOCAL_INFILE option. But i've found
that it's impossible to set options if using ConnectSync or Connect methods
and that the only way to set options is like this:

var mysql = require('mysql-libmysqlclient'),
conn = new mysql.bindings.MysqlConnection();
conn.initSync();
conn.setOptionSync(mysq.MYSQL_OPT_LOCAL_INFILE);
conn.realConnectSync(host, user, password, dbname);

As for me, it make's api inconsistent (i can not set options, if i want to connect in asyncronous mode), and introduces additional difficulties (at least 2 methods initSync, and realConnectSync).
So my proposal is to have _conn structrure initialized in constructor, (and every time when it closed, like when mysql_real_connect fails).
This makes possible to use setOptionSync between new MysqlConnection and any form of Connect method.
and makes possible to remove initSync and realConnectSync (and also remove RealConnect method from mysql_bindings_connection.cc, as it's almost copy&paste of Connect method)

@Sannis
Copy link
Owner

Sannis commented Sep 5, 2012

This is goes from MySQL C API: there is two ways to set connection settings: via flags on mysql_real_connect and via call mysql_options. So I prefer to keep this API on bindings level.

By the way, I agree with your arguments, so I can build consistent api for options as argument of MysqlHighlevelConnection@connect().

@ghost ghost assigned Sannis Sep 5, 2012
@anton-kotenko
Copy link
Contributor Author

Thank you, That would be great, but It seems to me that there are no way, to set options (not client flags, even it is acceptable solution of my problem), when connecting in asynchronous mode without notable change of api at bindings level.
Or there will be need to create asynchronous version of realConnect, and make obligatory call of initSync at JavaScript level, or need to pass options argument through chain MysqlConnection::Connect(Args&)->EIO_Connect->Connect, and execute mysql_options call there just after mysql_init.

@Sannis
Copy link
Owner

Sannis commented Sep 5, 2012

I need a closer look at the code to decide between this choices.

Or there will be need to create asynchronous version of realConnect, and make obligatory call of initSync at JavaScript level, or need to pass options argument through chain MysqlConnection::Connect(Args&)->EIO_Connect->Connect, and execute mysql_options call there just after mysql_init.

@pederbl
Copy link

pederbl commented Jan 24, 2013

Do you plan to implement CLIENT_LOCAL_FILES?

@Sannis Sannis removed this from the v1.6.0-high-level-options-2 milestone Jan 5, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants