1

I'm having trouble with a MySQL function I pulled across from another db. I did and import of the data and the functions and procedures separately.

I now have a makehash function that makes a call to preg_replace. I can't see this function or procedure anywhere though.

If I run show function status or show procedure status nothing to do with preg_replace shows up, only the custom procedures and functions that were there before.

Is there something I am missing that is installed on the db I copied from that I have neglected to copy over to the new one?

Here is the makehash function:

CREATE DEFINER=`root`@`localhost` FUNCTION `makehash`(description text, raw_location text, title text) RETURNS varchar(32) CHARSET utf8
NO SQL
DETERMINISTIC
begin
    declare data longtext;
    declare hash varchar(32);
    set data = ifnull(description, '');
    set hash = null;
    if length(data) > 64 then
        set data = lower(concat(data, ifnull(raw_location, ''), ifnull(title, '')));
        set hash = md5(preg_replace('/[^a-z]/', '', data));
    end if;
return hash;
Thomas Mitchell
  • 1,071
  • 2
  • 16
  • 29
  • 1
    preg_replace is a php function - not mysql. See also: http://stackoverflow.com/questions/1815865/is-there-a-mysql-equivalent-of-phps-preg-replace – ethrbunny Jan 07 '13 at 22:57
  • @ethrbunny I know but I was wondering if I am not seeing something in the other db. Ideally I just want to copy it over from there. This function works on the other db so I figure it must be there somewhere. Besides functions and procedures are there other things stored in a mysql db? – Thomas Mitchell Jan 07 '13 at 23:03

1 Answers1

2

It's likely that the database you copied that function from is using the lib_mysqludf_preg library, which provides, among other things, a preg_replace() function for MySQL. To make use of it, you'll need to download, compile (unless using a prebuilt binary package) and install that library; see the link above for details.

Ilmari Karonen
  • 49,047
  • 9
  • 93
  • 153