Adding SQL functions

Non-stable, do not use..