Hi All,

A few years ago I got bored over summer and wrote some code to act as an MSSQL 
compatibility layer to postgres. Mostly just to see if such a thing could work. 
The idea is that I can point the MSSQL Management Studio at the server running 
postgres and it looks like I am talking to an MSSQL server. Once I got it 
working to a basic level I went onto other things and kind of forgot about it 
until I was cleaning up my server a few days ago.

Right now the code is pretty rough. I've only implemented bits and pieces to a 
proof of concept stage so it's definitely way off being useful. At the moment 
the following pieces are in place:
. BackgroundWorker listening on port 1433 (hardcoded - I haven't implemented 
any of the udp/1434 discovery stuff)
. Parser to take TDS from an MSSQL client and make sense of it, and then take 
postgres results and send back to the client
. Parser to take T-SQL statements and convert them to postgresql
. Postgres data types for MSSQL types (the main ones at least) using an 
internal storage format compatible with TDS

It's also not really a way for an MSSQL client to access an existing postgres 
database, it's more about implementing an MSSQL-like database using postgres as 
the backend, so an application will think it is actually talking to an MSSQL 
server. I mostly don't use postgres types, just my own tds/tsql compatible 
types. I haven't explored what sort of performance impact this might have.

So right now you can connect, create a database, create/insert/select from some 
tables, etc. Stored procedures/functions should be working but I just tested 
against 9.6 and I get some error about permission denied, and then when I tried 
to grant access to sa to my tsql language I got some error about "GRANT and 
REVOKE are not allowed on untrusted languages" and haven't investigated yet.

I'm not really sure if anyone else would find this interesting, but the code is 
just sitting around on my server doing nothing at the moment. Let me know if 
you want to know more and I can send you a copy of the code (under GPL or 
whatever license). I'm not subscribed to the list so cc me or email me direct.

James


Reply via email to