postgresql/src/include
Tom Lane d5b90cd648 Fix bogus handling of XQuery regex option flags.
The SQL spec defers to XQuery to define what the option flags are
for LIKE_REGEX patterns.  XQuery says that:
* 's' allows the dot character to match newlines, which by
  default it will not;
* 'm' allows ^ and $ to match at newlines, not only at the
  start/end of the whole string.
Thus, these are *not* inverses as they are for the similarly-named
POSIX options, and neither one corresponds to the POSIX 'n' option.
Fortunately, Spencer's library does expose these two behaviors as
separately twiddlable flags, so we just have to fix the mapping from
JSP flag bits to REG flag bits.  I also chose to rename the symbol
for 's' to DOTALL, to make it clearer that it's not the inverse
of MLINE.

Also, XQuery says that if the 'q' flag "is used together with the m, s,
or x flag, that flag has no effect".  I read this as saying that 'q'
overrides the other flags; whoever wrote our code seems to have read
it backwards.

Lastly, while XQuery's 'x' flag is related to what Spencer's code
does for REG_EXPANDED, it's not the same or a subset.  It seems best
to treat XQuery's 'x' as unimplemented for now.  Maybe later we can
expand our regex code to offer 'x'-style parsing as a separate option.

While at it, refactor the jsonpath code so that (a) there's only
one copy of the flag transformation logic not two, and (b) the
processing of flags is independent of the order in which the flags
are written.

We need some documentation updates to go with this, but I'll
tackle that separately.

Back-patch to v12 where this code originated.

Discussion: https://postgr.es/m/CAPpHfdvDci4iqNF9fhRkTqhe-5_8HmzeLt56drH%2B_Rv2rNRqfg@mail.gmail.com
Reference: https://www.w3.org/TR/2017/REC-xpath-functions-31-20170321/#flags
2019-09-17 15:39:51 -04:00
..
access Fix nbtree page split rmgr desc routine. 2019-09-12 15:45:08 -07:00
bootstrap Remove more unreferenced function declarations 2019-07-07 09:58:33 +09:00
catalog Allow setting statistics target for extended statistics 2019-09-11 00:25:51 +02:00
commands Allow setting statistics target for extended statistics 2019-09-11 00:25:51 +02:00
common Add overflow-safe math inline functions for unsigned integers 2019-09-02 09:38:23 +09:00
datatype Update copyright for 2019 2019-01-02 12:44:25 -05:00
executor Reorder EPQ work, to fix rowmark related bugs and improve efficiency. 2019-09-09 05:14:11 -07:00
fe_utils Fix inconsistencies and typos in the tree, take 11 2019-08-19 16:21:39 +09:00
foreign Fix inconsistencies and typos in the tree 2019-07-16 13:23:53 +09:00
jit Remove fmgr.h includes from headers that don't really need it. 2019-08-16 10:35:31 -07:00
lib Allow simplehash to use already-calculated hash values. 2019-08-01 16:05:49 -07:00
libpq Update hardcoded DH parameters to IANA standards 2019-07-05 10:47:32 +09:00
mb Fix inconsistencies and typos in the tree, take 9 2019-08-05 12:14:58 +09:00
nodes Fix under-parenthesized macro definitions 2019-09-13 16:26:55 -03:00
optimizer Cosmetic improvements in setup of planner's per-RTE arrays. 2019-08-09 12:33:43 -04:00
parser Require the schema qualification in pg_temp.type_name(arg). 2019-08-05 07:48:41 -07:00
partitioning Improve pruning of a default partition 2019-08-04 11:18:45 -04:00
port Revert "For all ppc compilers, implement pg_atomic_fetch_add_ with inline asm." 2019-09-14 19:38:41 -07:00
portability Update copyright for 2019 2019-01-02 12:44:25 -05:00
postmaster Fix inconsistencies and typos in the tree 2019-07-16 13:23:53 +09:00
regex Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
replication Fix inconsistencies and typos in the tree, take 11 2019-08-19 16:21:39 +09:00
rewrite Fix inconsistencies and typos in the tree, take 10 2019-08-13 13:53:41 +09:00
snowball Sync our Snowball stemmer dictionaries with current upstream 2019-07-04 13:26:48 +02:00
statistics Allow setting statistics target for extended statistics 2019-09-11 00:25:51 +02:00
storage Rearrange postmaster's startup sequence for better syslogger results. 2019-09-11 11:43:01 -04:00
tcop Fix many typos and inconsistencies 2019-07-01 10:00:23 +09:00
tsearch Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
utils Fix bogus handling of XQuery regex option flags. 2019-09-17 15:39:51 -04:00
.gitignore Refactor dlopen() support 2018-09-06 11:33:04 +02:00
c.h Improve Assert output 2019-08-17 12:50:50 +02:00
fmgr.h Make comment in fmgr.h match the one in fmgr.c. 2019-08-26 14:32:48 -04:00
funcapi.h Fix many typos and inconsistencies 2019-07-01 10:00:23 +09:00
getaddrinfo.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
getopt_long.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
Makefile Get rid of jsonpath_gram.h and jsonpath_scanner.h 2019-03-20 11:13:34 +03:00
miscadmin.h Fix inconsistencies and typos in the tree, take 11 2019-08-19 16:21:39 +09:00
pg_config.h.in Revert "For all ppc compilers, implement pg_atomic_fetch_add_ with inline asm." 2019-09-14 19:38:41 -07:00
pg_config.h.win32 Use explicit_bzero 2019-09-05 08:30:42 +02:00
pg_config_ext.h.in Autoconfiscate selection of 64-bit int type for 64-bit large object API. 2012-10-07 21:52:43 -04:00
pg_config_ext.h.win32 Autoconfiscate selection of 64-bit int type for 64-bit large object API. 2012-10-07 21:52:43 -04:00
pg_config_manual.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
pg_getopt.h Use our own getopt() on OpenBSD. 2019-01-18 15:06:26 -05:00
pg_trace.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
pgstat.h Remove fmgr.h includes from headers that don't really need it. 2019-08-16 10:35:31 -07:00
pgtar.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
pgtime.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
port.h Use explicit_bzero 2019-09-05 08:30:42 +02:00
postgres.h Change function call information to be variable length. 2019-01-26 14:17:52 -08:00
postgres_ext.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
postgres_fe.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
rusagestub.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
windowapi.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00