Only 128 inserts with NULL value for INTEGER PRIMARY KEY

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Only 128 inserts with NULL value for INTEGER PRIMARY KEY

Tom Deblauwe-2
Hello,

I have the problem that I can only insert 128 values into my databases
if I use NULL als value for the INTEGER PRIMARY KEY field.  If I supply
myself an unique number, then there is no problem to add more than 128
records!  I am running 2.8.16, on an embedded platform, with 32 bit
pointers, and no native 64bit integers.  What would be the problem?  I'd
appreciate any help, thanks!

regards,
Tom,


Reply | Threaded
Open this post in threaded view
|

Re: Only 128 inserts with NULL value for INTEGER PRIMARY KEY

D. Richard Hipp
On Mon, 2005-06-06 at 13:02 +0200, Tom Deblauwe wrote:
> Hello,
>
> I have the problem that I can only insert 128 values into my databases

What happens when you try to insert the 129th value?

I just tried inserting 100000 rows using 2.8.16 and a NULL
integer primary key and everything worked great.
--
D. Richard Hipp <[hidden email]>

Reply | Threaded
Open this post in threaded view
|

Re: Only 128 inserts with NULL value for INTEGER PRIMARY KEY

Tom Deblauwe-2
D. Richard Hipp wrote:
>
> What happens when you try to insert the 129th value?
>
> I just tried inserting 100000 rows using 2.8.16 and a NULL
> integer primary key and everything worked great.

I get the error message that the integer primary key must be unique.
It seems that when the new number is generated, it first sets the cursor
to the last element, and then does keyToInt, and then reads the value.
This goes fine until element 128 is written.  After it is written, it
goes to the last element, but I get this value: 2130706560(01111111
00000000 00000000 10000000) again! So after keyToInt this becomes 127,
it adds one, and then it uses 128 again as integer primary key, and then
it concludes that the primary key must be unique.

regards,
Tom,




Reply | Threaded
Open this post in threaded view
|

Re: Only 128 inserts with NULL value for INTEGER PRIMARY KEY

Tom Deblauwe-2
Tom Deblauwe wrote:
> D. Richard Hipp wrote:
>
>>
>> What happens when you try to insert the 129th value?
>>

I tried now the following:

add entries with NULL => ok until 128
when I first add index 100, and then add values with NULL as index, it
stops inserts until 128, then I get the message again about primary key
must be unique.  If I do a MAX(iID) then I get the value 127, but when I
do a select * then I get this:

128 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |


When I start at index 129 and then add with NULL, it goes ok, until 384.

Maybe it has something to do with padding or something?

Regards,
Tom,


Reply | Threaded
Open this post in threaded view
|

Re: Only 128 inserts with NULL value for INTEGER PRIMARY KEY

Tom Deblauwe-2
Tom Deblauwe wrote:

> Tom Deblauwe wrote:
>
>> D. Richard Hipp wrote:
>>
>>>
>>> What happens when you try to insert the 129th value?
>>>
>
> I tried now the following:
>
I get the same results in the windows commandline tool: MAX(iID) gives
met 127 and COUNT(iID) gives me 29... Hereby is the database attached!
sqlite_analyzer doesn't say it is broken or something.

kind regards,
Tom,