Subject | Re: File seek to external "file of records" within UDF |
---|---|
Author | Adam |
Post date | 2006-04-22T03:13:58Z |
--- In firebird-support@yahoogroups.com, "phil_henningsen"
<PHenningsen@...> wrote:
Not too sure of the exact details of what you are trying to do, but it
is usually a bad practice to do anything time consuming from within a
UDF. They are really designed for simple conversions, a UDF could be
used to convert MilesToKm for example, or could be used to perform
some formatting which is not provided by standard SQL and PSQL (or is
unreadable when it is implemented as such). I will leave it to the
more expert members to explain the potential implications of waiting
for file access or waiting for the critical section to become available.
Speaking of critical sections, that is my second point. IIRC, they are
*process specific* objects used to prevent multiple threads stepping
on each others toes. Two *different processes* can simultaneosly
aquire a single critical section, although only a single thread within
each of the processes can hold it at a time. If I am correct here, you
will encounter problems when you use it with classic server, which
spawns a different thread for each connection. You may want to
investigate mutex which is like a global process independent critical
section.
Adam
<PHenningsen@...> wrote:
>Hi Phil,
> Oh, so sorry, my bad. In the class of "rtfm" (read the darn manual!)
>
> The fix is:
> wYr := tm_date.tm_year+1900; // rtfm!
>
> which caused "iFilePos" in the "offending code" to be negative and all
> hell broke loose.
>
Not too sure of the exact details of what you are trying to do, but it
is usually a bad practice to do anything time consuming from within a
UDF. They are really designed for simple conversions, a UDF could be
used to convert MilesToKm for example, or could be used to perform
some formatting which is not provided by standard SQL and PSQL (or is
unreadable when it is implemented as such). I will leave it to the
more expert members to explain the potential implications of waiting
for file access or waiting for the critical section to become available.
Speaking of critical sections, that is my second point. IIRC, they are
*process specific* objects used to prevent multiple threads stepping
on each others toes. Two *different processes* can simultaneosly
aquire a single critical section, although only a single thread within
each of the processes can hold it at a time. If I am correct here, you
will encounter problems when you use it with classic server, which
spawns a different thread for each connection. You may want to
investigate mutex which is like a global process independent critical
section.
Adam