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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
9fb261e3
Commit
9fb261e3
authored
Jan 21, 2003
by
hf@deer.mysql.r18.ru
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SCRUM
Default in UPDATE & SELECT
parent
9967da94
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
43 additions
and
36 deletions
+43
-36
sql/field.h
sql/field.h
+1
-1
sql/item.cc
sql/item.cc
+12
-3
sql/item.h
sql/item.h
+21
-23
sql/sql_yacc.yy
sql/sql_yacc.yy
+8
-6
sql/table.cc
sql/table.cc
+0
-2
sql/table.h
sql/table.h
+1
-1
No files found.
sql/field.h
View file @
9fb261e3
...
@@ -78,7 +78,7 @@ class Field
...
@@ -78,7 +78,7 @@ class Field
virtual
void
reset_fields
()
{}
virtual
void
reset_fields
()
{}
virtual
void
set_default
()
virtual
void
set_default
()
{
{
my_ptrdiff_t
offset
=
table
->
default_values
-
table
->
record
[
0
];
my_ptrdiff_t
offset
=
table
->
default_values
()
-
table
->
record
[
0
];
memcpy
(
ptr
,
ptr
+
offset
,
pack_length
());
memcpy
(
ptr
,
ptr
+
offset
,
pack_length
());
if
(
null_ptr
)
if
(
null_ptr
)
*
null_ptr
=
((
*
null_ptr
&
(
uchar
)
~
null_bit
)
|
*
null_ptr
=
((
*
null_ptr
&
(
uchar
)
~
null_bit
)
|
...
...
sql/item.cc
View file @
9fb261e3
...
@@ -1121,15 +1121,20 @@ bool Item_ref::check_loop(uint id)
...
@@ -1121,15 +1121,20 @@ bool Item_ref::check_loop(uint id)
bool
Item_default_value
::
eq
(
const
Item
*
item
,
bool
binary_cmp
)
const
bool
Item_default_value
::
eq
(
const
Item
*
item
,
bool
binary_cmp
)
const
{
{
return
item
->
type
()
==
DEFAULT_
VALUE_
ITEM
&&
return
item
->
type
()
==
DEFAULT_ITEM
&&
((
Item_default_value
*
)
item
)
->
arg
->
eq
(
arg
,
binary_cmp
);
((
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
)
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
);
bool
res
=
arg
->
fix_fields
(
thd
,
table_list
,
items
);
if
(
res
)
if
(
res
)
return
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
)
if
(
arg
->
type
()
==
REF_ITEM
)
{
{
Item_ref
*
ref
=
(
Item_ref
*
)
arg
;
Item_ref
*
ref
=
(
Item_ref
*
)
arg
;
...
@@ -1144,7 +1149,7 @@ bool Item_default_value::fix_fields(THD *thd, struct st_table_list *table_list,
...
@@ -1144,7 +1149,7 @@ bool Item_default_value::fix_fields(THD *thd, struct st_table_list *table_list,
if
(
!
def_field
)
if
(
!
def_field
)
return
1
;
return
1
;
memcpy
(
def_field
,
field_arg
->
field
,
field_arg
->
field
->
size_of
());
memcpy
(
def_field
,
field_arg
->
field
,
field_arg
->
field
->
size_of
());
def_field
->
move_field
(
def_field
->
table
->
default_values
-
def_field
->
move_field
(
def_field
->
table
->
default_values
()
-
def_field
->
table
->
record
[
0
]);
def_field
->
table
->
record
[
0
]);
set_field
(
def_field
);
set_field
(
def_field
);
return
0
;
return
0
;
...
@@ -1152,7 +1157,11 @@ bool Item_default_value::fix_fields(THD *thd, struct st_table_list *table_list,
...
@@ -1152,7 +1157,11 @@ bool Item_default_value::fix_fields(THD *thd, struct st_table_list *table_list,
void
Item_default_value
::
print
(
String
*
str
)
void
Item_default_value
::
print
(
String
*
str
)
{
{
str
->
append
(
"default("
);
if
(
!
arg
)
{
str
->
append
(
"DEFAULT"
);
}
str
->
append
(
"DEFAULT("
);
arg
->
print
(
str
);
arg
->
print
(
str
);
str
->
append
(
')'
);
str
->
append
(
')'
);
}
}
...
...
sql/item.h
View file @
9fb261e3
...
@@ -36,8 +36,8 @@ class Item {
...
@@ -36,8 +36,8 @@ class Item {
COPY_STR_ITEM
,
FIELD_AVG_ITEM
,
DEFAULT_ITEM
,
COPY_STR_ITEM
,
FIELD_AVG_ITEM
,
DEFAULT_ITEM
,
PROC_ITEM
,
COND_ITEM
,
REF_ITEM
,
FIELD_STD_ITEM
,
PROC_ITEM
,
COND_ITEM
,
REF_ITEM
,
FIELD_STD_ITEM
,
FIELD_VARIANCE_ITEM
,
CONST_ITEM
,
FIELD_VARIANCE_ITEM
,
CONST_ITEM
,
SUBSELECT_ITEM
,
ROW_ITEM
,
CACHE_ITEM
,
SUBSELECT_ITEM
,
ROW_ITEM
,
CACHE_ITEM
};
DEFAULT_VALUE_ITEM
};
enum
cond_result
{
COND_UNDEF
,
COND_OK
,
COND_TRUE
,
COND_FALSE
};
enum
cond_result
{
COND_UNDEF
,
COND_OK
,
COND_TRUE
,
COND_FALSE
};
String
str_value
;
/* used to store value */
String
str_value
;
/* used to store value */
...
@@ -369,26 +369,6 @@ class Item_string :public Item
...
@@ -369,26 +369,6 @@ class Item_string :public Item
void
print
(
String
*
str
);
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 */
/* for show tables */
class
Item_datetime
:
public
Item_string
class
Item_datetime
:
public
Item_string
...
@@ -669,9 +649,11 @@ class Item_default_value : public Item_field
...
@@ -669,9 +649,11 @@ class Item_default_value : public Item_field
{
{
public:
public:
Item
*
arg
;
Item
*
arg
;
Item_default_value
()
:
Item_field
((
const
char
*
)
NULL
,
(
const
char
*
)
NULL
,
(
const
char
*
)
NULL
),
arg
(
NULL
)
{}
Item_default_value
(
Item
*
a
)
:
Item_default_value
(
Item
*
a
)
:
Item_field
((
const
char
*
)
NULL
,
(
const
char
*
)
NULL
,
(
const
char
*
)
NULL
),
arg
(
a
)
{}
Item_field
((
const
char
*
)
NULL
,
(
const
char
*
)
NULL
,
(
const
char
*
)
NULL
),
arg
(
a
)
{}
enum
Type
type
()
const
{
return
DEFAULT_
VALUE_
ITEM
;
}
enum
Type
type
()
const
{
return
DEFAULT_ITEM
;
}
bool
eq
(
const
Item
*
item
,
bool
binary_cmp
)
const
;
bool
eq
(
const
Item
*
item
,
bool
binary_cmp
)
const
;
bool
fix_fields
(
THD
*
,
struct
st_table_list
*
,
Item
**
);
bool
fix_fields
(
THD
*
,
struct
st_table_list
*
,
Item
**
);
bool
check_loop
(
uint
id
)
bool
check_loop
(
uint
id
)
...
@@ -680,6 +662,22 @@ class Item_default_value : public Item_field
...
@@ -680,6 +662,22 @@ class Item_default_value : public Item_field
}
}
void
set_outer_resolving
()
{
arg
->
set_outer_resolving
();
}
void
set_outer_resolving
()
{
arg
->
set_outer_resolving
();
}
void
print
(
String
*
str
);
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
class
Item_cache
:
public
Item
...
...
sql/sql_yacc.yy
View file @
9fb261e3
...
@@ -1831,8 +1831,10 @@ optional_braces:
...
@@ -1831,8 +1831,10 @@ optional_braces:
| '(' ')' {};
| '(' ')' {};
/* all possible expressions */
/* all possible expressions */
expr: expr_expr { $$= $1; }
expr:
| simple_expr { $$= $1; };
expr_expr { $$= $1; }
| simple_expr { $$= $1; }
;
comp_op: EQ { $$ = &comp_eq_creator; }
comp_op: EQ { $$ = &comp_eq_creator; }
| GE { $$ = &comp_ge_creator; }
| GE { $$ = &comp_ge_creator; }
...
@@ -1848,7 +1850,7 @@ all_or_any: ALL { $$ = 1; }
...
@@ -1848,7 +1850,7 @@ all_or_any: ALL { $$ = 1; }
/* expressions that begin with 'expr' */
/* expressions that begin with 'expr' */
expr_expr:
expr_expr:
expr IN_SYM '(' expr_list ')'
expr IN_SYM '(' expr_list ')'
{ $$= new Item_func_in($1,*$4); }
{ $$= new Item_func_in($1,*$4); }
| expr NOT IN_SYM '(' expr_list ')'
| expr NOT IN_SYM '(' expr_list ')'
{ $$= new Item_func_not(new Item_func_in($1,*$5)); }
{ $$= new Item_func_not(new Item_func_in($1,*$5)); }
...
@@ -2055,10 +2057,10 @@ simple_expr:
...
@@ -2055,10 +2057,10 @@ simple_expr:
{ $$= new Item_func_conv_charset($3,$5); }
{ $$= new Item_func_conv_charset($3,$5); }
| CONVERT_SYM '(' expr ',' expr ',' expr ')'
| CONVERT_SYM '(' expr ',' expr ',' expr ')'
{ $$= new Item_func_conv_charset3($3,$7,$5); }
{ $$= new Item_func_conv_charset3($3,$7,$5); }
| FUNC_ARG0 '(' ')'
{ $$= ((Item*(*)(void))($1.symbol->create_func))();}
| DEFAULT '(' simple_ident ')'
| DEFAULT '(' simple_ident ')'
{ $$= new Item_default_value($3); }
{ $$= new Item_default_value($3); }
| FUNC_ARG0 '(' ')'
{ $$= ((Item*(*)(void))($1.symbol->create_func))();}
| FUNC_ARG1 '(' expr ')'
| FUNC_ARG1 '(' expr ')'
{ $$= ((Item*(*)(Item*))($1.symbol->create_func))($3);}
{ $$= ((Item*(*)(Item*))($1.symbol->create_func))($3);}
| FUNC_ARG2 '(' expr ',' expr ')'
| FUNC_ARG2 '(' expr ',' expr ')'
...
@@ -3122,7 +3124,7 @@ values:
...
@@ -3122,7 +3124,7 @@ values:
expr_or_default:
expr_or_default:
expr { $$= $1;}
expr { $$= $1;}
| DEFAULT {$$= new Item_default(); }
| DEFAULT {$$= new Item_default
_value
(); }
;
;
opt_insert_update:
opt_insert_update:
...
...
sql/table.cc
View file @
9fb261e3
...
@@ -261,8 +261,6 @@ int openfrm(const char *name, const char *alias, uint db_stat, uint prgflag,
...
@@ -261,8 +261,6 @@ int openfrm(const char *name, const char *alias, uint db_stat, uint prgflag,
outparam
->
record
[
1
]
=
outparam
->
record
[
0
];
/* purecov: inspected */
outparam
->
record
[
1
]
=
outparam
->
record
[
0
];
/* purecov: inspected */
}
}
outparam
->
default_values
=
outparam
->
record
[
2
];
VOID
(
my_seek
(
file
,
pos
,
MY_SEEK_SET
,
MYF
(
0
)));
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
(
my_read
(
file
,(
byte
*
)
head
,
288
,
MYF
(
MY_NABP
)))
goto
err_not_open
;
if
(
crypted
)
if
(
crypted
)
...
...
sql/table.h
View file @
9fb261e3
...
@@ -54,7 +54,6 @@ struct st_table {
...
@@ -54,7 +54,6 @@ struct st_table {
Field_blob
**
blob_field
;
/* Pointer to blob fields */
Field_blob
**
blob_field
;
/* Pointer to blob fields */
HASH
name_hash
;
/* hash of field names */
HASH
name_hash
;
/* hash of field names */
byte
*
record
[
3
];
/* Pointer to records */
byte
*
record
[
3
];
/* Pointer to records */
byte
*
default_values
;
uint
fields
;
/* field count */
uint
fields
;
/* field count */
uint
reclength
;
/* Recordlength */
uint
reclength
;
/* Recordlength */
uint
rec_buff_length
;
uint
rec_buff_length
;
...
@@ -137,6 +136,7 @@ struct st_table {
...
@@ -137,6 +136,7 @@ struct st_table {
uint
derived_select_number
;
uint
derived_select_number
;
THD
*
in_use
;
/* Which thread uses this */
THD
*
in_use
;
/* Which thread uses this */
struct
st_table
*
next
,
*
prev
;
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