Re: Unescaped new lines in postgres

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Unescaped new lines in postgres
Дата
Msg-id 6214.1006532610@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Unescaped new lines in postgres  ("Christopher Kings-Lynne" <chriskl@familyhealth.com.au>)
Список pgsql-hackers
"Christopher Kings-Lynne" <chriskl@familyhealth.com.au> writes:
>> From heap.c:
>        /*
>          * sanity checks
>          */
>         if (relname && !allow_system_table_mods &&
>                 IsSystemRelationName(relname) && IsNormalProcessingMode())
>                 elog(ERROR, "invalid relation name \"%s\"; "
>                          "the 'pg_' name prefix is reserved for system
> catalogs",
>                          relname);

> I guess this is a slightly different example than what the issue is below.
> Maybe I'm wrong and the above code is still legal.

This is legal ANSI C.  The spec says that one of the later phases of the
preprocessor is
        6.  Adjacent string literal tokens are concatenated.

I have an old book on C portability that says that this behavior
actually predates the ANSI spec, but wasn't universal in pre-ANSI
compilers.

It's also legal per spec to write
        "invalid relation name \"%s\"; \
the 'pg_' name prefix is reserved for system catalogs",

(note the backslash before the newline) but this strikes me as worse
style since you now have a critical dependency on (a) lack of trailing
whitespace on the first line and (b) lack of leading whitespace on the
second.

What the gcc release note is about is
        "invalid relation name \"%s\"; 
the 'pg_' name prefix is reserved for system catalogs",

Unescaped newlines in string literals are specifically forbidden by
the spec, but apparently gcc takes them anyway.
        regards, tom lane


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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: v7.2b3 packaged, but not announced beyond here yet ...
Следующее
От: "Jim Buttafuoco"
Дата:
Сообщение: Re: postgresql.conf (Proposed settings)