I get the following strange behavior with a user variable.  @T has the value
0 to start; after adding 1 to @T a few times, it ends up with a clearly
incorrect value.  I'd expect it to have a value of 280 after the second
select.

--------------
SELECT @T
--------------

+------+
| @T   |
+------+
| 0    |
+------+
1 row in set (0.00 sec)

--------------
UPDATE contown_svr SET contown_id=(@T:[EMAIL PROTECTED])
--------------

Query OK, 280 rows affected (0.05 sec)
Rows matched: 280  Changed: 280  Warnings: 280

--------------
SELECT @T
--------------

+----------------------+
| @T                   |
+----------------------+
| 1.8669204411349e+021 |
+----------------------+
1 row in set (0.00 sec)

---

More data:

I'm using Windows 2000 with MySQL 4.0.14b, and connected through localhost.
It appears to work correctly on MySQL 4.0.13 and MySQL 3.23.57.
I also tried it on Linux with MySQL 4.0.13, and it worked correctly.
It continues to fail with the 3.23.57 client and the 4.0.14b server.

I get various values for @T, sometimes with a negative exponent.
Sometimes it gives the correct value once, then twice the correct value on
the second try, etc., despite @T being reset to zero.
Sometimes, when I select the values in contown_svr, contown_id (which is an
int) prints as something like 561.000000001.

This happens when I have the mysql client read a file.  When I cut and paste
the content of the file to console, it appears to give the correct result.

Any help would be appreciated.  It sure sounds to me like a bug in thread
synchronization within the server.

Here's the smallest program I've gotten to fail.  It still fails (gives
wrong value to @T) even if the select returns 0 rows, but it doesn't fail if
I remove the insert...select.  I'll try to cut it down some more and post an
example that's not missing the data--but it may take a while to get to it.

-----

select @t:=0;

drop table if exists contown_svr;
create table contown_svr select * from contown where 0;

insert  into contown_svr
select -999,pw.owner,pc.contact_id,0
from fundown pw
   inner join fundcont pc using (funding_id)
   left join contown cw on cw.contact_id = pc.contact_id
   left join grouptree on pw.owner=subject and cw.owner=target
where subject is null
   and pc.contact_id <> 0;

select @t;

update contown_svr set contown_id=(@t:=(@t+1));

select @t;

exit



-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to