From: | mikeo <mikeo(at)spectrumtelecorp(dot)com> |
---|---|
To: | mjp(at)ornl(dot)gov |
Cc: | parangm(at)ornl(dot)gov, pgsql-general(at)postgresql(dot)org |
Subject: | Re: bytea question |
Date: | 2000-08-16 13:04:51 |
Message-ID: | 3.0.1.32.20000816090451.00931c60@pop.spectrumtelecorp.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
thanks, i already have a perl script that splits based on
the backslash. guess i'll just stick with that. thanks for
you time and suggestions.
mikeo
At 06:06 PM 8/15/00 -0400, mjp(at)ornl(dot)gov wrote:
>Oops! You have to write a function for it. Here is a
>sample quick C function:
>
>typedef struct
>{ int len;
> char data[1];
>} string;
>
>string *byteatostr(bytea *arg)
>{
> char buf[1024];
> int ln,i;
> string *res;
> ln = VARSIZE(arg) - VARHDRSZ;
> memmove(buf, VARDATA(arg), ln);
> for(i=0; i < ln; i++)
> if( buf[i] < 32 ) buf[i]='?';
>
> res = (string *) palloc(VARHDRSZ + ln);
> memset(res, 0, VARHDRSZ + ln);
> res->len = VARHDRSZ + ln;
> memmove(res->data, buf, (int) ln);
> return res;
>}
>
>where all non-printable chars are replaced with '?'. Optionally,
>the chars can be escaped (prefixed with '\') - adjusting ln as neccessry.
>
>
>now you get:
>
># select byteatostr(col) from test2;
>
> byteatostr
>------------------------------------------------------------
> fk_uste_wu_id?us_states?web_users?UNSPECIFIED?wu_id?wu_id?
>(1 rows)
From | Date | Subject | |
---|---|---|---|
Next Message | Oakley | 2000-08-16 13:06:39 | List of Large sites using Postgres |
Previous Message | Andrew McMillan | 2000-08-16 12:29:20 | Re: Interval examples |