Hi Alexander, The fix looks reasonable to me. It matches the existing natural-key approach in DOTypeNameCompare(), and using pgTypeNameCompare() for the referenced types seems like the right way to avoid falling back to OID order.
One small test-coverage suggestion - the added cast test exercises the casttarget tie-breaker, because both casts use the same source type and only the target type differs by schema. Since the patch also adds a castsource tie-breaker, it may be worth adding a symmetric case where two source types share the same typname across schemas and cast to the same target type. That would cover both new comparisons explicitly. Best Regards, Nitin Jadhav Azure Database for PostgreSQL Microsoft
