From 7327cd9717f0b98499f0f5b19c84e5e3e48241df Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 28 Sep 2012 14:01:17 +0300 Subject: =?UTF-8?q?MDEV-377=20Name=20support=20for=20dynamic=20columns=20M?= =?UTF-8?q?DEV-127=20Optimization=20of=20memory=20allocation=20MDEV-483=20?= =?UTF-8?q?Make=20column=5Fcheck=20function=20which=20che=D1=81ks=20dynami?= =?UTF-8?q?c=20columns=20integrit=20JSON=20conversion=20function?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/item_create.cc | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'sql/item_create.cc') diff --git a/sql/item_create.cc b/sql/item_create.cc index 96837a8f262..f886b3d598b 100644 --- a/sql/item_create.cc +++ b/sql/item_create.cc @@ -5704,7 +5704,7 @@ static List *create_func_dyncol_prepare(THD *thd, for (uint i= 0; (def= li++) ;) { dfs[0][i++]= *def; - args->push_back(def->num); + args->push_back(def->key); args->push_back(def->value); } return args; @@ -5720,6 +5720,10 @@ Item *create_func_dyncol_create(THD *thd, List &list) return new (thd->mem_root) Item_func_dyncol_create(*args, dfs); } +Item *create_func_dyncol_json(THD *thd, Item *str) +{ + return new (thd->mem_root) Item_func_dyncol_json(str); +} Item *create_func_dyncol_add(THD *thd, Item *str, List &list) @@ -5740,7 +5744,7 @@ Item *create_func_dyncol_add(THD *thd, Item *str, Item *create_func_dyncol_delete(THD *thd, Item *str, List &nums) { DYNCALL_CREATE_DEF *dfs; - Item *num; + Item *key; List_iterator_fast it(nums); List *args= new (thd->mem_root) List; @@ -5750,12 +5754,12 @@ Item *create_func_dyncol_delete(THD *thd, Item *str, List &nums) if (!args || !dfs) return NULL; - for (uint i= 0; (num= it++); i++) + for (uint i= 0; (key= it++); i++) { - dfs[i].num= num; + dfs[i].key= key; dfs[i].value= new Item_null(); dfs[i].type= DYN_COL_INT; - args->push_back(dfs[i].num); + args->push_back(dfs[i].key); args->push_back(dfs[i].value); } -- cgit v1.2.1 From 40ae63dd65fb9e812f29d3520acb0ba6b64d3005 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 23 Dec 2012 20:57:54 +0200 Subject: backport to 5.5 dyncol changes and names support --- sql/item_create.cc | 89 +++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 84 insertions(+), 5 deletions(-) (limited to 'sql/item_create.cc') diff --git a/sql/item_create.cc b/sql/item_create.cc index f886b3d598b..bc449b0aaf2 100644 --- a/sql/item_create.cc +++ b/sql/item_create.cc @@ -526,6 +526,54 @@ protected: virtual ~Create_func_coercibility() {} }; +class Create_func_dyncol_check : public Create_func_arg1 +{ +public: + virtual Item *create_1_arg(THD *thd, Item *arg1); + + static Create_func_dyncol_check s_singleton; + +protected: + Create_func_dyncol_check() {} + virtual ~Create_func_dyncol_check() {} +}; + +class Create_func_dyncol_exists : public Create_func_arg2 +{ +public: + virtual Item *create_2_arg(THD *thd, Item *arg1, Item *arg2); + + static Create_func_dyncol_exists s_singleton; + +protected: + Create_func_dyncol_exists() {} + virtual ~Create_func_dyncol_exists() {} +}; + +class Create_func_dyncol_list : public Create_func_arg1 +{ +public: + virtual Item *create_1_arg(THD *thd, Item *arg1); + + static Create_func_dyncol_list s_singleton; + +protected: + Create_func_dyncol_list() {} + virtual ~Create_func_dyncol_list() {} +}; + +class Create_func_dyncol_json : public Create_func_arg1 +{ +public: + virtual Item *create_1_arg(THD *thd, Item *arg1); + + static Create_func_dyncol_json s_singleton; + +protected: + Create_func_dyncol_json() {} + virtual ~Create_func_dyncol_json() {} +}; + class Create_func_compress : public Create_func_arg1 { @@ -3108,6 +3156,38 @@ Create_func_coercibility::create_1_arg(THD *thd, Item *arg1) } +Create_func_dyncol_check Create_func_dyncol_check::s_singleton; + +Item* +Create_func_dyncol_check::create_1_arg(THD *thd, Item *arg1) +{ + return new (thd->mem_root) Item_func_dyncol_check(arg1); +} + +Create_func_dyncol_exists Create_func_dyncol_exists::s_singleton; + +Item* +Create_func_dyncol_exists::create_2_arg(THD *thd, Item *arg1, Item *arg2) +{ + return new (thd->mem_root) Item_func_dyncol_exists(arg1, arg2); +} + +Create_func_dyncol_list Create_func_dyncol_list::s_singleton; + +Item* +Create_func_dyncol_list::create_1_arg(THD *thd, Item *arg1) +{ + return new (thd->mem_root) Item_func_dyncol_list(arg1); +} + +Create_func_dyncol_json Create_func_dyncol_json::s_singleton; + +Item* +Create_func_dyncol_json::create_1_arg(THD *thd, Item *arg1) +{ + return new (thd->mem_root) Item_func_dyncol_json(arg1); +} + Create_func_concat Create_func_concat::s_singleton; Item* @@ -5245,6 +5325,10 @@ static Native_func_registry func_array[] = { { C_STRING_WITH_LEN("CHARACTER_LENGTH") }, BUILDER(Create_func_char_length)}, { { C_STRING_WITH_LEN("CHAR_LENGTH") }, BUILDER(Create_func_char_length)}, { { C_STRING_WITH_LEN("COERCIBILITY") }, BUILDER(Create_func_coercibility)}, + { { C_STRING_WITH_LEN("COLUMN_CHECK") }, BUILDER(Create_func_dyncol_check)}, + { { C_STRING_WITH_LEN("COLUMN_EXISTS") }, BUILDER(Create_func_dyncol_exists)}, + { { C_STRING_WITH_LEN("COLUMN_LIST") }, BUILDER(Create_func_dyncol_list)}, + { { C_STRING_WITH_LEN("COLUMN_JSON") }, BUILDER(Create_func_dyncol_json)}, { { C_STRING_WITH_LEN("COMPRESS") }, BUILDER(Create_func_compress)}, { { C_STRING_WITH_LEN("CONCAT") }, BUILDER(Create_func_concat)}, { { C_STRING_WITH_LEN("CONCAT_WS") }, BUILDER(Create_func_concat_ws)}, @@ -5720,11 +5804,6 @@ Item *create_func_dyncol_create(THD *thd, List &list) return new (thd->mem_root) Item_func_dyncol_create(*args, dfs); } -Item *create_func_dyncol_json(THD *thd, Item *str) -{ - return new (thd->mem_root) Item_func_dyncol_json(str); -} - Item *create_func_dyncol_add(THD *thd, Item *str, List &list) { -- cgit v1.2.1