While Mr. Haacked and company fight emergencies, I've been making some progress with Subtext's MySQL port. So here is what is done so far.
All SQL has been converted to MySQL. The effort was actually pretty enormous, considering time constraints. There were 7 installation files full of CREATE TABLE scripts.
And then there were 90 stored procedures. Two thirds of stored procs converted with minor tweaking. Some, particularly ones that fetch paged data were greatly simplified, thanks to MySQL LIMIT command. And a few had to be basically rewritten. All in all, good learning experience in MySQL. Compared to the original, Stored Procedures.sql file has lost 32 kb, mostly because getting paged data did not require the complexity that the MS SQL Server requires.
Next I converted Microsoft Application Data Block to MySQL. This was fairly easy. The only hickup I experienced is that initially I renamed SqlHelper class to MySqlHelper. Well, it turns out that the MySQL ado.net provider already has a MySqlHelper class. In it, they implemented a small subset of the Application Data Block. Unfortunately, it was not the subset that Subtext is using. So my class is called MySqlHelperEx.
Then I methodically ripped out of Subtext all the MSSQL related goodness and replaced it with MySQL equivalents.
| Ripped out | Replaced with |
| SqlClient | MySQL provider |
| Microsoft Application Data Block | MySQL Application Data Block |
| Calls to SET NOCOUNT ON | Not needed on MySQL |
| Stored Parameters starting with @ | MySQL can't handle parameters starting with @, so had to replace it with _ (underscore) |
| nvarchar, ntext, int, etc... | Equivalent types |
There are also a ton of other little, tiny differences that make writing database agnostic code difficult. For instance, SELECT COUNT(*) as TotalRecords returns INT on MSSQL, but LONG on MySQL.
Another rather annoying problem is that MySQL does not support default parameters, while Subtext makes a fairly liberal use of them.
What Works So Far.
I got the installation working well. Blog comes up and I can configure it fine. From there things get a bit dicey. There are exceptions here and there, probably due to the use of default parameters.