I'd like to keep state between calls to a UDF (mainly for caching purposes). I can shove an object into the appdomain using SetData and read it using GetData, but that requires the assembly to be set to UNSAFE. I'm confident I can secure the DB and the assembly fairly well, but I like defense in depth, and if there's another way to save state between calls to a UDF, I would prefer those.
Is there another way to store state between calls to a UDF, without putting data into DB tables or using things that will require the assembly to have such a wide permission set?
Thanks,
AlexYou may try with CONTEXT_INFO: it allows you to associates up to 128 bytes of binary information with the current session or
connection.|||
NOTE: following suggestions are not supported by Microsoft.
You have two options:
first is to declare the class with CompilerGenerated attribute and store whatever you want:|||Thanks Sergei, that was exactly what I was looking for!
Carlop, thank you too. I should have been more clear that I'm trying to cache between connections to the database as well, not just inside a single batch/session.
No comments:
Post a Comment