# Trouble with create\_function and sqlite3-ruby-1.1.0

**URL:** <https://www.ruby-forum.com/t/trouble-with-create-function-and-sqlite3-ruby-1-1-0/62711>\
**Category:** Ruby\
**Created:** [June 7, 2006, 2:50pm UTC](https://www.ruby-forum.com/t/trouble-with-create-function-and-sqlite3-ruby-1-1-0/62711 "2006-06-07T14:50:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kivle](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/e480ec/32.png) [@kivle](https://www.ruby-forum.com/u/kivle)\
**Post date:** [June 7, 2006, 2:50pm UTC](https://www.ruby-forum.com/t/trouble-with-create-function-and-sqlite3-ruby-1-1-0/62711/1 "2006-06-07T14:50:27Z")

</div>

Hi,

I’m currently trying to implement an app that makes use of the  
sqlite3-ruby library. My app requires that I compute soundexes for a lot  
of values, and also that I’m able to clean up some names with a basic  
gsub-based function. For that I’ve created two very basic functions  
called “soundex” and “cleanup\_name”. The cleanup-function is pretty much  
a one-liner that does a gsub on the value, while the soundex function  
calls Text::Soundex.soundex on the value. I run version 1.1.0 of  
sqlite3-ruby (MSWIN32), and I’ve installed version 3.3.5 of the  
sqlite3.dll. (just to check, I also tried to downgrade to the previous  
version of sqlite3-ruby, without any luck)

The problem is that I’m getting an awful lot of segfaults. Sometimes  
I’ve been able to get the functions to run on a table or two, only to  
fail on another one. I’ve tried to reform my functions in every way I  
can think of, including using “.dup”, “.to\_s”, “.dup”-ing into an  
intermediate variable etc, but I still keep getting the segfaults.

Is there any special way I should handle the arguments to the  
create\_function block? Should I for instance make a copy of them before  
I change them? Should I treat my return values a certain way? The  
documentation doesn’t mention anything specific, other than that you  
should use result= or set\_result() functions on the FunctionProxy to  
return the value of the function.

Also, could the problem be that I use the two functions together? I use  
them like this: “soundex(cleanup\_name(COLUMN)) as COLUMN\_SOUNDEX” in the  
SQL.

By putting in a bit of “puts” here and there in the ruby-code in  
sqlite3-ruby, I’ve narrowed the problem down to the “step”-function.  
It’s called in the native-code, but control is never returned to the  
ruby-api before the segfault.

I should probably also mention that I used the sqlite-ruby-api at first,  
and then both functions worked without any issues. I’d really like to  
use sqlite3 though for the added functionality.

Helge E.
