tsvector string representation and parsing - Mailing list pgsql-general

From Johannes Graën
Subject tsvector string representation and parsing
Date
Msg-id 9e1f312a-92cf-e002-9bfd-728aa450ee09@selfnet.de
Whole thread Raw
Responses Re: tsvector string representation and parsing  (Tom Lane <tgl@sss.pgh.pa.us>)
List 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



pgsql-general by date:

Previous
From: Radu Radutiu
Date:
Subject: Plan regression from 12 to 13
Next
From: Tom Lane
Date:
Subject: Re: tsvector string representation and parsing