24384275 Make DBD::mysql use mysql 5.7
authorVladimir Marek <Vladimir.Marek@oracle.com>
Wed, 27 Jul 2016 08:28:16 -0700
changeset 6541 e00afd505b4e
parent 6540 a6868ecc80b4
child 6542 8af6b6d966a0
24384275 Make DBD::mysql use mysql 5.7
components/perl_modules/dbd-mysql/Makefile
components/perl_modules/dbd-mysql/TESTING
components/perl_modules/dbd-mysql/patches/05_31insertid.t.patch
components/perl_modules/dbd-mysql/test/results-all.master
--- a/components/perl_modules/dbd-mysql/Makefile	Tue Aug 02 12:50:07 2016 -0700
+++ b/components/perl_modules/dbd-mysql/Makefile	Wed Jul 27 08:28:16 2016 -0700
@@ -62,7 +62,7 @@
 
 ASLR_MODE = $(ASLR_NOT_APPLICABLE)
 
-MYSQL_VERSION       = 5.6
+MYSQL_VERSION       = 5.7
 MYSQL_BINDIR        = $(USRDIR)/mysql/$(MYSQL_VERSION)/bin
 MYSQL_TEST_USER     = root
 MYSQL_TEST_PASSWORD = new-password
@@ -100,7 +100,7 @@
 #    background task
 
 # If you want to keep mysqld running for your own testing purposes, delete all
-# the lines containing 'kill' in COMPONENT_PRE_TEST_ACTION and
+# the lines containing 'kill' in COMPONENT_PRE_TEST_ACTION and whole
 # COMPONENT_POST_TEST_ACTION. Then run "gmake test" once which will both run
 # the DB and configure the module to use it. After that you can "cd builds/..."
 # and "gmake test" directly there.
@@ -126,26 +126,27 @@
 	TEST_LINK=`mktemp -t dbd-mysql-test.XXXXXX`; \
 	$(RM) "$$TEST_LINK"; \
 	ln -s $(MYSQL_TEST_DATADIR) "$$TEST_LINK"; \
-	echo "$$TEST_LINK" > "$$TEST_LINK"/test_link; \
 	\
 	: "alter the tests to use the path we just created"; \
 	$(PERL) -pi -e "s,('testsocket' => ').*?',\$$1/$$TEST_LINK/socket'," t/mysql.mtest ;\
 	\
 	: "Initialize mysql DB"; \
-	"$(MYSQL_BINDIR)/mysql_install_db" \
-			--keep-my-cnf \
+	"$(MYSQL_BINDIR)/mysqld" \
+			--initialize-insecure \
 			--datadir="$$TEST_LINK" \
 			--basedir=/usr/mysql/$(MYSQL_VERSION) $(SILENT) ; \
 	\
+	echo "$$TEST_LINK" > "$$TEST_LINK"/test_link; \
+	\
 	: "Run the daemon in background. --gdb makes it possible to terminate mysqld via Ctrl+C"; \
 	"$(MYSQL_BINDIR)/mysqld" \
 			$(MYSQLD_VERBOSE) \
 			--skip-networking \
+			-u "$(MYSQL_TEST_USER)"\
 			--datadir="$$TEST_LINK" \
 			--socket="$$TEST_LINK"/socket \
 			--pid-file="$$TEST_LINK"/pid \
 			--gdb \
-			--log-warnings=0 \
 			$(SILENT) & \
 	: "Now wait for the database to be online"; \
 	sleep 10; \
@@ -163,6 +164,13 @@
 			-u "$(MYSQL_TEST_USER)" \
 			password "$(MYSQL_TEST_PASSWORD)" ; \
 	\
+	: "Create a database"; \
+	"$(MYSQL_BINDIR)/mysqladmin" \
+			--socket "$$TEST_LINK"/socket \
+			-u "$(MYSQL_TEST_USER)" \
+			--password="$(MYSQL_TEST_PASSWORD)" \
+			create test; \
+	\
 	: "Run job which will kill mysqld in 10 minutes"; \
 	( $(SET_X) PID=`cat "$$TEST_LINK"/pid`; sleep 600; ps -p $$PID && kill $$PID || : ) $(SILENT) & \
 	echo $$! > "$$TEST_LINK"/pid_of_guard; \
