Skip to content
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

Validate dbConnect() parameters #4

Closed
krlmlr opened this issue Jul 5, 2017 · 9 comments
Closed

Validate dbConnect() parameters #4

krlmlr opened this issue Jul 5, 2017 · 9 comments

Comments

@krlmlr
Copy link
Member

krlmlr commented Jul 5, 2017

Issue by stevenpollack
Wednesday Mar 11, 2015 at 21:31 GMT
Originally opened as r-dbi/RMySQL#56


Same setup as with issue #55 except my ~/.my.cnf now is a bit more complicated:

[mysql]
database=algo
host=so1db.cjvo6rncstds.eu-west-1.rds.amazonaws.com
port=3306
user=so1engine
password=fakepassword123456789

and now when I reference the mysql group in dbConnect:

> X <- dbConnect(RMySQL::MySQL(), groups="mysql")
Error: Failed to connect: Access denied for user 'so1engine'@'c-24-12-233-98.hsd1.il.comcast.net' (using password: NO)

Enter a frame number, or 0 to exit

1: dbConnect(RMySQL::MySQL(), groups = "mysql")
2: .valueClassTest(standardGeneric("dbConnect"), "DBIConnection", "dbConnect")
3: is(object, Cl)
4: is(object, Cl)
5: .local(drv, ...)
6: connection_create(host, username, password, dbname, port, unix.socket, client.flag, groups, default.file)

I know the ~/.my.cnf is proper, since I can call mysql and perform queries without issues:

$ mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 79090
Server version: 5.6.21-log MySQL Community Server (GPL)

Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> SHOW DATABASES;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| algo               |
| campaigns          |
| loyalty            |
| masters            |
| reporting          |
| segment            |
+--------------------+
7 rows in set (0.13 sec)

Furthermore, when I try to fully qualify my call to dbConnect, I get an even weirder error, "Error: not compatible with requested type":

> X <- dbConnect(drv =RMySQL::MySQL(),
+        dbname='algo',
+        host='so1db.cjvo6rncstds.eu-west-1.rds.amazonaws.com',
+        port='3306',
+        user='so1engine',
+        password='fakepassword123456789')
Error: not compatible with requested type

Enter a frame number, or 0 to exit

1: dbConnect(drv = RMySQL::MySQL(), dbname = "algo", host = "so1db.cjvo6rncstds.eu-west-1.rds.amazonaws.com", port = "3306", user = "so1engine", password = "
2: .valueClassTest(standardGeneric("dbConnect"), "DBIConnection", "dbConnect")
3: is(object, Cl)
4: is(object, Cl)
5: .local(drv, ...)
6: connection_create(host, username, password, dbname, port, unix.socket, client.flag, groups, default.file)
@krlmlr
Copy link
Member Author

krlmlr commented Jul 5, 2017

Comment by peternowee
Thursday Oct 01, 2015 at 15:32 GMT


The first part of this issue is a duplicate of #55.

With regard to the second part:

Error: not compatible with requested type

This seems to be Rcpp complaining about the port parameter being a
string, where it was expecting a numeric. I am able to reproduce the
issue and solve it by using port=3306 instead of port='3306'.

Current stable (RMySQL 0.10.6) also requires an integer, though it
gives a clearer error message:

Error in .local(drv, ...) : Argument port must be an integer value

@krlmlr
Copy link
Member Author

krlmlr commented Jul 5, 2017

Comment by krlmlr
Wednesday Nov 11, 2015 at 10:49 GMT


Can we close this?

@krlmlr
Copy link
Member Author

krlmlr commented Jul 5, 2017

Comment by peternowee
Thursday Nov 12, 2015 at 12:16 GMT


I think the main point left open here is that parameters of dbConnect(), such as port, are not validated by RMySQL itself anymore, as they were in version 0.10.7, resulting in vaguer error messages from Rcpp in case the end user makes a mistake.

Perhaps this issue could be retitled to something like "dbConnect() parameters should be validated".

@krlmlr
Copy link
Member Author

krlmlr commented Jul 5, 2017

Comment by krlmlr
Thursday Nov 12, 2015 at 12:21 GMT


I don't see a reason why a string that looks like an integer shouldn't be coerced to an integer. Other than that, I think the errors emitted by the MySQL driver should be fine in most cases.

@krlmlr
Copy link
Member Author

krlmlr commented Sep 13, 2017

@stevenpollack @peternowee: Coercing to integer now.

@peternowee
Copy link
Contributor

That's the best, thanks!

krlmlr added a commit that referenced this issue Sep 24, 2017
- Improve documentation for location of option files, with reference (#18).
- Fully support parametrized queries (#22, #27, #39).
- Use snake_case in C++ code.
- Make transactions compliant to the spec (#38, #49).
- 64-bit integers are now supported through the `bit64` package. Unfortunately, this also means that numeric literals (as in `SELECT 1`) are returned as 64-bit integers (#12).
- Support timestamp values with sub-second precision on output.
- The connection now uses the "utf8mb4" charset by default (#7).
- The `port` and `client.flag` arguments to `dbConnect()` are coerced to integer (#4).
- Date values with the year beyond 2038 are supported (#56).
- Improve DBI compliance (#1, #5, #10, #15, #17, #40).
- Correct handling of DATETIME and TIME columns (#52, @noahwilliamsson).
@thayzacoelho
Copy link

It keep showing me it
Error in .local(drv, ...) :
Failed to connect to database: Error: Plugin caching_sha2_password could not be loaded: The specified module could not be found.

Help!!

@peternowee
Copy link
Contributor

@thayzacoelho I think that is a different issue. Perhaps #134 or open a new issue.

@github-actions
Copy link

This old thread has been automatically locked. If you think you have found something related to this, please open a new issue and link to this old issue if necessary.

@github-actions github-actions bot locked and limited conversation to collaborators Jun 15, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants