I CAN HAS PADAWAN!

Tuesday, June 12th, 2007 01:34 am
robinturner: Raybans + Matrix coat (rayban)
[personal profile] robinturner
First lolcats, then philolsophers and now lolcode ... this is 2 viral 4 wurdz.

Aaaargh! Snap out of it, Solri!

Anyway, I now have a Padawan apprentice. OK, I'm not teaching her to use the Force; I'm teaching her to fiddle with the student re-registration program I wrote, but I call her "my young Padawan" and she calls me "Master", and that's good enough for me. In the process, I too am learning. For example, I've learned that the unfixable bug which I thought was a weird PHP bug is actually a weird MySQL bug. This leaves it just as unfixable but much more interesting: the database will sometimes (though not always) change the student's university ID to 2147483647 and then refuse to change it to any other number whatever I do. I think I'm about to have one of those numerical epiphanies that crop up from time to time in films and TV series (Lost being a recent example). I have also learned that I really need to write some code to move records from one table to another. And it took someone who ten minutes earlier was asking about the difference between a client and server to point that out, so maybe I should start calling her "Master".

Update: Aha, I have just found that 2147483647 is (2^31)-1, which is the largest integer that will fit in that field. The plot thickens ...
Upperdate: Solved! I CAN HAS BIGINT! (see comments)

Date: 2007-06-12 12:33 am (UTC)
From: [identity profile] evan.livejournal.com
It's also -1 in two's complement (http://en.wikipedia.org/wiki/Two's_complement) which is what all modern computers use.

Same problem

Date: 2007-06-12 05:30 am (UTC)
From: [identity profile] scarythedave.livejournal.com
I've got the same problem in one of my mySQL tables. I'll let you know if I find a reason/solution.

Date: 2007-06-12 08:00 am (UTC)
From: [identity profile] solri.livejournal.com
Aha. So something is either saying I CAN HAS BIGEZT STDNT NMB3R! (dammit, I'm doing it again!) or deciding it wants a student number of -1. Weird.

Re: Same problem

Date: 2007-06-12 08:00 am (UTC)
From: [identity profile] solri.livejournal.com
Please do. I will of course post my solution if I find one.

Date: 2007-06-12 08:29 am (UTC)
From: [identity profile] b0rg.livejournal.com
hmm...
perhaps reading the manual would help :)

Some data access frameworks assign int ID field to -1 untill insert transaction finishes, but if you wrote everything youself this is not the case.

How does the ID setup and what's the sql you're using to insert the record?

Re: Same problem

Date: 2007-06-12 08:34 am (UTC)
From: [identity profile] solri.livejournal.com
Turned out to be simple in my case - I just needed to change the data type from INT to BIGINT. Some students have an ID number with an extra digit, which was pushing the value up further than was allowed.

Date: 2007-06-12 08:48 am (UTC)
From: [identity profile] solri.livejournal.com
I just solved it - turns out that some students have an ID with an extra digit, which means the datatype needs to be BIGINT rather than INT. Mind-numbingly obvious, really - it was just that for ages I'd been thinking in terms of a PHP error, not a MySQL error.

Re: Same problem

Date: 2007-06-12 10:51 am (UTC)
From: [identity profile] scarythedave.livejournal.com
Yeah, I found this (http://forums.mysql.com/read.php?10,53986,54089#msg-54089), which points out that of course my 14 digit timestamp being stored as INT would be out of range and force that result. Glad you got it resolved ^^

Date: 2007-06-12 01:59 pm (UTC)
From: [identity profile] vret.livejournal.com
About 20 years ago I did a few days contract work at a small insurance company's Head Office. There was a big panic while I was there when the end of month procedure fell over and no-one there could work out why. Eventually, in desperation, they asked me and I asked whether it was possible that sales for the year up to the end of the previous month had exceeded £21 1/2 million for the first time. I'd noticed that the trends for the previous months implied it would.

Date: 2007-06-12 05:23 pm (UTC)