anse1 / sqlsmith

A random SQL query generator
GNU General Public License v3.0
754 stars 128 forks source link

MariaDB Support! #37

Open mariadb-RoelVandePaar opened 3 years ago

mariadb-RoelVandePaar commented 3 years ago

Hi SQLSmith Team! Roel here (principal test engineer at MariaDB). Great program you have here. Would you be so kind as to a connector to MariaDB? Thank you & God bless

Ref https://mariadb.com/kb/en/mysql_query/

anse1 commented 3 years ago

Hello Roel,

Roel Van de Paar writes:

Hi SQLSmith Team! Roel here (principal test engineer at MariaDB). Great program you have here. Would you be so kind as to a connector to MariaDB? Thank you & God bless

I think one of the many forks on github worked on that, I can't remember which one though...

I do also have some work-in-progress dut/schema classes for mysql from

  1. I just pushed this old work-in-progress code to a new branch "mysql". No warranties though...

IIRC testing mysql didn't work as well with it when compared to testing monedb/postgres because mysql yielded syntax errors instead of type errors for invalid casts. This is a real problem for sqlsmith since syntax errors lead to blacklisted grammar rules and products reporting syntax errors for things that aren't will end up with an empty grammar eventually... Part of the errors seem to be caused by sqlsmith not knowing about typemods, so it gets part of the blame :-)

Also, I noticed the old code doesn't set the parameter max_statement_time mariadb supports. This should be set to something low, e.g. 1 second, to avoid the database number-crunching on huge queries for hours, which doesn't have much test value IMHO.

I do not currently plan to resume working on mariadb/mysql support in sqlsmith in my spare time, but can offer to do paid work on it via my employer (credativ.de). Of course, patches/merge requests for supporting more free software databases are welcome any time.

regards, Andreas

mariadb-RoelVandePaar commented 3 years ago

Hi Andreas,

Thank you.

It would be really great if you could implement this. Please.

God bless, Roel

On Wed, Mar 31, 2021 at 5:24 AM Andreas Seltenreich < @.***> wrote:

Hello Roel,

Roel Van de Paar writes:

Hi SQLSmith Team! Roel here (principal test engineer at MariaDB). Great program you have here. Would you be so kind as to a connector to MariaDB? Thank you & God bless

I think one of the many forks on github worked on that, I can't remember which one though...

I do also have some work-in-progress dut/schema classes for mysql from

  1. I just pushed this old work-in-progress code to a new branch "mysql". No warranties though...

IIRC testing mysql didn't work as well with it when compared to testing monedb/postgres because mysql yielded syntax errors instead of type errors for invalid casts. This is a real problem for sqlsmith since syntax errors lead to blacklisted grammar rules and products reporting syntax errors for things that aren't will end up with an empty grammar eventually... Part of the errors seem to be caused by sqlsmith not knowing about typemods, so it gets part of the blame :-)

Also, I noticed the old code doesn't set the parameter max_statement_time mariadb supports. This should be set to something low, e.g. 1 second, to avoid the database number-crunching on huge queries for hours, which doesn't have much test value IMHO.

I do not currently plan to resume working on mariadb/mysql support in sqlsmith in my spare time, but can offer to do paid work on it via my employer (credativ.de). Of course, patches/merge requests for supporting more free software databases are welcome any time.

regards, Andreas

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/anse1/sqlsmith/issues/37#issuecomment-810479153, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOTENMFT7N6G6W4SPNVT6IDTGIJNBANCNFSM4Z4SP5TQ .

anse1 commented 3 years ago

Hi Roel,

Roel Van de Paar writes:

On Wed, Mar 31, 2021 at 5:24 AM Andreas Seltenreich wrote:

I do not currently plan to resume working on mariadb/mysql support in sqlsmith in my spare time, but can offer to do paid work on it via my employer (credativ.de). It would be really great if you could implement this. Please.

great, I think 40 hours of work will be enough to address the issues I mentioned and get a release with it out of the door. Simply get in touch with @.*** for a quote for 40 hours of coding work on sqlsmith.

regards, Andreas

anse1 commented 3 years ago

Oops, looks like the mail address got censored. You can use the web form to get in contact with credativ's sales for coding work on sqlsmith as well:

https://www.credativ.de/en/contact/
mariadb-RoelVandePaar commented 3 years ago

Done. Thanks

On Sat, Apr 17, 2021 at 6:38 AM Andreas Seltenreich < @.***> wrote:

Oops, looks like the mail address got censored. You can use the web form to get in contact with credativ's sales for coding work on sqlsmith as well:

https://www.credativ.de/en/contact/

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/anse1/sqlsmith/issues/37#issuecomment-821550450, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOTENMCKEXENPER266I7BHDTJCN4JANCNFSM4Z4SP5TQ .

RoelVdP commented 2 years ago

Updates: 1) It was decided not to proceed with a consultancy setup. 2) I pulled the mysql branch and tested it. Changed the connection to local parameters including using socket (faster!) and recompiled. In the example below, /test/socket.sock is a symlink which can easily be pointed at other instances to test.

~/sqlsmith$ git diff
diff --git a/mysql.cc b/mysql.cc
index 138218c..781ff2e 100644
--- a/mysql.cc
+++ b/mysql.cc
@@ -13,8 +13,8 @@ mysql_connection::mysql_connection(const std::string &conninfo)
 {
   (void) conninfo;
   con = mysql_init(NULL);
-  if (!mysql_real_connect(con, "localhost", "smith", "smith", 
-                         "smith" /*dbname*/, 0, NULL, 0)) {
+  if (!mysql_real_connect(con, "localhost", "root", "",
+                         "test" /*dbname*/, 0, "/test/socket.sock", 0)) {
     throw runtime_error(mysql_error(con));
   }
 }

3) Ran various tests. It generally generates many long and interesting queries and provided verbose output. Logging statements to a file was also possible.

I would propose, as further steps, to do this:

  1. Introduce variables in mysql.cc instead of hardcoded items so a real --mysql="host='x';port=x;socket='x';user='x';password='x';db='x'" or similar connect string can be used.
  2. merge the mysql branch into master/trunk. The branch will have to pull the current master/trunk first (there are merge conflicts).
  3. Even if there are still some shortcomings, it already works and is usable as-is (release early/release often). This will also make it easier to submit further patches and can widen the use of the product.

Could you kindly have a look at this Andreas (@anse1)? Thank you!