Tom Lane <t...@sss.pgh.pa.us> writes: > Peter Eisentraut <pe...@eisentraut.org> writes: >> Would it work to change the signature of pg_get_serial_sequence to >> pg_get_serial_sequence(table anyelement, column text) -> anyelement >> and then check inside the function code whether text or regclass was passed? > > Probably not very well, because then we'd get no automatic coercion of > inputs that were not either type. > > Maybe it would work to have both > > pg_get_serial_sequence(table text, column text) -> text > pg_get_serial_sequence(table regclass, column text) -> regclass
I think it would be more correct to use name for the column argument type, rather than text. > but I wonder if that would create any situations where the parser > couldn't choose between these candidates. According to my my earlier testing¹, the parser prefers the text version for unknown-type arguments, and further testing shows that that's also the case for other types with implicit casts to text such as varchar and name. The regclass version gets chosen for oid and (big)int, because of the implicit cast from (big)int to oid and oid to regclass. The only case I could foresee failing would be types that have implicit casts to both text and regtype. It turns out that varchar does have both, but the parser still picks the text version without copmlaint. Does it prefer the binary-coercible cast over the one that requires calling a conversion function? > regards, tom lane - ilmari [1]: https://postgr.es/m/87v8cfo32v....@wibble.ilmari.org