Skip to content
Browse files

1.1 update

*	modified:   ChangeLog
*	modified:   INSTALL
*	modified:   Makefile.am
*	modified:   Makefile.in
*	modified:   README.md
*	new file:   config/ghmysql.m4
*	modified:   configure
*	modified:   configure.ac
*	modified:   doc/Makefile.in
*	modified:   test/Makefile.in
*	modified:   test/create_testdb.sql
*	modified:   test/lib_mysqludf_preg_capture.result
*	modified:   test/lib_mysqludf_preg_capture.test
*	modified:   test/lib_mysqludf_preg_check.result
*	modified:   test/lib_mysqludf_preg_info.result
*	modified:   test/lib_mysqludf_preg_position.result
*	modified:   test/lib_mysqludf_preg_replace.result
*	modified:   test/lib_mysqludf_preg_replace.test
*	modified:   test/lib_mysqludf_preg_rlike.result
*	modified:   test/lib_mysqludf_preg_rlike.test
*
  • Loading branch information...
1 parent f8265e6 commit 4acbd9a1aa59948d2256cf8d6b799e9255f4658e raw committed
View
9 ChangeLog
@@ -1,3 +1,12 @@
+
+
+1.1
+---
+Fixed potential garbage results due to uninitialized argument to pcre_exec
+Return NULL in most cases when NULL is passed in as an argument
+Fixed problem where PREG_CAPTURE didn't return NULL if occurrence was out of bounds
+
+
1.0.1
-----
Fixed autoconf with pcre on Snow Leaopard by upgrading to new pcre.m4
View
4 INSTALL
@@ -15,6 +15,10 @@ If libpcre is in an unusual place, try adding:
--with-pcre-prefix=<path to pcre root>
+Version 1.1 changes the way NULLs are handled. To restore the legacy NULL handling:
+
+ --enable-legacy-nulls
+
Example (on macosx with fink)
View
11 Makefile.am
@@ -1,16 +1,15 @@
AUTOMAKE_OPTIONS = foreign
-
.PHONY : test mrproper
-
lib_LTLIBRARIES = lib_mysqludf_preg.la
lib_mysqludf_preg_la_SOURCES = \
preg.c preg.h \
ghmysql.c ghmysql.h \
- from_php.c \
+ ghfcns.c ghfcns.h \
+ from_php.c from_php.h \
lib_mysqludf_preg_capture.c \
lib_mysqludf_preg_check.c \
lib_mysqludf_preg_info.c \
@@ -19,9 +18,9 @@ lib_mysqludf_preg_la_SOURCES = \
lib_mysqludf_preg_rlike.c
SUBDIRS=test doc
+DIFFPROGRAM:=kompare -
-
-lib_mysqludf_preg_la_CFLAGS = -DSTANDARD -DMYSQL_SERVER @MYSQL_CFLAGS@ @MYSQL_HEADERS@ @PCRE_CFLAGS@
+lib_mysqludf_preg_la_CFLAGS = -DSTANDARD -DMYSQL_SERVER @MYSQL_CFLAGS@ @MYSQL_HEADERS@ @PCRE_CFLAGS@ @GHMYSQL_CFLAGS@
lib_mysqludf_preg_la_LDFLAGS = -module -avoid-version -no-undefined @PCRE_LIBS@
EXTRA_DIST = *.sql
@@ -58,5 +57,5 @@ maintainer-dist:
git tag "$(PACKAGE)-$(VERSION)"
maintainer-diff:
- git diff "$(PACKAGE)-$(DIFFVERSION)" . | gitx
+ git diff "$(PACKAGE)-$(DIFFVERSION)" . | $(DIFFPROGRAM)
View
22 Makefile.in
@@ -64,7 +64,8 @@ DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/config/ax_lib_mysql.m4 \
$(top_srcdir)/config/ax_mysql_bin.m4 \
- $(top_srcdir)/config/pcre.m4 $(top_srcdir)/configure.ac
+ $(top_srcdir)/config/pcre.m4 $(top_srcdir)/config/ghmysql.m4 \
+ $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
@@ -104,7 +105,7 @@ am__installdirs = "$(DESTDIR)$(libdir)"
LTLIBRARIES = $(lib_LTLIBRARIES)
lib_mysqludf_preg_la_LIBADD =
am_lib_mysqludf_preg_la_OBJECTS = lib_mysqludf_preg_la-preg.lo \
- lib_mysqludf_preg_la-ghmysql.lo \
+ lib_mysqludf_preg_la-ghmysql.lo lib_mysqludf_preg_la-ghfcns.lo \
lib_mysqludf_preg_la-from_php.lo \
lib_mysqludf_preg_la-lib_mysqludf_preg_capture.lo \
lib_mysqludf_preg_la-lib_mysqludf_preg_check.lo \
@@ -268,6 +269,7 @@ ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
+GHMYSQL_CFLAGS = @GHMYSQL_CFLAGS@
GREP = @GREP@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
@@ -374,7 +376,8 @@ lib_LTLIBRARIES = lib_mysqludf_preg.la
lib_mysqludf_preg_la_SOURCES = \
preg.c preg.h \
ghmysql.c ghmysql.h \
- from_php.c \
+ ghfcns.c ghfcns.h \
+ from_php.c from_php.h \
lib_mysqludf_preg_capture.c \
lib_mysqludf_preg_check.c \
lib_mysqludf_preg_info.c \
@@ -383,7 +386,8 @@ lib_mysqludf_preg_la_SOURCES = \
lib_mysqludf_preg_rlike.c
SUBDIRS = test doc
-lib_mysqludf_preg_la_CFLAGS = -DSTANDARD -DMYSQL_SERVER @MYSQL_CFLAGS@ @MYSQL_HEADERS@ @PCRE_CFLAGS@
+DIFFPROGRAM := kompare -
+lib_mysqludf_preg_la_CFLAGS = -DSTANDARD -DMYSQL_SERVER @MYSQL_CFLAGS@ @MYSQL_HEADERS@ @PCRE_CFLAGS@ @GHMYSQL_CFLAGS@
lib_mysqludf_preg_la_LDFLAGS = -module -avoid-version -no-undefined @PCRE_LIBS@
EXTRA_DIST = *.sql
all: config.h
@@ -485,6 +489,7 @@ distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lib_mysqludf_preg_la-from_php.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lib_mysqludf_preg_la-ghfcns.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lib_mysqludf_preg_la-ghmysql.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lib_mysqludf_preg_la-lib_mysqludf_preg_capture.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lib_mysqludf_preg_la-lib_mysqludf_preg_check.Plo@am__quote@
@@ -529,6 +534,13 @@ lib_mysqludf_preg_la-ghmysql.lo: ghmysql.c
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_mysqludf_preg_la_CFLAGS) $(CFLAGS) -c -o lib_mysqludf_preg_la-ghmysql.lo `test -f 'ghmysql.c' || echo '$(srcdir)/'`ghmysql.c
+lib_mysqludf_preg_la-ghfcns.lo: ghfcns.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_mysqludf_preg_la_CFLAGS) $(CFLAGS) -MT lib_mysqludf_preg_la-ghfcns.lo -MD -MP -MF $(DEPDIR)/lib_mysqludf_preg_la-ghfcns.Tpo -c -o lib_mysqludf_preg_la-ghfcns.lo `test -f 'ghfcns.c' || echo '$(srcdir)/'`ghfcns.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/lib_mysqludf_preg_la-ghfcns.Tpo $(DEPDIR)/lib_mysqludf_preg_la-ghfcns.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ghfcns.c' object='lib_mysqludf_preg_la-ghfcns.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_mysqludf_preg_la_CFLAGS) $(CFLAGS) -c -o lib_mysqludf_preg_la-ghfcns.lo `test -f 'ghfcns.c' || echo '$(srcdir)/'`ghfcns.c
+
lib_mysqludf_preg_la-from_php.lo: from_php.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_mysqludf_preg_la_CFLAGS) $(CFLAGS) -MT lib_mysqludf_preg_la-from_php.lo -MD -MP -MF $(DEPDIR)/lib_mysqludf_preg_la-from_php.Tpo -c -o lib_mysqludf_preg_la-from_php.lo `test -f 'from_php.c' || echo '$(srcdir)/'`from_php.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/lib_mysqludf_preg_la-from_php.Tpo $(DEPDIR)/lib_mysqludf_preg_la-from_php.Plo
@@ -1045,7 +1057,7 @@ maintainer-dist:
git tag "$(PACKAGE)-$(VERSION)"
maintainer-diff:
- git diff "$(PACKAGE)-$(DIFFVERSION)" . | gitx
+ git diff "$(PACKAGE)-$(DIFFVERSION)" . | $(DIFFPROGRAM)
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
View
1 README.md
@@ -84,6 +84,7 @@ raw@goodhumans.com
Known Issues & Caveats
======================
+- Version 1.1 changes the way NULLs are handled. To restore the legacy NULL handling, use configure --enable-legacy-nulls
- pcre_study should be used (but isn't) for constant patterns;
- there is no localization or locale support
- there is no multi-byte character set support
View
22 config/ghmysql.m4
@@ -0,0 +1,22 @@
+#####
+#
+# SYNOPSIS
+#
+# AX_GHMYSQL
+#
+# DESCRIPTION
+#
+#
+#####
+
+AC_DEFUN([AX_GHMYSQL], [
+ AC_ARG_ENABLE(
+ [legacy-nulls],
+ AC_HELP_STRING([--enable-legacy-nulls],[replace NULLs with empty strings]) ,
+ [GHMYSQL_CFLAGS="-DGH_1_0_NULL_HANDLING=1"],
+ [GHMYSQL_CFLAGS=""]
+
+ )
+ AC_SUBST(GHMYSQL_CFLAGS)
+])
+
View
60 configure
@@ -1,8 +1,8 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for lib_mysqludf_preg 1.0.2.
+# Generated by GNU Autoconf 2.69 for lib_mysqludf_preg 1.1.
#
-# Report bugs to <raw@goodhumans.com>.
+# Report bugs to <raw@goodhumans.net>.
#
#
# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
@@ -274,7 +274,7 @@ fi
$as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should"
$as_echo "$0: be upgraded to zsh 4.3.4 or later."
else
- $as_echo "$0: Please tell bug-autoconf@gnu.org and raw@goodhumans.com
+ $as_echo "$0: Please tell bug-autoconf@gnu.org and raw@goodhumans.net
$0: about your system, including any error possibly output
$0: before this message. Then install a modern shell, or
$0: manually run the script under such a shell if you do
@@ -590,9 +590,9 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='lib_mysqludf_preg'
PACKAGE_TARNAME='lib_mysqludf_preg'
-PACKAGE_VERSION='1.0.2'
-PACKAGE_STRING='lib_mysqludf_preg 1.0.2'
-PACKAGE_BUGREPORT='raw@goodhumans.com'
+PACKAGE_VERSION='1.1'
+PACKAGE_STRING='lib_mysqludf_preg 1.1'
+PACKAGE_BUGREPORT='raw@goodhumans.net'
PACKAGE_URL=''
# Factoring default headers for most tests.
@@ -635,6 +635,7 @@ ac_subst_vars='am__EXEEXT_FALSE
am__EXEEXT_TRUE
LTLIBOBJS
LIBOBJS
+GHMYSQL_CFLAGS
PCRE_LIBS
PCRE_CFLAGS
PCRE_CONFIG
@@ -780,6 +781,7 @@ with_mysql
with_pcre_prefix
with_pcre
with_pcre_exec_prefix
+enable_legacy_nulls
'
ac_precious_vars='build_alias
host_alias
@@ -1330,7 +1332,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-\`configure' configures lib_mysqludf_preg 1.0.2 to adapt to many kinds of systems.
+\`configure' configures lib_mysqludf_preg 1.1 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1401,7 +1403,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of lib_mysqludf_preg 1.0.2:";;
+ short | recursive ) echo "Configuration of lib_mysqludf_preg 1.1:";;
esac
cat <<\_ACEOF
@@ -1420,6 +1422,7 @@ Optional Features:
--disable-dependency-tracking
speeds up one-time build
--disable-libtool-lock avoid locking (might break parallel builds)
+ --enable-legacy-nulls replace NULLs with empty strings
Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
@@ -1452,7 +1455,7 @@ Some influential environment variables:
Use these variables to override the choices made by `configure' or to help
it to find libraries and programs with nonstandard names/locations.
-Report bugs to <raw@goodhumans.com>.
+Report bugs to <raw@goodhumans.net>.
_ACEOF
ac_status=$?
fi
@@ -1515,7 +1518,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
-lib_mysqludf_preg configure 1.0.2
+lib_mysqludf_preg configure 1.1
generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
@@ -1793,7 +1796,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by lib_mysqludf_preg $as_me 1.0.2, which was
+It was created by lib_mysqludf_preg $as_me 1.1, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@
@@ -2245,6 +2248,20 @@ ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var.
+#####
+#
+# SYNOPSIS
+#
+# AX_GHMYSQL
+#
+# DESCRIPTION
+#
+#
+#####
+
+
+
+
am__api_version='1.13'
@@ -2732,7 +2749,7 @@ fi
# Define the identity of the package.
PACKAGE='lib_mysqludf_preg'
- VERSION='1.0.2'
+ VERSION='1.1'
cat >>confdefs.h <<_ACEOF
@@ -12683,6 +12700,19 @@ $as_echo "no" >&6; }
+
+ # Check whether --enable-legacy-nulls was given.
+if test "${enable_legacy_nulls+set}" = set; then :
+ enableval=$enable_legacy_nulls; GHMYSQL_CFLAGS="-DGH_1_0_NULL_HANDLING=1"
+else
+ GHMYSQL_CFLAGS=""
+
+
+fi
+
+
+
+
ac_config_headers="$ac_config_headers config.h"
@@ -13222,7 +13252,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
-This file was extended by lib_mysqludf_preg $as_me 1.0.2, which was
+This file was extended by lib_mysqludf_preg $as_me 1.1, which was
generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -13282,13 +13312,13 @@ $config_headers
Configuration commands:
$config_commands
-Report bugs to <raw@goodhumans.com>."
+Report bugs to <raw@goodhumans.net>."
_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
-lib_mysqludf_preg config.status 1.0.2
+lib_mysqludf_preg config.status 1.1
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"
View
5 configure.ac
@@ -1,12 +1,13 @@
AC_PREREQ(2.59)
-AC_INIT(lib_mysqludf_preg,1.0.2,raw@goodhumans.com)
+AC_INIT(lib_mysqludf_preg,1.1,raw@goodhumans.net)
AC_CONFIG_AUX_DIR(config)
m4_include([config/ax_lib_mysql.m4])
m4_include([config/ax_mysql_bin.m4])
m4_include([config/pcre.m4])
+m4_include([config/ghmysql.m4])
AM_INIT_AUTOMAKE
@@ -25,6 +26,8 @@ fi
AM_PATH_PCRE(1,,AC_MSG_ERROR( "Can't find libpcre" ) )
+AX_GHMYSQL
+
AC_CONFIG_HEADERS(config.h)
AC_OUTPUT([ Makefile
View
4 doc/Makefile.in
@@ -54,7 +54,8 @@ DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/config/ax_lib_mysql.m4 \
$(top_srcdir)/config/ax_mysql_bin.m4 \
- $(top_srcdir)/config/pcre.m4 $(top_srcdir)/configure.ac
+ $(top_srcdir)/config/pcre.m4 $(top_srcdir)/config/ghmysql.m4 \
+ $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
@@ -108,6 +109,7 @@ ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
+GHMYSQL_CFLAGS = @GHMYSQL_CFLAGS@
GREP = @GREP@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
View
4 test/Makefile.in
@@ -54,7 +54,8 @@ DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/config/ax_lib_mysql.m4 \
$(top_srcdir)/config/ax_mysql_bin.m4 \
- $(top_srcdir)/config/pcre.m4 $(top_srcdir)/configure.ac
+ $(top_srcdir)/config/pcre.m4 $(top_srcdir)/config/ghmysql.m4 \
+ $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
@@ -108,6 +109,7 @@ ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
+GHMYSQL_CFLAGS = @GHMYSQL_CFLAGS@
GREP = @GREP@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
View
4 test/create_testdb.sql
@@ -17,8 +17,10 @@ CREATE TABLE `state` (
`code` varchar(2) NOT NULL,
`country_code` varchar(2) NOT NULL,
`description` varchar(255) NOT NULL,
+ `regex` varchar(255) ,
PRIMARY KEY (`code`)
) ENGINE=HEAP DEFAULT CHARSET=latin1;
-INSERT INTO `state` VALUES ('al','us','Alabama'),('ak','us','Alaska'),('as','us','American Samoa'),('az','us','Arizona'),('ar','us','Arkansas'),('ca','us','California'),('co','us','Colorado'),('ct','us','Connecticut'),('de','us','Delaware'),('dc','us','District of Columbia'),('fm','us','Federated States of Micronesia'),('fl','us','Florida'),('ga','us','Georgia'),('gu','us','Guam'),('hi','us','Hawaii'),('id','us','Idaho'),('il','us','Illinois'),('in','us','Indiana'),('ia','us','Iowa'),('ks','us','Kansas'),('ky','us','Kentucky'),('la','us','Louisiana'),('me','us','Maine'),('mh','us','Marshall Islands'),('md','us','Maryland'),('ma','us','Massachusetts'),('mi','us','Michigan'),('mn','us','Minnesota'),('ms','us','Mississippi'),('mo','us','Missouri'),('mt','us','Montana'),('ne','us','Nebraska'),('nv','us','Nevada'),('nh','us','New Hampshire'),('nj','us','New Jersey'),('nm','us','New Mexico'),('ny','us','New York'),('nc','us','North Carolina'),('nd','us','North Dakota'),('mp','us','Northern Mariana Islands'),('oh','us','Ohio'),('ok','us','Oklahoma'),('or','us','Oregon'),('pw','us','Palau'),('pa','us','Pennsylvania'),('pr','us','Puerto Rico'),('ri','us','Rhode Island'),('sc','us','South Carolina'),('sd','us','South Dakota'),('tn','us','Tennessee'),('tx','us','Texas'),('ut','us','Utah'),('vt','us','Vermont'),('vi','us','Virgin Island'),('va','us','Virginia'),('wa','us','Washington'),('wv','us','West Virginia'),('wi','us','Wisconsin'),('wy','us','Wyoming'),('ab','ca','Alberta'),('bc','ca','British Columbia'),('mb','ca','Manitoba'),('nb','ca','New Brunswick'),('nf','ca','New Foundland'),('nt','ca','Northwest Territories'),('ns','ca','Nova Scotia'),('on','ca','Ontario'),('pe','ca','Prince Edward Island'),('pq','ca','Quebec'),('sk','ca','Saskatchewan'),('yt','ca','Yukon Territories');
+INSERT INTO `state`(code,country_code,description) VALUES ('al','us','Alabama'),('ak','us','Alaska'),('as','us','American Samoa'),('az','us','Arizona'),('ar','us','Arkansas'),('ca','us','California'),('co','us','Colorado'),('ct','us','Connecticut'),('de','us','Delaware'),('dc','us','District of Columbia'),('fm','us','Federated States of Micronesia'),('fl','us','Florida'),('ga','us','Georgia'),('gu','us','Guam'),('hi','us','Hawaii'),('id','us','Idaho'),('il','us','Illinois'),('in','us','Indiana'),('ia','us','Iowa'),('ks','us','Kansas'),('ky','us','Kentucky'),('la','us','Louisiana'),('me','us','Maine'),('mh','us','Marshall Islands'),('md','us','Maryland'),('ma','us','Massachusetts'),('mi','us','Michigan'),('mn','us','Minnesota'),('ms','us','Mississippi'),('mo','us','Missouri'),('mt','us','Montana'),('ne','us','Nebraska'),('nv','us','Nevada'),('nh','us','New Hampshire'),('nj','us','New Jersey'),('nm','us','New Mexico'),('ny','us','New York'),('nc','us','North Carolina'),('nd','us','North Dakota'),('mp','us','Northern Mariana Islands'),('oh','us','Ohio'),('ok','us','Oklahoma'),('or','us','Oregon'),('pw','us','Palau'),('pa','us','Pennsylvania'),('pr','us','Puerto Rico'),('ri','us','Rhode Island'),('sc','us','South Carolina'),('sd','us','South Dakota'),('tn','us','Tennessee'),('tx','us','Texas'),('ut','us','Utah'),('vt','us','Vermont'),('vi','us','Virgin Island'),('va','us','Virginia'),('wa','us','Washington'),('wv','us','West Virginia'),('wi','us','Wisconsin'),('wy','us','Wyoming'),('ab','ca','Alberta'),('bc','ca','British Columbia'),('mb','ca','Manitoba'),('nb','ca','New Brunswick'),('nf','ca','New Foundland'),('nt','ca','Northwest Territories'),('ns','ca','Nova Scotia'),('on','ca','Ontario'),('pe','ca','Prince Edward Island'),('pq','ca','Quebec'),('sk','ca','Saskatchewan'),('yt','ca','Yukon Territories');
+UPDATE state SET regex=CONCAT('/(',code,')/i');
View
16 test/lib_mysqludf_preg_capture.result
@@ -6,9 +6,11 @@ CREATE TABLE `state` (
`code` varchar(2) NOT NULL,
`country_code` varchar(2) NOT NULL,
`description` varchar(255) NOT NULL,
+`regex` varchar(255) ,
PRIMARY KEY (`code`)
) ENGINE=HEAP DEFAULT CHARSET=latin1;
-INSERT INTO `state` VALUES ('al','us','Alabama'),('ak','us','Alaska'),('as','us','American Samoa'),('az','us','Arizona'),('ar','us','Arkansas'),('ca','us','California'),('co','us','Colorado'),('ct','us','Connecticut'),('de','us','Delaware'),('dc','us','District of Columbia'),('fm','us','Federated States of Micronesia'),('fl','us','Florida'),('ga','us','Georgia'),('gu','us','Guam'),('hi','us','Hawaii'),('id','us','Idaho'),('il','us','Illinois'),('in','us','Indiana'),('ia','us','Iowa'),('ks','us','Kansas'),('ky','us','Kentucky'),('la','us','Louisiana'),('me','us','Maine'),('mh','us','Marshall Islands'),('md','us','Maryland'),('ma','us','Massachusetts'),('mi','us','Michigan'),('mn','us','Minnesota'),('ms','us','Mississippi'),('mo','us','Missouri'),('mt','us','Montana'),('ne','us','Nebraska'),('nv','us','Nevada'),('nh','us','New Hampshire'),('nj','us','New Jersey'),('nm','us','New Mexico'),('ny','us','New York'),('nc','us','North Carolina'),('nd','us','North Dakota'),('mp','us','Northern Mariana Islands'),('oh','us','Ohio'),('ok','us','Oklahoma'),('or','us','Oregon'),('pw','us','Palau'),('pa','us','Pennsylvania'),('pr','us','Puerto Rico'),('ri','us','Rhode Island'),('sc','us','South Carolina'),('sd','us','South Dakota'),('tn','us','Tennessee'),('tx','us','Texas'),('ut','us','Utah'),('vt','us','Vermont'),('vi','us','Virgin Island'),('va','us','Virginia'),('wa','us','Washington'),('wv','us','West Virginia'),('wi','us','Wisconsin'),('wy','us','Wyoming'),('ab','ca','Alberta'),('bc','ca','British Columbia'),('mb','ca','Manitoba'),('nb','ca','New Brunswick'),('nf','ca','New Foundland'),('nt','ca','Northwest Territories'),('ns','ca','Nova Scotia'),('on','ca','Ontario'),('pe','ca','Prince Edward Island'),('pq','ca','Quebec'),('sk','ca','Saskatchewan'),('yt','ca','Yukon Territories');
+INSERT INTO `state`(code,country_code,description) VALUES ('al','us','Alabama'),('ak','us','Alaska'),('as','us','American Samoa'),('az','us','Arizona'),('ar','us','Arkansas'),('ca','us','California'),('co','us','Colorado'),('ct','us','Connecticut'),('de','us','Delaware'),('dc','us','District of Columbia'),('fm','us','Federated States of Micronesia'),('fl','us','Florida'),('ga','us','Georgia'),('gu','us','Guam'),('hi','us','Hawaii'),('id','us','Idaho'),('il','us','Illinois'),('in','us','Indiana'),('ia','us','Iowa'),('ks','us','Kansas'),('ky','us','Kentucky'),('la','us','Louisiana'),('me','us','Maine'),('mh','us','Marshall Islands'),('md','us','Maryland'),('ma','us','Massachusetts'),('mi','us','Michigan'),('mn','us','Minnesota'),('ms','us','Mississippi'),('mo','us','Missouri'),('mt','us','Montana'),('ne','us','Nebraska'),('nv','us','Nevada'),('nh','us','New Hampshire'),('nj','us','New Jersey'),('nm','us','New Mexico'),('ny','us','New York'),('nc','us','North Carolina'),('nd','us','North Dakota'),('mp','us','Northern Mariana Islands'),('oh','us','Ohio'),('ok','us','Oklahoma'),('or','us','Oregon'),('pw','us','Palau'),('pa','us','Pennsylvania'),('pr','us','Puerto Rico'),('ri','us','Rhode Island'),('sc','us','South Carolina'),('sd','us','South Dakota'),('tn','us','Tennessee'),('tx','us','Texas'),('ut','us','Utah'),('vt','us','Vermont'),('vi','us','Virgin Island'),('va','us','Virginia'),('wa','us','Washington'),('wv','us','West Virginia'),('wi','us','Wisconsin'),('wy','us','Wyoming'),('ab','ca','Alberta'),('bc','ca','British Columbia'),('mb','ca','Manitoba'),('nb','ca','New Brunswick'),('nf','ca','New Foundland'),('nt','ca','Northwest Territories'),('ns','ca','Nova Scotia'),('on','ca','Ontario'),('pe','ca','Prince Edward Island'),('pq','ca','Quebec'),('sk','ca','Saskatchewan'),('yt','ca','Yukon Territories');
+UPDATE state SET regex=CONCAT('/(',code,')/i');
SELECT PREG_CAPTURE( '/(x)(?:(abc)|(xyz))(x)/' , 'xabcx' , 2 ) ;
PREG_CAPTURE( '/(x)(?:(abc)|(xyz))(x)/' , 'xabcx' , 2 )
abc
@@ -46,6 +48,18 @@ NULL
SELECT PREG_CAPTURE( '/b[^\\s]*/' , 'the quick brown fox jumped up & down',4);
PREG_CAPTURE( '/b[^\\s]*/' , 'the quick brown fox jumped up & down',4)
NULL
+SELECT PREG_CAPTURE('/ ([A-Za-z]+) /', '13 robin road', 1, 1);
+PREG_CAPTURE('/ ([A-Za-z]+) /', '13 robin road', 1, 1)
+robin
+SELECT PREG_CAPTURE('/([A-Za-z]+)/', '13 robin road', 1, 2);
+PREG_CAPTURE('/([A-Za-z]+)/', '13 robin road', 1, 2)
+road
+SELECT PREG_CAPTURE('/([A-Za-z]+)/', '13 robin road', 1, 3);
+PREG_CAPTURE('/([A-Za-z]+)/', '13 robin road', 1, 3)
+NULL
+SELECT PREG_CAPTURE('/([A-Za-z]+)/', '13 robin road', 1, 4);
+PREG_CAPTURE('/([A-Za-z]+)/', '13 robin road', 1, 4)
+NULL
DROP TABLE IF EXISTS `patterns`;
CREATE TABLE `patterns` (
`pattern` varchar(255) NOT NULL,
View
6 test/lib_mysqludf_preg_capture.test
@@ -47,6 +47,12 @@ SELECT PREG_CAPTURE( '/b[^\\s]*/' , 'the quick brown fox jumped up & down' );
SELECT PREG_CAPTURE( '/b[^\\s]*/' , 'the quick brown fox jumped up & down',0,4);
SELECT PREG_CAPTURE( '/b[^\\s]*/' , 'the quick brown fox jumped up & down',4);
+#### Occurence out of boungs (Bug #12)
+SELECT PREG_CAPTURE('/ ([A-Za-z]+) /', '13 robin road', 1, 1);
+SELECT PREG_CAPTURE('/([A-Za-z]+)/', '13 robin road', 1, 2);
+SELECT PREG_CAPTURE('/([A-Za-z]+)/', '13 robin road', 1, 3);
+SELECT PREG_CAPTURE('/([A-Za-z]+)/', '13 robin road', 1, 4);
+
######### try some none-constant patterns & replacements
#
View
6 test/lib_mysqludf_preg_check.result
@@ -6,9 +6,11 @@ CREATE TABLE `state` (
`code` varchar(2) NOT NULL,
`country_code` varchar(2) NOT NULL,
`description` varchar(255) NOT NULL,
+`regex` varchar(255) ,
PRIMARY KEY (`code`)
) ENGINE=HEAP DEFAULT CHARSET=latin1;
-INSERT INTO `state` VALUES ('al','us','Alabama'),('ak','us','Alaska'),('as','us','American Samoa'),('az','us','Arizona'),('ar','us','Arkansas'),('ca','us','California'),('co','us','Colorado'),('ct','us','Connecticut'),('de','us','Delaware'),('dc','us','District of Columbia'),('fm','us','Federated States of Micronesia'),('fl','us','Florida'),('ga','us','Georgia'),('gu','us','Guam'),('hi','us','Hawaii'),('id','us','Idaho'),('il','us','Illinois'),('in','us','Indiana'),('ia','us','Iowa'),('ks','us','Kansas'),('ky','us','Kentucky'),('la','us','Louisiana'),('me','us','Maine'),('mh','us','Marshall Islands'),('md','us','Maryland'),('ma','us','Massachusetts'),('mi','us','Michigan'),('mn','us','Minnesota'),('ms','us','Mississippi'),('mo','us','Missouri'),('mt','us','Montana'),('ne','us','Nebraska'),('nv','us','Nevada'),('nh','us','New Hampshire'),('nj','us','New Jersey'),('nm','us','New Mexico'),('ny','us','New York'),('nc','us','North Carolina'),('nd','us','North Dakota'),('mp','us','Northern Mariana Islands'),('oh','us','Ohio'),('ok','us','Oklahoma'),('or','us','Oregon'),('pw','us','Palau'),('pa','us','Pennsylvania'),('pr','us','Puerto Rico'),('ri','us','Rhode Island'),('sc','us','South Carolina'),('sd','us','South Dakota'),('tn','us','Tennessee'),('tx','us','Texas'),('ut','us','Utah'),('vt','us','Vermont'),('vi','us','Virgin Island'),('va','us','Virginia'),('wa','us','Washington'),('wv','us','West Virginia'),('wi','us','Wisconsin'),('wy','us','Wyoming'),('ab','ca','Alberta'),('bc','ca','British Columbia'),('mb','ca','Manitoba'),('nb','ca','New Brunswick'),('nf','ca','New Foundland'),('nt','ca','Northwest Territories'),('ns','ca','Nova Scotia'),('on','ca','Ontario'),('pe','ca','Prince Edward Island'),('pq','ca','Quebec'),('sk','ca','Saskatchewan'),('yt','ca','Yukon Territories');
+INSERT INTO `state`(code,country_code,description) VALUES ('al','us','Alabama'),('ak','us','Alaska'),('as','us','American Samoa'),('az','us','Arizona'),('ar','us','Arkansas'),('ca','us','California'),('co','us','Colorado'),('ct','us','Connecticut'),('de','us','Delaware'),('dc','us','District of Columbia'),('fm','us','Federated States of Micronesia'),('fl','us','Florida'),('ga','us','Georgia'),('gu','us','Guam'),('hi','us','Hawaii'),('id','us','Idaho'),('il','us','Illinois'),('in','us','Indiana'),('ia','us','Iowa'),('ks','us','Kansas'),('ky','us','Kentucky'),('la','us','Louisiana'),('me','us','Maine'),('mh','us','Marshall Islands'),('md','us','Maryland'),('ma','us','Massachusetts'),('mi','us','Michigan'),('mn','us','Minnesota'),('ms','us','Mississippi'),('mo','us','Missouri'),('mt','us','Montana'),('ne','us','Nebraska'),('nv','us','Nevada'),('nh','us','New Hampshire'),('nj','us','New Jersey'),('nm','us','New Mexico'),('ny','us','New York'),('nc','us','North Carolina'),('nd','us','North Dakota'),('mp','us','Northern Mariana Islands'),('oh','us','Ohio'),('ok','us','Oklahoma'),('or','us','Oregon'),('pw','us','Palau'),('pa','us','Pennsylvania'),('pr','us','Puerto Rico'),('ri','us','Rhode Island'),('sc','us','South Carolina'),('sd','us','South Dakota'),('tn','us','Tennessee'),('tx','us','Texas'),('ut','us','Utah'),('vt','us','Vermont'),('vi','us','Virgin Island'),('va','us','Virginia'),('wa','us','Washington'),('wv','us','West Virginia'),('wi','us','Wisconsin'),('wy','us','Wyoming'),('ab','ca','Alberta'),('bc','ca','British Columbia'),('mb','ca','Manitoba'),('nb','ca','New Brunswick'),('nf','ca','New Foundland'),('nt','ca','Northwest Territories'),('ns','ca','Nova Scotia'),('on','ca','Ontario'),('pe','ca','Prince Edward Island'),('pq','ca','Quebec'),('sk','ca','Saskatchewan'),('yt','ca','Yukon Territories');
+UPDATE state SET regex=CONCAT('/(',code,')/i');
select PREG_CHECK("/h[[:alpha:]]+r/") ;
PREG_CHECK("/h[[:alpha:]]+r/")
1
@@ -17,7 +19,7 @@ PREG_CHECK("/^(a|b)*$/" )
1
select PREG_CHECK(NULL);
PREG_CHECK(NULL)
-0
+NULL
select PREG_CHECK('/goobar');
PREG_CHECK('/goobar')
0
View
4 test/lib_mysqludf_preg_info.result
@@ -6,9 +6,11 @@ CREATE TABLE `state` (
`code` varchar(2) NOT NULL,
`country_code` varchar(2) NOT NULL,
`description` varchar(255) NOT NULL,
+`regex` varchar(255) ,
PRIMARY KEY (`code`)
) ENGINE=HEAP DEFAULT CHARSET=latin1;
-INSERT INTO `state` VALUES ('al','us','Alabama'),('ak','us','Alaska'),('as','us','American Samoa'),('az','us','Arizona'),('ar','us','Arkansas'),('ca','us','California'),('co','us','Colorado'),('ct','us','Connecticut'),('de','us','Delaware'),('dc','us','District of Columbia'),('fm','us','Federated States of Micronesia'),('fl','us','Florida'),('ga','us','Georgia'),('gu','us','Guam'),('hi','us','Hawaii'),('id','us','Idaho'),('il','us','Illinois'),('in','us','Indiana'),('ia','us','Iowa'),('ks','us','Kansas'),('ky','us','Kentucky'),('la','us','Louisiana'),('me','us','Maine'),('mh','us','Marshall Islands'),('md','us','Maryland'),('ma','us','Massachusetts'),('mi','us','Michigan'),('mn','us','Minnesota'),('ms','us','Mississippi'),('mo','us','Missouri'),('mt','us','Montana'),('ne','us','Nebraska'),('nv','us','Nevada'),('nh','us','New Hampshire'),('nj','us','New Jersey'),('nm','us','New Mexico'),('ny','us','New York'),('nc','us','North Carolina'),('nd','us','North Dakota'),('mp','us','Northern Mariana Islands'),('oh','us','Ohio'),('ok','us','Oklahoma'),('or','us','Oregon'),('pw','us','Palau'),('pa','us','Pennsylvania'),('pr','us','Puerto Rico'),('ri','us','Rhode Island'),('sc','us','South Carolina'),('sd','us','South Dakota'),('tn','us','Tennessee'),('tx','us','Texas'),('ut','us','Utah'),('vt','us','Vermont'),('vi','us','Virgin Island'),('va','us','Virginia'),('wa','us','Washington'),('wv','us','West Virginia'),('wi','us','Wisconsin'),('wy','us','Wyoming'),('ab','ca','Alberta'),('bc','ca','British Columbia'),('mb','ca','Manitoba'),('nb','ca','New Brunswick'),('nf','ca','New Foundland'),('nt','ca','Northwest Territories'),('ns','ca','Nova Scotia'),('on','ca','Ontario'),('pe','ca','Prince Edward Island'),('pq','ca','Quebec'),('sk','ca','Saskatchewan'),('yt','ca','Yukon Territories');
+INSERT INTO `state`(code,country_code,description) VALUES ('al','us','Alabama'),('ak','us','Alaska'),('as','us','American Samoa'),('az','us','Arizona'),('ar','us','Arkansas'),('ca','us','California'),('co','us','Colorado'),('ct','us','Connecticut'),('de','us','Delaware'),('dc','us','District of Columbia'),('fm','us','Federated States of Micronesia'),('fl','us','Florida'),('ga','us','Georgia'),('gu','us','Guam'),('hi','us','Hawaii'),('id','us','Idaho'),('il','us','Illinois'),('in','us','Indiana'),('ia','us','Iowa'),('ks','us','Kansas'),('ky','us','Kentucky'),('la','us','Louisiana'),('me','us','Maine'),('mh','us','Marshall Islands'),('md','us','Maryland'),('ma','us','Massachusetts'),('mi','us','Michigan'),('mn','us','Minnesota'),('ms','us','Mississippi'),('mo','us','Missouri'),('mt','us','Montana'),('ne','us','Nebraska'),('nv','us','Nevada'),('nh','us','New Hampshire'),('nj','us','New Jersey'),('nm','us','New Mexico'),('ny','us','New York'),('nc','us','North Carolina'),('nd','us','North Dakota'),('mp','us','Northern Mariana Islands'),('oh','us','Ohio'),('ok','us','Oklahoma'),('or','us','Oregon'),('pw','us','Palau'),('pa','us','Pennsylvania'),('pr','us','Puerto Rico'),('ri','us','Rhode Island'),('sc','us','South Carolina'),('sd','us','South Dakota'),('tn','us','Tennessee'),('tx','us','Texas'),('ut','us','Utah'),('vt','us','Vermont'),('vi','us','Virgin Island'),('va','us','Virginia'),('wa','us','Washington'),('wv','us','West Virginia'),('wi','us','Wisconsin'),('wy','us','Wyoming'),('ab','ca','Alberta'),('bc','ca','British Columbia'),('mb','ca','Manitoba'),('nb','ca','New Brunswick'),('nf','ca','New Foundland'),('nt','ca','Northwest Territories'),('ns','ca','Nova Scotia'),('on','ca','Ontario'),('pe','ca','Prince Edward Island'),('pq','ca','Quebec'),('sk','ca','Saskatchewan'),('yt','ca','Yukon Territories');
+UPDATE state SET regex=CONCAT('/(',code,')/i');
SELECT SUBSTR( LIB_MYSQLUDF_PREG_INFO() , 1, 17 ) ;
SUBSTR( LIB_MYSQLUDF_PREG_INFO() , 1, 17 )
lib_mysqludf_preg
View
4 test/lib_mysqludf_preg_position.result
@@ -6,9 +6,11 @@ CREATE TABLE `state` (
`code` varchar(2) NOT NULL,
`country_code` varchar(2) NOT NULL,
`description` varchar(255) NOT NULL,
+`regex` varchar(255) ,
PRIMARY KEY (`code`)
) ENGINE=HEAP DEFAULT CHARSET=latin1;
-INSERT INTO `state` VALUES ('al','us','Alabama'),('ak','us','Alaska'),('as','us','American Samoa'),('az','us','Arizona'),('ar','us','Arkansas'),('ca','us','California'),('co','us','Colorado'),('ct','us','Connecticut'),('de','us','Delaware'),('dc','us','District of Columbia'),('fm','us','Federated States of Micronesia'),('fl','us','Florida'),('ga','us','Georgia'),('gu','us','Guam'),('hi','us','Hawaii'),('id','us','Idaho'),('il','us','Illinois'),('in','us','Indiana'),('ia','us','Iowa'),('ks','us','Kansas'),('ky','us','Kentucky'),('la','us','Louisiana'),('me','us','Maine'),('mh','us','Marshall Islands'),('md','us','Maryland'),('ma','us','Massachusetts'),('mi','us','Michigan'),('mn','us','Minnesota'),('ms','us','Mississippi'),('mo','us','Missouri'),('mt','us','Montana'),('ne','us','Nebraska'),('nv','us','Nevada'),('nh','us','New Hampshire'),('nj','us','New Jersey'),('nm','us','New Mexico'),('ny','us','New York'),('nc','us','North Carolina'),('nd','us','North Dakota'),('mp','us','Northern Mariana Islands'),('oh','us','Ohio'),('ok','us','Oklahoma'),('or','us','Oregon'),('pw','us','Palau'),('pa','us','Pennsylvania'),('pr','us','Puerto Rico'),('ri','us','Rhode Island'),('sc','us','South Carolina'),('sd','us','South Dakota'),('tn','us','Tennessee'),('tx','us','Texas'),('ut','us','Utah'),('vt','us','Vermont'),('vi','us','Virgin Island'),('va','us','Virginia'),('wa','us','Washington'),('wv','us','West Virginia'),('wi','us','Wisconsin'),('wy','us','Wyoming'),('ab','ca','Alberta'),('bc','ca','British Columbia'),('mb','ca','Manitoba'),('nb','ca','New Brunswick'),('nf','ca','New Foundland'),('nt','ca','Northwest Territories'),('ns','ca','Nova Scotia'),('on','ca','Ontario'),('pe','ca','Prince Edward Island'),('pq','ca','Quebec'),('sk','ca','Saskatchewan'),('yt','ca','Yukon Territories');
+INSERT INTO `state`(code,country_code,description) VALUES ('al','us','Alabama'),('ak','us','Alaska'),('as','us','American Samoa'),('az','us','Arizona'),('ar','us','Arkansas'),('ca','us','California'),('co','us','Colorado'),('ct','us','Connecticut'),('de','us','Delaware'),('dc','us','District of Columbia'),('fm','us','Federated States of Micronesia'),('fl','us','Florida'),('ga','us','Georgia'),('gu','us','Guam'),('hi','us','Hawaii'),('id','us','Idaho'),('il','us','Illinois'),('in','us','Indiana'),('ia','us','Iowa'),('ks','us','Kansas'),('ky','us','Kentucky'),('la','us','Louisiana'),('me','us','Maine'),('mh','us','Marshall Islands'),('md','us','Maryland'),('ma','us','Massachusetts'),('mi','us','Michigan'),('mn','us','Minnesota'),('ms','us','Mississippi'),('mo','us','Missouri'),('mt','us','Montana'),('ne','us','Nebraska'),('nv','us','Nevada'),('nh','us','New Hampshire'),('nj','us','New Jersey'),('nm','us','New Mexico'),('ny','us','New York'),('nc','us','North Carolina'),('nd','us','North Dakota'),('mp','us','Northern Mariana Islands'),('oh','us','Ohio'),('ok','us','Oklahoma'),('or','us','Oregon'),('pw','us','Palau'),('pa','us','Pennsylvania'),('pr','us','Puerto Rico'),('ri','us','Rhode Island'),('sc','us','South Carolina'),('sd','us','South Dakota'),('tn','us','Tennessee'),('tx','us','Texas'),('ut','us','Utah'),('vt','us','Vermont'),('vi','us','Virgin Island'),('va','us','Virginia'),('wa','us','Washington'),('wv','us','West Virginia'),('wi','us','Wisconsin'),('wy','us','Wyoming'),('ab','ca','Alberta'),('bc','ca','British Columbia'),('mb','ca','Manitoba'),('nb','ca','New Brunswick'),('nf','ca','New Foundland'),('nt','ca','Northwest Territories'),('ns','ca','Nova Scotia'),('on','ca','Ontario'),('pe','ca','Prince Edward Island'),('pq','ca','Quebec'),('sk','ca','Saskatchewan'),('yt','ca','Yukon Territories');
+UPDATE state SET regex=CONCAT('/(',code,')/i');
SELECT PREG_POSITION( '/(x)(?:(abc)|(xyz))(x)/' , 'xabcx' , 2 ) ;
PREG_POSITION( '/(x)(?:(abc)|(xyz))(x)/' , 'xabcx' , 2 )
2
View
13 test/lib_mysqludf_preg_replace.result
@@ -6,9 +6,11 @@ CREATE TABLE `state` (
`code` varchar(2) NOT NULL,
`country_code` varchar(2) NOT NULL,
`description` varchar(255) NOT NULL,
+`regex` varchar(255) ,
PRIMARY KEY (`code`)
) ENGINE=HEAP DEFAULT CHARSET=latin1;
-INSERT INTO `state` VALUES ('al','us','Alabama'),('ak','us','Alaska'),('as','us','American Samoa'),('az','us','Arizona'),('ar','us','Arkansas'),('ca','us','California'),('co','us','Colorado'),('ct','us','Connecticut'),('de','us','Delaware'),('dc','us','District of Columbia'),('fm','us','Federated States of Micronesia'),('fl','us','Florida'),('ga','us','Georgia'),('gu','us','Guam'),('hi','us','Hawaii'),('id','us','Idaho'),('il','us','Illinois'),('in','us','Indiana'),('ia','us','Iowa'),('ks','us','Kansas'),('ky','us','Kentucky'),('la','us','Louisiana'),('me','us','Maine'),('mh','us','Marshall Islands'),('md','us','Maryland'),('ma','us','Massachusetts'),('mi','us','Michigan'),('mn','us','Minnesota'),('ms','us','Mississippi'),('mo','us','Missouri'),('mt','us','Montana'),('ne','us','Nebraska'),('nv','us','Nevada'),('nh','us','New Hampshire'),('nj','us','New Jersey'),('nm','us','New Mexico'),('ny','us','New York'),('nc','us','North Carolina'),('nd','us','North Dakota'),('mp','us','Northern Mariana Islands'),('oh','us','Ohio'),('ok','us','Oklahoma'),('or','us','Oregon'),('pw','us','Palau'),('pa','us','Pennsylvania'),('pr','us','Puerto Rico'),('ri','us','Rhode Island'),('sc','us','South Carolina'),('sd','us','South Dakota'),('tn','us','Tennessee'),('tx','us','Texas'),('ut','us','Utah'),('vt','us','Vermont'),('vi','us','Virgin Island'),('va','us','Virginia'),('wa','us','Washington'),('wv','us','West Virginia'),('wi','us','Wisconsin'),('wy','us','Wyoming'),('ab','ca','Alberta'),('bc','ca','British Columbia'),('mb','ca','Manitoba'),('nb','ca','New Brunswick'),('nf','ca','New Foundland'),('nt','ca','Northwest Territories'),('ns','ca','Nova Scotia'),('on','ca','Ontario'),('pe','ca','Prince Edward Island'),('pq','ca','Quebec'),('sk','ca','Saskatchewan'),('yt','ca','Yukon Territories');
+INSERT INTO `state`(code,country_code,description) VALUES ('al','us','Alabama'),('ak','us','Alaska'),('as','us','American Samoa'),('az','us','Arizona'),('ar','us','Arkansas'),('ca','us','California'),('co','us','Colorado'),('ct','us','Connecticut'),('de','us','Delaware'),('dc','us','District of Columbia'),('fm','us','Federated States of Micronesia'),('fl','us','Florida'),('ga','us','Georgia'),('gu','us','Guam'),('hi','us','Hawaii'),('id','us','Idaho'),('il','us','Illinois'),('in','us','Indiana'),('ia','us','Iowa'),('ks','us','Kansas'),('ky','us','Kentucky'),('la','us','Louisiana'),('me','us','Maine'),('mh','us','Marshall Islands'),('md','us','Maryland'),('ma','us','Massachusetts'),('mi','us','Michigan'),('mn','us','Minnesota'),('ms','us','Mississippi'),('mo','us','Missouri'),('mt','us','Montana'),('ne','us','Nebraska'),('nv','us','Nevada'),('nh','us','New Hampshire'),('nj','us','New Jersey'),('nm','us','New Mexico'),('ny','us','New York'),('nc','us','North Carolina'),('nd','us','North Dakota'),('mp','us','Northern Mariana Islands'),('oh','us','Ohio'),('ok','us','Oklahoma'),('or','us','Oregon'),('pw','us','Palau'),('pa','us','Pennsylvania'),('pr','us','Puerto Rico'),('ri','us','Rhode Island'),('sc','us','South Carolina'),('sd','us','South Dakota'),('tn','us','Tennessee'),('tx','us','Texas'),('ut','us','Utah'),('vt','us','Vermont'),('vi','us','Virgin Island'),('va','us','Virginia'),('wa','us','Washington'),('wv','us','West Virginia'),('wi','us','Wisconsin'),('wy','us','Wyoming'),('ab','ca','Alberta'),('bc','ca','British Columbia'),('mb','ca','Manitoba'),('nb','ca','New Brunswick'),('nf','ca','New Foundland'),('nt','ca','Northwest Territories'),('ns','ca','Nova Scotia'),('on','ca','Ontario'),('pe','ca','Prince Edward Island'),('pq','ca','Quebec'),('sk','ca','Saskatchewan'),('yt','ca','Yukon Territories');
+UPDATE state SET regex=CONCAT('/(',code,')/i');
SELECT PREG_REPLACE('/fox/i' , '' , 'the quick brown fox' ,2 );
PREG_REPLACE('/fox/i' , '' , 'the quick brown fox' ,2 )
the quick brown
@@ -51,6 +53,15 @@ Foundland New
Territories Northwest
Scotia Nova
Territories Yukon
+SELECT PREG_REPLACE ('/a*/',NULL, 'America');
+PREG_REPLACE ('/a*/',NULL, 'America')
+NULL
+SELECT PREG_REPLACE (NULL ,'foo', 'America');
+PREG_REPLACE (NULL ,'foo', 'America')
+NULL
+SELECT PREG_REPLACE ('/a*/' ,'foo', NULL);
+PREG_REPLACE ('/a*/' ,'foo', NULL)
+NULL
DROP TABLE IF EXISTS `patterns`;
CREATE TABLE `patterns` (
`pattern` varchar(255) NOT NULL,
View
6 test/lib_mysqludf_preg_replace.test
@@ -33,6 +33,12 @@ SELECT PREG_REPLACE( '/(new)(\\s+)([a-zA-Z]*)(.*)/i' ,'$1$2 Old$4', description
#### Reverse state
SELECT PREG_REPLACE( '/([^\\s]*)(\\s+)([^\\s]*)/' ,'$3 $1', description ) FROM state WHERE PREG_RLIKE( '/^[a-z]+\\s+[a-z]+$/i',description);
+###### Check NULL stufff (Bug #4)
+SELECT PREG_REPLACE ('/a*/',NULL, 'America');
+SELECT PREG_REPLACE (NULL ,'foo', 'America');
+SELECT PREG_REPLACE ('/a*/' ,'foo', NULL);
+
+
######### try some none-constant patterns & replacements
#
--disable_warnings
View
13 test/lib_mysqludf_preg_rlike.result
@@ -6,9 +6,11 @@ CREATE TABLE `state` (
`code` varchar(2) NOT NULL,
`country_code` varchar(2) NOT NULL,
`description` varchar(255) NOT NULL,
+`regex` varchar(255) ,
PRIMARY KEY (`code`)
) ENGINE=HEAP DEFAULT CHARSET=latin1;
-INSERT INTO `state` VALUES ('al','us','Alabama'),('ak','us','Alaska'),('as','us','American Samoa'),('az','us','Arizona'),('ar','us','Arkansas'),('ca','us','California'),('co','us','Colorado'),('ct','us','Connecticut'),('de','us','Delaware'),('dc','us','District of Columbia'),('fm','us','Federated States of Micronesia'),('fl','us','Florida'),('ga','us','Georgia'),('gu','us','Guam'),('hi','us','Hawaii'),('id','us','Idaho'),('il','us','Illinois'),('in','us','Indiana'),('ia','us','Iowa'),('ks','us','Kansas'),('ky','us','Kentucky'),('la','us','Louisiana'),('me','us','Maine'),('mh','us','Marshall Islands'),('md','us','Maryland'),('ma','us','Massachusetts'),('mi','us','Michigan'),('mn','us','Minnesota'),('ms','us','Mississippi'),('mo','us','Missouri'),('mt','us','Montana'),('ne','us','Nebraska'),('nv','us','Nevada'),('nh','us','New Hampshire'),('nj','us','New Jersey'),('nm','us','New Mexico'),('ny','us','New York'),('nc','us','North Carolina'),('nd','us','North Dakota'),('mp','us','Northern Mariana Islands'),('oh','us','Ohio'),('ok','us','Oklahoma'),('or','us','Oregon'),('pw','us','Palau'),('pa','us','Pennsylvania'),('pr','us','Puerto Rico'),('ri','us','Rhode Island'),('sc','us','South Carolina'),('sd','us','South Dakota'),('tn','us','Tennessee'),('tx','us','Texas'),('ut','us','Utah'),('vt','us','Vermont'),('vi','us','Virgin Island'),('va','us','Virginia'),('wa','us','Washington'),('wv','us','West Virginia'),('wi','us','Wisconsin'),('wy','us','Wyoming'),('ab','ca','Alberta'),('bc','ca','British Columbia'),('mb','ca','Manitoba'),('nb','ca','New Brunswick'),('nf','ca','New Foundland'),('nt','ca','Northwest Territories'),('ns','ca','Nova Scotia'),('on','ca','Ontario'),('pe','ca','Prince Edward Island'),('pq','ca','Quebec'),('sk','ca','Saskatchewan'),('yt','ca','Yukon Territories');
+INSERT INTO `state`(code,country_code,description) VALUES ('al','us','Alabama'),('ak','us','Alaska'),('as','us','American Samoa'),('az','us','Arizona'),('ar','us','Arkansas'),('ca','us','California'),('co','us','Colorado'),('ct','us','Connecticut'),('de','us','Delaware'),('dc','us','District of Columbia'),('fm','us','Federated States of Micronesia'),('fl','us','Florida'),('ga','us','Georgia'),('gu','us','Guam'),('hi','us','Hawaii'),('id','us','Idaho'),('il','us','Illinois'),('in','us','Indiana'),('ia','us','Iowa'),('ks','us','Kansas'),('ky','us','Kentucky'),('la','us','Louisiana'),('me','us','Maine'),('mh','us','Marshall Islands'),('md','us','Maryland'),('ma','us','Massachusetts'),('mi','us','Michigan'),('mn','us','Minnesota'),('ms','us','Mississippi'),('mo','us','Missouri'),('mt','us','Montana'),('ne','us','Nebraska'),('nv','us','Nevada'),('nh','us','New Hampshire'),('nj','us','New Jersey'),('nm','us','New Mexico'),('ny','us','New York'),('nc','us','North Carolina'),('nd','us','North Dakota'),('mp','us','Northern Mariana Islands'),('oh','us','Ohio'),('ok','us','Oklahoma'),('or','us','Oregon'),('pw','us','Palau'),('pa','us','Pennsylvania'),('pr','us','Puerto Rico'),('ri','us','Rhode Island'),('sc','us','South Carolina'),('sd','us','South Dakota'),('tn','us','Tennessee'),('tx','us','Texas'),('ut','us','Utah'),('vt','us','Vermont'),('vi','us','Virgin Island'),('va','us','Virginia'),('wa','us','Washington'),('wv','us','West Virginia'),('wi','us','Wisconsin'),('wy','us','Wyoming'),('ab','ca','Alberta'),('bc','ca','British Columbia'),('mb','ca','Manitoba'),('nb','ca','New Brunswick'),('nf','ca','New Foundland'),('nt','ca','Northwest Territories'),('ns','ca','Nova Scotia'),('on','ca','Ontario'),('pe','ca','Prince Edward Island'),('pq','ca','Quebec'),('sk','ca','Saskatchewan'),('yt','ca','Yukon Territories');
+UPDATE state SET regex=CONCAT('/(',code,')/i');
select PREG_RLIKE("/h[[:alpha:]]+r/","Det h�r �r svenska");
PREG_RLIKE("/h[[:alpha:]]+r/","Det h�r �r svenska")
0
@@ -27,6 +29,15 @@ PREG_RLIKE( '/the quick brown fox/' , 'What do you know about THE QUICK BROWN FO
SELECT PREG_RLIKE('/The quick brown fox/i' , 'the quick brown fox' );
PREG_RLIKE('/The quick brown fox/i' , 'the quick brown fox' )
1
+SELECT PREG_RLIKE('/.*/', '');
+PREG_RLIKE('/.*/', '')
+1
+SELECT PREG_RLIKE('/a*/', 'b');
+PREG_RLIKE('/a*/', 'b')
+1
+SELECT PREG_RLIKE('/a*/', '');
+PREG_RLIKE('/a*/', '')
+1
SELECT description FROM state WHERE PREG_RLIKE( '/new/i' , description ) ;
description
New Hampshire
View
7 test/lib_mysqludf_preg_rlike.test
@@ -33,6 +33,13 @@ SELECT PREG_RLIKE( '/the quick brown fox/' , 'What do you know about THE QUICK B
SELECT PREG_RLIKE('/The quick brown fox/i' , 'the quick brown fox' );
+####################################################
+# Empty String (Bug #6)
+SELECT PREG_RLIKE('/.*/', '');
+SELECT PREG_RLIKE('/a*/', 'b');
+SELECT PREG_RLIKE('/a*/', '');
+
+
####################################################
#### Here are some others

0 comments on commit 4acbd9a

Please sign in to comment.
Something went wrong with that request. Please try again.