问题描述:

I was verifying how length(x) works on BLOBs with SQLite, and I was surprised to find that the length of randomblob(0) is 1, even more so as the the length of zeroblob(0) is 0 as shown below. Shouldn't randomblob(0) and zeroblob(0) both have 0 length? If not, why?

SQLite version 3.7.11 2012-03-20 11:35:50

Enter ".help" for instructions

Enter SQL statements terminated with a ";"

sqlite> select length(zeroblob(0));

sqlite> select length(zeroblob(1));

1

sqlite> select length(zeroblob(2));

2

sqlite> select length(randomblob(0));

1

sqlite> select length(randomblob(1));

1

sqlite> select length(randomblob(2));

2

网友答案:

The sqlite documentation says:

The randomblob(N) function return an N-byte blob containing pseudo-random bytes. If N is less than 1 then a 1-byte random blob is returned.

I should have read your whole question before bashing the answer in. Anyhow, here it still is.

相关阅读:
Top