"David G. Johnston" <david.g.johnston@xxxxxxxxx> writes: > On Wed, Jan 20, 2021 at 5:00 AM Avery Fischer <biggerfisch@xxxxxxxxx> wrote: >> ERROR: PL/pgSQL functions cannot return type myrange >> Am I misunderstanding the docs, or are they out-of-date, or is something >> else going on? How can I create a canonicalization function for my range >> type? > Thus one needs to write a C language function if one wishes to implement a > custom range. Yeah, that's the only way at the moment. We've not seen much use-case for writing canonicalization functions in PLs, because of (a) performance and (b) circularity concerns --- the latter meaning that the PL's own infrastructure is likely to expect that it can manipulate scalar values without incurring recursion. These are pretty much the same reasons why a datatype's I/O functions can't be written in a PL. regards, tom lane