| From: | Johannes Graën <johannes(at)selfnet(dot)de> |
|---|---|
| To: | pgsql-general(at)lists(dot)postgresql(dot)org |
| Subject: | tsvector string representation and parsing |
| Date: | 2022-02-23 21:15:48 |
| Message-ID: | 9e1f312a-92cf-e002-9bfd-728aa450ee09@selfnet.de |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tom Lane | 2022-02-23 22:30:11 | Re: tsvector string representation and parsing |
| Previous Message | Radu Radutiu | 2022-02-23 13:44:24 | Plan regression from 12 to 13 |