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
7dc1815d
Commit
7dc1815d
authored
Sep 26, 2017
by
Sergei Golubchik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cleanup: reduce code duplication
remove copy-pasted code, fix meaningless comparison. followup for
ea2162b6
parent
0627929f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
34 deletions
+23
-34
storage/maria/ma_create.c
storage/maria/ma_create.c
+23
-34
No files found.
storage/maria/ma_create.c
View file @
7dc1815d
...
...
@@ -33,6 +33,27 @@
static
int
compare_columns
(
MARIA_COLUMNDEF
**
a
,
MARIA_COLUMNDEF
**
b
);
static
ulonglong
update_tot_length
(
ulonglong
tot_length
,
ulonglong
max_rows
,
uint
length
)
{
ulonglong
tot_length_part
;
if
(
tot_length
==
ULONGLONG_MAX
)
return
ULONGLONG_MAX
;
tot_length_part
=
(
max_rows
/
(
ulong
)
((
maria_block_size
-
MAX_KEYPAGE_HEADER_SIZE
-
KEYPAGE_CHECKSUM_SIZE
)
/
(
length
*
2
)));
if
(
tot_length_part
>=
ULONGLONG_MAX
/
maria_block_size
)
return
ULONGLONG_MAX
;
if
(
tot_length
>
ULONGLONG_MAX
-
tot_length_part
*
maria_block_size
)
return
ULONGLONG_MAX
;
return
tot_length
+
tot_length_part
*
maria_block_size
;
}
/*
Old options is used when recreating database, from maria_chk
*/
...
...
@@ -661,23 +682,7 @@ int maria_create(const char *name, enum data_file_type datafile_type,
if
(
length
>
max_key_length
)
max_key_length
=
length
;
if
(
tot_length
==
ULLONG_MAX
)
continue
;
ulonglong
tot_length_part
=
(
max_rows
/
(
ulong
)
(((
uint
)
maria_block_size
-
MAX_KEYPAGE_HEADER_SIZE
-
KEYPAGE_CHECKSUM_SIZE
)
/
(
length
*
2
)));
if
(
tot_length_part
>=
(
ULLONG_MAX
/
maria_block_size
+
ULLONG_MAX
%
maria_block_size
))
tot_length
=
ULLONG_MAX
;
else
{
if
(
tot_length
>
ULLONG_MAX
-
tot_length_part
*
maria_block_size
)
tot_length
=
ULLONG_MAX
;
else
tot_length
+=
tot_length_part
*
maria_block_size
;
}
tot_length
=
update_tot_length
(
tot_length
,
max_rows
,
length
);
}
unique_key_parts
=
0
;
...
...
@@ -687,23 +692,7 @@ int maria_create(const char *name, enum data_file_type datafile_type,
unique_key_parts
+=
uniquedef
->
keysegs
;
share
.
state
.
key_root
[
keys
+
i
]
=
HA_OFFSET_ERROR
;
if
(
tot_length
==
ULLONG_MAX
)
continue
;
ulonglong
tot_length_part
=
(
max_rows
/
(
ulong
)
(((
uint
)
maria_block_size
-
MAX_KEYPAGE_HEADER_SIZE
-
KEYPAGE_CHECKSUM_SIZE
)
/
((
MARIA_UNIQUE_HASH_LENGTH
+
pointer
)
*
2
)));
if
(
tot_length_part
>=
(
ULLONG_MAX
/
maria_block_size
+
ULLONG_MAX
%
maria_block_size
))
tot_length
=
ULLONG_MAX
;
else
{
if
(
tot_length
>
ULLONG_MAX
-
tot_length_part
*
maria_block_size
)
tot_length
=
ULLONG_MAX
;
else
tot_length
+=
tot_length_part
*
maria_block_size
;
}
tot_length
=
update_tot_length
(
tot_length
,
max_rows
,
MARIA_UNIQUE_HASH_LENGTH
+
pointer
);
}
keys
+=
uniques
;
/* Each unique has 1 key */
key_segs
+=
uniques
;
/* Each unique has 1 key seg */
...
...
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