Postgres functions, transactions and rollback

I have a psql function that selects for update and then iterates through an array to update the table. If an error is found it correctly returns false, but does not rollback. So if the error is half way through the array, the first half will have been updated.

I was under the impression that all postgres functions were transactional. Is this not the case?

Should I look into converting my function to a stored procedure so I can get the benefits of transactions?

Thank you