pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Phil Endecott <spam_from_pgsql_lists@chezphil.org>
To: pgsql-general@lists.postgresql.org
Cc: Andrew Gierth <andrew@tao11.riddles.org.uk>
Subject: Re: Text-indexing UTF-8 bytea, convert_from() immutability, null bytes...
Date: Sun, 07 Oct 2018 13:45:07 +0100
Message-ID: <1538916307632@dmwebmail.dmwebmail.chezphil.org> (raw)
In-Reply-To: <87ftxia3l4.fsf@news-spur.riddles.org.uk>
References: <87ftxia3l4.fsf@news-spur.riddles.org.uk>

Hi Andrew,

Thanks for your great reply.

Andrew Gierth wrote:
>>>>>> "Phil" == Phil Endecott <spam_from_pgsql_lists@chezphil.org> writes:
>  Phil> As a hack I tried ALTER FUNCTION to make it immutable,
>
> A better approach is to wrap it in a function of your own which is
> declared immutable, rather than hacking the catalogs:
>
> create function from_utf8(bytea) returns text language plpgsql immutable
>   as $$ begin return convert_from($1, 'UTF8'); end; $$;

Thanks.  I'm a bit surprised that it will allow me to declare a
function immutable if it calls functions that aren't themselves
immutable, but if it works... great.

>  Phil> Anyway: given the problem of creating a text search index over
>  Phil> bytea data that contains UTF-8 text, which may include oddities
>  Phil> like null bytes, what would you do?
>
> You can search for 0x00 in a bytea using position() or LIKE. What do you
> want to do with values that contain null bytes? or values which you
> think are supposed to be valid utf8 text but are not?

As long as it doesn't crash I don't really care; it would be better
if the text search worked for the valid parts of the text but even
that isn't essential.

I think I will probably need to do some more preprocessing on the
data when I load it, at least to remove the null bytes.


Regards, Phil.








view thread (3+ messages)

Message-ID: <1538916307632@dmwebmail.dmwebmail.chezphil.org>
Permalink:  ../1538916307632@dmwebmail.dmwebmail.chezphil.org/
Also on:    postgresql.org/message-id/1538916307632@dmwebmail.dmwebmail.chezphil.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: spam_from_pgsql_lists@chezphil.org, andrew@tao11.riddles.org.uk
  Subject: Re: Text-indexing UTF-8 bytea, convert_from() immutability, null bytes...
  In-Reply-To: <1538916307632@dmwebmail.dmwebmail.chezphil.org>
  References: <87ftxia3l4.fsf@news-spur.riddles.org.uk> <1538916307632@dmwebmail.dmwebmail.chezphil.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox