Skip to content

Commit

Permalink
Fixed MySQL v5.7.25 database name issue.
Browse files Browse the repository at this point in the history
Signed-off-by: ashraful <[email protected]>
  • Loading branch information
AshrafulHaqueToni committed Nov 10, 2023
1 parent fe9cd7c commit df88fe1
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions pkg/data/mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ func InsertMySQLDataCMD(f cmdutil.Factory) *cobra.Command {
log.Fatal("Inserted rows must be greater than 0")
}

if rows > 100000 {
log.Fatal("Inserted rows must be less than or equal 100000")
}

err = opts.insertDataExecCmd(rows)
if err != nil {
log.Fatal(err)
Expand All @@ -94,7 +98,8 @@ func InsertMySQLDataCMD(f cmdutil.Factory) *cobra.Command {

func (opts *mysqlOpts) insertDataExecCmd(rows int) error {
command := `
USE mysql;
CREATE DATABASE IF NOT EXISTS MySQL;
USE MySQL;
CREATE TABLE IF NOT EXISTS kubedb_table (id VARCHAR(255) PRIMARY KEY);
DROP PROCEDURE IF EXISTS insert_data;
DELIMITER //
Expand Down Expand Up @@ -124,7 +129,7 @@ func (opts *mysqlOpts) insertDataExecCmd(rows int) error {
return err
}

fmt.Printf("\nSuccess! %d keys inserted in mysql database %s/%s.\n", rows, opts.db.Namespace, opts.db.Name)
fmt.Printf("\nSuccess! %d keys inserted in MySQL database %s/%s.\n", rows, opts.db.Namespace, opts.db.Name)
return nil
}

Expand Down Expand Up @@ -176,7 +181,9 @@ func (opts *mysqlOpts) verifyDataExecCmd(rows int) error {
}

command := `
USE mysql;
CREATE DATABASE IF NOT EXISTS MySQL;
USE MySQL;
CREATE TABLE IF NOT EXISTS kubedb_table (id VARCHAR(255) PRIMARY KEY);
SELECT COUNT(*) FROM kubedb_table;
`
o, err := opts.executeCommand(command)
Expand Down Expand Up @@ -238,7 +245,7 @@ func DropMySQLDataCMD(f cmdutil.Factory) *cobra.Command {

func (opts *mysqlOpts) dropDataExecCmd() error {
command := `
USE mysql;
USE MySQL;
DROP TABLE IF EXISTS kubedb_table;
`
_, err := opts.executeCommand(command)
Expand Down

0 comments on commit df88fe1

Please sign in to comment.