简体   繁体   中英

Case insensitive custom replace() function

I'm attempting to do a batch replace on a database to translate british to american words. I've got a large array of words to replace, and also an array of various different tables to run through. I've come across the following thread that appears to provide exactly what I need, however I'm getting errors when trying it.

This is the error I'm encountering.

Exception caught: exception 'PDOException' with message
'SQLSTATE[HY000]: General error: 1436 Thread stack overrun:
10816 bytes used of a 131072 byte stack, and 128000 bytes needed.
Use 'mysqld -O thread_stack=#' to specify a bigger stack.' in /var/.../....php:303
Stack trace: #0 /var/.../....php(303): PDOStatement->execute(Array) #1 {main}

I'm using the custom defined MySQL function in this answer and generating a query that looks like this;

UPDATE field_data_body SET body_value = case_insensitive_replace(body_value, :british, :american)

I'm using the following to handle the PDO;

$query = $db->prepare($sql);
try {
    $query->execute($sql_fields_array);
} catch (PDOException $e) {
    echo "Exception caught: $e";
}

The $sql_fields_array array looks like this;

Array ( [british] => acclimatise [american] => acclimate )

I've tested changing the name of the custom function to make sure I created it correctly, and I did get an error saying the function name did not exist. So at least that part of what I've tried is correct.

Originally I was using the replace(lower(body_value), :british, :american) to do the search and replace, however this then changed everything to lowercase which is not what I want.

Any ideas with this error? Or if there's actually a better way I can automate this batch search and replace.

Seems to be a duplicate of MySQL error 1436: Thread stack overrun, with simple query .

Posting it here since don't have comment rights.

Regards

The query appears to be working fine. After raising the thread stack from 128K to 256K the query successfully executed. It took a good 20-30 seconds mind you, but ran non the less.

I've not noticed any adverse effects on the server after increasing this limit.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM