Bug #9486 | can't perform multi-update in stored procedure | ||
---|---|---|---|
Submitted: | 30 Mar 2005 13:58 | Modified: | 14 Jun 2005 7:18 |
Reporter: | Dmitry L | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server | Severity: | S3 (Non-critical) |
Version: | 5.0.3 | OS: | Windows (Win2k) |
Assigned to: | Dmitry Lenev | CPU Architecture: | Any |
[30 Mar 2005 13:58]
Dmitry L
[9 Apr 2005 12:05]
Dmitry Lenev
Please also note that second invocation of updateTitles() will block current connection...
[14 Apr 2005 4:51]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/internals/24000
[15 Apr 2005 16:30]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/internals/24057
[22 Apr 2005 8:32]
Dmitry Lenev
Fixed in 5.0.5
[26 Apr 2005 3:10]
Paul DuBois
Noted in 5.0.5 changelog.
[14 Jun 2005 0:12]
Peter Brawley
This bug persists in 5.0.6, as the following script shows: CREATE TABLE airports ( code char(3) NOT NULL, city char(100) default NULL, latitude float NOT NULL, longitude float NOT NULL, PRIMARY KEY (code) ) ENGINE=MyISAM; INSERT INTO airports VALUES ('JFK', 'New York, NY', 40.75, -73.97); INSERT INTO airports VALUES ('LAX', 'Los Angeles, CA', 34.05, -118.22); INSERT INTO airports VALUES ('LHR', 'London, England', 51.5, -0.45); INSERT INTO airports VALUES ('HEL', 'Helsinki, Finland', 60.17, 24.97); INSERT INTO airports VALUES ('CDG', 'Paris, France', 48.86, 2.33); INSERT INTO airports VALUES ('STL', 'St Louis, MO', 38.63, -90.2); INSERT INTO airports VALUES ('ARN', 'Stockholm, Sweden', 59.33, 18.05); -- Workaround for another bug SET GLOBAL log_bin_trust_routine_creators=TRUE; DROP FUNCTION IF EXISTS GeoDistKM; DELIMITER | CREATE FUNCTION GeoDistKM( lat1 FLOAT, lon1 FLOAT, lat2 FLOAT, lon2 FLOAT ) RETURNS float BEGIN DECLARE pi, q1, q2, q3 FLOAT; DECLARE rads FLOAT DEFAULT 0; SET pi = PI(); SET lat1 = lat1 * pi / 180; SET lon1 = lon1 * pi / 180; SET lat2 = lat2 * pi / 180; SET lon2 = lon2 * pi / 180; SET q1 = COS(lon1-lon2); SET q2 = COS(lat1-lat2); SET q3 = COS(lat1+lat2); SET rads = ACOS( 0.5*((1.0+q1)*q2 - (1.0-q1)*q3) ); RETURN 6378.388 * rads; END; | DELIMITER ; CREATE TABLE flights ( id INT PRIMARY KEY AUTO_INCREMENT, depart CHAR(3), arrive CHAR(3), distance DECIMAL(10,2), direction DECIMAL(10,2) ) ENGINE=MYISAM; INSERT INTO flights SELECT NULL, depart.code, arrive.code, ROUND(GeoDistKM(depart.latitude,depart.longitude,arrive.latitude,arrive.longitude),2) AS Km, ROUND(DEGREES(ATAN(arrive.latitude-depart.latitude,arrive.longitude-depart.longitude)),2) FROM airports AS depart INNER JOIN airports AS arrive ON depart.code <> arrive.code HAVING Km <= 6000; CREATE TABLE routes ( id INT PRIMARY KEY AUTO_INCREMENT, depart CHAR(3), arrive CHAR(3), hops SMALLINT, route CHAR(50), distance DECIMAL(10,2), direction DECIMAL(10,2) ) ENGINE=MYISAM; CREATE OR REPLACE VIEW nexthops AS SELECT routes.depart, flights.arrive, routes.hops+1 AS hops, CONCAT(routes.route, ',', flights.arrive) AS route, MIN(routes.distance + flights.distance) AS distance, routes.direction FROM routes INNER JOIN flights ON routes.arrive = flights.depart AND LOCATE(flights.arrive,routes.route) = 0 WHERE flights.direction+360>routes.direction+270 AND flights.direction+360<routes.direction+450 GROUP BY depart,arrive; SET GLOBAL log_bin_trust_routine_creators=TRUE; DROP PROCEDURE IF EXISTS BuildRoutes; DELIMITER | CREATE PROCEDURE BuildRoutes() BEGIN DECLARE rows INT DEFAULT 0; TRUNCATE routes; -- STEP 1, LISTING 5: SEED ROUTES WITH 1-HOP FLIGHTS INSERT INTO routes SELECT NULL, depart, arrive, 1, CONCAT(depart,',',arrive), distance, direction FROM flights; SET rows = ROW_COUNT(); WHILE (rows > 0) DO -- STEP 2, LISTING 8: ADD NEXT SET OF ROUTES INSERT INTO routes SELECT NULL, nexthops.depart, nexthops.arrive, nexthops.hops, nexthops.route, nexthops.distance, nexthops.direction FROM nexthops LEFT JOIN routes ON nexthops.depart = routes.depart AND nexthops.arrive = routes.arrive WHERE routes.depart IS NULL AND routes.arrive IS NULL; SET rows = ROW_COUNT(); END WHILE; END; | DELIMITER ; ERROR 1099 (HY000): Table 'routes' was locked with a READ lock and can't be updated
[14 Jun 2005 7:18]
Dmitry Lenev
Hi, Peter! Original problem mentioned in this bug report was impossibility to perform multi-update in stored procedure due to problem with table locking (I have updated synopsis to clarify this). After investigating your issue I think that your problem has nothing to do with original one so it should be reported and handled separately. And as I've noticed you already have done that! :) Thank you!