From: Jan Dvorak Date: February 22 2000 11:40am Subject: SELECT doesn't let an alias to a LOCKed table List-Archive: http://lists.mysql.com/bugs/14 Message-Id: <200002221140.MAA29891@medved.mathan.cz> >Description: A table that has been LOCKed is not allowed to be aliased in a SELECT. One gets ERROR 1100: Table '...' was not locked with LOCK TABLES where the ... is the alias, not the name of the table. This makes it difficult for MySQL users to wrap SQL code in LOCK TABLES ... UNLOCK TABLES, because some SELECT:s may break. >How-To-Repeat: drop table if exists A; select "Create a simple table A and put some stuff in it:" as message; create table A ( id integer unsigned not null primary key ); insert into A values (1), (2); select "Here it is:" as message; select * from A; select "Under a lock, I can still select from the table if I don't alias it:" as mesage; lock tables A write; select * from A; unlock tables; select "Under a lock, I cannot access it aliased in a select:" as message; lock tables A write; select * from A a1, A a2 where a2.id = a1.id; unlock tables; >Fix: The locks should be checked agains the real table, not the alias. Revise sql/sql_select.cc ? >Submitter-Id: jan.dvorak@stripped >Originator: jan.dvorak@stripped >Organization: MathAn Praha, Ltd.; CZ. >MySQL support: none >Synopsis: SELECT doesn't let an alias to a LOCKed table >Severity: non-critical >Priority: medium >Category: mysql >Class: sw-bug >Release: mysql-3.23.11-alpha (Source distribution) >Server: /usr/bin/mysqladmin Ver 8.0 Distrib 3.23.11-alpha, for pc-linux-gnu on i686 TCX Datakonsult AB, by Monty Server version 3.23.11-alpha-log Protocol version 10 Connection Localhost via UNIX socket UNIX socket /var/lib/mysql/mysql.sock Uptime: 3 days 20 hours 52 min 46 sec Threads: 1 Questions: 8991 Slow queries: 0 Opens: 0 Flush tables: 2 Open tables: 0 >Environment: System: Linux medved.mathan.cz 2.2.13 #2 SMP Thu Dec 16 09:47:45 CET 1999 i686 unknown Architecture: i686 Some paths: /usr/bin/perl /usr/bin/make /usr/bin/gmake /usr/bin/gcc /usr/bin/cc GCC: Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/specs gcc version egcs-2.91.66 19990314/Linux (egcs-1.1.2 release) Compilation info: CC='gcc' CFLAGS='' CXX='c++' CXXFLAGS='' LDFLAGS='' LIBC: lrwxrwxrwx 1 root root 13 Jun 9 1999 /lib/libc.so.6 -> libc-2.1.1.so -rwxr-xr-x 1 root root 4016683 Apr 17 1999 /lib/libc-2.1.1.so -rw-r--r-- 1 root root 19533408 Apr 17 1999 /usr/lib/libc.a -rw-r--r-- 1 root root 178 Apr 17 1999 /usr/lib/libc.so Configure command: ./configure --disable-shared --with-mysqld-ldflags=-all-static --with-client-ldflags=-all-static --enable-assembler --with-mysqld-user=mysql --with-unix-socket-path=/var/lib/mysql/mysql.sock --prefix=/ --exec-prefix=/usr --libexecdir=/usr/sbin --sysconfdir=/etc --datadir=/usr/share --localstatedir=/var/lib/mysql --infodir=/usr/info --includedir=/usr/include --mandir=/usr/man --with-charset=czech --without-docs Perl: This is perl, version 5.005_03 built for i386-linux