Re: Improved regular expression error message for backrefs - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Improved regular expression error message for backrefs
Date
Msg-id 58295.1629686845@sss.pgh.pa.us
Whole thread Raw
In response to Improved regular expression error message for backrefs  (Mark Dilger <mark.dilger@enterprisedb.com>)
Responses Re: Improved regular expression error message for backrefs  (Mark Dilger <mark.dilger@enterprisedb.com>)
List pgsql-hackers
Mark Dilger <mark.dilger@enterprisedb.com> writes:
> The patch defines a new error code REG_ENOBREF in regex/regex.h right next to REG_ESUBREG from which it is split out,
ratherthan at the end of the list.  Is there a project preference to add it at the end?  Certainly, that would give a
shortergit diff. 
> Are there dependencies on the current error messages which prevent such changes?

Yeah: the POSIX standard says what the error codes from regcomp() are.

POSIX defines

    REG_ESUBREG
        Number in \digit invalid or in error.

which does seem to cover this case, so what I'd argue is that we should
improve the "invalid backreference number" text rather than invent
a nonstandard error code.  Maybe about like "backreference number does
not exist or cannot be referenced from here"?

(Admittedly, there's not a huge reason why src/backend/regex/ needs to
stay compliant with the POSIX API today.  But I still have ambitions to
split that out as a free-standing library someday, as Henry Spencer had
originally planned to do.  So I'd rather stick to the API spec.)

It might be worth checking what text is attributed to this error code
by PCRE and other implementations of the POSIX spec.

            regards, tom lane



pgsql-hackers by date:

Previous
From: "Bossart, Nathan"
Date:
Subject: Re: .ready and .done files considered harmful
Next
From: li jie
Date:
Subject: Re: Is it worth pushing conditions to sublink/subplan?