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
3046c3ca
Commit
3046c3ca
authored
Feb 28, 2003
by
bar@bar.mysql.r18.ru
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Many files:
Coercibility, initial stage item_func.h: Coercibility, initial stage
parent
959e1428
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
43 additions
and
6 deletions
+43
-6
sql/item.cc
sql/item.cc
+6
-2
sql/item.h
sql/item.h
+9
-3
sql/item_create.cc
sql/item_create.cc
+5
-0
sql/item_create.h
sql/item_create.h
+1
-0
sql/item_func.cc
sql/item_func.cc
+11
-0
sql/item_func.h
sql/item_func.h
+9
-0
sql/lex.h
sql/lex.h
+1
-0
sql/sql_yacc.yy
sql/sql_yacc.yy
+1
-1
No files found.
sql/item.cc
View file @
3046c3ca
...
...
@@ -39,6 +39,7 @@ Item::Item():
{
marker
=
0
;
maybe_null
=
null_value
=
with_sum_func
=
unsigned_flag
=
0
;
coercibility
=
COER_NOCOLL
;
name
=
0
;
decimals
=
0
;
max_length
=
0
;
THD
*
thd
=
current_thd
;
...
...
@@ -63,7 +64,8 @@ Item::Item(THD *thd, Item &item):
null_value
(
item
.
null_value
),
unsigned_flag
(
item
.
unsigned_flag
),
with_sum_func
(
item
.
with_sum_func
),
fixed
(
item
.
fixed
)
fixed
(
item
.
fixed
),
coercibility
(
item
.
coercibility
)
{
next
=
thd
->
free_list
;
// Put in free list
thd
->
free_list
=
this
;
...
...
@@ -169,6 +171,7 @@ CHARSET_INFO * Item::thd_charset() const
Item_field
::
Item_field
(
Field
*
f
)
:
Item_ident
(
NullS
,
f
->
table_name
,
f
->
field_name
)
{
set_field
(
f
);
coercibility
=
COER_IMPLICIT
;
fixed
=
1
;
// This item is not needed in fix_fields
}
...
...
@@ -177,7 +180,7 @@ Item_field::Item_field(THD *thd, Item_field &item):
Item_ident
(
thd
,
item
),
field
(
item
.
field
),
result_field
(
item
.
result_field
)
{}
{
coercibility
=
COER_IMPLICIT
;
}
void
Item_field
::
set_field
(
Field
*
field_par
)
{
...
...
@@ -189,6 +192,7 @@ void Item_field::set_field(Field *field_par)
field_name
=
field_par
->
field_name
;
unsigned_flag
=
test
(
field_par
->
flags
&
UNSIGNED_FLAG
);
set_charset
(
field_par
->
charset
());
coercibility
=
COER_IMPLICIT
;
}
const
char
*
Item_ident
::
full_name
()
const
...
...
sql/item.h
View file @
3046c3ca
...
...
@@ -39,6 +39,8 @@ class Item {
SUBSELECT_ITEM
,
ROW_ITEM
,
CACHE_ITEM
};
enum
cond_result
{
COND_UNDEF
,
COND_OK
,
COND_TRUE
,
COND_FALSE
};
enum
coercion
{
COER_NOCOLL
=
0
,
COER_COERCIBLE
=
1
,
COER_IMPLICIT
=
2
,
COER_EXPLICIT
=
3
};
String
str_value
;
/* used to store value */
my_string
name
;
/* Name from select */
...
...
@@ -50,6 +52,7 @@ class Item {
my_bool
unsigned_flag
;
my_bool
with_sum_func
;
my_bool
fixed
;
/* If item fixed with fix_fields */
enum
coercion
coercibility
;
/* Precedence order of collation */
// alloc & destruct is done as start of select using sql_alloc
Item
();
...
...
@@ -155,7 +158,7 @@ class Item_field :public Item_ident
Item_field
(
const
char
*
db_par
,
const
char
*
table_name_par
,
const
char
*
field_name_par
)
:
Item_ident
(
db_par
,
table_name_par
,
field_name_par
),
field
(
0
),
result_field
(
0
)
{}
{
coercibility
=
COER_IMPLICIT
;
}
// Constructor need to process subselect with temporary tables (see Item)
Item_field
(
THD
*
thd
,
Item_field
&
item
);
Item_field
(
Field
*
field
);
...
...
@@ -350,17 +353,20 @@ class Item_float :public Item_real
class
Item_string
:
public
Item
{
public:
Item_string
(
const
char
*
str
,
uint
length
,
CHARSET_INFO
*
cs
)
Item_string
(
const
char
*
str
,
uint
length
,
CHARSET_INFO
*
cs
,
enum
coercion
coer
=
COER_COERCIBLE
)
{
str_value
.
set
(
str
,
length
,
cs
);
coercibility
=
coer
;
max_length
=
length
;
name
=
(
char
*
)
str_value
.
ptr
();
decimals
=
NOT_FIXED_DEC
;
}
Item_string
(
const
char
*
name_par
,
const
char
*
str
,
uint
length
,
CHARSET_INFO
*
cs
)
CHARSET_INFO
*
cs
,
enum
coercion
coer
=
COER_COERCIBLE
)
{
str_value
.
set
(
str
,
length
,
cs
);
coercibility
=
coer
;
max_length
=
length
;
name
=
(
char
*
)
name_par
;
decimals
=
NOT_FIXED_DEC
;
...
...
sql/item_create.cc
View file @
3046c3ca
...
...
@@ -230,6 +230,11 @@ Item *create_func_bit_length(Item* a)
return
new
Item_func_bit_length
(
a
);
}
Item
*
create_func_coercibility
(
Item
*
a
)
{
return
new
Item_func_coercibility
(
a
);
}
Item
*
create_func_char_length
(
Item
*
a
)
{
return
new
Item_func_char_length
(
a
);
...
...
sql/item_create.h
View file @
3046c3ca
...
...
@@ -25,6 +25,7 @@ Item *create_func_asin(Item* a);
Item
*
create_func_bin
(
Item
*
a
);
Item
*
create_func_bit_count
(
Item
*
a
);
Item
*
create_func_bit_length
(
Item
*
a
);
Item
*
create_func_coercibility
(
Item
*
a
);
Item
*
create_func_ceiling
(
Item
*
a
);
Item
*
create_func_char_length
(
Item
*
a
);
Item
*
create_func_cast
(
Item
*
a
,
Item_cast
cast_type
);
...
...
sql/item_func.cc
View file @
3046c3ca
...
...
@@ -107,6 +107,7 @@ Item_func::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
return
0
;
// Fatal error if flag is set!
if
(
arg_count
)
{
// Print purify happy
coercibility
=
COER_NOCOLL
;
for
(
arg
=
args
,
arg_end
=
args
+
arg_count
;
arg
!=
arg_end
;
arg
++
)
{
if
((
*
arg
)
->
fix_fields
(
thd
,
tables
,
arg
)
||
...
...
@@ -1004,6 +1005,16 @@ longlong Item_func_char_length::val_int()
return
(
longlong
)
(
!
args
[
0
]
->
binary
())
?
res
->
numchars
()
:
res
->
length
();
}
longlong
Item_func_coercibility
::
val_int
()
{
if
(
args
[
0
]
->
null_value
)
{
null_value
=
1
;
return
0
;
}
null_value
=
0
;
return
(
longlong
)
args
[
0
]
->
coercibility
;
}
longlong
Item_func_locate
::
val_int
()
{
...
...
sql/item_func.h
View file @
3046c3ca
...
...
@@ -590,6 +590,15 @@ class Item_func_char_length :public Item_int_func
void
fix_length_and_dec
()
{
max_length
=
10
;
}
};
class
Item_func_coercibility
:
public
Item_int_func
{
public:
Item_func_coercibility
(
Item
*
a
)
:
Item_int_func
(
a
)
{}
longlong
val_int
();
const
char
*
func_name
()
const
{
return
"coercibility"
;
}
void
fix_length_and_dec
()
{
max_length
=
10
;
}
};
class
Item_func_locate
:
public
Item_int_func
{
String
value1
,
value2
;
...
...
sql/lex.h
View file @
3046c3ca
...
...
@@ -441,6 +441,7 @@ static SYMBOL sql_functions[] = {
{
"CHAR_LENGTH"
,
SYM
(
FUNC_ARG1
),
0
,
CREATE_FUNC
(
create_func_char_length
)},
{
"CHARACTER_LENGTH"
,
SYM
(
FUNC_ARG1
),
0
,
CREATE_FUNC
(
create_func_char_length
)},
{
"COALESCE"
,
SYM
(
COALESCE
),
0
,
0
},
{
"COERCIBILITY"
,
SYM
(
FUNC_ARG1
),
0
,
CREATE_FUNC
(
create_func_coercibility
)},
{
"CONCAT"
,
SYM
(
CONCAT
),
0
,
0
},
{
"CONCAT_WS"
,
SYM
(
CONCAT_WS
),
0
,
0
},
{
"CONNECTION_ID"
,
SYM
(
FUNC_ARG0
),
0
,
CREATE_FUNC
(
create_func_connection_id
)},
...
...
sql/sql_yacc.yy
View file @
3046c3ca
...
...
@@ -3778,7 +3778,7 @@ text_literal:
{ $$ = new Item_string($1.str,$1.length,
YYTHD->variables.thd_charset); }
| UNDERSCORE_CHARSET TEXT_STRING
{ $$ = new Item_string($2.str,$2.length,Lex->charset); }
{ $$ = new Item_string($2.str,$2.length,Lex->charset
,Item::COER_EXPLICIT
); }
| text_literal TEXT_STRING
{ ((Item_string*) $1)->append($2.str,$2.length); };
...
...
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