added psql functions script