jstedfast/MimeKit — pull request #52 by fogzot (2014-04-20 11:17:09+00:00)
Title: Added support for PostgreSQL-based certificate database

This splits out some common parts from SqliteCertificateDatabase in an abstract base class and adds support for PostgreSQL in the new NpgsqlCertificateDatabase class. The code had some assumptions on using SQLite that I had to fix:

* Some backends don't support case-independent collation using `COLLATE NOCASE` so I removed that and added an explicit `lower()` call when comparing CI columns.
* The correct form to check if a column is `NULL` is `IS NOT NULL`, just `NOT NULL` doesn't work on all backends.
* Most backends implicitly convert identifiers to lower casing unless they are quoted and return the canonical name in queries. Using upper case identifiers without quoting and then depending on the column names returned by the backend is a bad idea. I didn't want to change the schema so I fixed this by adding case insensitive comparisons to "Load" methods.

The version of Npgsql distributed with Mono is old and broken and doesn't support `bytea` (byte[] on the CLR side) correctly. I had to bundle the latest version of Npgsql to make sure the tests worked.

Also, I marked the Npgsql tests `[Exlicit]` but MonoDevelop executes them always anyway... alas.