From: Johannes Graën <johannes@selfnet.de>
To: pgsql-general@lists.postgresql.org
Subject: tsvector string representation and parsing
Date: Wed, 23 Feb 2022 22:15:48 +0100
Message-ID: <9e1f312a-92cf-e002-9bfd-728aa450ee09@selfnet.de> (raw)
Hi,
I am constructing a tsvector representation of some text manually
because I need to provide explicit positional parameters. In some cases,
the conversion fails and I get a "syntax error in tsvector".
This is a minimal example that goes wrong (but shouldn't IMHO:
> SELECT format('%L:1', '\:')::tsvector
My expectation here is that %L would transform '\:' into a correctly
formatted character string, including single quotes around the string.
The documentation reads:
> L quotes the argument value as an SQL literal
> SELECT $$'\:':1$$
returns «'\:':1», but
> SELECT $$'\:':1$$::tsvector
returns «':':1», so something is happening here inside the single-quoted
lexemes to the backslash. My understanding is that everything inside
single quotes is taken as a lexeme. From the documentation:
> To represent lexemes containing whitespace or punctuation, surround them with quotes
So having everything surrounded by single quotes (followed by a
positional argument after the colon), «$$'\:':1$$::tsvector» should
actually return a vector with a single lexeme «\:» at position 1.
Am I missing something?
Regards
Johannes
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: johannes@selfnet.de
Subject: Re: tsvector string representation and parsing
In-Reply-To: <9e1f312a-92cf-e002-9bfd-728aa450ee09@selfnet.de>
References: <9e1f312a-92cf-e002-9bfd-728aa450ee09@selfnet.de>
* 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