SQL Games

I have just created a GitHub repository called sql_games. It contains games implemented as stored procedures, that can run on MariaDB or (with some changes) on Percona Server or Oracle MySQL.

You play the games via the command-line client. You call a procedure to make your move, then a text or an ASCII image appears.

Of course the same call should produce a different effect, depending on the game’s current state. To remember the state I use both user variables and temporary tables.

Why did I do that? Mainly because it was funny. I can’t explain why. And I can’t tell that it is funny for anyone: perhaps, where I’ve found interesting challenges, someone else would find a cause a frustration. But yes, it has been funny for me.

Also, I did it because I could. This means that others can do it. Stored procedures are not a useless and nasty feature that users should ignore – they are useful tools. Yes, several times I’ve complained that they need important improvements. But I complain because I like them.

Currently, three games are implemented:

  • Anagram – The anagram game. See a randomly generated anagram and try to guess the word. You can choose a language, and a min/max word length.
  • Bulls And Cows – If you don’t know the game, take a look at the Wikipedia page.
  • Hangman –  Try to guess letters and see an ASCII hangman materializing slowly while you fail.

Each game will be installed in a different database. CALL help() in the proper database to see how to play.

2 thoughts on “SQL Games

  1. It is great to see games like this. Certainly something different. A nice Christmas/New Year’s present…

    However, I see from github you say: “It can run on Percona Server or Oracle MySQL, but will probably require some small changes, since I may have used MariaDB-specific features.”. That worries me.

    Everyone is free to use or do what they want, but the fact that software starts to only work on one “flavour” of MySQL or its derivatives means “sharding” the user base and in the end the community. I think that is bad.

    If MariaDB has something that Oracle’s MySQL does not (and it is better) I would hope that functionality would make it to Oracle’s MySQL.

    When new functionality is needed (and we are seeing a lot of new things going into all the different flavours of MySQL/MariaDB) then I would hope that where possible they would be “compatible”. I do not see a community forum (though I may not have looked in the right place) where this challenge is addressed. That is “how to enhance MySQL (in its generic meeting), allow the different forks to experiment and become better, yet do so in a way which will not fracture the common community.” Failing to address this is long term something we should all be worried about.

    So Federico, if you can make this work on Oracle/Percona’s MySQL too, I would encourage that. If you think you need the MariaDB-specific functionality file a feature request for it in bugs.mysql.com explaining why that functionality is needed. This may not get addressed quickly but if it does then your user base will grow. That’s good for you and good for others.

    • Hi Simon! Thank you for your comment.
      In my specific case, I’ve used MariaDB features (like the SEQUENCE engine) because they’re convenient. Rewriting the parts that don’t work on Oracle MySQL should be very easy, but these are just ASCII games, so I don’t think that this work is necessary.
      More generally speaking… I partly share your concern. But compatibility cannot (and should not) be created by users. If MariaDB and Oracle don’t want to share the exact same set of features, it’s their choice. Oracle goes even further, by re-implementing some MariaDB features with minor syntax changes (virtual columns, replication filters).
      We can avoid using useful features from our favourite MySQL flavor, but this means that we’ll need more code or less optimizations. We can handle syntax incompatibilities, but again, we need more code and testing. If one does this additional work for open source software, well it’s great, I’ll be thankful for this. But it’s not something I want to do, sorry.

Leave a comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s