Re: UDF behaves non-deterministic

2012-11-07 Thread Stefan Kuhn
Hi everybody, it looks like the reason for the problem was me not handling string arguments properly (I did not use the provided lengths, but relied on string being null-terminated, it's in the doc, but ...). It seems this became a problem specifically in the parallel situation, misleading me i

Re: UDF behaves non-deterministic

2012-11-05 Thread Stefan Kuhn
On Monday 05 November 2012 18:02:28 h...@tbbs.net wrote: > 2012/11/04 22:23 +, Stefan Kuhn > > select * from table order by udf(column, 'input_value') desc; > For my understanding, this should give the same result always. > > But if for your data function "udf" returns the sa

Re: UDF behaves non-deterministic

2012-11-05 Thread hsv
2012/11/04 22:23 +, Stefan Kuhn select * from table order by udf(column, 'input_value') desc; For my understanding, this should give the same result always. But if for your data function "udf" returns the same for more arguments there is not enough to fix the order. In that

Re: UDF behaves non-deterministic

2012-11-05 Thread walter harms
can you reduce the UDF just to return 1; ? that should give you a clue what is going on. Random values usualy point to two suspects 1. mixing 32bit and 64bit 2. using void instead of int re, wh Am 04.11.2012 23:23, schrieb Stefan Kuhn: > Hi all, > I have a weired (for me at least) problem with

Re: Re: UDF behaves non-deterministic

2012-11-05 Thread Michael Dykman
C is not an inherently thread-safe language. Several of the standard library functions use static data, which gets stepped on during concurrent operation. Many of those do have thread-safe equivalents on many platforms such as strtok/strtok_r (the latter being the safe one). If you are confident

Aw: Re: UDF behaves non-deterministic

2012-11-05 Thread Stefan Kuhn
Hi Dan, thanks for your answer. The UDF only contains functions (the one called in sql plus two functions called in it). There are no variables outside them and nothing is declared static. All variables inside the functions are declared just like "double x=0;" etc. I am not an expert on C, but

Re: UDF behaves non-deterministic

2012-11-04 Thread Dan Nelson
In the last episode (Nov 04), Stefan Kuhn said: > I have a weired (for me at least) problem with a user defined function, > written in C. The function seems to return different results in different > runs (the code of the function does not contain random elements). > Basically, the function calcu

Re: UDF behaves non-deterministic

2012-11-04 Thread Stefan Kuhn
On Sunday 04 November 2012 22:34:22 Michael Dykman wrote: > A couple of questions present. > > You mention that selecting from the whole table takes 5-10s so I assume you > have a lot of records. Yes, and the calculation of the score is fairly complicated. Plust the test server is slow (Pentium II

Re: UDF behaves non-deterministic

2012-11-04 Thread Michael Dykman
A couple of questions present. You mention that selecting from the whole table takes 5-10s so I assume you have a lot of records. is the data not in flux? are you sure? these conflict queries are all on the same server? i would have structured the query like so: select *, udf(column,'value'

UDF behaves non-deterministic

2012-11-04 Thread Stefan Kuhn
Hi all, I have a weired (for me at least) problem with a user defined function, written in C. The function seems to return different results in different runs (the code of the function does not contain random elements). Basically, the function calculates a score based on a column in a table and