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
87681bb8
Commit
87681bb8
authored
Jan 21, 2003
by
hf@deer.mysql.r18.ru
Browse files
Options
Browse Files
Download
Plain Diff
Merge abotchkov@work.mysql.com:/home/bk/mysql-4.1
into deer.mysql.r18.ru:/home/hf/work/mysql-default
parents
62c02d4b
9fb261e3
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
98 additions
and
30 deletions
+98
-30
sql/field.h
sql/field.h
+3
-2
sql/item.cc
sql/item.cc
+46
-0
sql/item.h
sql/item.h
+37
-21
sql/sql_yacc.yy
sql/sql_yacc.yy
+10
-6
sql/table.cc
sql/table.cc
+1
-1
sql/table.h
sql/table.h
+1
-0
No files found.
sql/field.h
View file @
87681bb8
...
...
@@ -78,10 +78,11 @@ public:
virtual
void
reset_fields
()
{}
virtual
void
set_default
()
{
memcpy
(
ptr
,
ptr
+
table
->
rec_buff_length
,
pack_length
());
my_ptrdiff_t
offset
=
table
->
default_values
()
-
table
->
record
[
0
];
memcpy
(
ptr
,
ptr
+
offset
,
pack_length
());
if
(
null_ptr
)
*
null_ptr
=
((
*
null_ptr
&
(
uchar
)
~
null_bit
)
|
null_ptr
[
table
->
rec_buff_length
]
&
null_bit
);
null_ptr
[
offset
]
&
null_bit
);
}
virtual
bool
binary
()
const
{
return
1
;
}
virtual
bool
zero_pack
()
const
{
return
1
;
}
...
...
sql/item.cc
View file @
87681bb8
...
...
@@ -1126,6 +1126,52 @@ bool Item_ref::check_loop(uint id)
DBUG_RETURN
((
*
ref
)
->
check_loop
(
id
));
}
bool
Item_default_value
::
eq
(
const
Item
*
item
,
bool
binary_cmp
)
const
{
return
item
->
type
()
==
DEFAULT_ITEM
&&
((
Item_default_value
*
)
item
)
->
arg
->
eq
(
arg
,
binary_cmp
);
}
bool
Item_default_value
::
fix_fields
(
THD
*
thd
,
struct
st_table_list
*
table_list
,
Item
**
items
)
{
if
(
!
arg
)
return
false
;
bool
res
=
arg
->
fix_fields
(
thd
,
table_list
,
items
);
if
(
res
)
return
res
;
/* arg->type() can be only REF_ITEM or FIELD_ITEM for it defined as
simple_ident in sql_yacc.yy
*/
if
(
arg
->
type
()
==
REF_ITEM
)
{
Item_ref
*
ref
=
(
Item_ref
*
)
arg
;
if
(
ref
->
ref
[
0
]
->
type
()
!=
FIELD_ITEM
)
{
return
1
;
}
arg
=
ref
->
ref
[
0
];
}
Item_field
*
field_arg
=
(
Item_field
*
)
arg
;
Field
*
def_field
=
(
Field
*
)
sql_alloc
(
field_arg
->
field
->
size_of
());
if
(
!
def_field
)
return
1
;
memcpy
(
def_field
,
field_arg
->
field
,
field_arg
->
field
->
size_of
());
def_field
->
move_field
(
def_field
->
table
->
default_values
()
-
def_field
->
table
->
record
[
0
]);
set_field
(
def_field
);
return
0
;
}
void
Item_default_value
::
print
(
String
*
str
)
{
if
(
!
arg
)
{
str
->
append
(
"DEFAULT"
);
}
str
->
append
(
"DEFAULT("
);
arg
->
print
(
str
);
str
->
append
(
')'
);
}
/*
If item is a const function, calculate it and return a const item
...
...
sql/item.h
View file @
87681bb8
...
...
@@ -37,6 +37,7 @@ public:
PROC_ITEM
,
COND_ITEM
,
REF_ITEM
,
FIELD_STD_ITEM
,
FIELD_VARIANCE_ITEM
,
CONST_ITEM
,
SUBSELECT_ITEM
,
ROW_ITEM
,
CACHE_ITEM
};
enum
cond_result
{
COND_UNDEF
,
COND_OK
,
COND_TRUE
,
COND_FALSE
};
String
str_value
;
/* used to store value */
...
...
@@ -167,9 +168,9 @@ public:
bool
get_date
(
TIME
*
ltime
,
bool
fuzzydate
);
bool
get_time
(
TIME
*
ltime
);
bool
is_null
()
{
return
field
->
is_null
();
}
friend
class
Item_default_value
;
};
class
Item_null
:
public
Item
{
public:
...
...
@@ -370,26 +371,6 @@ public:
void
print
(
String
*
str
);
};
/* For INSERT ... VALUES (DEFAULT) */
class
Item_default
:
public
Item
{
public:
Item_default
()
{
name
=
(
char
*
)
"DEFAULT"
;
}
enum
Type
type
()
const
{
return
DEFAULT_ITEM
;
}
int
save_in_field
(
Field
*
field
,
bool
no_conversions
)
{
field
->
set_default
();
return
0
;
}
virtual
double
val
()
{
return
0.0
;
}
virtual
longlong
val_int
()
{
return
0
;
}
virtual
String
*
val_str
(
String
*
str
)
{
return
0
;
}
bool
basic_const_item
()
const
{
return
1
;
}
};
/* for show tables */
class
Item_datetime
:
public
Item_string
...
...
@@ -674,6 +655,41 @@ public:
bool
cmp
(
void
);
};
class
Item_default_value
:
public
Item_field
{
public:
Item
*
arg
;
Item_default_value
()
:
Item_field
((
const
char
*
)
NULL
,
(
const
char
*
)
NULL
,
(
const
char
*
)
NULL
),
arg
(
NULL
)
{}
Item_default_value
(
Item
*
a
)
:
Item_field
((
const
char
*
)
NULL
,
(
const
char
*
)
NULL
,
(
const
char
*
)
NULL
),
arg
(
a
)
{}
enum
Type
type
()
const
{
return
DEFAULT_ITEM
;
}
bool
eq
(
const
Item
*
item
,
bool
binary_cmp
)
const
;
bool
fix_fields
(
THD
*
,
struct
st_table_list
*
,
Item
**
);
bool
check_loop
(
uint
id
)
{
return
Item_field
::
check_loop
(
id
)
||
arg
->
check_loop
(
id
);
}
void
set_outer_resolving
()
{
arg
->
set_outer_resolving
();
}
void
print
(
String
*
str
);
virtual
bool
basic_const_item
()
const
{
return
true
;
}
int
save_in_field
(
Field
*
field
,
bool
no_conversions
)
{
if
(
!
arg
)
{
field
->
set_default
();
return
0
;
}
return
Item_field
::
save_in_field
(
field
,
no_conversions
);
}
table_map
used_tables
()
const
{
if
(
!
arg
)
return
(
table_map
)
0L
;
return
Item_field
::
used_tables
();
}
};
class
Item_cache
:
public
Item
{
public:
...
...
sql/sql_yacc.yy
View file @
87681bb8
...
...
@@ -1863,8 +1863,10 @@ optional_braces:
| '(' ')' {};
/* all possible expressions */
expr: expr_expr { $$= $1; }
| simple_expr { $$= $1; };
expr:
expr_expr { $$= $1; }
| simple_expr { $$= $1; }
;
comp_op: EQ { $$ = &comp_eq_creator; }
| GE { $$ = &comp_ge_creator; }
...
...
@@ -1880,7 +1882,7 @@ all_or_any: ALL { $$ = 1; }
/* expressions that begin with 'expr' */
expr_expr:
expr IN_SYM '(' expr_list ')'
expr IN_SYM '(' expr_list ')'
{ $$= new Item_func_in($1,*$4); }
| expr NOT IN_SYM '(' expr_list ')'
{ $$= new Item_func_not(new Item_func_in($1,*$5)); }
...
...
@@ -2087,6 +2089,8 @@ simple_expr:
{ $$= new Item_func_conv_charset($3,$5); }
| CONVERT_SYM '(' expr ',' expr ',' expr ')'
{ $$= new Item_func_conv_charset3($3,$7,$5); }
| DEFAULT '(' simple_ident ')'
{ $$= new Item_default_value($3); }
| FUNC_ARG0 '(' ')'
{ $$= ((Item*(*)(void))($1.symbol->create_func))();}
| FUNC_ARG1 '(' expr ')'
...
...
@@ -3178,7 +3182,7 @@ values:
expr_or_default:
expr { $$= $1;}
| DEFAULT {$$= new Item_default(); }
| DEFAULT {$$= new Item_default
_value
(); }
;
opt_insert_update:
...
...
@@ -3216,12 +3220,12 @@ update:
;
update_list:
update_list ',' simple_ident equal expr
update_list ',' simple_ident equal expr
_or_default
{
if (add_item_to_list(YYTHD, $3) || add_value_to_list(YYTHD, $5))
YYABORT;
}
| simple_ident equal expr
| simple_ident equal expr
_or_default
{
if (add_item_to_list(YYTHD, $1) || add_value_to_list(YYTHD, $3))
YYABORT;
...
...
sql/table.cc
View file @
87681bb8
...
...
@@ -260,7 +260,7 @@ int openfrm(const char *name, const char *alias, uint db_stat, uint prgflag,
if
(
db_stat
&
HA_READ_ONLY
)
outparam
->
record
[
1
]
=
outparam
->
record
[
0
];
/* purecov: inspected */
}
VOID
(
my_seek
(
file
,
pos
,
MY_SEEK_SET
,
MYF
(
0
)));
if
(
my_read
(
file
,(
byte
*
)
head
,
288
,
MYF
(
MY_NABP
)))
goto
err_not_open
;
if
(
crypted
)
...
...
sql/table.h
View file @
87681bb8
...
...
@@ -137,6 +137,7 @@ struct st_table {
uint
derived_select_number
;
THD
*
in_use
;
/* Which thread uses this */
struct
st_table
*
next
,
*
prev
;
byte
*
default_values
()
{
return
record
[
2
];
}
};
...
...
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