summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKeith Bostic <keith@wiredtiger.com>2015-03-20 10:31:28 -0400
committerKeith Bostic <keith@wiredtiger.com>2015-03-20 10:31:28 -0400
commit94d3e1ff61eeff4801a64cc6f753eeb7a8eb9650 (patch)
tree24d2a9f1380a167b75036a529b9d92fd37f1ad82 /src
parent9883fb3533fcea5c436cb473fa0643cdac1591ec (diff)
downloadmongo-94d3e1ff61eeff4801a64cc6f753eeb7a8eb9650.tar.gz
Add tests for illegal key/value format configurations.
Diffstat (limited to 'src')
-rw-r--r--src/btree/bt_handle.c4
-rw-r--r--src/config/config_def.c16
-rw-r--r--src/include/extern.h1
-rw-r--r--src/packing/pack_impl.c10
-rw-r--r--src/schema/schema_create.c4
5 files changed, 23 insertions, 12 deletions
diff --git a/src/btree/bt_handle.c b/src/btree/bt_handle.c
index 430795288f2..b4115117ad5 100644
--- a/src/btree/bt_handle.c
+++ b/src/btree/bt_handle.c
@@ -212,7 +212,7 @@ __btree_conf(WT_SESSION_IMPL *session, WT_CKPT *ckpt)
/* Validate file types and check the data format plan. */
WT_RET(__wt_config_gets(session, cfg, "key_format", &cval));
- WT_RET(__wt_struct_check(session, cval.str, cval.len, NULL, NULL));
+ WT_RET(__wt_struct_confchk(session, &cval));
if (WT_STRING_MATCH("r", cval.str, cval.len))
btree->type = BTREE_COL_VAR;
else
@@ -220,7 +220,7 @@ __btree_conf(WT_SESSION_IMPL *session, WT_CKPT *ckpt)
WT_RET(__wt_strndup(session, cval.str, cval.len, &btree->key_format));
WT_RET(__wt_config_gets(session, cfg, "value_format", &cval));
- WT_RET(__wt_struct_check(session, cval.str, cval.len, NULL, NULL));
+ WT_RET(__wt_struct_confchk(session, &cval));
WT_RET(__wt_strndup(session, cval.str, cval.len, &btree->value_format));
/* Row-store key comparison and key gap for prefix compression. */
diff --git a/src/config/config_def.c b/src/config/config_def.c
index feea18674c3..65955240847 100644
--- a/src/config/config_def.c
+++ b/src/config/config_def.c
@@ -164,7 +164,7 @@ static const WT_CONFIG_CHECK confchk_file_meta[] = {
{ "internal_page_max", "int",
NULL, "min=512B,max=512MB",
NULL },
- { "key_format", "format", NULL, NULL, NULL },
+ { "key_format", "format", __wt_struct_confchk, NULL, NULL },
{ "key_gap", "int", NULL, "min=0", NULL },
{ "leaf_item_max", "int", NULL, "min=0", NULL },
{ "leaf_key_max", "int", NULL, "min=0", NULL },
@@ -178,7 +178,7 @@ static const WT_CONFIG_CHECK confchk_file_meta[] = {
{ "split_deepen_min_child", "int", NULL, NULL, NULL },
{ "split_deepen_per_child", "int", NULL, NULL, NULL },
{ "split_pct", "int", NULL, "min=25,max=100", NULL },
- { "value_format", "format", NULL, NULL, NULL },
+ { "value_format", "format", __wt_struct_confchk, NULL, NULL },
{ "version", "string", NULL, NULL, NULL },
{ NULL, NULL, NULL, NULL, NULL }
};
@@ -190,10 +190,10 @@ static const WT_CONFIG_CHECK confchk_index_meta[] = {
{ "extractor", "string", NULL, NULL, NULL },
{ "immutable", "boolean", NULL, NULL, NULL },
{ "index_key_columns", "int", NULL, NULL, NULL },
- { "key_format", "format", NULL, NULL, NULL },
+ { "key_format", "format", __wt_struct_confchk, NULL, NULL },
{ "source", "string", NULL, NULL, NULL },
{ "type", "string", NULL, NULL, NULL },
- { "value_format", "format", NULL, NULL, NULL },
+ { "value_format", "format", __wt_struct_confchk, NULL, NULL },
{ NULL, NULL, NULL, NULL, NULL }
};
@@ -265,7 +265,7 @@ static const WT_CONFIG_CHECK confchk_session_create[] = {
{ "internal_page_max", "int",
NULL, "min=512B,max=512MB",
NULL },
- { "key_format", "format", NULL, NULL, NULL },
+ { "key_format", "format", __wt_struct_confchk, NULL, NULL },
{ "key_gap", "int", NULL, "min=0", NULL },
{ "leaf_item_max", "int", NULL, "min=0", NULL },
{ "leaf_key_max", "int", NULL, "min=0", NULL },
@@ -282,7 +282,7 @@ static const WT_CONFIG_CHECK confchk_session_create[] = {
{ "split_deepen_per_child", "int", NULL, NULL, NULL },
{ "split_pct", "int", NULL, "min=25,max=100", NULL },
{ "type", "string", NULL, NULL, NULL },
- { "value_format", "format", NULL, NULL, NULL },
+ { "value_format", "format", __wt_struct_confchk, NULL, NULL },
{ NULL, NULL, NULL, NULL, NULL }
};
@@ -338,8 +338,8 @@ static const WT_CONFIG_CHECK confchk_table_meta[] = {
{ "colgroups", "list", NULL, NULL, NULL },
{ "collator", "string", __wt_collator_confchk, NULL, NULL },
{ "columns", "list", NULL, NULL, NULL },
- { "key_format", "format", NULL, NULL, NULL },
- { "value_format", "format", NULL, NULL, NULL },
+ { "key_format", "format", __wt_struct_confchk, NULL, NULL },
+ { "value_format", "format", __wt_struct_confchk, NULL, NULL },
{ NULL, NULL, NULL, NULL, NULL }
};
diff --git a/src/include/extern.h b/src/include/extern.h
index f22a8da0b5c..5c2fe8f952d 100644
--- a/src/include/extern.h
+++ b/src/include/extern.h
@@ -497,6 +497,7 @@ extern int __wt_ext_struct_pack(WT_EXTENSION_API *wt_api, WT_SESSION *wt_session
extern int __wt_ext_struct_size(WT_EXTENSION_API *wt_api, WT_SESSION *wt_session, size_t *sizep, const char *fmt, ...);
extern int __wt_ext_struct_unpack(WT_EXTENSION_API *wt_api, WT_SESSION *wt_session, const void *buffer, size_t size, const char *fmt, ...);
extern int __wt_struct_check(WT_SESSION_IMPL *session, const char *fmt, size_t len, int *fixedp, uint32_t *fixed_lenp);
+extern int __wt_struct_confchk(WT_SESSION_IMPL *session, WT_CONFIG_ITEM *v);
extern int __wt_struct_size(WT_SESSION_IMPL *session, size_t *sizep, const char *fmt, ...);
extern int __wt_struct_pack(WT_SESSION_IMPL *session, void *buffer, size_t size, const char *fmt, ...);
extern int __wt_struct_unpack(WT_SESSION_IMPL *session, const void *buffer, size_t size, const char *fmt, ...);
diff --git a/src/packing/pack_impl.c b/src/packing/pack_impl.c
index 0b699814fc1..c92325a4c23 100644
--- a/src/packing/pack_impl.c
+++ b/src/packing/pack_impl.c
@@ -44,6 +44,16 @@ __wt_struct_check(WT_SESSION_IMPL *session,
}
/*
+ * __wt_struct_confchk --
+ * Check that the specified packing format is valid, configuration version.
+ */
+int
+__wt_struct_confchk(WT_SESSION_IMPL *session, WT_CONFIG_ITEM *v)
+{
+ return (__wt_struct_check(session, v->str, v->len, NULL, NULL));
+}
+
+/*
* __wt_struct_size --
* Calculate the size of a packed byte string.
*/
diff --git a/src/schema/schema_create.c b/src/schema/schema_create.c
index c0f4f4bb57e..720b6fc6412 100644
--- a/src/schema/schema_create.c
+++ b/src/schema/schema_create.c
@@ -580,9 +580,9 @@ __create_data_source(WT_SESSION_IMPL *session,
* data source doesn't have access to the functions that check.
*/
WT_RET(__wt_config_gets(session, cfg, "key_format", &cval));
- WT_RET(__wt_struct_check(session, cval.str, cval.len, NULL, NULL));
+ WT_RET(__wt_struct_confchk(session, &cval));
WT_RET(__wt_config_gets(session, cfg, "value_format", &cval));
- WT_RET(__wt_struct_check(session, cval.str, cval.len, NULL, NULL));
+ WT_RET(__wt_struct_confchk(session, &cval));
/*
* User-specified collators aren't supported for data-source objects.