Re: BUG #4908: escaping and dollar quotes: "ERROR: unterminated string"

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: BUG #4908: escaping and dollar quotes: "ERROR: unterminated string"
Дата
Msg-id 10216.1247087160@sss.pgh.pa.us
обсуждение исходный текст
Ответ на BUG #4908: escaping and dollar quotes: "ERROR: unterminated string"  ("Jack Douglas" <jackpdouglas@gmail.com>)
Ответы Re: BUG #4908: escaping and dollar quotes: "ERROR: unterminated string"  ("Kevin Grittner" <Kevin.Grittner@wicourts.gov>)
Re: BUG #4908: escaping and dollar quotes: "ERROR: unterminated string"  (Jack Douglas <jackpdouglas@gmail.com>)
Список pgsql-bugs
"Jack Douglas" <jackpdouglas@gmail.com> writes:
> Am I missing something obvious here - I understand from the documentation no
> escapes are counted in dollar quoted strings?

Yes, and yes.

> postgres=> create or replace function temp() returns text language plpgsql
> AS $$
> postgres$> begin
> postgres$>   return '\';
> postgres$> end; $$;
> ERROR:  unterminated string
> CONTEXT:  compile of PL/pgSQL function "temp" near line 2

The function body contains
    return '\';

and that string literal causes a syntax error when we come to parse the
RETURN statement.  You could do
    return '\\';
or
    return $q$\$q$;
or
    return $$\$$;
but the last requires using other $-delimiters around the function body.

Or you could turn on standard_conforming_strings if you'd prefer not to
deal with escapes.

            regards, tom lane

В списке pgsql-bugs по дате отправления:

Предыдущее
От: "Jack Douglas"
Дата:
Сообщение: BUG #4908: escaping and dollar quotes: "ERROR: unterminated string"
Следующее
От: "Kevin Grittner"
Дата:
Сообщение: Re: BUG #4908: escaping and dollar quotes: "ERROR: unterminated string"