From: Jet Zhang <jet.cx.zhang@hotmail.com>
To: Japin Li <japinli@hotmail.com>
Cc: Daniel Gustafsson <daniel@yesql.se>
Cc: pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>
Subject: RE: Bug of psql meta-command \sf & \sv
Date: Wed, 27 Sep 2023 11:03:48 +0000
Message-ID: <TY3P286MB2594818653BF91EEA0F0E43CD5C2A@TY3P286MB2594.JPNP286.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <MEYP282MB16696D7F5E9201521AC5040BB6C2A@MEYP282MB1669.AUSP282.PROD.OUTLOOK.COM>
References: <TY3P286MB259429FE5F1A31B3D7A2ABD2D5C2A@TY3P286MB2594.JPNP286.PROD.OUTLOOK.COM>
<52B143ED-EBAF-456E-B159-21FC77BB7B98@yesql.se>
<TY3P286MB2594ABE47C8F546CD3E09E0AD5C2A@TY3P286MB2594.JPNP286.PROD.OUTLOOK.COM>
<MEYP282MB16696D7F5E9201521AC5040BB6C2A@MEYP282MB1669.AUSP282.PROD.OUTLOOK.COM>
Yes, you’re right. Maybe we can spend some effort to strength the function psgl_scan_slash_option.
[cid:image001.png@01D80E0F.FAC36F80]
章晨曦 Jet C.X. ZHANG
18657181679
易景科技 http://www.halodbtech.com
浙江省杭州市滨江区长河街道建业路511号华创大厦5层505
From: Japin Li<mailto:japinli@hotmail.com>
Sent: 2023年9月27日 18:33
To: Jet Zhang<mailto:jet.cx.zhang@hotmail.com>
Cc: Daniel Gustafsson<mailto:daniel@yesql.se>; pgsql-bugs@lists.postgresql.org<mailto:pgsql-bugs@lists.postgresql.org>
Subject: Re: Bug of psql meta-command \sf & \sv
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.
Attachments:D34C3C37F8064725932B6933724325A3[2761581].png (image/png, 9.4K) downloadview image
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: jet.cx.zhang@hotmail.com, japinli@hotmail.com, daniel@yesql.se
Subject: Re: Bug of psql meta-command \sf & \sv
In-Reply-To: <TY3P286MB2594818653BF91EEA0F0E43CD5C2A@TY3P286MB2594.JPNP286.PROD.OUTLOOK.COM>
References: <TY3P286MB259429FE5F1A31B3D7A2ABD2D5C2A@TY3P286MB2594.JPNP286.PROD.OUTLOOK.COM> <52B143ED-EBAF-456E-B159-21FC77BB7B98@yesql.se> <TY3P286MB2594ABE47C8F546CD3E09E0AD5C2A@TY3P286MB2594.JPNP286.PROD.OUTLOOK.COM> <MEYP282MB16696D7F5E9201521AC5040BB6C2A@MEYP282MB1669.AUSP282.PROD.OUTLOOK.COM> <TY3P286MB2594818653BF91EEA0F0E43CD5C2A@TY3P286MB2594.JPNP286.PROD.OUTLOOK.COM>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox