Thanks for the response.  I'm not sure either will work since my random
table can be created at many different points in my application.

I looked at the source, and I think that if I expose the state structure (
prng) in randomByte (remove static and move it outside of the function), I
can save off the state structure before I generate my table for the first
time, and then use this saved state to "re-seed" randomByte when I need to
recreate the random table.

(Basically I allow the users to save off "views" of some static tables, and
one view option allows the rows to presented in a random order.  I only
store the options used to create the view.  If they save this view and the
go back to it later, I'd like the random order to be the same).

Other than the normal caveats for using customized versions of the SQLite
code, does this sound like it would work?



On 8/15/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> "Shane Harrelson" <[EMAIL PROTECTED]> wrote:
> > I have a table that has the rows sorted by using a column which is
> filled
> > with values from random(*).
> >
> > Is there a PRAGMA or other API which allows me to set the "seed" used by
> > random(*) such that
> > I can reproduce the same random sequence each time?
> >
>
> If you compile with -DSQLITE_TEST then the same seed is used
> every time and the sequence will be reproducible.  You can also
> overload the RandomSeed() interface in the OS module.  (The
> techniques for doing that are going to change in version 3.5,
> so anything you do there will not be portable moving forward.)
> Otherwise, no, there is no good way to set the seed for the PRNG.
> There is no pragma.
>
> --
> D. Richard Hipp <[EMAIL PROTECTED]>
>
>
>
>
> -----------------------------------------------------------------------------
> To unsubscribe, send email to [EMAIL PROTECTED]
>
> -----------------------------------------------------------------------------
>
>

Reply via email to