1

I am trying to write a script to patch our mysql database. Something like this I can run:

If IsTargetVersion(1.1) 
THEN
ALTER TABLE t1 ENGINE = InnoDB;
END IF;

The funny thing I found about MySql is: it doesn't support if condition in script. I don't want to create a store procedure, call it and drop it in my script. That looks stupid...

Does anybody have better approach?

Thanks

2
  • Excuse my ignorance but what exactly is IsTargetVersion? Commented Mar 28, 2012 at 1:46
  • a function to tell the version Commented Mar 28, 2012 at 17:10

1 Answer 1

2

This (pattern) solution just a workaround which will help you to use IF condition in the MySQL scripts -

SET @s = IF(IsTargetVersion(1.1), 'ALTER TABLE t1 ENGINE = InnoDB', 'DO SLEEP(0)');
PREPARE stmt1 FROM @s;
EXECUTE stmt1;
Sign up to request clarification or add additional context in comments.

1 Comment

Your answer is amazing!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.