Unix Technical Forum

Unwanted Updates Auto Follow a Select !

This is a discussion on Unwanted Updates Auto Follow a Select ! within the MySQL forums, part of the Database Server Software category; --> I update a field after a very banal query (call it the WANTED update). After that, this crazy thing ...


Go Back   Unix Technical Forum > Database Server Software > MySQL

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-28-2008, 09:10 AM
FPUSAVIT33
 
Posts: n/a
Default Unwanted Updates Auto Follow a Select !

I update a field after a very banal query (call it the WANTED update).

After that, this crazy thing happens: if I load a page of statistics
(=selects) to see the newly updated values after the mentioned update query
has run, it results updates by 3 numbers rather than increased just by 1.
I am absolutely, positively sure the WANTED update increased only by 1: I
printed the result all in the page, No weird addition ensued. But uponm
issuing a select, the value gets updated... again, even 3 times
occasionally.

If I reload again the statistics (that is, I deliver one more select), it
doesn't happen.

Morale, an update, followed by a select, updates (this is not wanted!) the
selected fields of more than 2 or 3 digits. If another select follows on the
same table, no unwanted updates occurs.

Anyone ever met such bad issue before?

DETAILS IF NEEDED FOLLOW:
------------------------------

"SELECT RXamount FROM RXtable WHERE RXcat LIKE 'urban' AND
RXid={$_GET['city']} LIMIT 1"

If that statement returns no result, Insert

"INSERT INTO RXtable VALUES ('urban', {$_GET['city']}, 1)"

otherwise Update:


"UPDATE RXtable SET RXamount=RXamount+1 WHERE RXcat LIKE 'urban' AND
RXid={$_GET['city']} LIMIT 1"

These two statements are correct, I tested them printing the outcome in may
page section, always reporting the right value of either 1 or added 1

Then I go to the page that shwos the statistics:

"SELECT RXid, RXamount FROM RXtable WHERE RXcat LIKE 'urban' ORDER BY
RXamount DESC LIMIT 50" //get city filter not needed here: i want 50
results, not to pinpoint a specific one to update

The first time this last select runs, it shows a value increased by 2 more
digits instead then 1 in the RXamount of the specific RXid record previously
updated (or inserted). If I load the page again, it shows no such behaviour.
If I wait say 5 minutes and I repeat the process, the behaviour repats
itself.
No tables are locked, so the 5 min thing can't be due to locks.

queried table structure quick overview:
ENUM NOT NULL
MEDIUMINT NOT NULL
BIGINT NOT NULL

These queries work as EXPECTED on localhost mysql 5.0.24 but on server Mysql
5.1.11 exhibit the mentioned problem.


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-28-2008, 09:10 AM
FPUSAVIT33
 
Posts: n/a
Default Re: Unwanted Updates Auto Follow a Select !

I am getting insane after this.

I now performed an update, i printed the result before and after:
before= 2
after= 3
Correct.

I now go on... MySql Administrator and check the stored value, namely
WITHOUT using the website script, I perform a SELECT via MySql
administrator: stored value revealed:
4

Now, I did not alter the data, because I read it via MySql Admin, I just
issued a select. The select has updated again...


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 11:00 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com