Re: pgbench failed when -f option contains a char '@'

From: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
To: "Wang, Shenhao" <wangsh(dot)fnst(at)cn(dot)fujitsu(dot)com>, "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: pgbench failed when -f option contains a char '@'
Date: 2020-12-18 08:59:33
Message-ID: a1237800-4983-c7ca-13db-35c7e9bc1c2c@iki.fi
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 18/12/2020 08:22, Wang, Shenhao wrote:
> Hi, hackers
>
> pgbench use -f filename[(at)weight] to receive a sql script file with a weight,
> but if I create a file contains char'@', like a(at)2(dot)sql, specify this file without weigth,
> pgbench will failed with error:
> pgbench: fatal: invalid weight specification: @2.sql
>
> This action may be unfriendly, because the char '@' is a valid character on Linux
> and Windows.
>
> I have created a patch to modify this action. The patch is attached.

This patch changes it to first check if the file "a(at)2(dot)sql" exists, and
if it doesn't, only then it tries to interpret it as a weight, as
filename "a" and weight "2.sql". That stilll doesn't fix the underlying
ambiguity, though. If you have a file called "script" and "script(at)1",
this makes it impossible to specify "script" with weight 1, because "-f
script(at)1" will now always open the file "script(at)1".

I think we should just leave this as it is. The user can simply rename
the file.

Or maybe one change would be worthwhile here: First check if the part
after the @ contains only digits. If doesn't, then assume it's part of
the filename rather than a weight. That would fix this for cases like
"foo(at)1(dot)sql", although not for "foo(at)1".

- Heikki

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Heikki Linnakangas 2020-12-18 09:35:14 Re: Incorrect allocation handling for cryptohash functions with OpenSSL
Previous Message osumi.takamichi@fujitsu.com 2020-12-18 08:45:24 how to use valgrind for TAP tests