Re: carray_to_bytea?

From: Ken Been <kbbeen(at)gmail(dot)com>
To: Jim Nasby <Jim(dot)Nasby(at)bluetreble(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-general(at)postgresql(dot)org
Subject: Re: carray_to_bytea?
Date: 2015-10-22 17:27:00
Message-ID: CANe84rzZVOm_ys998B1J3LLFx5Ma3u8UqNw80WjhTrLKtbtbrg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Yeah, I thought of that (actually bytea *), but then you have to assume
that bytea and text will always be typedef'ed to the same thing. (Is
casting between different non-void pointer types, even if they are
compatible, a warning/error in C? I can't remember.)

On Thu, Oct 22, 2015 at 5:16 PM, Jim Nasby <Jim(dot)Nasby(at)bluetreble(dot)com> wrote:

> On 10/22/15 12:13 PM, Ken Been wrote:
>
>> My input is a byte array with a length.
>> I can't assume zero-termination for varchar fields, so
>> cstring_to_text_with_len
>> is exactly what I need for those. For varbinary (i.e., bytea), you're
>> right, it's
>> just a couple of lines of code, but what if the implementation of struct
>> varlena
>> changes? Are we guaranteed that "palloc(len + VARHDRSZ)" will always
>> allocate the correct amount?
>>
>
> Why not just (bytea) cstring_to_text_with_len(...) ?
> --
> Jim Nasby, Data Architect, Blue Treble Consulting, Austin TX
> Experts in Analytics, Data Architecture and PostgreSQL
> Data in Trouble? Get it in Treble! http://BlueTreble.com
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2015-10-22 17:36:43 Re: temporary indexes?
Previous Message Jim Nasby 2015-10-22 17:16:55 Re: carray_to_bytea?