Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mariadb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
393e41fe
Commit
393e41fe
authored
Aug 24, 2004
by
bell@sanja.is.com.ua
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sending right error message where VIEW is not expected (BUG#4606)
parent
ea1df67d
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
51 additions
and
20 deletions
+51
-20
mysql-test/r/view.result
mysql-test/r/view.result
+6
-0
mysql-test/t/view.test
mysql-test/t/view.test
+10
-0
sql/sql_base.cc
sql/sql_base.cc
+26
-13
sql/sql_view.h
sql/sql_view.h
+0
-7
sql/table.h
sql/table.h
+9
-0
No files found.
mysql-test/r/view.result
View file @
393e41fe
...
...
@@ -1047,3 +1047,9 @@ select * from v1;
EXISTS (SELECT 1 UNION SELECT 2)
1
drop view v1;
create table t1 (col1 int,col2 char(22));
create view v1 as select * from t1;
create index i1 on v1 (col1);
ERROR HY000: 'test.v1' is not BASIC TABLE
drop view v1;
drop table t1;
mysql-test/t/view.test
View file @
393e41fe
...
...
@@ -987,3 +987,13 @@ SHOW TABLES;
CREATE
VIEW
v1
AS
SELECT
EXISTS
(
SELECT
1
UNION
SELECT
2
);
select
*
from
v1
;
drop
view
v1
;
#
# using VIEW where table is required
#
create
table
t1
(
col1
int
,
col2
char
(
22
));
create
view
v1
as
select
*
from
t1
;
--
error
1346
create
index
i1
on
v1
(
col1
);
drop
view
v1
;
drop
table
t1
;
sql/sql_base.cc
View file @
393e41fe
...
...
@@ -38,6 +38,7 @@ static int open_unireg_entry(THD *thd, TABLE *entry, const char *db,
static
void
free_cache_entry
(
TABLE
*
entry
);
static
void
mysql_rm_tmp_tables
(
void
);
static
my_bool
open_new_frm
(
const
char
*
path
,
const
char
*
alias
,
const
char
*
db
,
const
char
*
table_name
,
uint
db_stat
,
uint
prgflag
,
uint
ha_open_flags
,
TABLE
*
outparam
,
TABLE_LIST
*
table_desc
,
MEM_ROOT
*
mem_root
);
...
...
@@ -1379,8 +1380,6 @@ static int open_unireg_entry(THD *thd, TABLE *entry, const char *db,
{
char
path
[
FN_REFLEN
];
int
error
;
// we support new format only is have all parameters for it
uint
new_frm_flag
=
(
table_desc
&&
mem_root
)
?
NO_ERR_ON_NEW_FRM
:
0
;
uint
discover_retry_count
=
0
;
DBUG_ENTER
(
"open_unireg_entry"
);
...
...
@@ -1388,12 +1387,12 @@ static int open_unireg_entry(THD *thd, TABLE *entry, const char *db,
while
((
error
=
openfrm
(
path
,
alias
,
(
uint
)
(
HA_OPEN_KEYFILE
|
HA_OPEN_RNDFILE
|
HA_GET_INDEX
|
HA_TRY_READ_ONLY
|
new_frm_flag
),
NO_ERR_ON_NEW_FRM
),
READ_KEYINFO
|
COMPUTE_TYPES
|
EXTRA_RECORD
,
thd
->
open_options
,
entry
))
&&
(
error
!=
5
||
fn_format
(
path
,
path
,
0
,
reg_ext
,
MY_UNPACK_FILENAME
),
open_new_frm
(
path
,
alias
,
open_new_frm
(
path
,
alias
,
db
,
name
,
(
uint
)
(
HA_OPEN_KEYFILE
|
HA_OPEN_RNDFILE
|
HA_GET_INDEX
|
HA_TRY_READ_ONLY
),
READ_KEYINFO
|
COMPUTE_TYPES
|
EXTRA_RECORD
,
...
...
@@ -1679,6 +1678,8 @@ TABLE *open_ltable(THD *thd, TABLE_LIST *table_list, thr_lock_type lock_type)
thd
->
proc_info
=
"Opening table"
;
thd
->
current_tablenr
=
0
;
/* open_ltable can be used only for BASIC TABLEs */
table_list
->
required_type
=
FRMTYPE_TABLE
;
while
(
!
(
table
=
open_table
(
thd
,
table_list
,
0
,
&
refresh
))
&&
refresh
)
;
if
(
table
)
...
...
@@ -3209,6 +3210,8 @@ int init_ftfuncs(THD *thd, SELECT_LEX *select_lex, bool no_order)
open_new_frm()
path path to .frm
alias alias for table
db database
table_name name of table
db_stat open flags (for example HA_OPEN_KEYFILE|HA_OPEN_RNDFILE..)
can be 0 (example in ha_example_table)
prgflag READ_ALL etc..
...
...
@@ -3218,7 +3221,9 @@ int init_ftfuncs(THD *thd, SELECT_LEX *select_lex, bool no_order)
mem_root temporary MEM_ROOT for parsing
*/
static
my_bool
open_new_frm
(
const
char
*
path
,
const
char
*
alias
,
uint
db_stat
,
uint
prgflag
,
open_new_frm
(
const
char
*
path
,
const
char
*
alias
,
const
char
*
db
,
const
char
*
table_name
,
uint
db_stat
,
uint
prgflag
,
uint
ha_open_flags
,
TABLE
*
outparam
,
TABLE_LIST
*
table_desc
,
MEM_ROOT
*
mem_root
)
{
...
...
@@ -3226,28 +3231,36 @@ open_new_frm(const char *path, const char *alias, uint db_stat, uint prgflag,
LEX_STRING
pathstr
;
pathstr
.
str
=
(
char
*
)
path
;
pathstr
.
length
=
strlen
(
path
);
if
(
!
mem_root
)
mem_root
=
&
current_thd
->
mem_root
;
File_parser
*
parser
=
sql_parse_prepare
(
&
pathstr
,
mem_root
,
1
);
if
(
parser
)
{
if
(
!
strncmp
(
"VIEW"
,
parser
->
type
()
->
str
,
parser
->
type
()
->
length
))
{
if
(
mysql_make_view
(
parser
,
table_desc
)
)
if
(
table_desc
==
0
||
table_desc
->
required_type
==
FRMTYPE_TABLE
)
{
bzero
(
outparam
,
sizeof
(
*
outparam
));
// do not run repair
DBUG_RETURN
(
1
)
;
my_error
(
ER_WRONG_OBJECT
,
MYF
(
0
),
db
,
table_name
,
"BASIC TABLE"
);
goto
err
;
}
if
(
mysql_make_view
(
parser
,
table_desc
))
goto
err
;
}
else
{
/* only VIEWs are supported now */
my_error
(
ER_FRM_UNKNOWN_TYPE
,
MYF
(
0
),
path
,
parser
->
type
()
->
str
);
bzero
(
outparam
,
sizeof
(
outparam
));
// do not run repair
DBUG_RETURN
(
1
);
goto
err
;
}
}
else
{
DBUG_RETURN
(
1
);
}
goto
err
;
DBUG_RETURN
(
0
);
err:
bzero
(
outparam
,
sizeof
(
TABLE
));
// do not run repair
DBUG_RETURN
(
1
);
}
sql/sql_view.h
View file @
393e41fe
...
...
@@ -27,13 +27,6 @@ bool check_key_in_view(THD *thd, TABLE_LIST * view);
void
insert_view_fields
(
List
<
Item
>
*
list
,
TABLE_LIST
*
view
);
enum
frm_type_enum
{
FRMTYPE_ERROR
,
FRMTYPE_TABLE
,
FRMTYPE_VIEW
};
frm_type_enum
mysql_frm_type
(
char
*
path
);
extern
TYPELIB
sql_updatable_view_key_typelib
;
...
...
sql/table.h
View file @
393e41fe
...
...
@@ -47,6 +47,13 @@ typedef struct st_grant_info
enum
tmp_table_type
{
NO_TMP_TABLE
=
0
,
TMP_TABLE
=
1
,
TRANSACTIONAL_TMP_TABLE
=
2
};
enum
frm_type_enum
{
FRMTYPE_ERROR
=
0
,
FRMTYPE_TABLE
,
FRMTYPE_VIEW
};
typedef
struct
st_filesort_info
{
IO_CACHE
*
io_cache
;
/* If sorted through filebyte */
...
...
@@ -241,6 +248,8 @@ typedef struct st_table_list
bool
setup_is_done
;
/* setup_tables() is done */
/* do view contain auto_increment field */
bool
contain_auto_increment
;
/* FRMTYPE_ERROR if any type is acceptable */
enum
frm_type_enum
required_type
;
char
timestamp_buffer
[
20
];
/* buffer for timestamp (19+1) */
void
calc_md5
(
char
*
buffer
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment