Re: carray_to_bytea?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Ken Been <kbbeen(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: carray_to_bytea?
Date: 2015-10-22 16:12:33
Message-ID: 48898.1445530353@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Ken Been <kbbeen(at)gmail(dot)com> writes:
> I'd like to propose a carray_to_bytea function, similar to
> cstring_to_text_with_len, declared in src/include/utils.h and implemented
> in src/backend/utils/adt/varlena.c. The implementation would be the same
> as cstring_to_text_with_len, but with a different return type.

> I have put the implementation in my code, but I'd much prefer to use a
> public API with hidden implementation.

Hardly worth it, really. There is nothing to a bytea except the length
and the bytes, so I'd say that any "information hiding" you might be
getting is illusory. Moreover, such a function would encourage people
to assemble useless intermediate copies of the bytestring rather than
constructing it directly in the result object. Consider for example what
byteacat() would look like if it were required to use such a function.

(To some extent these arguments could also be made to apply to
cstring_to_text_with_len, of course, but I consider that to be a sibling
of cstring_to_text, which does have considerable usefulness.)

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2015-10-22 16:15:56 Re: ERROR: invalid page in block 1226710 of relation base/16750/27244
Previous Message bricklen 2015-10-22 15:12:41 Re: ERROR: invalid page in block 1226710 of relation base/16750/27244