Converted UDF to be PL/PGSQL instead of standard SQL.
Also converted the C function to use an oid, thus allowing us to keep ResolveRelationId unchanged.