Bug #8623 Alter a MERGE table to union a readonly table fails
Submitted: 19 Feb 2005 6:05 Modified: 2 Nov 2008 22:52
Reporter: Dave Pullin (Basic Quality Contributor) Email Updates:
Status: Won't fix Impact on me:
None 
Category:MySQL Server: Merge storage engine Severity:S2 (Serious)
Version:4.1.9 OS:Any
Assigned to: CPU Architecture:Any
Tags: qc

[19 Feb 2005 6:05] Dave Pullin
Description:
Using ALTER TABLE to change the UNION of a MERGE table to include a table that is in a database that is READONLY fails with errcode 13. It appears that the server thinks the temporary MRG file is on the readonly database.

mysql> alter table testM engine=merge union=(readonly.test1);
ERROR 1016 (HY000): Can't open file: '#sql-360_7d0.MRG' (errno: 13)

How to repeat:
do this when you have WRITE access to the database called READONLY:

drop table if exists readonly.test1;
create table readonly.test1 (x int);
flush tables /* and now make read only folder actually Read Only */;

do this when you have READONLY access to the database called READONLY,

drop table if exists testM;
create table if not exists testM (x int);

/* the following should work but fails */
alter table testM engine=merge union=(readonly.test1);

/* the following does the same thing but works */
drop table testM;
create table testM (x int) engine=merge union=(readonly.test1);

If you change the readonly database to readwrite, the ALTER works.
[19 Feb 2005 6:34] Jorge del Conde
Hi

Can you tell me what you mean by read-only ?  ... a readonly database / table can be performed by modifying the group permissions of the physical tables/database file, by using myisampack, grant select_priv for database roles, locking the tables thus they're only readonly etc...

Thanks.
[19 Feb 2005 13:01] Dave Pullin
Q. What does READONLY mean?

A. On my production server, the problem occurs when the readonly database is on a windows file server folder that is shared allowing "READ" only. (A SYM file is used to reference the database folder).

On the development system where I isolated the problem, I set the Windows "Read only" folder property (propagated to contained files) on a folder called readonly in my datadir.
[9 Oct 2006 22:23] RIchard Murphy
I am also using 4.1 and am experiencing a similar problem.  I cnnot get a packed file to work with the Merge Engine.  I consistently get 

ERROR 1016 (HY000): Can't open file: 'rvm_t1.MRG' (errno: 13)

whenever I attempt to query the table rvm_t1, which was created using a packed file.