Re: Verifying variable names in pgbench - Mailing list pgsql-hackers

From Takahiro Itagaki
Subject Re: Verifying variable names in pgbench
Date
Msg-id 20100104103442.98BA.52131E4D@oss.ntt.co.jp
Whole thread Raw
In response to Verifying variable names in pgbench  (Takahiro Itagaki <itagaki.takahiro@oss.ntt.co.jp>)
Responses Re: Verifying variable names in pgbench  (Takahiro Itagaki <itagaki.takahiro@oss.ntt.co.jp>)
List pgsql-hackers
Robert Haas <robertmhaas@gmail.com> wrote:

> > The attached patch verifies variable names at definition.
> >     $ pgbench -D var:name=value
> >     (global): invalid variable name 'var:name'
>
> I have reviewed this patch.  I think that the basic idea of rejecting
> invalid variable names is probably a good one, but I'm not totally
> happy with the implementation.  In particular:
>
> 1. The code that prints the invalid variable name message seems
> bizarrely complex and inexplicable relative to the way errors are
> handled elsewhere in the code.  If we really need to do this, it
> should be in its own function, not buried inside putVariable(), but
> isn't there some simpler alternative?

We can remove the complexity if we give up showing the command (arg0)
in error messages. Shall we remove it? Simplified patch attached.

> 2. I think it would be worth abstracting the actual test into a
> separate function, like isLegalVariableName().
> 3. In the department of nitpicking, I believe that the for loop test
> should be written as something like name[i] != '\0' rather than just
> name[i], for clarity.

Adjusted.

Regards,
---
Takahiro Itagaki
NTT Open Source Software Center


Attachment

pgsql-hackers by date:

Previous
From: Andrew Dunstan
Date:
Subject: Re: PATCH: Add hstore_to_json()
Next
From: Takahiro Itagaki
Date:
Subject: Re: pg_read_file() and non-ascii input file