Re: Some dead code in metaphone() of fuzzystrmatch.c

From: Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>
To: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>, PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Some dead code in metaphone() of fuzzystrmatch.c
Date: 2015-02-03 07:44:58
Message-ID: 54D07C7A.8070105@vmware.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 02/02/2015 03:39 AM, Michael Paquier wrote:
> In metaphone() we do the following:
> /* return an empty string if we receive one */
> if (!(str_i_len > 0))
> PG_RETURN_TEXT_P(cstring_to_text(""));
>
> if (str_i_len > MAX_METAPHONE_STRLEN)
> ereport(ERROR,
> (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
> errmsg("argument exceeds the maximum
> length of %d bytes",
> MAX_METAPHONE_STRLEN)));
>
> if (!(str_i_len > 0))
> ereport(ERROR,
> (errcode(ERRCODE_ZERO_LENGTH_CHARACTER_STRING),
> errmsg("argument is empty string")));
> As we already return an empty string if the first condition is
> satisfied, the third condition will never be satisfied. Returning an
> empty string when output string is NULL has been introduced in commit
> 13629df of 2004, so I think that we should simply remove the code
> block that will never be crossed, as in the patch attached.

Applied, thanks.

- Heikki

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Heikki Linnakangas 2015-02-03 07:49:48 Re: A minor comment typo in parse_utilcmd.c
Previous Message Ashutosh Bapat 2015-02-03 07:44:02 Re: EvalPlanQual behaves oddly for FDW queries involving system columns