Re: 001_password.pl fails with --without-readline

From: Oleg Tselebrovskiy <o(dot)tselebrovskiy(at)postgrespro(dot)ru>
To: Soumya S Murali <soumyamurali(dot)work(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: 001_password.pl fails with --without-readline
Date: 2026-01-14 08:32:34
Message-ID: d45671ce55b7b0434c620cebf7373d84@postgrespro.ru
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Thanks for your patch!

I like your behaviour-based approach more, but I have some questions
about the patch itself

1) There is a comment in query() function:
# We need to match for the newline, because we try to remove it below,
and
# it's possible to consume just the input *without* the newline. In
# interactive psql we emit \r\n, so we need to allow for that. Also need
# to be careful that we don't e.g. match the echoed \echo command,
rather
# than its output.

So, originally, checking that the banner is on it's own line is needed
to distiguish \echo $banner and \warn $banner from their output.

It seems that your patch does not distingush them all the time

(taken from query() function with your patch applied)
my $banner_detect_stdout = qr/\Q$banner\E/;
my $banner_detect_stderr = qr/(^|\n)\Q$banner\E\r?\n/;

Why do you check stderr for newline but not the stdout?

2) Why did you add /Q/E around the $banner variable? It doesn't
contain any regex metacharacters (in query() function there is
$query_cnt inside of $banner, but it should be substituted by Perl).
Maybe it is really necessary and I just don't get it

-----

While testing and checking, I've made a new patch. It's very
simple and it just checks that there is banner in a string, but
the string doesn't start with \echo or \warn

Maybe it needs some additional comments, but lets decide on which
approach to use

-----

There is also a problem of test src/bin/psql/t/030_pager.pl - it
just doesn't work with --without-readline, all regexes seem to be right
and debug output shows correct data. None of our patches
currently solve it, I'll look into it

-----

Regards,
Oleg

Attachment Content-Type Size
v2-0001-background-psql-without-readline.patch text/x-diff 1.2 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bertrand Drouvot 2026-01-14 08:38:51 Re: 64-bit wait_event and introduction of 32-bit wait_event_arg
Previous Message Chao Li 2026-01-14 08:22:49 Re: Remove redundant assignment in CreateWorkExprContext