First, "LOCK TABLES locks tables for the current thread." and "All tables 
that are locked by the current thread are automatically unlocked when the 
thread issues another LOCK TABLES, or WHEN THE CONNECTION TO THE SERVER IS 
CLOSED." (caps added by me)

Are you locking the table in the first CGI script, and then expecting the 
second script to view the results of that lock? If so, then I think that is 
your problem. You are correct about the locking behavior: "If a thread 
obtains a WRITE lock on a table, then only the thread holding the lock can 
READ from or WRITE to the table. Other threads are blocked."

At 11:36 AM 4/13/01 -0500, Jerome Giudicelli wrote:
>Well, maybe I am confused!
>I am running this code from a CGI script. After locking the table (with a
>write lock) I tried to view the locked table, using another CGI script. From
>what I understand a write lock prevents anybody from viewing the locked
>tables, on top of not being able to update those tables. But I could still
>view the locked table.
>Whereas if I locked the table from the command line, the CGI script would
>process  indefinitely and would not return anything until I had cleared the
>lock (through the command line).
>Is that clear?
>Is it a problem of using the same thread? I am not really clear on that.
>Thanks for your help.
>Jérôme
>
>
>
> > From: Drew Taylor <[EMAIL PROTECTED]>
> > Date: Fri, 13 Apr 2001 11:17:07 -0400
> > To: Jerome Giudicelli <[EMAIL PROTECTED]>,
> > [EMAIL PROTECTED]
> > Subject: Re: [Boston.pm] MySQL and Perl DBI
> >
> > The lock table syntax is correct. What is it you're trying to do, and why
> > do you think it's not working?
> >
> > Quoting from the manual:
> > "Then you use LOCK TABLES, you must lock all tables that you are going to
> > use and you must use tyhe same alias that you are going to use in your
> > queries. If you are using a table multiple times in a query (with aliases)
> > you must get a lock for each alias!"
> >
> > At 10:36 AM 4/13/01 -0400, Jerome Giudicelli wrote:
> >
> >> [forwarded submission from a non-member address -- rjk]
> >>
> >>
> >> From: Jerome Giudicelli <[EMAIL PROTECTED]>
> >> Date: Fri, 13 Apr 2001 10:08:26 -0500
> >> Subject: MySQL and Perl DBI
> >> To: <[EMAIL PROTECTED]>
> >>
> >> Hi, I have a MySQL question:
> >> I can't seem to  get the "lock tables" command to work other than from the
> >> command line.
> >> Here's the code I have been using through a CGI script:
> >> $q = $dbh->do("lock tables eval write");
> >> but that doesn't do anything!
> >> I have been searching a lot of sites to no avail.
> >> I am running MySQL version 3.22.21.
> >> Does anybody have any idea on what the correct syntax is or why this 
> doesn't
> >> work?
> >> Thank you.
> >>
> >> Jérôme
> >
> > Drew Taylor
> > mailto:[EMAIL PROTECTED]
> > http://www.drewtaylor.com/
> >
> >

Drew Taylor
mailto:[EMAIL PROTECTED]
http://www.drewtaylor.com/

Reply via email to