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
516cc6b4
Commit
516cc6b4
authored
Aug 06, 2002
by
unknown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
New CRC32() SQL function
parent
a7b1c856
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
30 additions
and
0 deletions
+30
-0
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
+13
-0
sql/item_func.h
sql/item_func.h
+10
-0
sql/lex.h
sql/lex.h
+1
-0
No files found.
sql/item_create.cc
View file @
516cc6b4
...
...
@@ -86,6 +86,11 @@ Item *create_func_cot(Item* a)
new
Item_func_tan
(
a
));
}
Item
*
create_func_crc32
(
Item
*
a
)
{
return
new
Item_func_crc32
(
a
);
}
Item
*
create_func_date_format
(
Item
*
a
,
Item
*
b
)
{
return
new
Item_func_date_format
(
a
,
b
,
0
);
...
...
sql/item_create.h
View file @
516cc6b4
...
...
@@ -29,6 +29,7 @@ Item *create_func_connection_id(void);
Item
*
create_func_conv
(
Item
*
a
,
Item
*
b
,
Item
*
c
);
Item
*
create_func_cos
(
Item
*
a
);
Item
*
create_func_cot
(
Item
*
a
);
Item
*
create_func_crc32
(
Item
*
a
);
Item
*
create_func_date_format
(
Item
*
a
,
Item
*
b
);
Item
*
create_func_dayname
(
Item
*
a
);
Item
*
create_func_dayofmonth
(
Item
*
a
);
...
...
sql/item_func.cc
View file @
516cc6b4
...
...
@@ -26,6 +26,7 @@
#include <hash.h>
#include <time.h>
#include <ft_global.h>
#include <zlib.h>
#include "slave.h" // for wait_for_master_pos
#include "gstream.h"
...
...
@@ -801,6 +802,18 @@ longlong Item_func_min_max::val_int()
return
value
;
}
longlong
Item_func_crc32
::
val_int
()
{
String
*
res
=
args
[
0
]
->
val_str
(
&
value
);
if
(
!
res
)
{
null_value
=
1
;
return
0
;
/* purecov: inspected */
}
null_value
=
0
;
return
(
longlong
)
crc32
(
0L
,
(
Bytef
*
)
res
->
ptr
(),
res
->
length
());
}
longlong
Item_func_length
::
val_int
()
{
...
...
sql/item_func.h
View file @
516cc6b4
...
...
@@ -518,6 +518,16 @@ class Item_func_max :public Item_func_min_max
const
char
*
func_name
()
const
{
return
"greatest"
;
}
};
class
Item_func_crc32
:
public
Item_int_func
{
String
value
;
public:
Item_func_crc32
(
Item
*
a
)
:
Item_int_func
(
a
)
{}
longlong
val_int
();
const
char
*
func_name
()
const
{
return
"crc32"
;
}
void
fix_length_and_dec
()
{
max_length
=
10
;
}
};
class
Item_func_length
:
public
Item_int_func
{
...
...
sql/lex.h
View file @
516cc6b4
...
...
@@ -430,6 +430,7 @@ static SYMBOL sql_functions[] = {
{
"COUNT"
,
SYM
(
COUNT_SYM
),
0
,
0
},
{
"COS"
,
SYM
(
FUNC_ARG1
),
0
,
CREATE_FUNC
(
create_func_cos
)},
{
"COT"
,
SYM
(
FUNC_ARG1
),
0
,
CREATE_FUNC
(
create_func_cot
)},
{
"CRC32"
,
SYM
(
FUNC_ARG1
),
0
,
CREATE_FUNC
(
create_func_crc32
)},
{
"CROSSES"
,
SYM
(
FUNC_ARG2
),
0
,
CREATE_FUNC
(
create_func_crosses
)},
{
"CURDATE"
,
SYM
(
CURDATE
),
0
,
0
},
{
"CURTIME"
,
SYM
(
CURTIME
),
0
,
0
},
...
...
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