View previous topic :: View next topic |
Author |
Message |
_LuCkY_
Joined: 16 Apr 2005 Posts: 1
|
Posted: Sat Apr 16, 2005 15:44 Post subject: Persistent variables 'bug' in aps_include |
|
|
Hi,
Today I noticed that there is a slight 'bug' in aps_include. The reason I placed bug in quotes is that it's hard to call it a real bug, perhaps it's better to call it an oversight.
The SetPersistent functions store the variables in the table pwdata. This table contains a timestamp in the column last. With every update the timestamp gets updated as well. However if you update the variable to the value it already had the timestamp does not update. If your scripts rely on the fact that it does get updated it will occasionally fail.
As an example:
On 11:00 you call SetPersistentInt(OBJECT_SELF, "foo", 1);
On 12:00 you call SetPersistentInt(OBJECT_SELF, "foo", 1);
You'd expect the timestamp to be 12:00, but it is 11:00. I suspect this is due to an optimization from MySQL which checks if the record actually changes before writing it.
Regardless, it can be easily solved by making a small addition to the UPDATE statements in aps_include:
Code: | UPDATE [...omitted...] ,last=NOW() WHERE [...omitted...] |
The last=NOW() part forces the timestamp to be updated even if there is no actual change in one of the columns. This change will not affect performance, nor will it affect existing scripts (unless they rely on the described behaviour).
I was asked to post this here to inform you of this, but also to check if this will be taken along in future updates. In case it wont we'll have to make sure that this change will not be overwritten in the future when the aps_include script gets an update. |
|
Back to top |
|
|
JeroenB
Joined: 31 Dec 2004 Posts: 228 Location: Netherlands
|
Posted: Sun Apr 17, 2005 8:30 Post subject: |
|
|
Thanks, we will update this in the next release. |
|
Back to top |
|
|
teleri
Joined: 28 Jan 2005 Posts: 21
|
Posted: Sun Apr 17, 2005 9:52 Post subject: |
|
|
This is the block of code you are talking about in aps_include.nss.
From this--> line 358
Code: |
355 {
356 // row exists
357 sSQL = "UPDATE " + sTable + " SET val='" + sValue +
358 "',expire=" + IntToString(iExpiration) + " WHERE player='" + sPlayer +
359 "' AND tag='" + sTag + "' AND name='" + sVarName + "'";
360 SQLExecDirect(sSQL);
361 }
|
to this --> line 358
Code: |
355 {
356 // row exists
357 sSQL = "UPDATE " + sTable + " SET val='" + sValue +
358 "',expire=" + IntToString(iExpiration) + " last=NOW() WHERE player='" + sPlayer +
359 "' AND tag='" + sTag + "' AND name='" + sVarName + "'";
360 SQLExecDirect(sSQL);
361 }
|
Cheers,
teleri |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|