MySQL Forums
Forum List  »  Stored Procedures

sp: select from INFORMATION_SCHEMA => read lock
Posted by: jholec
Date: December 05, 2005 03:33AM

Why the read lock? Isn't this a bug?

Script started on Mon Dec 5 11:16:44 2005
$ cat test.sql
SELECT version();
DESCRIBE tmp;

DELIMITER //
CREATE PROCEDURE addcolumn_ifnx ()
BEGIN
IF NOT EXISTS(
SELECT 1 FROM INFORMATION_SCHEMA.COLUMNS
WHERE (TABLE_NAME = 'tmp')
AND (TABLE_SCHEMA = 'dbname')
AND (COLUMN_NAME = 'b'))
THEN
ALTER TABLE tmp ADD COLUMN b int not null;
END IF;
END//
DELIMITER ;
CALL addcolumn_ifnx();
DROP PROCEDURE addcolumn_ifnx;


$ mysql -uusername -ppassword -hhostname dbname <test.sql
version()
5.0.10a-beta-nt
Field Type Null Key Default Extra
a int(11) YES NULL
c int(11) YES NULL
ERROR 1099 (HY000) at line 17: Table 'tmp' was locked with a READ lock and can't be updated
$
Script done on Mon Dec 5 11:17:10 2005

Options: ReplyQuote


Subject
Views
Written By
Posted
sp: select from INFORMATION_SCHEMA => read lock
2318
December 05, 2005 03:33AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.