Viktor/sqlfunctions

This is a massive rewrite of a lot of stuff, but it will let us lock down the database a lot better.

I've tested everything affected afaik, but I could have missed something. We need to write real integration tests.
I think we can put `rows 40` at the end here. A function that returns a set is estimated to return 1000 rows.
```
txbits_testnet=# explain analyze select * from open_asks('USD', 'CAD');
                                                  QUERY PLAN                                                  
--------------------------------------------------------------------------------------------------------------
 Function Scan on open_asks  (cost=0.25..10.25 rows=1000 width=128) (actual time=0.670..0.670 rows=2 loops=1)
 Total runtime: 0.696 ms
(2 rows)
```