Re: Bug of psql meta-command \sf & \sv

Поиск
Список
Период
Сортировка
От Japin Li
Тема Re: Bug of psql meta-command \sf & \sv
Дата
Msg-id MEYP282MB16696D7F5E9201521AC5040BB6C2A@MEYP282MB1669.AUSP282.PROD.OUTLOOK.COM
обсуждение исходный текст
Ответ на RE: Bug of psql meta-command \sf & \sv  (Jet Zhang <jet.cx.zhang@hotmail.com>)
Ответы RE: Bug of psql meta-command \sf & \sv  (Jet Zhang <jet.cx.zhang@hotmail.com>)
Список pgsql-bugs
On Wed, 27 Sep 2023 at 17:25, Jet Zhang <jet.cx.zhang@hotmail.com> wrote:
> I don’t think not a bug. As you said Semi-colon is not a meta-command terminator, but why the other meta-commands
> Exp. \dt able to work with Semi-colon?
>
> postgres=# \dt pg_class
>            List of relations
>    Schema   |   Name   | Type  | Owner
> ------------+----------+-------+-------
> pg_catalog | pg_class | table | jet
> (1 row)
>
> postgres=# \dt pg_class;
>            List of relations
>    Schema   |   Name   | Type  | Owner
> ------------+----------+-------+-------
> pg_catalog | pg_class | table | jet
> (1 row)
>
>

The \sf use the whole line as its input, it can accept more complex input,
for example:

postgres=# \sf test (int)
CREATE OR REPLACE PROCEDURE public.test(IN id integer)
 LANGUAGE plpgsql
AS $procedure$ BEGIN NULL; END; $procedure$
postgres=# \sf test (int, text)
CREATE OR REPLACE PROCEDURE public.test(IN id integer, IN info text)
 LANGUAGE plpgsql
AS $procedure$ BEGIN NULL; END; $procedure$

Same as \ef.

OTOH, \ev and \sv use same function as \ef and \sf, See exec_command_ef_ev()
and exec_command_sf_sv() in src/bin/psql/common.c file.

static backslashResult
exec_command_sf_sv(PsqlScanState scan_state, bool active_branch,
                   const char *cmd, bool is_func)
{
    backslashResult status = PSQL_CMD_SKIP_LINE;

    if (active_branch)
    {
        bool        show_linenumbers = (strchr(cmd, '+') != NULL);
        PQExpBuffer buf;
        char       *obj_desc;
        Oid         obj_oid = InvalidOid;
        EditableObjectType eot = is_func ? EditableFunction : EditableView;

        buf = createPQExpBuffer();
        obj_desc = psql_scan_slash_option(scan_state,
                                          OT_WHOLE_LINE, NULL, true);
                                          ^    -- use the whole line

Maybe we can split \sf and \sv, however, I'm not sure it worth.

--
Regrads,
Japin Li
ChengDu WenWu Information Technology Co., Ltd.



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

Предыдущее
От: Japin Li
Дата:
Сообщение: Re: BUG #18134: ROW_COUNT do not set to 0 when psql's \gset command get no rows returned
Следующее
От: Jet Zhang
Дата:
Сообщение: RE: Bug of psql meta-command \sf & \sv