I had written code that I thought should cache the repeated user function 
arguments used in a SQL statement generally like so:
SELECT a.id FROM a,b WHERE MyFunc(a.data,b.data);
But to my surprise, even though I was saving my (parsed and processed) 
arguments using at the end of my function implementation sqlite3_set_auxdata(), 
and checking for them at the top of my function implementation with 
sqlite3_get_auxdata(), sqlite3_get_auxdata() was always returning NULL for both 
arguments. ?This was a surprise as I expected one of them (but not both of 
course) would be successfully cached. ?So, I looked into the documentation, and 
I found this line on the page for sqlite3_get_auxdata()/sqlite3_set_auxdata() 
page (https://www.sqlite.org/c3ref/get_auxdata.html):
"In practice, metadata is preserved between function calls for function 
parameters that are compile-time constants, including literal values and 
parameters and expressions composed from the same."
So, why *isn't* metadata preserved between function calls for data values? 
?There's a lot more possible savings in pre-processing a blob containing an 
image or a geometry or a large text string containing XML than pre-processing a 
constant. ?Presumably, if someone goes through the effort of calling 
sqlite3_set_auxdata() that meant it to be kept.
Peter

Reply via email to