@@ -177,6 +185,6 @@
 $(LICENSE): $(LICENSE).template
 	$(PERL) -pe 's/COMPONENT_VERSION/$(COMPONENT_VERSION)/g' "$<" > "$@"
 
-REQUIRED_PACKAGES += database/mysql-56/library
+REQUIRED_PACKAGES += database/mysql-57/library
 REQUIRED_PACKAGES += library/perl-5/database
 REQUIRED_PACKAGES += system/library/c++-runtime
--- a/components/perl_modules/dbd-mysql/TESTING	Tue Aug 02 12:50:07 2016 -0700
+++ b/components/perl_modules/dbd-mysql/TESTING	Wed Jul 27 08:28:16 2016 -0700
@@ -2,7 +2,7 @@
 ================================ Install mysql =================================
 ================================================================================
 
-$ pkg install database/mysql-56 database/mysql-56/client
+$ pkg install database/mysql-57 database/mysql-57/client
 
 
 
@@ -15,15 +15,15 @@
 set -x
 
 MYSQL_TEST_DATADIR=/var/tmp/mysql
-MYSQL_VERSION=5.6
+MYSQL_VERSION=5.7
 MYSQL_BINDIR=/usr/mysql/$MYSQL_VERSION/bin
 MYSQL_TEST_USER=root
 MYSQL_TEST_PASSWORD=new-password
 
 rm -rf "$MYSQL_TEST_DATADIR"
 
-"$MYSQL_BINDIR/mysql_install_db" \
-        --keep-my-cnf \
+"$MYSQL_BINDIR/mysqld" \
+        --initialize-insecure \
         --datadir="$MYSQL_TEST_DATADIR" \
         --basedir=/usr/mysql/$MYSQL_VERSION
 
@@ -31,7 +31,7 @@
 #   --gdb makes it possible to terminate mysqld via Ctrl+C
 "$MYSQL_BINDIR/mysqld" \
         --skip-networking \
-        -u $MYSQL_TEST_USER \
+        -u "$MYSQL_TEST_USER" \
         --datadir="$MYSQL_TEST_DATADIR" \
         --socket="$MYSQL_TEST_DATADIR"/socket \
         --pid-file="$MYSQL_TEST_DATADIR"/pid \
@@ -44,6 +44,11 @@
         -u "$MYSQL_TEST_USER" \
         password "$MYSQL_TEST_PASSWORD"
 
