php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #33849 LOCK TABLES with mysql_query() works wrong
Submitted: 2005-07-25 03:48 UTC Modified: 2005-07-25 15:48 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:0 of 1 (0.0%)
From: test157 at starman dot ee Assigned:
Status: Not a bug Package: MySQL related
PHP Version: 4.4.0 OS: Linux Fedora Core 4
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: test157 at starman dot ee
New email:
PHP Version: OS:

 

 [2005-07-25 03:48 UTC] test157 at starman dot ee
Description:
------------
When I'am locking MySQL ISAM table from PHP env, all other threads still can use this table for READ/WRITE actions. But I didn't get from mysql_error() any message, and even cannot access other tables, untill they not locked too. So it's seems like PHP really thinks that MySQL locked. I think that this is problem of PHP because from MySQL console I can lock tables succesfuly, and after this lock even PHP cannot access this table.

Reproduce code:
---------------
mysql_pconnect("localhost","root","");
mysql_select_db("test_db");


mysql_query("LOCK TABLES `test_table_1` WRITE");
mysql_query("INSERT INTO `test_table_1` (`a`) VALUES (1)"); // returns OK
mysql_query("INSERT INTO `test_table_2` (`a`) VALUES (1)"); // Table was not locked with LOCK TABLES 
sleep(100);
mysql_query("UNLOCK TABLES");


Expected result:
----------------
with this code I want to show you that all works fine, from side of thread what lock MySQL table. But really nothing is locked, during this 100 seconds I can edit/read test_table_1, without any problems from other threads. If I will even remove UNLOCK TABLES command and will use presistent connection, I will not hang up system. Because nothing is locked.

   

Actual result:
--------------
I tried it on PHP v 4.4.0/5.0.3/snapshots, CLI mode/Apache 2.0.54 compiled as worker/prefork, mysql v 4.1.12,13,14. And everywhere the same picture.  I tried to compile PHP in different ways, from --disable-all + some only important keys, to full configs. Also tried to use budle MySQL libraries and what install on system. But all the same.

Hope on your fast bug_fix.

P.S: Also on this system I cannot flock(file) it all the same like with MySQL, no any error returned, but file no locked for other threads. (FS:ext2)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-07-25 15:48 UTC] wez@php.net
Consult mysql support channels for further assistance.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Mon Jul 21 17:00:03 2025 UTC