| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
There was a problem hiding this comment.
Thanks a lot for the PR. The changes look great overall.
I think that we need to expose the default port and host to the user in some way. See my thoughts in this respect as an in-line comment. Let me know if you have any follow-up questions or thoughts.
Thanks again for the great PR!
Sorry, something went wrong.
| import sqlancer.mysql.gen.tblmaintenance.MySQLRepair; | ||
|
|
||
| public class MySQLProvider extends SQLProviderAdapter<MySQLGlobalState, MySQLOptions> { | ||
| protected String username; |
There was a problem hiding this comment.
Why are these (and equivalent variables in other classes) fields and not local variables? They are only used in the createDatabase method, no?
Sorry, something went wrong.
There was a problem hiding this comment.
I do not really understand. Could you expand on what issues there might be when using a local variable rather than a field?
Sorry, something went wrong.
There was a problem hiding this comment.
Ideally, we would still use local variables here, but if you are reluctant to do this for this PR, I can also do this in a future follow-up PR.
Sorry, something went wrong.
| public SQLConnection createDatabase(ClickHouseGlobalState globalState) throws SQLException { | ||
| host = globalState.getOptions().getHost(); | ||
| port = globalState.getOptions().getPort(); | ||
| if ("sqlancer".equals(host)) { |
There was a problem hiding this comment.
As mentioned before, I think that this check makes it difficult to understand what's going on. I think that we want that the user has a clear understanding of the default values for the host and port. Currently, "sqlancer" is displayed as a default value for the host and port, but actually, these default values are overwritten by DBMS-specific ones that the user cannot see. I see two potential options to address this:
clickhouse ClickHouse (default port: 8123, default host: localhost)
Usage: clickhouse [options]
Options:
...
Previously, you mentioned that the host and port can be null, but would this not result in an invalid URL?
Sorry, something went wrong.
There was a problem hiding this comment.
This process actually involves two points:
(1) The user does not specify the host and port, then we need to replace it with the default value, which is different in different databases. This may be better set in xxOptions.java of each database.
(2) If the user sets one of host and port, we should use the value provided by the user to replace the default value of these systems. This should probably be set in xxProvider.java.
This may be modified in several places, refactoring several parts...(-:
Sorry, something went wrong.
There was a problem hiding this comment.
Yes, there are multiple ways to implement this. It would be great to have this, so that the user knows about the default values.
Sorry, something went wrong.
| globalState.setClickHouseOptions(clickHouseOptions); | ||
| String url = "jdbc:clickhouse://localhost:8123/default"; | ||
| // String url = "jdbc:clickhouse://localhost:8123/default"; | ||
| String url = "jdbc:clickhouse://" + host + ":" + port + "/defult"; |
There was a problem hiding this comment.
Typo: this should be default.
Sorry, something went wrong.
There was a problem hiding this comment.
Typo: this should be default.
I will modify it next time pull request.
Sorry, something went wrong.
| private String password = "sqlancer"; // NOPMD | ||
|
|
||
| @Parameter(names = "--host", description = "The host used to log into the DBMS") | ||
| private String host = "sqlancer"; // NOPMD |
There was a problem hiding this comment.
Since these options are not supported by all DBMSs (yet): Would it be possible to insert a (static) check method that is called by every provider that does not support these? This is optional for this PR, but it might be a useful future improvement.
Sorry, something went wrong.
There was a problem hiding this comment.
Since these options are not supported by all DBMSs (yet): Would it be possible to insert a (static) check method that is called by every provider that does not support these? This is optional for this PR, but it might be a useful future improvement.
We modify the description information to remind users that this value will be reset by the system. Is it feasible?
@Parameter(names = "--host", description = "The host used to log into the DBMS. If the user does not specify this value, it will be reset to localhost by the system")
private String host = "sqlancer"; // NOPMD
@Parameter(names = "--host", description = "The host used to log into the DBMS. If the user does not specify this value, it will be reset to database system default port by the system")
private String host = "sqlancer"; // NOPMD
In fact, another important function of placeholders is to facilitate us to determine whether the user has specified this parameter, so invalid values should be used as placeholders. The value sqlancer is a good choice. These two values are actually essentially different from username and password. The default of host is localhost. The default of port is database parameter.
what do you think? :) (-:
Sorry, something went wrong.
There was a problem hiding this comment.
I do not yet understand yet why we need any placeholders in the options. None of the other options have deliberately invalid default values, I believe. If you want to indicate that no port or host have been set, should they be null?
Sorry, something went wrong.
There was a problem hiding this comment.
I do not yet understand yet why we need any placeholders in the options. None of the other options have deliberately invalid default values, I believe. If you want to indicate that no port or host have been set, should they be null?
Yes, null is also possible. But according to the previous design, does the system still have to reset the host and port to the corresponding to localhost and the default port of database respectively? If you think null is more appropriate, I am willing to modify it. LMK, please.
Sorry, something went wrong.
There was a problem hiding this comment.
Yes, I believe that either null, while also printing the default values when the help text is printed, or implementing them as DBMS-specific options (rather than in MainOptions) would be ways to achieve this.
Sorry, something went wrong.
|
TBR. Please let me know if this version can be merged? Thank you @mrigger |
Sorry, something went wrong.
|
Sorry for the delayed response! As mentioned, it would be great to address the two concerns I mentioned: (1) we want to display the default values that each DBMS uses to the user as part of the help text and (2) not use invalid default values (i.e., either use null or implement them as DBMS-specific options). Please let me know if there are any unclarities, and I will provide more details. |
Sorry, something went wrong.
|
TBR @mrigger |
Sorry, something went wrong.
| import sqlancer.common.oracle.TestOracle; | ||
|
|
||
| @Parameters(separators = "=", commandDescription = "Test CockroachDB") | ||
| @Parameters(separators = "=", commandDescription = "CockroachDB (default port: 26257, default host: localhost)") |
There was a problem hiding this comment.
Rather than hard-coding the port and localhost, could you please introduce constants for them that you use in both the description and when setting the values?
For example, in CockroachDBOptions you can have a field final static int DEFAULT_PORT = 26257; and reference it both here as "CockroachDB (default port: " + CockroachDBOptions.DEFAULT_PORT + ... and below in createDatabase. By doing so, the help text and actual default values will always be consistent.
Sorry, something went wrong.
There was a problem hiding this comment.
Indeed, the current help text and default value can be consistent here.
Thank you for your suggestions.
TBR @mrigger
Sorry, something went wrong.
There was a problem hiding this comment.
Sorry again for the late response - I had some full-day obligations in the last couple of days, and will be able to respond much faster in the future.
Why does using the constant in the annotation text not work?
Sorry, something went wrong.
| private String host = null; // NOPMD | ||
|
|
||
| @Parameter(names = "--port", description = "The port used to log into the DBMS") | ||
| private int port = -1; // NOPMD |
There was a problem hiding this comment.
Rather than checking for -1, could you please introduce a constant like NO_PORT_SET and use it also in the createDatabase methods?
Sorry, something went wrong.
|
|
||
| String databaseName = globalState.getDatabaseName(); | ||
| String url = "jdbc:mysql://127.0.0.1:4000/"; | ||
| // String url = "jdbc:mysql://127.0.0.1:4000/"; |
There was a problem hiding this comment.
Ideally, we could remove the commented-out code (but you don't need to do this for this PR).
Sorry, something went wrong.
Thanks a lot again for your changes and for your patience! After introducing constants and using them to replace the hard-coded values, we can likely merge the PR. |
Sorry, something went wrong.
|
TBR @mrigger Thanks for your suggestions. Please review the latest revisions, and if necessary, please suggest revisions. |
Sorry, something went wrong.
|
Thanks a lot for your PR and for incorporating my improvement suggestions. I highly appreciate it! Merging the PR now. For future PRs, please pay attention to a "clean" commit history by avoid merges as well as rewriting the history for incorporating feedback (and removing accidentally committed files), see https://github.com/sqlancer/sqlancer/blob/master/CONTRIBUTING.md#commit-history. |
Sorry, something went wrong.
Thanks for your suggestions. It’s a great honor to contribute to this project. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
What problem does this PR solve?
Issue number: #95
Summary
Supporting host/port arguments for the follow databases:
Release note
No release note