code examples pulled from PG's ANSI CL