On 10/24/2011 8:19 PM, ChingChang Hsiao wrote:
   case SQLITE_INTEGER:
     sqlite3_result_int64( context, sqlite3_value_int64(argv[0]) );
     break;
   case SQLITE_NULL:
     sqlite3_result_null( context );
     break;

If you want to just return an argument unchanged, you can use sqlite3_result_value. In this case, you can probably do this whenever the type is anything other than SQLITE_TEXT.

     string token;
     token = sqlSortHelper.GetAlphaNumericOrderToken( 
(char*)sqlite3_value_text(argv[0]) );
     sqlite3_result_text( context, token.c_str(), token.length(), NULL );

NULL as the last parameter of sqlite3_result_text is the same as SQLITE_STATIC, telling SQLite that the string will persist sufficiently long beyond sqlite3_result_text call. This is not the case here - the string is destroyed and becomes garbage soon after sqlite3_result_text call. You should be passing SQLITE_TRANSIENT as the last parameter.
--
Igor Tandetnik

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to