[HACKERS] Bytea as C string in pg_convert?

2007-09-24 Thread Brendan Jurd
Hi hackers, In the process of trying to unify the various text/cstring conversions in the backend, I came across some stuff that seemed weird in pg_convert(). From src/backend/utils/mb/mbutils.c:345: Datum pg_convert(PG_FUNCTION_ARGS) { bytea *string = PG_GETARG_TEXT_P(0); Is this

Re: [HACKERS] Bytea as C string in pg_convert?

2007-09-24 Thread Andrew Dunstan
Brendan Jurd wrote: Hi hackers, In the process of trying to unify the various text/cstring conversions in the backend, I came across some stuff that seemed weird in pg_convert(). From src/backend/utils/mb/mbutils.c:345: Datum pg_convert(PG_FUNCTION_ARGS) { bytea *string =

Re: [HACKERS] Bytea as C string in pg_convert?

2007-09-24 Thread Tom Lane
Andrew Dunstan [EMAIL PROTECTED] writes: We can and possibly should change the GETARG call, but the varlena types are structurally equivalent, so it's not a mortal sin being committed here. We *definitely* should change it --- the reason for having all those variant macros in the first place

Re: [HACKERS] Bytea as C string in pg_convert?

2007-09-24 Thread Andrew Dunstan
Tom Lane wrote: Andrew Dunstan [EMAIL PROTECTED] writes: We can and possibly should change the GETARG call, but the varlena types are structurally equivalent, so it's not a mortal sin being committed here. We *definitely* should change it --- the reason for having all those variant

Re: [HACKERS] Bytea as C string in pg_convert?

2007-09-24 Thread Tom Lane
Andrew Dunstan [EMAIL PROTECTED] writes: I have changed it. The thing is, though, that this function not only performs the convert() function but acts as the engine for convert_to() and convert_from(). Those functions do some silent transformations, in one case passing a text Datum as the

Re: [HACKERS] Bytea as C string in pg_convert?

2007-09-24 Thread Andrew Dunstan
Tom Lane wrote: Andrew Dunstan [EMAIL PROTECTED] writes: I have changed it. The thing is, though, that this function not only performs the convert() function but acts as the engine for convert_to() and convert_from(). Those functions do some silent transformations, in one case passing a

Re: [HACKERS] Bytea as C string in pg_convert?

2007-09-24 Thread Tom Lane
Andrew Dunstan [EMAIL PROTECTED] writes: Tom Lane wrote: Hmm. One suggestion would be to have an internal function declared as taking and returning struct varlena *, with a comment saying that we depend on text and bytea both being compatible with this. All three SQL-visible functions are