php order random,php – ORDER BY random()与SQLITE中的种子
发布日期:2021-06-24 14:00:43 浏览次数:2 分类:技术文章

本文共 789 字,大约阅读时间需要 2 分钟。

简答:

你不行SQLite的random()函数不支持种子值.

不是那么简短的答案:

检查SQLite的func.c显示random()被定义没有任何参数..

VFUNCTION(random, 0, 0, 0, randomFunc ),

..而这个randomFunc()只是调用sqlite3_randomness()(再次没有任何明确的种子值)来获取sizeof(sqlite_int64)字节的随机值.

在内部,sqlite3_randomness()(见random.c)的实现将首次使用从OS获取的随机种子值来设置RC4伪随机数生成器:

/* Initialize the state of the random number generator once,

** the first time this routine is called. The seed value does

** not need to contain a lot of randomness since we are not

** trying to do secure encryption or anything like that...

**

** [..]

*/

if( !wsdPrng.isInit ){

[..]

sqlite3OsRandomness(sqlite3_vfs_find(0), 256, k);

[..]

wsdPrng.isInit = 1;

}

实际上,SQLite的单元测试功能本身就是在全局sqlite3Prng结构体上使用memcpy()来保存或恢复测试运行期间PRNG的状态.

所以,除非你愿意做一些奇怪的事情(像创建一个连续数字的临时表(1..max(动物)),洗牌,并使用它们从“动物”表中选择“随机播种”的RowIds)假设你没有运气.

转载地址:https://blog.csdn.net/weixin_33303537/article/details/116281742 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:liunx oracle 12505,Linux环境下Oracle的ORA-12505问题解决方案
下一篇:aide 可以用php.么,Linux加密安全—AIDE工具

发表评论

最新留言

表示我来过!
[***.240.166.169]2024年04月27日 16时25分50秒