diff options
author | Alexander Barkov <bar@mnogosearch.org> | 2013-05-21 18:29:10 +0400 |
---|---|---|
committer | Alexander Barkov <bar@mnogosearch.org> | 2013-05-21 18:29:10 +0400 |
commit | 41bda068a5affa1f8b483784df532c5a3ee8dcfd (patch) | |
tree | 9077b6ee41e7b8ded0d674fa2800305572bcef9a | |
parent | ca024d1c21649dec1caab2d4027b56f3fa01407e (diff) | |
download | mariadb-git-41bda068a5affa1f8b483784df532c5a3ee8dcfd.tar.gz |
"mtr --suite=connect --embedded" tests did not work for two reasons:
1. The Connect engine code assumed that mysql_home_directory is always "./",
which is not the fact in case of embedded server.
Fixing the routines creating file names to add the mysql_home_directory prefix.
2. FILE privilege is not checked in embedded server.
Moving FILE related tests into separate files.
Skipping the FILE related tests when running with --embedded.
added:
storage/connect/mysql-test/connect/r/grant.result
storage/connect/mysql-test/connect/r/ini_grant.result
storage/connect/mysql-test/connect/r/mysql_grant.result
storage/connect/mysql-test/connect/r/xml_grant.result
storage/connect/mysql-test/connect/t/grant.test
storage/connect/mysql-test/connect/t/ini_grant.test
storage/connect/mysql-test/connect/t/mysql_grant.test
storage/connect/mysql-test/connect/t/xml_grant.test
modified:
storage/connect/global.h
storage/connect/ha_connect.cc
storage/connect/mycat.cc
storage/connect/mysql-test/connect/r/bin.result
storage/connect/mysql-test/connect/r/csv.result
storage/connect/mysql-test/connect/r/dbf.result
storage/connect/mysql-test/connect/r/dir.result
storage/connect/mysql-test/connect/r/fix.result
storage/connect/mysql-test/connect/r/ini.result
storage/connect/mysql-test/connect/r/mysql.result
storage/connect/mysql-test/connect/r/vec.result
storage/connect/mysql-test/connect/r/xml.result
storage/connect/mysql-test/connect/t/bin.test
storage/connect/mysql-test/connect/t/csv.test
storage/connect/mysql-test/connect/t/dbf.test
storage/connect/mysql-test/connect/t/dir.test
storage/connect/mysql-test/connect/t/fix.test
storage/connect/mysql-test/connect/t/ini.test
storage/connect/mysql-test/connect/t/mysql.test
storage/connect/mysql-test/connect/t/vec.test
storage/connect/mysql-test/connect/t/xml.test
storage/connect/plgdbsem.h
storage/connect/plugutil.c
31 files changed, 1175 insertions, 1025 deletions
diff --git a/storage/connect/global.h b/storage/connect/global.h index ae50e5ac160..303078f5a18 100644 --- a/storage/connect/global.h +++ b/storage/connect/global.h @@ -239,7 +239,8 @@ DllExport short GetLineLength(PGLOBAL); // Console line length DllExport PGLOBAL PlugInit(LPCSTR, uint); // Plug global initialization DllExport int PlugExit(PGLOBAL); // Plug global termination DllExport LPSTR PlugRemoveType(LPSTR, LPCSTR); -DllExport LPCSTR PlugSetPath(LPSTR, LPCSTR, LPCSTR); +DllExport LPCSTR PlugSetPath(LPSTR to, LPCSTR prefix, LPCSTR name, LPCSTR dir); +DllExport BOOL PlugIsAbsolutePath(LPCSTR path); DllExport void *PlugAllocMem(PGLOBAL, uint); DllExport BOOL PlugSubSet(PGLOBAL, void *, uint); DllExport void *PlugSubAlloc(PGLOBAL, void *, size_t); diff --git a/storage/connect/ha_connect.cc b/storage/connect/ha_connect.cc index 7baffbb0684..3db86b8e607 100644 --- a/storage/connect/ha_connect.cc +++ b/storage/connect/ha_connect.cc @@ -289,6 +289,13 @@ static void init_connect_psi_keys() {} #endif +DllExport LPCSTR PlugSetPath(LPSTR to, LPCSTR name, LPCSTR dir) +{ + const char *res= PlugSetPath(to, mysql_data_home, name, dir); + return res; +} + + /** @brief If frm_error() is called then we will use this to determine @@ -3098,6 +3105,63 @@ THR_LOCK_DATA **ha_connect::store_lock(THD *thd, /** + Searches for a pointer to the last occurrence of the + character c in the string src. + Returns true on failure, false on success. +*/ +static bool +strnrchr(LEX_CSTRING *ls, const char *src, size_t length, int c) +{ + const char *srcend, *s; + for (s= srcend= src + length; s > src; s--) + { + if (s[-1] == c) + { + ls->str= s; + ls->length= srcend - s; + return false; + } + } + return true; +} + + +/** + Split filename into database and table name. +*/ +static bool +filename_to_dbname_and_tablename(const char *filename, + char *database, size_t database_size, + char *table, size_t table_size) +{ +#if defined(WIN32) + char slash= '\\'; +#else // !WIN32 + char slash= '/'; +#endif // !WIN32 + LEX_CSTRING d, t; + size_t length= strlen(filename); + + /* Find filename - the rightmost directory part */ + if (strnrchr(&t, filename, length, slash) || t.length + 1 > table_size) + return true; + memcpy(table, t.str, t.length); + table[t.length]= '\0'; + if (!(length-= t.length)) + return true; + + length--; /* Skip slash */ + + /* Find database name - the second rightmost directory part */ + if (strnrchr(&d, filename, length, slash) || d.length + 1 > database_size) + return true; + memcpy(database, d.str, d.length); + database[d.length]= '\0'; + return false; +} + + +/** @brief Used to delete or rename a table. By the time delete_table() has been called all opened references to this table will have been closed @@ -3123,22 +3187,20 @@ int ha_connect::delete_or_rename_table(const char *name, const char *to) DBUG_ENTER("ha_connect::delete_or_rename_table"); /* We have to retrieve the information about this table options. */ ha_table_option_struct *pos; -#if defined(WIN32) - const char *fmt= ".\\%[^\\]\\%s"; -#else // !WIN32 - const char *fmt= "./%[^/]/%s"; -#endif // !WIN32 char key[MAX_DBKEY_LENGTH], db[128], tabname[128]; int rc; uint key_length; TABLE_SHARE *share; THD *thd= current_thd; - if (to) - if (sscanf(to, fmt, db, tabname) != 2 || *tabname == '#') - goto fin; + if (to && (filename_to_dbname_and_tablename(to, db, sizeof(db), + tabname, sizeof(tabname)) || + *tabname == '#')) + goto fin; - if (sscanf(name, fmt, db, tabname) != 2 || *tabname == '#') + if (filename_to_dbname_and_tablename(name, db, sizeof(db), + tabname, sizeof(tabname)) || + *tabname == '#') goto fin; key_length= create_table_def_key(key, db, tabname); diff --git a/storage/connect/mycat.cc b/storage/connect/mycat.cc index 35a66f0d1a2..b5767b02180 100644 --- a/storage/connect/mycat.cc +++ b/storage/connect/mycat.cc @@ -293,6 +293,13 @@ void MYCAT::SetPath(PGLOBAL g, LPCSTR *datapath, const char *path) if (path) { size_t len= strlen(path) + (*path != '.' ? 4 : 1); char *buf= (char*)PlugSubAlloc(g, NULL, len); + + if (PlugIsAbsolutePath(path)) + { + strcpy(buf, path); + *datapath= buf; + return; + } if (*path != '.') { #if defined(WIN32) diff --git a/storage/connect/mysql-test/connect/r/bin.result b/storage/connect/mysql-test/connect/r/bin.result index d476aef6293..c64b270b538 100644 --- a/storage/connect/mysql-test/connect/r/bin.result +++ b/storage/connect/mysql-test/connect/r/bin.result @@ -1,98 +1,4 @@ # -# Beginning of grant.inc -# -GRANT ALL PRIVILEGES ON *.* TO user@localhost; -REVOKE FILE ON *.* FROM user@localhost; -SELECT user(); -user() -user@localhost -CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=BIN; -Warnings: -Warning 1105 No file name. Table will use t1.bin -INSERT INTO t1 VALUES (10); -SELECT * FROM t1; -a -10 -UPDATE t1 SET a=20; -SELECT * FROM t1; -a -20 -DELETE FROM t1; -SELECT * FROM t1; -a -INSERT INTO t1 VALUES(10); -TRUNCATE TABLE t1; -SELECT * FROM t1; -a -CREATE VIEW v1 AS SELECT * FROM t1; -SELECT * FROM v1; -a -DROP VIEW v1; -DROP TABLE t1; -CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=BIN FILE_NAME='t1.EXT'; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -SELECT user(); -user() -root@localhost -CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=BIN FILE_NAME='t1.EXT'; -INSERT INTO t1 VALUES (10); -SELECT user(); -user() -user@localhost -INSERT INTO t1 VALUES (10); -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -SELECT * FROM t1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -UPDATE t1 SET a=20; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -DELETE FROM t1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -TRUNCATE TABLE t1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -ALTER TABLE t1 READONLY=1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -ALTER TABLE t1 FILE_NAME='t2.EXT'; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -DROP TABLE t1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -CREATE VIEW v1 AS SELECT * FROM t1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -# Testing a VIEW created with FILE privileges but accessed with no FILE -SELECT user(); -user() -root@localhost -CREATE VIEW v1 AS SELECT * FROM t1; -SELECT user(); -user() -user@localhost -SELECT * FROM v1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -INSERT INTO v1 VALUES (2); -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -UPDATE v1 SET a=123; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -DELETE FROM v1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -SELECT user(); -user() -root@localhost -DROP VIEW v1; -DROP TABLE t1; -CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=BIN; -Warnings: -Warning 1105 No file name. Table will use t1.bin -INSERT INTO t1 VALUES (10); -SELECT user(); -user() -user@localhost -ALTER TABLE t1 FILE_NAME='t1.EXT'; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -DROP TABLE t1; -DROP USER user@localhost; -# -# End of grant.inc -# -# # Testing errors # CREATE TABLE t1 diff --git a/storage/connect/mysql-test/connect/r/csv.result b/storage/connect/mysql-test/connect/r/csv.result index 34734e164c0..b2498326edb 100644 --- a/storage/connect/mysql-test/connect/r/csv.result +++ b/storage/connect/mysql-test/connect/r/csv.result @@ -1,97 +1,3 @@ -# -# Beginning of grant.inc -# -GRANT ALL PRIVILEGES ON *.* TO user@localhost; -REVOKE FILE ON *.* FROM user@localhost; -SELECT user(); -user() -user@localhost -CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=CSV; -Warnings: -Warning 1105 No file name. Table will use t1.csv -INSERT INTO t1 VALUES (10); -SELECT * FROM t1; -a -10 -UPDATE t1 SET a=20; -SELECT * FROM t1; -a -20 -DELETE FROM t1; -SELECT * FROM t1; -a -INSERT INTO t1 VALUES(10); -TRUNCATE TABLE t1; -SELECT * FROM t1; -a -CREATE VIEW v1 AS SELECT * FROM t1; -SELECT * FROM v1; -a -DROP VIEW v1; -DROP TABLE t1; -CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=CSV FILE_NAME='t1.EXT'; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -SELECT user(); -user() -root@localhost -CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=CSV FILE_NAME='t1.EXT'; -INSERT INTO t1 VALUES (10); -SELECT user(); -user() -user@localhost -INSERT INTO t1 VALUES (10); -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -SELECT * FROM t1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -UPDATE t1 SET a=20; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -DELETE FROM t1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -TRUNCATE TABLE t1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -ALTER TABLE t1 READONLY=1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -ALTER TABLE t1 FILE_NAME='t2.EXT'; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -DROP TABLE t1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -CREATE VIEW v1 AS SELECT * FROM t1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -# Testing a VIEW created with FILE privileges but accessed with no FILE -SELECT user(); -user() -root@localhost -CREATE VIEW v1 AS SELECT * FROM t1; -SELECT user(); -user() -user@localhost -SELECT * FROM v1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -INSERT INTO v1 VALUES (2); -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -UPDATE v1 SET a=123; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -DELETE FROM v1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -SELECT user(); -user() -root@localhost -DROP VIEW v1; -DROP TABLE t1; -CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=CSV; -Warnings: -Warning 1105 No file name. Table will use t1.csv -INSERT INTO t1 VALUES (10); -SELECT user(); -user() -user@localhost -ALTER TABLE t1 FILE_NAME='t1.EXT'; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -DROP TABLE t1; -DROP USER user@localhost; -# -# End of grant.inc -# SET NAMES utf8; # # Testing errors diff --git a/storage/connect/mysql-test/connect/r/dbf.result b/storage/connect/mysql-test/connect/r/dbf.result index 27abbb84dc6..2e84c5b3090 100644 --- a/storage/connect/mysql-test/connect/r/dbf.result +++ b/storage/connect/mysql-test/connect/r/dbf.result @@ -1,98 +1,4 @@ # -# Beginning of grant.inc -# -GRANT ALL PRIVILEGES ON *.* TO user@localhost; -REVOKE FILE ON *.* FROM user@localhost; -SELECT user(); -user() -user@localhost -CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=DBF; -Warnings: -Warning 1105 No file name. Table will use t1.dbf -INSERT INTO t1 VALUES (10); -SELECT * FROM t1; -a -10 -UPDATE t1 SET a=20; -SELECT * FROM t1; -a -20 -DELETE FROM t1; -SELECT * FROM t1; -a -INSERT INTO t1 VALUES(10); -TRUNCATE TABLE t1; -SELECT * FROM t1; -a -CREATE VIEW v1 AS SELECT * FROM t1; -SELECT * FROM v1; -a -DROP VIEW v1; -DROP TABLE t1; -CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.EXT'; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -SELECT user(); -user() -root@localhost -CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.EXT'; -INSERT INTO t1 VALUES (10); -SELECT user(); -user() -user@localhost -INSERT INTO t1 VALUES (10); -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -SELECT * FROM t1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -UPDATE t1 SET a=20; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -DELETE FROM t1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -TRUNCATE TABLE t1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -ALTER TABLE t1 READONLY=1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -ALTER TABLE t1 FILE_NAME='t2.EXT'; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -DROP TABLE t1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -CREATE VIEW v1 AS SELECT * FROM t1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -# Testing a VIEW created with FILE privileges but accessed with no FILE -SELECT user(); -user() -root@localhost -CREATE VIEW v1 AS SELECT * FROM t1; -SELECT user(); -user() -user@localhost -SELECT * FROM v1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -INSERT INTO v1 VALUES (2); -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -UPDATE v1 SET a=123; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -DELETE FROM v1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -SELECT user(); -user() -root@localhost -DROP VIEW v1; -DROP TABLE t1; -CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=DBF; -Warnings: -Warning 1105 No file name. Table will use t1.dbf -INSERT INTO t1 VALUES (10); -SELECT user(); -user() -user@localhost -ALTER TABLE t1 FILE_NAME='t1.EXT'; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -DROP TABLE t1; -DROP USER user@localhost; -# -# End of grant.inc -# -# # Testing errors # CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf'; diff --git a/storage/connect/mysql-test/connect/r/dir.result b/storage/connect/mysql-test/connect/r/dir.result index 7beae815580..f4feb5fa960 100644 --- a/storage/connect/mysql-test/connect/r/dir.result +++ b/storage/connect/mysql-test/connect/r/dir.result @@ -1,72 +1,3 @@ -# -# Testing FILE privilege -# -GRANT ALL PRIVILEGES ON *.* TO user@localhost; -REVOKE FILE ON *.* FROM user@localhost; -SELECT user(); -user() -user@localhost -CREATE TABLE t1 ( -path VARCHAR(256) NOT NULL flag=1, -fname VARCHAR(256) NOT NULL, -ftype CHAR(4) NOT NULL, -size DOUBLE(12,0) NOT NULL flag=5 -) ENGINE=CONNECT TABLE_TYPE=DIR FILE_NAME='*.*'; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -SELECT user(); -user() -root@localhost -CREATE TABLE t1 ( -path VARCHAR(256) NOT NULL flag=1, -fname VARCHAR(256) NOT NULL, -ftype CHAR(4) NOT NULL, -size DOUBLE(12,0) NOT NULL flag=5 -) ENGINE=CONNECT TABLE_TYPE=DIR FILE_NAME='*.*'; -SELECT fname, ftype, size FROM t1 WHERE size>0; -fname ftype size -t1 .frm 1081 -SELECT user(); -user() -user@localhost -SELECT * FROM t1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -INSERT INTO t1 VALUES (); -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -DELETE FROM t1 WHERE path='xxx'; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -UPDATE t1 SET path='yyy' WHERE path='xxx'; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -TRUNCATE TABLE t1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -ALTER TABLE t1 READONLY=1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -CREATE VIEW v1 AS SELECT * FROM t1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -# Testing a VIEW created with FILE privileges but accessed with no FILE -SELECT user(); -user() -root@localhost -CREATE VIEW v1 AS SELECT * FROM t1; -SELECT user(); -user() -user@localhost -SELECT * FROM v1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -INSERT INTO v1 VALUES (1,1,1,1); -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -UPDATE v1 SET path=123; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -DELETE FROM v1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -SELECT user(); -user() -root@localhost -DROP VIEW v1; -DROP TABLE t1; -DROP USER user@localhost; -# -# Testing FILE privileges done -# CREATE TABLE t1 ( path VARCHAR(256) NOT NULL flag=1, fname VARCHAR(256) NOT NULL, diff --git a/storage/connect/mysql-test/connect/r/fix.result b/storage/connect/mysql-test/connect/r/fix.result index e9eb31d9bc8..c8f51abe961 100644 --- a/storage/connect/mysql-test/connect/r/fix.result +++ b/storage/connect/mysql-test/connect/r/fix.result @@ -1,98 +1,4 @@ # -# Beginning of grant.inc -# -GRANT ALL PRIVILEGES ON *.* TO user@localhost; -REVOKE FILE ON *.* FROM user@localhost; -SELECT user(); -user() -user@localhost -CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=FIX; -Warnings: -Warning 1105 No file name. Table will use t1.fix -INSERT INTO t1 VALUES (10); -SELECT * FROM t1; -a -10 -UPDATE t1 SET a=20; -SELECT * FROM t1; -a -20 -DELETE FROM t1; -SELECT * FROM t1; -a -INSERT INTO t1 VALUES(10); -TRUNCATE TABLE t1; -SELECT * FROM t1; -a -CREATE VIEW v1 AS SELECT * FROM t1; -SELECT * FROM v1; -a -DROP VIEW v1; -DROP TABLE t1; -CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=FIX FILE_NAME='t1.EXT'; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -SELECT user(); -user() -root@localhost -CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=FIX FILE_NAME='t1.EXT'; -INSERT INTO t1 VALUES (10); -SELECT user(); -user() -user@localhost -INSERT INTO t1 VALUES (10); -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -SELECT * FROM t1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -UPDATE t1 SET a=20; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -DELETE FROM t1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -TRUNCATE TABLE t1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -ALTER TABLE t1 READONLY=1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -ALTER TABLE t1 FILE_NAME='t2.EXT'; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -DROP TABLE t1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -CREATE VIEW v1 AS SELECT * FROM t1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -# Testing a VIEW created with FILE privileges but accessed with no FILE -SELECT user(); -user() -root@localhost -CREATE VIEW v1 AS SELECT * FROM t1; -SELECT user(); -user() -user@localhost -SELECT * FROM v1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -INSERT INTO v1 VALUES (2); -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -UPDATE v1 SET a=123; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -DELETE FROM v1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -SELECT user(); -user() -root@localhost -DROP VIEW v1; -DROP TABLE t1; -CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=FIX; -Warnings: -Warning 1105 No file name. Table will use t1.fix -INSERT INTO t1 VALUES (10); -SELECT user(); -user() -user@localhost -ALTER TABLE t1 FILE_NAME='t1.EXT'; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -DROP TABLE t1; -DROP USER user@localhost; -# -# End of grant.inc -# -# # Testing errors # CREATE TABLE t1 diff --git a/storage/connect/mysql-test/connect/r/grant.result b/storage/connect/mysql-test/connect/r/grant.result new file mode 100644 index 00000000000..ba5728703a5 --- /dev/null +++ b/storage/connect/mysql-test/connect/r/grant.result @@ -0,0 +1,539 @@ +# +# Testing FILE privilege +# +GRANT ALL PRIVILEGES ON *.* TO user@localhost; +REVOKE FILE ON *.* FROM user@localhost; +SELECT user(); +user() +user@localhost +CREATE TABLE t1 ( +path VARCHAR(256) NOT NULL flag=1, +fname VARCHAR(256) NOT NULL, +ftype CHAR(4) NOT NULL, +size DOUBLE(12,0) NOT NULL flag=5 +) ENGINE=CONNECT TABLE_TYPE=DIR FILE_NAME='*.*'; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +SELECT user(); +user() +root@localhost +CREATE TABLE t1 ( +path VARCHAR(256) NOT NULL flag=1, +fname VARCHAR(256) NOT NULL, +ftype CHAR(4) NOT NULL, +size DOUBLE(12,0) NOT NULL flag=5 +) ENGINE=CONNECT TABLE_TYPE=DIR FILE_NAME='*.*'; +SELECT fname, ftype, size FROM t1 WHERE size>0; +fname ftype size +t1 .frm 1081 +SELECT user(); +user() +user@localhost +SELECT * FROM t1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +INSERT INTO t1 VALUES (); +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +DELETE FROM t1 WHERE path='xxx'; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +UPDATE t1 SET path='yyy' WHERE path='xxx'; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +TRUNCATE TABLE t1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +ALTER TABLE t1 READONLY=1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +CREATE VIEW v1 AS SELECT * FROM t1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +# Testing a VIEW created with FILE privileges but accessed with no FILE +SELECT user(); +user() +root@localhost +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT user(); +user() +user@localhost +SELECT * FROM v1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +INSERT INTO v1 VALUES (1,1,1,1); +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +UPDATE v1 SET path=123; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +DELETE FROM v1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +SELECT user(); +user() +root@localhost +DROP VIEW v1; +DROP TABLE t1; +DROP USER user@localhost; +# +# Testing FILE privileges done +# +# +# Beginning of grant.inc +# +GRANT ALL PRIVILEGES ON *.* TO user@localhost; +REVOKE FILE ON *.* FROM user@localhost; +SELECT user(); +user() +user@localhost +CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=BIN; +Warnings: +Warning 1105 No file name. Table will use t1.bin +INSERT INTO t1 VALUES (10); +SELECT * FROM t1; +a +10 +UPDATE t1 SET a=20; +SELECT * FROM t1; +a +20 +DELETE FROM t1; +SELECT * FROM t1; +a +INSERT INTO t1 VALUES(10); +TRUNCATE TABLE t1; +SELECT * FROM t1; +a +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT * FROM v1; +a +DROP VIEW v1; +DROP TABLE t1; +CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=BIN FILE_NAME='t1.EXT'; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +SELECT user(); +user() +root@localhost +CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=BIN FILE_NAME='t1.EXT'; +INSERT INTO t1 VALUES (10); +SELECT user(); +user() +user@localhost +INSERT INTO t1 VALUES (10); +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +SELECT * FROM t1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +UPDATE t1 SET a=20; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +DELETE FROM t1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +TRUNCATE TABLE t1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +ALTER TABLE t1 READONLY=1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +ALTER TABLE t1 FILE_NAME='t2.EXT'; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +DROP TABLE t1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +CREATE VIEW v1 AS SELECT * FROM t1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +# Testing a VIEW created with FILE privileges but accessed with no FILE +SELECT user(); +user() +root@localhost +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT user(); +user() +user@localhost +SELECT * FROM v1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +INSERT INTO v1 VALUES (2); +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +UPDATE v1 SET a=123; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +DELETE FROM v1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +SELECT user(); +user() +root@localhost +DROP VIEW v1; +DROP TABLE t1; +CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=BIN; +Warnings: +Warning 1105 No file name. Table will use t1.bin +INSERT INTO t1 VALUES (10); +SELECT user(); +user() +user@localhost +ALTER TABLE t1 FILE_NAME='t1.EXT'; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +DROP TABLE t1; +DROP USER user@localhost; +# +# End of grant.inc +# +# +# Beginning of grant.inc +# +GRANT ALL PRIVILEGES ON *.* TO user@localhost; +REVOKE FILE ON *.* FROM user@localhost; +SELECT user(); +user() +user@localhost +CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=CSV; +Warnings: +Warning 1105 No file name. Table will use t1.csv +INSERT INTO t1 VALUES (10); +SELECT * FROM t1; +a +10 +UPDATE t1 SET a=20; +SELECT * FROM t1; +a +20 +DELETE FROM t1; +SELECT * FROM t1; +a +INSERT INTO t1 VALUES(10); +TRUNCATE TABLE t1; +SELECT * FROM t1; +a +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT * FROM v1; +a +DROP VIEW v1; +DROP TABLE t1; +CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=CSV FILE_NAME='t1.EXT'; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +SELECT user(); +user() +root@localhost +CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=CSV FILE_NAME='t1.EXT'; +INSERT INTO t1 VALUES (10); +SELECT user(); +user() +user@localhost +INSERT INTO t1 VALUES (10); +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +SELECT * FROM t1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +UPDATE t1 SET a=20; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +DELETE FROM t1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +TRUNCATE TABLE t1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +ALTER TABLE t1 READONLY=1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +ALTER TABLE t1 FILE_NAME='t2.EXT'; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +DROP TABLE t1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +CREATE VIEW v1 AS SELECT * FROM t1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +# Testing a VIEW created with FILE privileges but accessed with no FILE +SELECT user(); +user() +root@localhost +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT user(); +user() +user@localhost +SELECT * FROM v1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +INSERT INTO v1 VALUES (2); +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +UPDATE v1 SET a=123; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +DELETE FROM v1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +SELECT user(); +user() +root@localhost +DROP VIEW v1; +DROP TABLE t1; +CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=CSV; +Warnings: +Warning 1105 No file name. Table will use t1.csv +INSERT INTO t1 VALUES (10); +SELECT user(); +user() +user@localhost +ALTER TABLE t1 FILE_NAME='t1.EXT'; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +DROP TABLE t1; +DROP USER user@localhost; +# +# End of grant.inc +# +# +# Beginning of grant.inc +# +GRANT ALL PRIVILEGES ON *.* TO user@localhost; +REVOKE FILE ON *.* FROM user@localhost; +SELECT user(); +user() +user@localhost +CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=DBF; +Warnings: +Warning 1105 No file name. Table will use t1.dbf +INSERT INTO t1 VALUES (10); +SELECT * FROM t1; +a +10 +UPDATE t1 SET a=20; +SELECT * FROM t1; +a +20 +DELETE FROM t1; +SELECT * FROM t1; +a +INSERT INTO t1 VALUES(10); +TRUNCATE TABLE t1; +SELECT * FROM t1; +a +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT * FROM v1; +a +DROP VIEW v1; +DROP TABLE t1; +CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.EXT'; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +SELECT user(); +user() +root@localhost +CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.EXT'; +INSERT INTO t1 VALUES (10); +SELECT user(); +user() +user@localhost +INSERT INTO t1 VALUES (10); +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +SELECT * FROM t1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +UPDATE t1 SET a=20; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +DELETE FROM t1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +TRUNCATE TABLE t1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +ALTER TABLE t1 READONLY=1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +ALTER TABLE t1 FILE_NAME='t2.EXT'; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +DROP TABLE t1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +CREATE VIEW v1 AS SELECT * FROM t1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +# Testing a VIEW created with FILE privileges but accessed with no FILE +SELECT user(); +user() +root@localhost +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT user(); +user() +user@localhost +SELECT * FROM v1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +INSERT INTO v1 VALUES (2); +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +UPDATE v1 SET a=123; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +DELETE FROM v1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +SELECT user(); +user() +root@localhost +DROP VIEW v1; +DROP TABLE t1; +CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=DBF; +Warnings: +Warning 1105 No file name. Table will use t1.dbf +INSERT INTO t1 VALUES (10); +SELECT user(); +user() +user@localhost +ALTER TABLE t1 FILE_NAME='t1.EXT'; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +DROP TABLE t1; +DROP USER user@localhost; +# +# End of grant.inc +# +# +# Beginning of grant.inc +# +GRANT ALL PRIVILEGES ON *.* TO user@localhost; +REVOKE FILE ON *.* FROM user@localhost; +SELECT user(); +user() +user@localhost +CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=FIX; +Warnings: +Warning 1105 No file name. Table will use t1.fix +INSERT INTO t1 VALUES (10); +SELECT * FROM t1; +a +10 +UPDATE t1 SET a=20; +SELECT * FROM t1; +a +20 +DELETE FROM t1; +SELECT * FROM t1; +a +INSERT INTO t1 VALUES(10); +TRUNCATE TABLE t1; +SELECT * FROM t1; +a +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT * FROM v1; +a +DROP VIEW v1; +DROP TABLE t1; +CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=FIX FILE_NAME='t1.EXT'; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +SELECT user(); +user() +root@localhost +CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=FIX FILE_NAME='t1.EXT'; +INSERT INTO t1 VALUES (10); +SELECT user(); +user() +user@localhost +INSERT INTO t1 VALUES (10); +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +SELECT * FROM t1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +UPDATE t1 SET a=20; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +DELETE FROM t1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +TRUNCATE TABLE t1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +ALTER TABLE t1 READONLY=1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +ALTER TABLE t1 FILE_NAME='t2.EXT'; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +DROP TABLE t1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +CREATE VIEW v1 AS SELECT * FROM t1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +# Testing a VIEW created with FILE privileges but accessed with no FILE +SELECT user(); +user() +root@localhost +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT user(); +user() +user@localhost +SELECT * FROM v1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +INSERT INTO v1 VALUES (2); +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +UPDATE v1 SET a=123; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +DELETE FROM v1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +SELECT user(); +user() +root@localhost +DROP VIEW v1; +DROP TABLE t1; +CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=FIX; +Warnings: +Warning 1105 No file name. Table will use t1.fix +INSERT INTO t1 VALUES (10); +SELECT user(); +user() +user@localhost +ALTER TABLE t1 FILE_NAME='t1.EXT'; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +DROP TABLE t1; +DROP USER user@localhost; +# +# End of grant.inc +# +# +# Beginning of grant.inc +# +GRANT ALL PRIVILEGES ON *.* TO user@localhost; +REVOKE FILE ON *.* FROM user@localhost; +SELECT user(); +user() +user@localhost +CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=VEC MAX_ROWS=100; +Warnings: +Warning 1105 No file name. Table will use t1.vec +INSERT INTO t1 VALUES (10); +SELECT * FROM t1; +a +10 +UPDATE t1 SET a=20; +SELECT * FROM t1; +a +20 +DELETE FROM t1; +SELECT * FROM t1; +a +INSERT INTO t1 VALUES(10); +TRUNCATE TABLE t1; +SELECT * FROM t1; +a +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT * FROM v1; +a +DROP VIEW v1; +DROP TABLE t1; +CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=VEC MAX_ROWS=100 FILE_NAME='t1.EXT'; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +SELECT user(); +user() +root@localhost +CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=VEC MAX_ROWS=100 FILE_NAME='t1.EXT'; +INSERT INTO t1 VALUES (10); +SELECT user(); +user() +user@localhost +INSERT INTO t1 VALUES (10); +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +SELECT * FROM t1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +UPDATE t1 SET a=20; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +DELETE FROM t1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +TRUNCATE TABLE t1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +ALTER TABLE t1 READONLY=1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +ALTER TABLE t1 FILE_NAME='t2.EXT'; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +DROP TABLE t1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +CREATE VIEW v1 AS SELECT * FROM t1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +# Testing a VIEW created with FILE privileges but accessed with no FILE +SELECT user(); +user() +root@localhost +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT user(); +user() +user@localhost +SELECT * FROM v1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +INSERT INTO v1 VALUES (2); +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +UPDATE v1 SET a=123; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +DELETE FROM v1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +SELECT user(); +user() +root@localhost +DROP VIEW v1; +DROP TABLE t1; +CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=VEC MAX_ROWS=100; +Warnings: +Warning 1105 No file name. Table will use t1.vec +INSERT INTO t1 VALUES (10); +SELECT user(); +user() +user@localhost +ALTER TABLE t1 FILE_NAME='t1.EXT'; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +DROP TABLE t1; +DROP USER user@localhost; +# +# End of grant.inc +# diff --git a/storage/connect/mysql-test/connect/r/ini.result b/storage/connect/mysql-test/connect/r/ini.result index da846d466ba..83ba98fbd84 100644 --- a/storage/connect/mysql-test/connect/r/ini.result +++ b/storage/connect/mysql-test/connect/r/ini.result @@ -1,83 +1,4 @@ # -# Checking FILE privileges -# -GRANT ALL PRIVILEGES ON *.* TO user@localhost; -REVOKE FILE ON *.* FROM user@localhost; -SELECT user(); -user() -user@localhost -CREATE TABLE t1 (sec CHAR(10) NOT NULL FLAG=1, val CHAR(10) NOT NULL) ENGINE=CONNECT TABLE_TYPE=INI; -Warnings: -Warning 1105 No file name. Table will use t1.ini -INSERT INTO t1 VALUES ('sec1','val1'); -SELECT * FROM t1; -sec val -sec1 val1 -UPDATE t1 SET val='val11'; -SELECT * FROM t1; -sec val -sec1 val11 -DELETE FROM t1; -SELECT * FROM t1; -sec val -INSERT INTO t1 VALUES('sec2','val2'); -TRUNCATE TABLE t1; -SELECT * FROM t1; -sec val -CREATE VIEW v1 AS SELECT * FROM t1; -SELECT * FROM v1; -sec val -DROP VIEW v1; -DROP TABLE t1; -CREATE TABLE t1 (sec CHAR(10) NOT NULL FLAG=1, val CHAR(10) NOT NULL) ENGINE=CONNECT TABLE_TYPE=INI FILE_NAME='t1.EXT'; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -SELECT user(); -user() -root@localhost -CREATE TABLE t1 (sec CHAR(10) NOT NULL FLAG=1, val CHAR(10) NOT NULL) ENGINE=CONNECT TABLE_TYPE=INI FILE_NAME='t1.EXT'; -INSERT INTO t1 VALUES ('sec1','val1'); -SELECT user(); -user() -user@localhost -INSERT INTO t1 VALUES ('sec2','val2'); -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -SELECT * FROM t1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -UPDATE t1 SET val='val11'; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -DELETE FROM t1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -TRUNCATE TABLE t1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -ALTER TABLE t1 READONLY=1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -DROP TABLE t1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -CREATE VIEW v1 AS SELECT * FROM t1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -# Testing a VIEW created with FILE privileges but accessed with no FILE -SELECT user(); -user() -root@localhost -CREATE VIEW v1 AS SELECT * FROM t1; -SELECT user(); -user() -user@localhost -SELECT * FROM v1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -INSERT INTO v1 VALUES ('sec3','val3'); -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -UPDATE v1 SET val='val11'; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -DELETE FROM v1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -DROP VIEW v1; -DROP TABLE t1; -DROP USER user@localhost; -# -# Checking FILE privileges: done -# -# # Testing errors # CREATE TABLE t1 diff --git a/storage/connect/mysql-test/connect/r/ini_grant.result b/storage/connect/mysql-test/connect/r/ini_grant.result new file mode 100644 index 00000000000..c3acf7c8dfc --- /dev/null +++ b/storage/connect/mysql-test/connect/r/ini_grant.result @@ -0,0 +1,79 @@ +# +# Checking FILE privileges +# +GRANT ALL PRIVILEGES ON *.* TO user@localhost; +REVOKE FILE ON *.* FROM user@localhost; +SELECT user(); +user() +user@localhost +CREATE TABLE t1 (sec CHAR(10) NOT NULL FLAG=1, val CHAR(10) NOT NULL) ENGINE=CONNECT TABLE_TYPE=INI; +Warnings: +Warning 1105 No file name. Table will use t1.ini +INSERT INTO t1 VALUES ('sec1','val1'); +SELECT * FROM t1; +sec val +sec1 val1 +UPDATE t1 SET val='val11'; +SELECT * FROM t1; +sec val +sec1 val11 +DELETE FROM t1; +SELECT * FROM t1; +sec val +INSERT INTO t1 VALUES('sec2','val2'); +TRUNCATE TABLE t1; +SELECT * FROM t1; +sec val +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT * FROM v1; +sec val +DROP VIEW v1; +DROP TABLE t1; +CREATE TABLE t1 (sec CHAR(10) NOT NULL FLAG=1, val CHAR(10) NOT NULL) ENGINE=CONNECT TABLE_TYPE=INI FILE_NAME='t1.EXT'; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +SELECT user(); +user() +root@localhost +CREATE TABLE t1 (sec CHAR(10) NOT NULL FLAG=1, val CHAR(10) NOT NULL) ENGINE=CONNECT TABLE_TYPE=INI FILE_NAME='t1.EXT'; +INSERT INTO t1 VALUES ('sec1','val1'); +SELECT user(); +user() +user@localhost +INSERT INTO t1 VALUES ('sec2','val2'); +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +SELECT * FROM t1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +UPDATE t1 SET val='val11'; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +DELETE FROM t1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +TRUNCATE TABLE t1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +ALTER TABLE t1 READONLY=1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +DROP TABLE t1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +CREATE VIEW v1 AS SELECT * FROM t1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +# Testing a VIEW created with FILE privileges but accessed with no FILE +SELECT user(); +user() +root@localhost +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT user(); +user() +user@localhost +SELECT * FROM v1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +INSERT INTO v1 VALUES ('sec3','val3'); +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +UPDATE v1 SET val='val11'; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +DELETE FROM v1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +DROP VIEW v1; +DROP TABLE t1; +DROP USER user@localhost; +# +# Checking FILE privileges: done +# diff --git a/storage/connect/mysql-test/connect/r/mysql.result b/storage/connect/mysql-test/connect/r/mysql.result index a538c57c5ce..8d5507e121a 100644 --- a/storage/connect/mysql-test/connect/r/mysql.result +++ b/storage/connect/mysql-test/connect/r/mysql.result @@ -1,66 +1,3 @@ -# -# Testing FILE privilege -# -GRANT ALL PRIVILEGES ON *.* TO user@localhost; -REVOKE FILE ON *.* FROM user@localhost; -SELECT user(); -user() -user@localhost -CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=MySQL OPTION_LIST='host=localhost,user=root1,port=PORT'; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -SELECT user(); -user() -root@localhost -CREATE TABLE t1remote (a INT NOT NULL); -INSERT INTO t1remote VALUES (10),(20),(30); -CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=MySQL TABNAME=t1remote OPTION_LIST='host=localhost,user=root,port=PORT'; -SELECT * FROM t1; -a -10 -20 -30 -SELECT user(); -user() -user@localhost -SELECT * FROM t1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -INSERT INTO t1 VALUES ('xxx'); -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -DELETE FROM t1 WHERE a='xxx'; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -UPDATE t1 SET a='yyy' WHERE a='xxx'; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -TRUNCATE TABLE t1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -ALTER TABLE t1 READONLY=1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -CREATE VIEW v1 AS SELECT * FROM t1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -# Testing a VIEW created with FILE privileges but accessed with no FILE -SELECT user(); -user() -root@localhost -CREATE VIEW v1 AS SELECT * FROM t1; -SELECT user(); -user() -user@localhost -SELECT * FROM v1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -INSERT INTO v1 VALUES (2); -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -UPDATE v1 SET a=123; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -DELETE FROM v1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -SELECT user(); -user() -root@localhost -DROP VIEW v1; -DROP TABLE t1, t1remote; -DROP USER user@localhost; -# -# Testing FILE privileges done -# CREATE TABLE t1 (a int, b char(10)); INSERT INTO t1 VALUES (NULL,NULL),(0,'test00'),(1,'test01'),(2,'test02'),(3,'test03'); SELECT * FROM t1; diff --git a/storage/connect/mysql-test/connect/r/mysql_grant.result b/storage/connect/mysql-test/connect/r/mysql_grant.result new file mode 100644 index 00000000000..f8d0ee6ad6f --- /dev/null +++ b/storage/connect/mysql-test/connect/r/mysql_grant.result @@ -0,0 +1,63 @@ +# +# Testing FILE privilege +# +GRANT ALL PRIVILEGES ON *.* TO user@localhost; +REVOKE FILE ON *.* FROM user@localhost; +SELECT user(); +user() +user@localhost +CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=MySQL OPTION_LIST='host=localhost,user=root1,port=PORT'; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +SELECT user(); +user() +root@localhost +CREATE TABLE t1remote (a INT NOT NULL); +INSERT INTO t1remote VALUES (10),(20),(30); +CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=MySQL TABNAME=t1remote OPTION_LIST='host=localhost,user=root,port=PORT'; +SELECT * FROM t1; +a +10 +20 +30 +SELECT user(); +user() +user@localhost +SELECT * FROM t1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +INSERT INTO t1 VALUES ('xxx'); +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +DELETE FROM t1 WHERE a='xxx'; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +UPDATE t1 SET a='yyy' WHERE a='xxx'; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +TRUNCATE TABLE t1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +ALTER TABLE t1 READONLY=1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +CREATE VIEW v1 AS SELECT * FROM t1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +# Testing a VIEW created with FILE privileges but accessed with no FILE +SELECT user(); +user() +root@localhost +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT user(); +user() +user@localhost +SELECT * FROM v1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +INSERT INTO v1 VALUES (2); +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +UPDATE v1 SET a=123; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +DELETE FROM v1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +SELECT user(); +user() +root@localhost +DROP VIEW v1; +DROP TABLE t1, t1remote; +DROP USER user@localhost; +# +# Testing FILE privileges done +# diff --git a/storage/connect/mysql-test/connect/r/vec.result b/storage/connect/mysql-test/connect/r/vec.result index 9461966aef7..65513dc07db 100644 --- a/storage/connect/mysql-test/connect/r/vec.result +++ b/storage/connect/mysql-test/connect/r/vec.result @@ -1,97 +1,3 @@ -# -# Beginning of grant.inc -# -GRANT ALL PRIVILEGES ON *.* TO user@localhost; -REVOKE FILE ON *.* FROM user@localhost; -SELECT user(); -user() -user@localhost -CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=VEC MAX_ROWS=100; -Warnings: -Warning 1105 No file name. Table will use t1.vec -INSERT INTO t1 VALUES (10); -SELECT * FROM t1; -a -10 -UPDATE t1 SET a=20; -SELECT * FROM t1; -a -20 -DELETE FROM t1; -SELECT * FROM t1; -a -INSERT INTO t1 VALUES(10); -TRUNCATE TABLE t1; -SELECT * FROM t1; -a -CREATE VIEW v1 AS SELECT * FROM t1; -SELECT * FROM v1; -a -DROP VIEW v1; -DROP TABLE t1; -CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=VEC MAX_ROWS=100 FILE_NAME='t1.EXT'; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -SELECT user(); -user() -root@localhost -CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=VEC MAX_ROWS=100 FILE_NAME='t1.EXT'; -INSERT INTO t1 VALUES (10); -SELECT user(); -user() -user@localhost -INSERT INTO t1 VALUES (10); -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -SELECT * FROM t1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -UPDATE t1 SET a=20; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -DELETE FROM t1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -TRUNCATE TABLE t1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -ALTER TABLE t1 READONLY=1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -ALTER TABLE t1 FILE_NAME='t2.EXT'; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -DROP TABLE t1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -CREATE VIEW v1 AS SELECT * FROM t1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -# Testing a VIEW created with FILE privileges but accessed with no FILE -SELECT user(); -user() -root@localhost -CREATE VIEW v1 AS SELECT * FROM t1; -SELECT user(); -user() -user@localhost -SELECT * FROM v1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -INSERT INTO v1 VALUES (2); -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -UPDATE v1 SET a=123; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -DELETE FROM v1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -SELECT user(); -user() -root@localhost -DROP VIEW v1; -DROP TABLE t1; -CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=VEC MAX_ROWS=100; -Warnings: -Warning 1105 No file name. Table will use t1.vec -INSERT INTO t1 VALUES (10); -SELECT user(); -user() -user@localhost -ALTER TABLE t1 FILE_NAME='t1.EXT'; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -DROP TABLE t1; -DROP USER user@localhost; -# -# End of grant.inc -# CREATE TABLE dir1 ( spath VARCHAR(256) NOT NULL flag=1, fname VARCHAR(256) NOT NULL, diff --git a/storage/connect/mysql-test/connect/r/xml.result b/storage/connect/mysql-test/connect/r/xml.result index 554039dc3f1..44fab646dcf 100644 --- a/storage/connect/mysql-test/connect/r/xml.result +++ b/storage/connect/mysql-test/connect/r/xml.result @@ -1,99 +1,5 @@ Warnings: Warning 1105 No file name. Table will use t1.xml -# -# Beginning of grant.inc -# -GRANT ALL PRIVILEGES ON *.* TO user@localhost; -REVOKE FILE ON *.* FROM user@localhost; -SELECT user(); -user() -user@localhost -CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=XML OPTION_LIST='xmlsup=libxml2,rownode=row'; -Warnings: -Warning 1105 No file name. Table will use t1.xml -INSERT INTO t1 VALUES (10); -SELECT * FROM t1; -a -10 -UPDATE t1 SET a=20; -SELECT * FROM t1; -a -20 -DELETE FROM t1; -SELECT * FROM t1; -a -INSERT INTO t1 VALUES(10); -TRUNCATE TABLE t1; -SELECT * FROM t1; -a -CREATE VIEW v1 AS SELECT * FROM t1; -SELECT * FROM v1; -a -DROP VIEW v1; -DROP TABLE t1; -CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=XML OPTION_LIST='xmlsup=libxml2,rownode=row' FILE_NAME='t1.EXT'; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -SELECT user(); -user() -root@localhost -CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=XML OPTION_LIST='xmlsup=libxml2,rownode=row' FILE_NAME='t1.EXT'; -INSERT INTO t1 VALUES (10); -SELECT user(); -user() -user@localhost -INSERT INTO t1 VALUES (10); -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -SELECT * FROM t1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -UPDATE t1 SET a=20; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -DELETE FROM t1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -TRUNCATE TABLE t1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -ALTER TABLE t1 READONLY=1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -ALTER TABLE t1 FILE_NAME='t2.EXT'; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -DROP TABLE t1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -CREATE VIEW v1 AS SELECT * FROM t1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -# Testing a VIEW created with FILE privileges but accessed with no FILE -SELECT user(); -user() -root@localhost -CREATE VIEW v1 AS SELECT * FROM t1; -SELECT user(); -user() -user@localhost -SELECT * FROM v1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -INSERT INTO v1 VALUES (2); -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -UPDATE v1 SET a=123; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -DELETE FROM v1; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -SELECT user(); -user() -root@localhost -DROP VIEW v1; -DROP TABLE t1; -CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=XML OPTION_LIST='xmlsup=libxml2,rownode=row'; -Warnings: -Warning 1105 No file name. Table will use t1.xml -INSERT INTO t1 VALUES (10); -SELECT user(); -user() -user@localhost -ALTER TABLE t1 FILE_NAME='t1.EXT'; -ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) -DROP TABLE t1; -DROP USER user@localhost; -# -# End of grant.inc -# SET NAMES utf8; # # Testing tag values @@ -253,8 +159,8 @@ TITLE XML, Langage et Applications TRANSLATOR NULL PUBLISHER Eyrolles Paris DATEPUB 1998 -SELECT LOAD_FILE('test/xsample2.xml'); -LOAD_FILE('test/xsample2.xml') <?xml version="1.0" encoding="UTF-8"?> +SELECT LOAD_FILE('MYSQLD_DATADIR/test/xsample2.xml') AS xml; +xml <?xml version="1.0" encoding="UTF-8"?> <BIBLIO SUBJECT="XML"> <BOOK ISBN="9782212090819" LANG="fr" SUBJECT="applications"> <AUTHOR> @@ -467,7 +373,7 @@ SELECT node, hex(node) FROM t1; node ÀÁÂÃ hex(node) C0C1C2C3 DROP TABLE t1; -SET @a=LOAD_FILE('test/t1.xml'); +SET @a=LOAD_FILE('MYSQLD_DATADIR/test/t1.xml'); SELECT LEFT(@a,38); LEFT(@a,38) <?xml version="1.0" encoding="utf-8"?> SELECT HEX(EXTRACTVALUE(@a,'/t1/line/node')); @@ -481,7 +387,7 @@ SELECT node, hex(node) FROM t1; node ÀÁÂÃ hex(node) C0C1C2C3 DROP TABLE t1; -SET @a=LOAD_FILE('test/t1.xml'); +SET @a=LOAD_FILE('MYSQLD_DATADIR/test/t1.xml'); SELECT LEFT(@a,43); LEFT(@a,43) <?xml version="1.0" encoding="iso-8859-1"?> SELECT HEX(EXTRACTVALUE(@a,'/t1/line/node')); @@ -504,7 +410,7 @@ hex(node) D090D091D092D093 node &<>"' hex(node) 263C3E2227 DROP TABLE t1; -SET @a=LOAD_FILE('test/t1.xml'); +SET @a=LOAD_FILE('MYSQLD_DATADIR/test/t1.xml'); SELECT CAST(@a AS CHAR CHARACTER SET latin1); CAST(@a AS CHAR CHARACTER SET latin1) <?xml version="1.0" encoding="iso-8859-1"?> <!-- Created by CONNECT Version 1.01.0005 April 27, 2013 --> diff --git a/storage/connect/mysql-test/connect/r/xml_grant.result b/storage/connect/mysql-test/connect/r/xml_grant.result new file mode 100644 index 00000000000..ea38e57af86 --- /dev/null +++ b/storage/connect/mysql-test/connect/r/xml_grant.result @@ -0,0 +1,96 @@ +Warnings: +Warning 1105 No file name. Table will use t1.xml +# +# Beginning of grant.inc +# +GRANT ALL PRIVILEGES ON *.* TO user@localhost; +REVOKE FILE ON *.* FROM user@localhost; +SELECT user(); +user() +user@localhost +CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=XML OPTION_LIST='xmlsup=libxml2,rownode=row'; +Warnings: +Warning 1105 No file name. Table will use t1.xml +INSERT INTO t1 VALUES (10); +SELECT * FROM t1; +a +10 +UPDATE t1 SET a=20; +SELECT * FROM t1; +a +20 +DELETE FROM t1; +SELECT * FROM t1; +a +INSERT INTO t1 VALUES(10); +TRUNCATE TABLE t1; +SELECT * FROM t1; +a +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT * FROM v1; +a +DROP VIEW v1; +DROP TABLE t1; +CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=XML OPTION_LIST='xmlsup=libxml2,rownode=row' FILE_NAME='t1.EXT'; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +SELECT user(); +user() +root@localhost +CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=XML OPTION_LIST='xmlsup=libxml2,rownode=row' FILE_NAME='t1.EXT'; +INSERT INTO t1 VALUES (10); +SELECT user(); +user() +user@localhost +INSERT INTO t1 VALUES (10); +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +SELECT * FROM t1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +UPDATE t1 SET a=20; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +DELETE FROM t1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +TRUNCATE TABLE t1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +ALTER TABLE t1 READONLY=1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +ALTER TABLE t1 FILE_NAME='t2.EXT'; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +DROP TABLE t1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +CREATE VIEW v1 AS SELECT * FROM t1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +# Testing a VIEW created with FILE privileges but accessed with no FILE +SELECT user(); +user() +root@localhost +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT user(); +user() +user@localhost +SELECT * FROM v1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +INSERT INTO v1 VALUES (2); +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +UPDATE v1 SET a=123; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +DELETE FROM v1; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +SELECT user(); +user() +root@localhost +DROP VIEW v1; +DROP TABLE t1; +CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=XML OPTION_LIST='xmlsup=libxml2,rownode=row'; +Warnings: +Warning 1105 No file name. Table will use t1.xml +INSERT INTO t1 VALUES (10); +SELECT user(); +user() +user@localhost +ALTER TABLE t1 FILE_NAME='t1.EXT'; +ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) +DROP TABLE t1; +DROP USER user@localhost; +# +# End of grant.inc +# diff --git a/storage/connect/mysql-test/connect/t/bin.test b/storage/connect/mysql-test/connect/t/bin.test index 0266fd3e357..a9dab32987e 100644 --- a/storage/connect/mysql-test/connect/t/bin.test +++ b/storage/connect/mysql-test/connect/t/bin.test @@ -1,9 +1,5 @@ let $MYSQLD_DATADIR= `select @@datadir`; -let $TABLE_OPTIONS=TABLE_TYPE=BIN; -let $FILE_EXT=BIN; ---source grant.inc - --copy_file $MTR_SUITE_DIR/std_data/Testbal.dat $MYSQLD_DATADIR/test/Testbal.dat --echo # diff --git a/storage/connect/mysql-test/connect/t/csv.test b/storage/connect/mysql-test/connect/t/csv.test index 6578ba83a9a..685ac434df7 100644 --- a/storage/connect/mysql-test/connect/t/csv.test +++ b/storage/connect/mysql-test/connect/t/csv.test @@ -1,9 +1,5 @@ let $MYSQLD_DATADIR= `select @@datadir`; -let $TABLE_OPTIONS=TABLE_TYPE=CSV; -let $FILE_EXT=CSV; ---source grant.inc - --copy_file $MTR_SUITE_DIR/std_data/people.csv $MYSQLD_DATADIR/test/people.csv SET NAMES utf8; diff --git a/storage/connect/mysql-test/connect/t/dbf.test b/storage/connect/mysql-test/connect/t/dbf.test index fb0bc21f52d..b9a1b6e2183 100644 --- a/storage/connect/mysql-test/connect/t/dbf.test +++ b/storage/connect/mysql-test/connect/t/dbf.test @@ -1,9 +1,5 @@ let $MYSQLD_DATADIR= `select @@datadir`; -let $TABLE_OPTIONS=TABLE_TYPE=DBF; -let $FILE_EXT=DBF; ---source grant.inc - --echo # --echo # Testing errors --echo # diff --git a/storage/connect/mysql-test/connect/t/dir.test b/storage/connect/mysql-test/connect/t/dir.test index 073cdaa380b..fb69813d9f0 100644 --- a/storage/connect/mysql-test/connect/t/dir.test +++ b/storage/connect/mysql-test/connect/t/dir.test @@ -1,76 +1,6 @@ let $MYSQLD_DATADIR= `select @@datadir`; ---echo # ---echo # Testing FILE privilege ---echo # -GRANT ALL PRIVILEGES ON *.* TO user@localhost; -REVOKE FILE ON *.* FROM user@localhost; ---connect(user,localhost,user,,) ---connection user -SELECT user(); ---error ER_ACCESS_DENIED_ERROR -CREATE TABLE t1 ( - path VARCHAR(256) NOT NULL flag=1, - fname VARCHAR(256) NOT NULL, - ftype CHAR(4) NOT NULL, - size DOUBLE(12,0) NOT NULL flag=5 -) ENGINE=CONNECT TABLE_TYPE=DIR FILE_NAME='*.*'; ---connection default -SELECT user(); -CREATE TABLE t1 ( - path VARCHAR(256) NOT NULL flag=1, - fname VARCHAR(256) NOT NULL, - ftype CHAR(4) NOT NULL, - size DOUBLE(12,0) NOT NULL flag=5 -) ENGINE=CONNECT TABLE_TYPE=DIR FILE_NAME='*.*'; -# "size>0" to skip directory names on Windows ---replace_result $MYSQLD_DATADIR DATADIR/ -SELECT fname, ftype, size FROM t1 WHERE size>0; - ---connection user -SELECT user(); ---error ER_ACCESS_DENIED_ERROR -SELECT * FROM t1; ---error ER_ACCESS_DENIED_ERROR -INSERT INTO t1 VALUES (); ---error ER_ACCESS_DENIED_ERROR -DELETE FROM t1 WHERE path='xxx'; ---error ER_ACCESS_DENIED_ERROR -UPDATE t1 SET path='yyy' WHERE path='xxx'; ---error ER_ACCESS_DENIED_ERROR -TRUNCATE TABLE t1; ---error ER_ACCESS_DENIED_ERROR -ALTER TABLE t1 READONLY=1; ---error ER_ACCESS_DENIED_ERROR -CREATE VIEW v1 AS SELECT * FROM t1; - ---echo # Testing a VIEW created with FILE privileges but accessed with no FILE ---connection default -SELECT user(); -CREATE VIEW v1 AS SELECT * FROM t1; ---connection user -SELECT user(); ---error ER_ACCESS_DENIED_ERROR -SELECT * FROM v1; ---error ER_ACCESS_DENIED_ERROR -INSERT INTO v1 VALUES (1,1,1,1); ---error ER_ACCESS_DENIED_ERROR -UPDATE v1 SET path=123; ---error ER_ACCESS_DENIED_ERROR -DELETE FROM v1; - ---disconnect user ---connection default -SELECT user(); -DROP VIEW v1; -DROP TABLE t1; -DROP USER user@localhost; ---echo # ---echo # Testing FILE privileges done ---echo # - - CREATE TABLE t1 ( path VARCHAR(256) NOT NULL flag=1, fname VARCHAR(256) NOT NULL, diff --git a/storage/connect/mysql-test/connect/t/fix.test b/storage/connect/mysql-test/connect/t/fix.test index d2dfeb21352..c3cec55a217 100644 --- a/storage/connect/mysql-test/connect/t/fix.test +++ b/storage/connect/mysql-test/connect/t/fix.test @@ -1,9 +1,5 @@ let $MYSQLD_DATADIR= `select @@datadir`; -let $TABLE_OPTIONS=TABLE_TYPE=FIX; -let $FILE_EXT=FIX; ---source grant.inc - --copy_file $MTR_SUITE_DIR/std_data/dept.dat $MYSQLD_DATADIR/test/dept.dat --copy_file $MTR_SUITE_DIR/std_data/boys.txt $MYSQLD_DATADIR/test/boys.txt --copy_file $MTR_SUITE_DIR/std_data/boyswin.txt $MYSQLD_DATADIR/test/boyswin.txt diff --git a/storage/connect/mysql-test/connect/t/grant.test b/storage/connect/mysql-test/connect/t/grant.test new file mode 100644 index 00000000000..909bb4117a1 --- /dev/null +++ b/storage/connect/mysql-test/connect/t/grant.test @@ -0,0 +1,95 @@ +-- source include/not_embedded.inc + +let $MYSQLD_DATADIR= `select @@datadir`; + +--echo # +--echo # Testing FILE privilege +--echo # +GRANT ALL PRIVILEGES ON *.* TO user@localhost; +REVOKE FILE ON *.* FROM user@localhost; +--connect(user,localhost,user,,) +--connection user +SELECT user(); +--error ER_ACCESS_DENIED_ERROR +CREATE TABLE t1 ( + path VARCHAR(256) NOT NULL flag=1, + fname VARCHAR(256) NOT NULL, + ftype CHAR(4) NOT NULL, + size DOUBLE(12,0) NOT NULL flag=5 +) ENGINE=CONNECT TABLE_TYPE=DIR FILE_NAME='*.*'; +--connection default +SELECT user(); +CREATE TABLE t1 ( + path VARCHAR(256) NOT NULL flag=1, + fname VARCHAR(256) NOT NULL, + ftype CHAR(4) NOT NULL, + size DOUBLE(12,0) NOT NULL flag=5 +) ENGINE=CONNECT TABLE_TYPE=DIR FILE_NAME='*.*'; +# "size>0" to skip directory names on Windows +--replace_result $MYSQLD_DATADIR DATADIR/ +SELECT fname, ftype, size FROM t1 WHERE size>0; + +--connection user +SELECT user(); +--error ER_ACCESS_DENIED_ERROR +SELECT * FROM t1; +--error ER_ACCESS_DENIED_ERROR +INSERT INTO t1 VALUES (); +--error ER_ACCESS_DENIED_ERROR +DELETE FROM t1 WHERE path='xxx'; +--error ER_ACCESS_DENIED_ERROR +UPDATE t1 SET path='yyy' WHERE path='xxx'; +--error ER_ACCESS_DENIED_ERROR +TRUNCATE TABLE t1; +--error ER_ACCESS_DENIED_ERROR +ALTER TABLE t1 READONLY=1; +--error ER_ACCESS_DENIED_ERROR +CREATE VIEW v1 AS SELECT * FROM t1; + +--echo # Testing a VIEW created with FILE privileges but accessed with no FILE +--connection default +SELECT user(); +CREATE VIEW v1 AS SELECT * FROM t1; +--connection user +SELECT user(); +--error ER_ACCESS_DENIED_ERROR +SELECT * FROM v1; +--error ER_ACCESS_DENIED_ERROR +INSERT INTO v1 VALUES (1,1,1,1); +--error ER_ACCESS_DENIED_ERROR +UPDATE v1 SET path=123; +--error ER_ACCESS_DENIED_ERROR +DELETE FROM v1; + +--disconnect user +--connection default +SELECT user(); +DROP VIEW v1; +DROP TABLE t1; +DROP USER user@localhost; +--echo # +--echo # Testing FILE privileges done +--echo # + + +let $TABLE_OPTIONS=TABLE_TYPE=BIN; +let $FILE_EXT=BIN; +--source grant.inc + +let $TABLE_OPTIONS=TABLE_TYPE=CSV; +let $FILE_EXT=CSV; +--source grant.inc + +let $TABLE_OPTIONS=TABLE_TYPE=DBF; +let $FILE_EXT=DBF; +--source grant.inc + +let $TABLE_OPTIONS=TABLE_TYPE=FIX; +let $FILE_EXT=FIX; +--source grant.inc + +let $TABLE_OPTIONS=TABLE_TYPE=VEC MAX_ROWS=100; +let $FILE_EXT=VEC; +--source grant.inc + + diff --git a/storage/connect/mysql-test/connect/t/ini.test b/storage/connect/mysql-test/connect/t/ini.test index e862f3cd672..0d23142ac9e 100644 --- a/storage/connect/mysql-test/connect/t/ini.test +++ b/storage/connect/mysql-test/connect/t/ini.test @@ -1,80 +1,5 @@ let $MYSQLD_DATADIR= `select @@datadir`; ---echo # ---echo # Checking FILE privileges ---echo # -GRANT ALL PRIVILEGES ON *.* TO user@localhost; -REVOKE FILE ON *.* FROM user@localhost; ---connect(user,localhost,user,,) ---connection user -SELECT user(); -CREATE TABLE t1 (sec CHAR(10) NOT NULL FLAG=1, val CHAR(10) NOT NULL) ENGINE=CONNECT TABLE_TYPE=INI; -INSERT INTO t1 VALUES ('sec1','val1'); -SELECT * FROM t1; -UPDATE t1 SET val='val11'; -SELECT * FROM t1; -DELETE FROM t1; -SELECT * FROM t1; -INSERT INTO t1 VALUES('sec2','val2'); -TRUNCATE TABLE t1; -SELECT * FROM t1; -CREATE VIEW v1 AS SELECT * FROM t1; -SELECT * FROM v1; -DROP VIEW v1; -DROP TABLE t1; -# Making sure DROP erased the data file ---error 1 ---remove_file $MYSQLD_DATADIR/test/t1.ini ---error ER_ACCESS_DENIED_ERROR -CREATE TABLE t1 (sec CHAR(10) NOT NULL FLAG=1, val CHAR(10) NOT NULL) ENGINE=CONNECT TABLE_TYPE=INI FILE_NAME='t1.EXT'; ---connection default -SELECT user(); -CREATE TABLE t1 (sec CHAR(10) NOT NULL FLAG=1, val CHAR(10) NOT NULL) ENGINE=CONNECT TABLE_TYPE=INI FILE_NAME='t1.EXT'; -INSERT INTO t1 VALUES ('sec1','val1'); ---connection user -SELECT user(); ---error ER_ACCESS_DENIED_ERROR -INSERT INTO t1 VALUES ('sec2','val2'); ---error ER_ACCESS_DENIED_ERROR -SELECT * FROM t1; ---error ER_ACCESS_DENIED_ERROR -UPDATE t1 SET val='val11'; ---error ER_ACCESS_DENIED_ERROR -DELETE FROM t1; ---error ER_ACCESS_DENIED_ERROR -TRUNCATE TABLE t1; ---error ER_ACCESS_DENIED_ERROR -ALTER TABLE t1 READONLY=1; ---error ER_ACCESS_DENIED_ERROR -DROP TABLE t1; ---error ER_ACCESS_DENIED_ERROR -CREATE VIEW v1 AS SELECT * FROM t1; ---echo # Testing a VIEW created with FILE privileges but accessed with no FILE ---connection default -SELECT user(); -CREATE VIEW v1 AS SELECT * FROM t1; ---connection user -SELECT user(); ---error ER_ACCESS_DENIED_ERROR -SELECT * FROM v1; ---error ER_ACCESS_DENIED_ERROR -INSERT INTO v1 VALUES ('sec3','val3'); ---error ER_ACCESS_DENIED_ERROR -UPDATE v1 SET val='val11'; ---error ER_ACCESS_DENIED_ERROR -DELETE FROM v1; ---disconnect user ---connection default -DROP VIEW v1; -DROP TABLE t1; ---remove_file $MYSQLD_DATADIR/test/t1.EXT -DROP USER user@localhost; - ---echo # ---echo # Checking FILE privileges: done ---echo # - - --copy_file $MTR_SUITE_DIR/std_data/contact.ini $MYSQLD_DATADIR/test/contact.ini --echo # diff --git a/storage/connect/mysql-test/connect/t/ini_grant.test b/storage/connect/mysql-test/connect/t/ini_grant.test new file mode 100644 index 00000000000..30678645692 --- /dev/null +++ b/storage/connect/mysql-test/connect/t/ini_grant.test @@ -0,0 +1,79 @@ +-- source include/not_embedded.inc + +let $MYSQLD_DATADIR= `select @@datadir`; + +--echo # +--echo # Checking FILE privileges +--echo # +GRANT ALL PRIVILEGES ON *.* TO user@localhost; +REVOKE FILE ON *.* FROM user@localhost; +--connect(user,localhost,user,,) +--connection user +SELECT user(); +CREATE TABLE t1 (sec CHAR(10) NOT NULL FLAG=1, val CHAR(10) NOT NULL) ENGINE=CONNECT TABLE_TYPE=INI; +INSERT INTO t1 VALUES ('sec1','val1'); +SELECT * FROM t1; +UPDATE t1 SET val='val11'; +SELECT * FROM t1; +DELETE FROM t1; +SELECT * FROM t1; +INSERT INTO t1 VALUES('sec2','val2'); +TRUNCATE TABLE t1; +SELECT * FROM t1; +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT * FROM v1; +DROP VIEW v1; +DROP TABLE t1; +# Making sure DROP erased the data file +--error 1 +--remove_file $MYSQLD_DATADIR/test/t1.ini +--error ER_ACCESS_DENIED_ERROR +CREATE TABLE t1 (sec CHAR(10) NOT NULL FLAG=1, val CHAR(10) NOT NULL) ENGINE=CONNECT TABLE_TYPE=INI FILE_NAME='t1.EXT'; +--connection default +SELECT user(); +CREATE TABLE t1 (sec CHAR(10) NOT NULL FLAG=1, val CHAR(10) NOT NULL) ENGINE=CONNECT TABLE_TYPE=INI FILE_NAME='t1.EXT'; +INSERT INTO t1 VALUES ('sec1','val1'); +--connection user +SELECT user(); +--error ER_ACCESS_DENIED_ERROR +INSERT INTO t1 VALUES ('sec2','val2'); +--error ER_ACCESS_DENIED_ERROR +SELECT * FROM t1; +--error ER_ACCESS_DENIED_ERROR +UPDATE t1 SET val='val11'; +--error ER_ACCESS_DENIED_ERROR +DELETE FROM t1; +--error ER_ACCESS_DENIED_ERROR +TRUNCATE TABLE t1; +--error ER_ACCESS_DENIED_ERROR +ALTER TABLE t1 READONLY=1; +--error ER_ACCESS_DENIED_ERROR +DROP TABLE t1; +--error ER_ACCESS_DENIED_ERROR +CREATE VIEW v1 AS SELECT * FROM t1; +--echo # Testing a VIEW created with FILE privileges but accessed with no FILE +--connection default +SELECT user(); +CREATE VIEW v1 AS SELECT * FROM t1; +--connection user +SELECT user(); +--error ER_ACCESS_DENIED_ERROR +SELECT * FROM v1; +--error ER_ACCESS_DENIED_ERROR +INSERT INTO v1 VALUES ('sec3','val3'); +--error ER_ACCESS_DENIED_ERROR +UPDATE v1 SET val='val11'; +--error ER_ACCESS_DENIED_ERROR +DELETE FROM v1; +--disconnect user +--connection default +DROP VIEW v1; +DROP TABLE t1; +--remove_file $MYSQLD_DATADIR/test/t1.EXT +DROP USER user@localhost; + +--echo # +--echo # Checking FILE privileges: done +--echo # + + diff --git a/storage/connect/mysql-test/connect/t/mysql.test b/storage/connect/mysql-test/connect/t/mysql.test index 45d26cdf9eb..7c90acdd149 100644 --- a/storage/connect/mysql-test/connect/t/mysql.test +++ b/storage/connect/mysql-test/connect/t/mysql.test @@ -14,66 +14,6 @@ if (!`SELECT count(*) FROM INFORMATION_SCHEMA.TABLES DROP TABLE t1; --enable_query_log ---echo # ---echo # Testing FILE privilege ---echo # -GRANT ALL PRIVILEGES ON *.* TO user@localhost; -REVOKE FILE ON *.* FROM user@localhost; ---connect(user,localhost,user,,) ---connection user -SELECT user(); ---replace_result $PORT PORT ---error ER_ACCESS_DENIED_ERROR ---eval CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=MySQL OPTION_LIST='host=localhost,user=root1,port=$PORT' ---connection default -SELECT user(); -CREATE TABLE t1remote (a INT NOT NULL); -INSERT INTO t1remote VALUES (10),(20),(30); ---replace_result $PORT PORT ---eval CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=MySQL TABNAME=t1remote OPTION_LIST='host=localhost,user=root,port=$PORT' -SELECT * FROM t1; ---connection user -SELECT user(); ---error ER_ACCESS_DENIED_ERROR -SELECT * FROM t1; ---error ER_ACCESS_DENIED_ERROR -INSERT INTO t1 VALUES ('xxx'); ---error ER_ACCESS_DENIED_ERROR -DELETE FROM t1 WHERE a='xxx'; ---error ER_ACCESS_DENIED_ERROR -UPDATE t1 SET a='yyy' WHERE a='xxx'; ---error ER_ACCESS_DENIED_ERROR -TRUNCATE TABLE t1; ---error ER_ACCESS_DENIED_ERROR -ALTER TABLE t1 READONLY=1; ---error ER_ACCESS_DENIED_ERROR -CREATE VIEW v1 AS SELECT * FROM t1; - ---echo # Testing a VIEW created with FILE privileges but accessed with no FILE ---connection default -SELECT user(); -CREATE VIEW v1 AS SELECT * FROM t1; ---connection user -SELECT user(); ---error ER_ACCESS_DENIED_ERROR -SELECT * FROM v1; ---error ER_ACCESS_DENIED_ERROR -INSERT INTO v1 VALUES (2); ---error ER_ACCESS_DENIED_ERROR -UPDATE v1 SET a=123; ---error ER_ACCESS_DENIED_ERROR -DELETE FROM v1; - ---disconnect user ---connection default -SELECT user(); -DROP VIEW v1; -DROP TABLE t1, t1remote; -DROP USER user@localhost; ---echo # ---echo # Testing FILE privileges done ---echo # - # TODO: remote VARCHAR is displayed as CHAR CREATE TABLE t1 (a int, b char(10)); diff --git a/storage/connect/mysql-test/connect/t/mysql_grant.test b/storage/connect/mysql-test/connect/t/mysql_grant.test new file mode 100644 index 00000000000..e825e70a84b --- /dev/null +++ b/storage/connect/mysql-test/connect/t/mysql_grant.test @@ -0,0 +1,78 @@ +-- source include/not_embedded.inc + +let $PORT= `select @@port`; + +--disable_query_log +--replace_result $PORT PORT +--error 0,ER_UNKNOWN_ERROR +--eval CREATE TABLE t1 (a INT) ENGINE=CONNECT TABLE_TYPE=MYSQL TABNAME='t1' OPTION_LIST='host=localhost,user=root,port=$PORT' +if (!`SELECT count(*) FROM INFORMATION_SCHEMA.TABLES + WHERE TABLE_SCHEMA='test' AND TABLE_NAME='t1' + AND ENGINE='CONNECT' + AND CREATE_OPTIONS LIKE '%`table_type`=MySQL%'`) +{ + Skip Need MySQL support; +} +DROP TABLE t1; +--enable_query_log + +--echo # +--echo # Testing FILE privilege +--echo # +GRANT ALL PRIVILEGES ON *.* TO user@localhost; +REVOKE FILE ON *.* FROM user@localhost; +--connect(user,localhost,user,,) +--connection user +SELECT user(); +--replace_result $PORT PORT +--error ER_ACCESS_DENIED_ERROR +--eval CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=MySQL OPTION_LIST='host=localhost,user=root1,port=$PORT' +--connection default +SELECT user(); +CREATE TABLE t1remote (a INT NOT NULL); +INSERT INTO t1remote VALUES (10),(20),(30); +--replace_result $PORT PORT +--eval CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=MySQL TABNAME=t1remote OPTION_LIST='host=localhost,user=root,port=$PORT' +SELECT * FROM t1; +--connection user +SELECT user(); +--error ER_ACCESS_DENIED_ERROR +SELECT * FROM t1; +--error ER_ACCESS_DENIED_ERROR +INSERT INTO t1 VALUES ('xxx'); +--error ER_ACCESS_DENIED_ERROR +DELETE FROM t1 WHERE a='xxx'; +--error ER_ACCESS_DENIED_ERROR +UPDATE t1 SET a='yyy' WHERE a='xxx'; +--error ER_ACCESS_DENIED_ERROR +TRUNCATE TABLE t1; +--error ER_ACCESS_DENIED_ERROR +ALTER TABLE t1 READONLY=1; +--error ER_ACCESS_DENIED_ERROR +CREATE VIEW v1 AS SELECT * FROM t1; + +--echo # Testing a VIEW created with FILE privileges but accessed with no FILE +--connection default +SELECT user(); +CREATE VIEW v1 AS SELECT * FROM t1; +--connection user +SELECT user(); +--error ER_ACCESS_DENIED_ERROR +SELECT * FROM v1; +--error ER_ACCESS_DENIED_ERROR +INSERT INTO v1 VALUES (2); +--error ER_ACCESS_DENIED_ERROR +UPDATE v1 SET a=123; +--error ER_ACCESS_DENIED_ERROR +DELETE FROM v1; + +--disconnect user +--connection default +SELECT user(); +DROP VIEW v1; +DROP TABLE t1, t1remote; +DROP USER user@localhost; +--echo # +--echo # Testing FILE privileges done +--echo # + diff --git a/storage/connect/mysql-test/connect/t/vec.test b/storage/connect/mysql-test/connect/t/vec.test index 79ed4eabd86..ee504e9925a 100644 --- a/storage/connect/mysql-test/connect/t/vec.test +++ b/storage/connect/mysql-test/connect/t/vec.test @@ -1,9 +1,5 @@ let $MYSQLD_DATADIR= `select @@datadir`; -let $TABLE_OPTIONS=TABLE_TYPE=VEC MAX_ROWS=100; -let $FILE_EXT=VEC; ---source grant.inc - CREATE TABLE dir1 ( spath VARCHAR(256) NOT NULL flag=1, fname VARCHAR(256) NOT NULL, diff --git a/storage/connect/mysql-test/connect/t/xml.test b/storage/connect/mysql-test/connect/t/xml.test index 96e7e1a3a97..3914bed307d 100644 --- a/storage/connect/mysql-test/connect/t/xml.test +++ b/storage/connect/mysql-test/connect/t/xml.test @@ -16,11 +16,6 @@ DROP TABLE t1; let $MYSQLD_DATADIR= `select @@datadir`; -let $TABLE_OPTIONS=TABLE_TYPE=XML OPTION_LIST='xmlsup=libxml2,rownode=row'; -let $FILE_EXT=XML; ---source grant.inc - - SET NAMES utf8; --vertical_results @@ -132,7 +127,8 @@ INSERT INTO t1 (ISBN, LANG, SUBJECT, AUTHOR, TITLE, PUBLISHEr, DATEPUB) VALUES('9782212090529','fr','général','Alain Michard', 'XML, Langage et Applications','Eyrolles Paris',1998); SELECT * FROM t1; -SELECT LOAD_FILE('test/xsample2.xml'); +--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR +--eval SELECT LOAD_FILE('$MYSQLD_DATADIR/test/xsample2.xml') AS xml DROP TABLE t1; --remove_file $MYSQLD_DATADIR/test/xsample2.xml @@ -289,7 +285,8 @@ INSERT INTO t1 VALUES (_latin1 0xC0C1C2C3); SELECT node, hex(node) FROM t1; DROP TABLE t1; --chmod 0777 $MYSQLD_DATADIR/test/t1.xml -SET @a=LOAD_FILE('test/t1.xml'); +--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR +--eval SET @a=LOAD_FILE('$MYSQLD_DATADIR/test/t1.xml') SELECT LEFT(@a,38); SELECT HEX(EXTRACTVALUE(@a,'/t1/line/node')); --remove_file $MYSQLD_DATADIR/test/t1.xml @@ -302,7 +299,8 @@ INSERT INTO t1 VALUES (_latin1 0xC0C1C2C3); SELECT node, hex(node) FROM t1; DROP TABLE t1; --chmod 0777 $MYSQLD_DATADIR/test/t1.xml -SET @a=LOAD_FILE('test/t1.xml'); +--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR +--eval SET @a=LOAD_FILE('$MYSQLD_DATADIR/test/t1.xml') SELECT LEFT(@a,43); SELECT HEX(EXTRACTVALUE(@a,'/t1/line/node')); --remove_file $MYSQLD_DATADIR/test/t1.xml @@ -321,7 +319,8 @@ INSERT INTO t1 VALUES ('&<>"\''); SELECT node, hex(node) FROM t1; DROP TABLE t1; --chmod 0777 $MYSQLD_DATADIR/test/t1.xml -SET @a=LOAD_FILE('test/t1.xml'); +--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR +--eval SET @a=LOAD_FILE('$MYSQLD_DATADIR/test/t1.xml') SELECT CAST(@a AS CHAR CHARACTER SET latin1); --remove_file $MYSQLD_DATADIR/test/t1.xml diff --git a/storage/connect/mysql-test/connect/t/xml_grant.test b/storage/connect/mysql-test/connect/t/xml_grant.test new file mode 100644 index 00000000000..f8401efaa64 --- /dev/null +++ b/storage/connect/mysql-test/connect/t/xml_grant.test @@ -0,0 +1,23 @@ +-- source include/not_embedded.inc + +--disable_query_log +--error 0,ER_UNKNOWN_ERROR +CREATE TABLE t1 (a VARCHAR(10)) +ENGINE=CONNECT TABLE_TYPE=XML OPTION_LIST='xmlsup=libxml2'; +if (!`SELECT count(*) FROM INFORMATION_SCHEMA.TABLES + WHERE TABLE_SCHEMA='test' AND TABLE_NAME='t1' + AND ENGINE='CONNECT' + AND CREATE_OPTIONS LIKE '%`table_type`=XML%' + AND CREATE_OPTIONS LIKE '%xmlsup=libxml2%'`) +{ + Skip Need LIBXML2; +} +DROP TABLE t1; +--enable_query_log + + +let $MYSQLD_DATADIR= `select @@datadir`; + +let $TABLE_OPTIONS=TABLE_TYPE=XML OPTION_LIST='xmlsup=libxml2,rownode=row'; +let $FILE_EXT=XML; +--source grant.inc diff --git a/storage/connect/plgdbsem.h b/storage/connect/plgdbsem.h index 6884c1c4176..dfa46a650a6 100644 --- a/storage/connect/plgdbsem.h +++ b/storage/connect/plgdbsem.h @@ -577,5 +577,6 @@ DllExport void NewPointer(PTABS, void *, void *); FILE *global_fopen(GLOBAL *g, int msgid, const char *path, const char *mode); int global_open(GLOBAL *g, int msgid, const char *filename, int flags); int global_open(GLOBAL *g, int msgid, const char *filename, int flags, int mode); +DllExport LPCSTR PlugSetPath(LPSTR to, LPCSTR name, LPCSTR dir); bool PushWarning(PGLOBAL, PTDBASE); diff --git a/storage/connect/plugutil.c b/storage/connect/plugutil.c index 67947e3042b..e8098bb2512 100644 --- a/storage/connect/plugutil.c +++ b/storage/connect/plugutil.c @@ -219,11 +219,23 @@ LPSTR PlugRemoveType(LPSTR pBuff, LPCSTR FileName) return pBuff; } // end of PlugRemoveType + +BOOL PlugIsAbsolutePath(LPCSTR path) +{ +#if defined(WIN32) + return ((path[0] >= 'a' && path[0] <= 'z') || + (path[0] >= 'A' && path[0] <= 'Z')) && path[1] == ':'; +#else + return path[0] == '/'; +#endif +} + + /***********************************************************************/ /* Set the full path of a file relatively to a given path. */ /* Note: this routine is not really implemented for Unix. */ /***********************************************************************/ -LPCSTR PlugSetPath(LPSTR pBuff, LPCSTR FileName, LPCSTR defpath) +LPCSTR PlugSetPath(LPSTR pBuff, LPCSTR prefix, LPCSTR FileName, LPCSTR defpath) { char newname[_MAX_PATH]; char direc[_MAX_DIR], defdir[_MAX_DIR]; @@ -240,6 +252,22 @@ LPCSTR PlugSetPath(LPSTR pBuff, LPCSTR FileName, LPCSTR defpath) return pBuff; } // endif + if (PlugIsAbsolutePath(FileName)) + { + strcpy(pBuff, FileName); // FileName includes absolute path + return pBuff; + } // endif + + if (strcmp(prefix, ".") && !PlugIsAbsolutePath(defpath)) + { + char tmp[_MAX_PATH]; + int len= snprintf(tmp, sizeof(tmp) - 1, "%s%s%s", + prefix, defpath, FileName); + memcpy(pBuff, tmp, (size_t) len); + pBuff[len]= '\0'; + return pBuff; + } + _splitpath(FileName, drive, direc, fname, ftype); _splitpath(defpath, defdrv, defdir, NULL, NULL); |