+"$MYSQL_BINDIR/mysqladmin" \
+        --socket "$MYSQL_TEST_DATADIR"/socket \
+        -u "$MYSQL_TEST_USER" \
+        --password="$MYSQL_TEST_PASSWORD" \
+        create test
 
 
 ================================================================================
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/perl_modules/dbd-mysql/patches/05_31insertid.t.patch	Wed Jul 27 08:28:16 2016 -0700
@@ -0,0 +1,98 @@
+https://rt.cpan.org/Public/Bug/Display.html?id=108000
+https://bugs.mysql.com/bug.php?id=78778
+
+The fix will be available in next DBD::mysql stable release
+
+commit 85459c2f43243e41841180e554e4ef142d95d56b
+Author: Michiel Beijen <[email protected]>
+Date:   Mon Aug 1 08:10:33 2016 +0200
+
+    $dbh->{mysql_insertid} is cleared after SELECT
+    
+    Apparently, on t/31insertid.t, there is one test that fails when
+    compiled against libmysqlclient 5.7 or up; issuing a SELECT statement
+    on the same database handle that previously executed an INSERT clears
+    $dbh->{mysql_insertid}, while previously this was retained.
+      (https://rt.cpan.org/Ticket/Display.html?id=108000)
+
+--- a/Changes
++++ b/Changes
+@@ -1,3 +1,10 @@
++2016-08-01 Patrick Galbraith, Michiel Beijen, DBI/DBD community (4.035_01)
++* Apparently, on t/31insertid.t, there is one test that fails when compiled
++  against libmysqlclient 5.7 or up; issuing a SELECT statement on the same
++  database handle that previously executed an INSERT clears
++  $dbh->{mysql_insertid}, while previously this was retained.
++  (https://rt.cpan.org/Ticket/Display.html?id=108000)
++
+ 2016-07-09 Patrick Galbraith, Michiel Beijen, DBI/DBD community (4.035)
+ *  Add DBI back to configure_requires, fix by miyagawa.
+
+diff --git a/lib/DBD/mysql.pm b/lib/DBD/mysql.pm
+index 069e882..4830b9d 100644
+--- a/lib/DBD/mysql.pm
++++ b/lib/DBD/mysql.pm
+@@ -1733,10 +1733,14 @@ have impact on the I<max_length> attribute.
+ 
+ =item mysql_insertid
+ 
+-MySQL has the ability to choose unique key values automatically. If this
+-happened, the new ID will be stored in this attribute. An alternative
+-way for accessing this attribute is via $dbh->{'mysql_insertid'}.
+-(Note we are using the $dbh in this case!)
++If the statement you executed performs an INSERT, and there is an AUTO_INCREMENT
++column in the table you inserted in, this attribute holds the value stored into
++the AUTO_INCREMENT column, if that value is automatically generated, by
++storing NULL or 0 or was specified as an explicit value.
++
++Typically, you'd access the value via $sth->{mysql_insertid}. The value can
++also be accessed via $dbh->{mysql_insertid} but this can easily
++produce incorrect results in case one database handle is shared.
+ 
+ =item mysql_is_blob
+ 
+diff --git a/t/31insertid.t b/t/31insertid.t
+index 18a6d3b..f00c5a4 100644
+--- a/t/31insertid.t
++++ b/t/31insertid.t
+@@ -16,7 +16,7 @@ if ($@) {
+     plan skip_all =>
+         "no database connection";
+ }
+-plan tests => 18;
++plan tests => 19;
+ 
+ ok $dbh->do('SET @@auto_increment_offset = 1');
+ ok $dbh->do('SET @@auto_increment_increment = 1');
+@@ -38,7 +38,8 @@ ok defined $sth;
+ 
+ ok $sth->execute("Jochen");
+ 
+-is $dbh->{'mysql_insertid'}, 1, "insert id == $dbh->{mysql_insertid}";
++is $sth->{mysql_insertid}, 1, "insert id == $sth->{mysql_insertid}";
++is $dbh->{mysql_insertid}, 1, "insert id == $dbh->{mysql_insertid}";
+ 
+ ok $sth->execute("Patrick");
+ 
+@@ -53,12 +54,15 @@ ok ($max_id= $sth2->fetch());
+ 
+ ok defined $max_id;
+ 
+-cmp_ok $sth->{'mysql_insertid'}, '==', $max_id->[0], "sth insert id $sth->{'mysql_insertid'} == max(id) $max_id->[0]  in dbd_mysql_t31";
+-
+-cmp_ok $dbh->{'mysql_insertid'}, '==', $max_id->[0], "dbh insert id $dbh->{'mysql_insertid'} == max(id) $max_id->[0] in dbd_mysql_t31";
++SKIP: {
++  skip 'using libmysqlclient 5.7 or up we now have an empty dbh insertid',
++    1, if $dbh->{mysql_clientversion} >= 50700;
++  cmp_ok $dbh->{mysql_insertid}, '==', $max_id->[0],
++    "dbh insert id $dbh->{'mysql_insertid'} == max(id) $max_id->[0] in dbd_mysql_t31";
++}
++cmp_ok $sth->{mysql_insertid}, '==', $max_id->[0],
++  "sth insert id $sth->{'mysql_insertid'} == max(id) $max_id->[0]  in dbd_mysql_t31";
+ 
+ ok $sth->finish();
+-
+ ok $sth2->finish();
+-
+ ok $dbh->disconnect();
+ 
--- a/components/perl_modules/dbd-mysql/test/results-all.master	Tue Aug 02 12:50:07 2016 -0700
+++ b/components/perl_modules/dbd-mysql/test/results-all.master	Wed Jul 27 08:28:16 2016 -0700
@@ -79,6 +79,6 @@
 t/rt91715.t .......................... ok
 t/version.t .......................... ok
 All tests successful.
-Files=67, Tests=1641, <TIMINGS REMOVED>
+Files=67, Tests=1642, <TIMINGS REMOVED>
 Result: PASS
 make[1]: Leaving directory '$(@D)'