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
5ab46afc
Commit
5ab46afc
authored
Apr 22, 2003
by
unknown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
small compress/uncompress modification after monty's review
parent
7c87a3f1
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
43 additions
and
39 deletions
+43
-39
mysql-test/r/func_compress.result
mysql-test/r/func_compress.result
+12
-5
mysql-test/t/func_compress.test
mysql-test/t/func_compress.test
+7
-2
sql/item_create.cc
sql/item_create.cc
+7
-1
sql/item_create.h
sql/item_create.h
+0
-2
sql/item_func.cc
sql/item_func.cc
+2
-1
sql/item_strfunc.cc
sql/item_strfunc.cc
+15
-24
sql/lex.h
sql/lex.h
+0
-4
No files found.
mysql-test/r/func_compress.result
View file @
5ab46afc
...
@@ -7,11 +7,6 @@ length(@test_compress_string)
...
@@ -7,11 +7,6 @@ length(@test_compress_string)
select uncompress(compress(@test_compress_string));
select uncompress(compress(@test_compress_string));
uncompress(compress(@test_compress_string))
uncompress(compress(@test_compress_string))
string for test compress function aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
string for test compress function aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
select uncompress(@test_compress_string);
uncompress(@test_compress_string)
NULL
Warnings:
Error 1254 Too big size of uncompressed data. The maximum size is 8192. (probably, length of uncompressed data was corrupted)
select uncompressed_length(compress(@test_compress_string))=length(@test_compress_string);
select uncompressed_length(compress(@test_compress_string))=length(@test_compress_string);
uncompressed_length(compress(@test_compress_string))=length(@test_compress_string)
uncompressed_length(compress(@test_compress_string))=length(@test_compress_string)
1
1
...
@@ -33,3 +28,15 @@ select concat('|',c,'|') from t1;
...
@@ -33,3 +28,15 @@ select concat('|',c,'|') from t1;
concat('|',c,'|')
concat('|',c,'|')
|d|
|d|
drop table t1;
drop table t1;
select compress("");
compress("")
select uncompress("");
uncompress("")
select uncompress(compress(""));
uncompress(compress(""))
select uncompressed_length("");
uncompressed_length("")
0
mysql-test/t/func_compress.test
View file @
5ab46afc
...
@@ -7,7 +7,6 @@ select @test_compress_string:='string for test compress function aaaaaaaaaaaaaaa
...
@@ -7,7 +7,6 @@ select @test_compress_string:='string for test compress function aaaaaaaaaaaaaaa
select
length
(
@
test_compress_string
);
select
length
(
@
test_compress_string
);
select
uncompress
(
compress
(
@
test_compress_string
));
select
uncompress
(
compress
(
@
test_compress_string
));
select
uncompress
(
@
test_compress_string
);
select
uncompressed_length
(
compress
(
@
test_compress_string
))
=
length
(
@
test_compress_string
);
select
uncompressed_length
(
compress
(
@
test_compress_string
))
=
length
(
@
test_compress_string
);
select
uncompressed_length
(
compress
(
@
test_compress_string
));
select
uncompressed_length
(
compress
(
@
test_compress_string
));
select
length
(
compress
(
@
test_compress_string
))
<
length
(
@
test_compress_string
);
select
length
(
compress
(
@
test_compress_string
))
<
length
(
@
test_compress_string
);
...
@@ -18,3 +17,9 @@ select uncompress(a) from t1;
...
@@ -18,3 +17,9 @@ select uncompress(a) from t1;
select
uncompress
(
b
)
from
t1
;
select
uncompress
(
b
)
from
t1
;
select
concat
(
'|'
,
c
,
'|'
)
from
t1
;
select
concat
(
'|'
,
c
,
'|'
)
from
t1
;
drop
table
t1
;
drop
table
t1
;
select
compress
(
""
);
select
uncompress
(
""
);
select
uncompress
(
compress
(
""
));
select
uncompressed_length
(
""
);
sql/item_create.cc
View file @
5ab46afc
...
@@ -646,7 +646,13 @@ Item *create_func_point(Item *a, Item *b)
...
@@ -646,7 +646,13 @@ Item *create_func_point(Item *a, Item *b)
return
new
Item_func_point
(
a
,
b
);
return
new
Item_func_point
(
a
,
b
);
}
}
#ifdef HAVE_COMPRESS
#if !defined(HAVE_COMPRESS)
Item
*
create_func_compress
(
Item
*
a
__attribute__
((
unused
))){
return
0
;}
Item
*
create_func_uncompress
(
Item
*
a
__attribute__
((
unused
))){
return
0
;}
Item
*
create_func_uncompressed_length
(
Item
*
a
__attribute__
((
unused
))){
return
0
;}
#else
Item
*
create_func_compress
(
Item
*
a
)
Item
*
create_func_compress
(
Item
*
a
)
{
{
...
...
sql/item_create.h
View file @
5ab46afc
...
@@ -142,9 +142,7 @@ Item *create_func_numgeometries(Item *a);
...
@@ -142,9 +142,7 @@ Item *create_func_numgeometries(Item *a);
Item
*
create_func_point
(
Item
*
a
,
Item
*
b
);
Item
*
create_func_point
(
Item
*
a
,
Item
*
b
);
#ifdef HAVE_COMPRESS
Item
*
create_func_compress
(
Item
*
a
);
Item
*
create_func_compress
(
Item
*
a
);
Item
*
create_func_uncompress
(
Item
*
a
);
Item
*
create_func_uncompress
(
Item
*
a
);
Item
*
create_func_uncompressed_length
(
Item
*
a
);
Item
*
create_func_uncompressed_length
(
Item
*
a
);
#endif
sql/item_func.cc
View file @
5ab46afc
...
@@ -993,7 +993,8 @@ longlong Item_func_uncompressed_length::val_int()
...
@@ -993,7 +993,8 @@ longlong Item_func_uncompressed_length::val_int()
return
0
;
/* purecov: inspected */
return
0
;
/* purecov: inspected */
}
}
null_value
=
0
;
null_value
=
0
;
return
uint4korr
(
res
->
c_ptr
());
if
(
res
->
is_empty
())
return
0
;
return
uint4korr
(
res
->
c_ptr
())
&
0x3FFFFFFF
;
}
}
#endif
/* HAVE_COMPRESS */
#endif
/* HAVE_COMPRESS */
...
...
sql/item_strfunc.cc
View file @
5ab46afc
...
@@ -2924,6 +2924,8 @@ ret:
...
@@ -2924,6 +2924,8 @@ ret:
String
*
Item_func_compress
::
val_str
(
String
*
str
)
String
*
Item_func_compress
::
val_str
(
String
*
str
)
{
{
String
*
res
=
args
[
0
]
->
val_str
(
str
);
String
*
res
=
args
[
0
]
->
val_str
(
str
);
if
(
res
->
is_empty
())
return
res
;
int
err
=
Z_OK
;
int
err
=
Z_OK
;
int
code
;
int
code
;
...
@@ -2939,14 +2941,13 @@ String *Item_func_compress::val_str(String *str)
...
@@ -2939,14 +2941,13 @@ String *Item_func_compress::val_str(String *str)
compress(compress(compress(...)))
compress(compress(compress(...)))
I.e. zlib give number 'at least'..
I.e. zlib give number 'at least'..
*/
*/
uLongf
new_size
=
(
uLongf
)((
res
->
length
()
*
120
)
/
100
)
+
12
;
ulong
new_size
=
(
ulong
)((
res
->
length
()
*
120
)
/
100
)
+
12
;
buffer
.
realloc
((
uint32
)
new_size
+
sizeof
(
int32
)
+
sizeof
(
char
));
Byte
*
body
=
((
Byte
*
)
buffer
.
c_ptr
())
+
sizeof
(
int32
);
buffer
.
realloc
((
uint32
)
new_size
+
4
);
err
=
compress
(
body
,
&
new_size
,(
const
Bytef
*
)
res
->
c_ptr
(),
res
->
length
())
;
Byte
*
body
=
((
Byte
*
)
buffer
.
c_ptr
())
+
4
;
if
(
err
!=
Z_OK
)
if
((
err
=
compress
(
body
,
&
new_size
,
(
const
Bytef
*
)
res
->
c_ptr
(),
res
->
length
()))
!=
Z_OK
)
{
{
code
=
err
==
Z_MEM_ERROR
?
ER_ZLIB_Z_MEM_ERROR
:
ER_ZLIB_Z_BUF_ERROR
;
code
=
err
==
Z_MEM_ERROR
?
ER_ZLIB_Z_MEM_ERROR
:
ER_ZLIB_Z_BUF_ERROR
;
push_warning
(
current_thd
,
MYSQL_ERROR
::
WARN_LEVEL_ERROR
,
code
,
ER
(
code
));
push_warning
(
current_thd
,
MYSQL_ERROR
::
WARN_LEVEL_ERROR
,
code
,
ER
(
code
));
...
@@ -2954,18 +2955,8 @@ String *Item_func_compress::val_str(String *str)
...
@@ -2954,18 +2955,8 @@ String *Item_func_compress::val_str(String *str)
return
0
;
return
0
;
}
}
int4store
(
buffer
.
c_ptr
(),
res
->
length
());
int4store
(
buffer
.
c_ptr
(),
res
->
length
()
&
0x3FFFFFFF
);
buffer
.
length
((
uint32
)
new_size
+
sizeof
(
int32
));
buffer
.
length
((
uint32
)
new_size
+
4
);
/* This is for the stupid char fields which trimm ' ': */
char
*
last_char
=
((
char
*
)
body
)
+
new_size
-
1
;
if
(
*
last_char
==
' '
)
{
*++
last_char
=
'.'
;
new_size
++
;
}
buffer
.
length
((
uint32
)
new_size
+
sizeof
(
int32
));
return
&
buffer
;
return
&
buffer
;
}
}
...
@@ -2973,7 +2964,9 @@ String *Item_func_compress::val_str(String *str)
...
@@ -2973,7 +2964,9 @@ String *Item_func_compress::val_str(String *str)
String
*
Item_func_uncompress
::
val_str
(
String
*
str
)
String
*
Item_func_uncompress
::
val_str
(
String
*
str
)
{
{
String
*
res
=
args
[
0
]
->
val_str
(
str
);
String
*
res
=
args
[
0
]
->
val_str
(
str
);
uLongf
new_size
=
uint4korr
(
res
->
c_ptr
());
if
(
res
->
is_empty
())
return
res
;
ulong
new_size
=
uint4korr
(
res
->
c_ptr
())
&
0x3FFFFFFF
;
int
err
=
Z_OK
;
int
err
=
Z_OK
;
uint
code
;
uint
code
;
...
@@ -2982,16 +2975,14 @@ String *Item_func_uncompress::val_str(String *str)
...
@@ -2982,16 +2975,14 @@ String *Item_func_uncompress::val_str(String *str)
push_warning_printf
(
current_thd
,
MYSQL_ERROR
::
WARN_LEVEL_ERROR
,
push_warning_printf
(
current_thd
,
MYSQL_ERROR
::
WARN_LEVEL_ERROR
,
ER_TOO_BIG_FOR_UNCOMPRESS
,
ER_TOO_BIG_FOR_UNCOMPRESS
,
ER
(
ER_TOO_BIG_FOR_UNCOMPRESS
),
MAX_BLOB_WIDTH
);
ER
(
ER_TOO_BIG_FOR_UNCOMPRESS
),
MAX_BLOB_WIDTH
);
null_value
=
1
;
null_value
=
0
;
return
0
;
return
0
;
}
}
buffer
.
realloc
((
uint32
)
new_size
);
buffer
.
realloc
((
uint32
)
new_size
);
err
=
uncompress
((
Byte
*
)
buffer
.
c_ptr
(),
&
new_size
,
if
((
err
=
uncompress
((
Byte
*
)
buffer
.
c_ptr
(),
&
new_size
,
((
const
Bytef
*
)
res
->
c_ptr
())
+
sizeof
(
int32
),
res
->
length
());
((
const
Bytef
*
)
res
->
c_ptr
())
+
4
,
res
->
length
()))
==
Z_OK
)
if
(
err
==
Z_OK
)
{
{
buffer
.
length
((
uint32
)
new_size
);
buffer
.
length
((
uint32
)
new_size
);
return
&
buffer
;
return
&
buffer
;
...
...
sql/lex.h
View file @
5ab46afc
...
@@ -448,9 +448,7 @@ static SYMBOL sql_functions[] = {
...
@@ -448,9 +448,7 @@ static SYMBOL sql_functions[] = {
{
"CHARACTER_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
},
{
"COALESCE"
,
SYM
(
COALESCE
),
0
,
0
},
{
"COERCIBILITY"
,
SYM
(
FUNC_ARG1
),
0
,
CREATE_FUNC
(
create_func_coercibility
)},
{
"COERCIBILITY"
,
SYM
(
FUNC_ARG1
),
0
,
CREATE_FUNC
(
create_func_coercibility
)},
#ifdef HAVE_COMPRESS
{
"COMPRESS"
,
SYM
(
FUNC_ARG1
),
0
,
CREATE_FUNC
(
create_func_compress
)},
{
"COMPRESS"
,
SYM
(
FUNC_ARG1
),
0
,
CREATE_FUNC
(
create_func_compress
)},
#endif
{
"CONCAT"
,
SYM
(
CONCAT
),
0
,
0
},
{
"CONCAT"
,
SYM
(
CONCAT
),
0
,
0
},
{
"CONCAT_WS"
,
SYM
(
CONCAT_WS
),
0
,
0
},
{
"CONCAT_WS"
,
SYM
(
CONCAT_WS
),
0
,
0
},
{
"CONNECTION_ID"
,
SYM
(
FUNC_ARG0
),
0
,
CREATE_FUNC
(
create_func_connection_id
)},
{
"CONNECTION_ID"
,
SYM
(
FUNC_ARG0
),
0
,
CREATE_FUNC
(
create_func_connection_id
)},
...
@@ -627,10 +625,8 @@ static SYMBOL sql_functions[] = {
...
@@ -627,10 +625,8 @@ static SYMBOL sql_functions[] = {
{
"TOUCHES"
,
SYM
(
FUNC_ARG2
),
0
,
CREATE_FUNC
(
create_func_touches
)},
{
"TOUCHES"
,
SYM
(
FUNC_ARG2
),
0
,
CREATE_FUNC
(
create_func_touches
)},
{
"TRIM"
,
SYM
(
TRIM
),
0
,
0
},
{
"TRIM"
,
SYM
(
TRIM
),
0
,
0
},
{
"UCASE"
,
SYM
(
FUNC_ARG1
),
0
,
CREATE_FUNC
(
create_func_ucase
)},
{
"UCASE"
,
SYM
(
FUNC_ARG1
),
0
,
CREATE_FUNC
(
create_func_ucase
)},
#ifdef HAVE_COMPRESS
{
"UNCOMPRESS"
,
SYM
(
FUNC_ARG1
),
0
,
CREATE_FUNC
(
create_func_uncompress
)},
{
"UNCOMPRESS"
,
SYM
(
FUNC_ARG1
),
0
,
CREATE_FUNC
(
create_func_uncompress
)},
{
"UNCOMPRESSED_LENGTH"
,
SYM
(
FUNC_ARG1
),
0
,
CREATE_FUNC
(
create_func_uncompressed_length
)},
{
"UNCOMPRESSED_LENGTH"
,
SYM
(
FUNC_ARG1
),
0
,
CREATE_FUNC
(
create_func_uncompressed_length
)},
#endif
{
"UNIQUE_USERS"
,
SYM
(
UNIQUE_USERS
),
0
,
0
},
{
"UNIQUE_USERS"
,
SYM
(
UNIQUE_USERS
),
0
,
0
},
{
"UNIX_TIMESTAMP"
,
SYM
(
UNIX_TIMESTAMP
),
0
,
0
},
{
"UNIX_TIMESTAMP"
,
SYM
(
UNIX_TIMESTAMP
),
0
,
0
},
{
"UPPER"
,
SYM
(
FUNC_ARG1
),
0
,
CREATE_FUNC
(
create_func_ucase
)},
{
"UPPER"
,
SYM
(
FUNC_ARG1
),
0
,
CREATE_FUNC
(
create_func_ucase
)},
...
...
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