Skip to content

2201B — invalid_regular_expression

Source-backed reference for PostgreSQL SQLSTATE 2201B.

At a glance

SQL regular-expression compilation and execution have separate 2201B paths, and HBA/ident configuration handling uses the same code with log-level reporting. The fixed messages and severities must be read by owner rather than merged into one generic regex failure.

Field Value
SQLSTATE 2201B
Condition invalid_regular_expression
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_INVALID_REGULAR_EXPRESSION
Aliases

Meaning

In regexp.c, a pattern that cannot compile raises ERROR with invalid regular expression: %s; a compiled pattern whose execution returns a regex-engine error raises ERROR with regular expression failed: %s. REG_NOMATCH is an ordinary no-match result, not this SQLSTATE. In hba.c, configuration regex compilation uses invalid regular expression "%s": %s at the caller’s level (the normal load_hba path passes LOG), and ident-map match/backreference failures are also logged with their own primary text. These configuration messages are not SQL expression ERROR paths.

Diagnosis

Use the complete primary, severity, and context to identify the owner. For SQL regex functions, inspect the pattern and flags and distinguish compile errors from execution errors. For HBA or ident configuration, inspect the named file and line, the token’s leading-slash marker and the regex text after it, and the reload/startup context; a logged configuration failure can leave the previous HBA configuration in place on reload. Do not treat a normal REG_NOMATCH as invalid syntax.

Response

Repair the pattern or flags in the owning syntax and validate that same subsystem. A SQL regex ERROR aborts the current statement, so an explicit transaction must be rolled back or rolled back to an existing savepoint before retrying; autocommit can retry only the corrected statement. A configuration LOG/debug report requires fixing the HBA or ident file and reloading or restarting according to that subsystem, not transaction rollback.

Messages

  • SQL regex compile, ERROR: invalid regular expression: %s.
  • SQL regex execution error, ERROR: regular expression failed: %s.
  • HBA regex compilation, caller-selected level (the normal load_hba path uses LOG): invalid regular expression "%s": %s; the source also adds configuration-file line context.
  • HBA ident-map execution, LOG: regular expression match for "%s" failed: %s.
  • HBA ident backreference without a captured subexpression, LOG: regular expression "%s" has no subexpressions as requested by backreference in "%s".

Versions

The locked catalogue records this condition from 7.4; fixed source coverage is PostgreSQL 18.6. The cited SQL regex and HBA/ident paths are distinct owners; extension or other subsystem messages are outside this bounded review.

2200C, 2200D

Sources

Runtime verification is not_run; no regex runtime observation is claimed. The structured evidence record retains owner-specific messages, severities, and source limits.