Commit 40ae63dd authored by unknown's avatar unknown

backport to 5.5 dyncol changes and names support

parent 28c9e1a5
...@@ -38,12 +38,13 @@ ...@@ -38,12 +38,13 @@
how the offset are stored. how the offset are stored.
*/ */
#define MAX_DYNAMIC_COLUMN_LENGTH 0X1FFFFFFFL #define MAX_DYNAMIC_COLUMN_LENGTH 0X1FFFFFFFL
#define MAX_DYNAMIC_COLUMN_LENGTH_NM 0XFFFFFFFFFL
/* /*
Limits of implementation Limits of implementation
*/ */
#define MAX_NAME_LENGTH 255
#define MAX_TOTAL_NAME_LENGTH 65535 #define MAX_TOTAL_NAME_LENGTH 65535
#define MAX_NAME_LENGTH (MAX_TOTAL_NAME_LENGTH/4)
/* NO and OK is the same used just to show semantics */ /* NO and OK is the same used just to show semantics */
#define ER_DYNCOL_NO ER_DYNCOL_OK #define ER_DYNCOL_NO ER_DYNCOL_OK
...@@ -72,7 +73,8 @@ enum enum_dynamic_column_type ...@@ -72,7 +73,8 @@ enum enum_dynamic_column_type
DYN_COL_DECIMAL, DYN_COL_DECIMAL,
DYN_COL_DATETIME, DYN_COL_DATETIME,
DYN_COL_DATE, DYN_COL_DATE,
DYN_COL_TIME DYN_COL_TIME,
DYN_COL_DYNCOL
}; };
typedef enum enum_dynamic_column_type DYNAMIC_COLUMN_TYPE; typedef enum enum_dynamic_column_type DYNAMIC_COLUMN_TYPE;
...@@ -88,7 +90,6 @@ struct st_dynamic_column_value ...@@ -88,7 +90,6 @@ struct st_dynamic_column_value
struct { struct {
LEX_STRING value; LEX_STRING value;
CHARSET_INFO *charset; CHARSET_INFO *charset;
my_bool nonfreeable;
} string; } string;
struct { struct {
decimal_digit_t buffer[DECIMAL_BUFF_LENGTH]; decimal_digit_t buffer[DECIMAL_BUFF_LENGTH];
...@@ -100,6 +101,8 @@ struct st_dynamic_column_value ...@@ -100,6 +101,8 @@ struct st_dynamic_column_value
typedef struct st_dynamic_column_value DYNAMIC_COLUMN_VALUE; typedef struct st_dynamic_column_value DYNAMIC_COLUMN_VALUE;
/* old functions (deprecated) */
#ifdef MADYNCOL_DEPRECATED
enum enum_dyncol_func_result enum enum_dyncol_func_result
dynamic_column_create(DYNAMIC_COLUMN *str, dynamic_column_create(DYNAMIC_COLUMN *str,
uint column_nr, DYNAMIC_COLUMN_VALUE *value); uint column_nr, DYNAMIC_COLUMN_VALUE *value);
...@@ -109,21 +112,6 @@ dynamic_column_create_many(DYNAMIC_COLUMN *str, ...@@ -109,21 +112,6 @@ dynamic_column_create_many(DYNAMIC_COLUMN *str,
uint column_count, uint column_count,
uint *column_numbers, uint *column_numbers,
DYNAMIC_COLUMN_VALUE *values); DYNAMIC_COLUMN_VALUE *values);
enum enum_dyncol_func_result
dynamic_column_create_many_fmt(DYNAMIC_COLUMN *str,
uint column_count,
uchar *column_keys,
DYNAMIC_COLUMN_VALUE *values,
my_bool names);
enum enum_dyncol_func_result
dynamic_column_create_many_internal_fmt(DYNAMIC_COLUMN *str,
uint column_count,
void *column_keys,
DYNAMIC_COLUMN_VALUE *values,
my_bool new_str,
my_bool string_keys);
enum enum_dyncol_func_result enum enum_dyncol_func_result
dynamic_column_update(DYNAMIC_COLUMN *org, uint column_nr, dynamic_column_update(DYNAMIC_COLUMN *org, uint column_nr,
DYNAMIC_COLUMN_VALUE *value); DYNAMIC_COLUMN_VALUE *value);
...@@ -133,73 +121,105 @@ dynamic_column_update_many(DYNAMIC_COLUMN *str, ...@@ -133,73 +121,105 @@ dynamic_column_update_many(DYNAMIC_COLUMN *str,
uint *column_numbers, uint *column_numbers,
DYNAMIC_COLUMN_VALUE *values); DYNAMIC_COLUMN_VALUE *values);
enum enum_dyncol_func_result enum enum_dyncol_func_result
dynamic_column_update_many_fmt(DYNAMIC_COLUMN *str,
uint add_column_count,
void *column_keys,
DYNAMIC_COLUMN_VALUE *values,
my_bool string_keys);
enum enum_dyncol_func_result
dynamic_column_delete(DYNAMIC_COLUMN *org, uint column_nr); dynamic_column_delete(DYNAMIC_COLUMN *org, uint column_nr);
enum enum_dyncol_func_result enum enum_dyncol_func_result
dynamic_column_exists(DYNAMIC_COLUMN *org, uint column_nr); dynamic_column_exists(DYNAMIC_COLUMN *org, uint column_nr);
enum enum_dyncol_func_result enum enum_dyncol_func_result
dynamic_column_exists_str(DYNAMIC_COLUMN *str, LEX_STRING *name); dynamic_column_list(DYNAMIC_COLUMN *org, DYNAMIC_ARRAY *array_of_uint);
enum enum_dyncol_func_result enum enum_dyncol_func_result
dynamic_column_exists_fmt(DYNAMIC_COLUMN *str, void *key, my_bool string_keys); dynamic_column_get(DYNAMIC_COLUMN *org, uint column_nr,
DYNAMIC_COLUMN_VALUE *store_it_here);
#endif
/* List of not NULL columns */ /* new functions */
enum enum_dyncol_func_result enum enum_dyncol_func_result
dynamic_column_list(DYNAMIC_COLUMN *org, DYNAMIC_ARRAY *array_of_uint); mariadb_dyncol_create_many(DYNAMIC_COLUMN *str,
uint column_count,
uint *column_numbers,
DYNAMIC_COLUMN_VALUE *values,
my_bool new_string);
enum enum_dyncol_func_result enum enum_dyncol_func_result
dynamic_column_list_str(DYNAMIC_COLUMN *str, DYNAMIC_ARRAY *array_of_lexstr); mariadb_dyncol_create_many_named(DYNAMIC_COLUMN *str,
uint column_count,
LEX_STRING *column_keys,
DYNAMIC_COLUMN_VALUE *values,
my_bool new_string);
enum enum_dyncol_func_result
mariadb_dyncol_update_many(DYNAMIC_COLUMN *str,
uint add_column_count,
uint *column_keys,
DYNAMIC_COLUMN_VALUE *values);
enum enum_dyncol_func_result
mariadb_dyncol_update_many_named(DYNAMIC_COLUMN *str,
uint add_column_count,
LEX_STRING *column_keys,
DYNAMIC_COLUMN_VALUE *values);
enum enum_dyncol_func_result
mariadb_dyncol_exists(DYNAMIC_COLUMN *org, uint column_nr);
enum enum_dyncol_func_result enum enum_dyncol_func_result
dynamic_column_list_fmt(DYNAMIC_COLUMN *str, DYNAMIC_ARRAY *array, my_bool string_keys); mariadb_dyncol_exists_named(DYNAMIC_COLUMN *str, LEX_STRING *name);
/* List of not NULL columns */
enum enum_dyncol_func_result
mariadb_dyncol_list(DYNAMIC_COLUMN *org, DYNAMIC_ARRAY *array_of_uint);
enum enum_dyncol_func_result
mariadb_dyncol_list_named(DYNAMIC_COLUMN *str, uint *count, LEX_STRING **names);
/* /*
if the column do not exists it is NULL if the column do not exists it is NULL
*/ */
enum enum_dyncol_func_result enum enum_dyncol_func_result
dynamic_column_get(DYNAMIC_COLUMN *org, uint column_nr, mariadb_dyncol_get(DYNAMIC_COLUMN *org, uint column_nr,
DYNAMIC_COLUMN_VALUE *store_it_here); DYNAMIC_COLUMN_VALUE *store_it_here);
enum enum_dyncol_func_result enum enum_dyncol_func_result
dynamic_column_get_str(DYNAMIC_COLUMN *str, LEX_STRING *name, mariadb_dyncol_get_named(DYNAMIC_COLUMN *str, LEX_STRING *name,
DYNAMIC_COLUMN_VALUE *store_it_here); DYNAMIC_COLUMN_VALUE *store_it_here);
my_bool dynamic_column_has_names(DYNAMIC_COLUMN *str); my_bool mariadb_dyncol_has_names(DYNAMIC_COLUMN *str);
enum enum_dyncol_func_result enum enum_dyncol_func_result
dynamic_column_check(DYNAMIC_COLUMN *str); mariadb_dyncol_check(DYNAMIC_COLUMN *str);
enum enum_dyncol_func_result enum enum_dyncol_func_result
dynamic_column_json(DYNAMIC_COLUMN *str, DYNAMIC_STRING *json); mariadb_dyncol_json(DYNAMIC_COLUMN *str, DYNAMIC_STRING *json);
#define dynamic_column_initialize(A) memset((A), 0, sizeof(*(A))) #define dynamic_column_initialize(A) memset((A), 0, sizeof(*(A)))
#define dynamic_column_column_free(V) dynstr_free(V) #define dynamic_column_column_free(V) dynstr_free(V)
/* conversion of values to 3 base types */ /* conversion of values to 3 base types */
enum enum_dyncol_func_result enum enum_dyncol_func_result
dynamic_column_val_str(DYNAMIC_STRING *str, DYNAMIC_COLUMN_VALUE *val, mariadb_dyncol_val_str(DYNAMIC_STRING *str, DYNAMIC_COLUMN_VALUE *val,
CHARSET_INFO *cs, my_bool quote); CHARSET_INFO *cs, my_bool quote);
enum enum_dyncol_func_result enum enum_dyncol_func_result
dynamic_column_val_long(longlong *ll, DYNAMIC_COLUMN_VALUE *val); mariadb_dyncol_val_long(longlong *ll, DYNAMIC_COLUMN_VALUE *val);
enum enum_dyncol_func_result
mariadb_dyncol_val_double(double *dbl, DYNAMIC_COLUMN_VALUE *val);
enum enum_dyncol_func_result enum enum_dyncol_func_result
dynamic_column_val_double(double *dbl, DYNAMIC_COLUMN_VALUE *val); mariadb_dyncol_unpack(DYNAMIC_COLUMN *str,
uint *count,
LEX_STRING **names, DYNAMIC_COLUMN_VALUE **vals);
int mariadb_dyncol_column_cmp_named(const LEX_STRING *s1, const LEX_STRING *s2);
enum enum_dyncol_func_result enum enum_dyncol_func_result
dynamic_column_vals(DYNAMIC_COLUMN *str, mariadb_dyncol_column_count(DYNAMIC_COLUMN *str, uint *column_count);
DYNAMIC_ARRAY *names, DYNAMIC_ARRAY *vals,
char **free_names);
/*************************************************************************** /***************************************************************************
Internal functions, don't use if you don't know what you are doing... Internal functions, don't use if you don't know what you are doing...
***************************************************************************/ ***************************************************************************/
#define dynamic_column_reassociate(V,P,L, A) dynstr_reassociate((V),(P),(L),(A)) #define mariadb_dyncol_reassociate(V,P,L, A) dynstr_reassociate((V),(P),(L),(A))
#define dynamic_column_value_init(V) (V)->type= DYN_COL_NULL #define dyncol_value_init(V) (V)->type= DYN_COL_NULL
/* /*
Prepare value for using as decimal Prepare value for using as decimal
......
...@@ -794,11 +794,16 @@ my_bool dynstr_append_mem(DYNAMIC_STRING *str, const char *append, ...@@ -794,11 +794,16 @@ my_bool dynstr_append_mem(DYNAMIC_STRING *str, const char *append,
extern my_bool dynstr_append_os_quoted(DYNAMIC_STRING *str, const char *append, extern my_bool dynstr_append_os_quoted(DYNAMIC_STRING *str, const char *append,
...); ...);
extern my_bool dynstr_append_quoted(DYNAMIC_STRING *str, extern my_bool dynstr_append_quoted(DYNAMIC_STRING *str,
const char *append, size_t len); const char *append, size_t len,
char quote);
extern my_bool dynstr_set(DYNAMIC_STRING *str, const char *init_str); extern my_bool dynstr_set(DYNAMIC_STRING *str, const char *init_str);
extern my_bool dynstr_realloc(DYNAMIC_STRING *str, size_t additional_size); extern my_bool dynstr_realloc(DYNAMIC_STRING *str, size_t additional_size);
extern my_bool dynstr_trunc(DYNAMIC_STRING *str, size_t n); extern my_bool dynstr_trunc(DYNAMIC_STRING *str, size_t n);
extern void dynstr_free(DYNAMIC_STRING *str); extern void dynstr_free(DYNAMIC_STRING *str);
extern uint32 copy_and_convert_extended(char *to, uint32 to_length,
CHARSET_INFO *to_cs,
const char *from, uint32 from_length,
CHARSET_INFO *from_cs, uint *errors);
extern void dynstr_reassociate(DYNAMIC_STRING *str, char **res, size_t *length, extern void dynstr_reassociate(DYNAMIC_STRING *str, char **res, size_t *length,
size_t *alloc_length); size_t *alloc_length);
extern uint32 copy_and_convert_extended(char *to, uint32 to_length, extern uint32 copy_and_convert_extended(char *to, uint32 to_length,
......
...@@ -532,7 +532,7 @@ delete from t1; ...@@ -532,7 +532,7 @@ delete from t1;
drop table t1; drop table t1;
CREATE TABLE t1 (rowkey varchar(10) PRIMARY KEY, dyn blob DYNAMIC_COLUMN_STORAGE=yes) ENGINE=CASSANDRA thrift_host='localhost' keyspace='mariadbtest2' column_family = 'cfd1'; CREATE TABLE t1 (rowkey varchar(10) PRIMARY KEY, dyn blob DYNAMIC_COLUMN_STORAGE=yes) ENGINE=CASSANDRA thrift_host='localhost' keyspace='mariadbtest2' column_family = 'cfd1';
select * from t1; select * from t1;
ERROR HY000: Internal error: 'Unable to convert value for field `dyn` from Cassandra's data format. Name length exceed limit of 255: 'very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_ver' ERROR HY000: Internal error: 'Unable to convert value for field `dyn` from Cassandra's data format. Name length exceed limit of 16383: 'very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_v'
drop table t1; drop table t1;
CREATE TABLE t1 (rowkey int PRIMARY KEY, dyn blob DYNAMIC_COLUMN_STORAGE=yes) CREATE TABLE t1 (rowkey int PRIMARY KEY, dyn blob DYNAMIC_COLUMN_STORAGE=yes)
ENGINE=CASSANDRA thrift_host='localhost' keyspace='mariadbtest2' column_family = 'cfd2'; ENGINE=CASSANDRA thrift_host='localhost' keyspace='mariadbtest2' column_family = 'cfd2';
......
This diff is collapsed.
This diff is collapsed.
...@@ -636,9 +636,14 @@ select COLUMN_CREATE(color, "black"); ...@@ -636,9 +636,14 @@ select COLUMN_CREATE(color, "black");
CREATE TABLE t1 (f1 tinyblob); CREATE TABLE t1 (f1 tinyblob);
INSERT INTO t1 VALUES (COLUMN_CREATE('col1', REPEAT('a',30))); INSERT INTO t1 VALUES (COLUMN_CREATE('col1', REPEAT('a',30)));
select column_check(f1) from t1;
UPDATE t1 SET f1 = COLUMN_ADD( f1, REPEAT('b',211), 'val2' ); UPDATE t1 SET f1 = COLUMN_ADD( f1, REPEAT('b',211), 'val2' );
--error ER_DYN_COL_WRONG_FORMAT # we can't detect last string cut with 100% probability,
# because we detect it by string end
select column_check(f1) from t1;
UPDATE t1 SET f1 = COLUMN_ADD( f1, REPEAT('c',211), 'val3' ); UPDATE t1 SET f1 = COLUMN_ADD( f1, REPEAT('c',211), 'val3' );
select column_check(f1) from t1;
drop table t1; drop table t1;
--echo # --echo #
...@@ -657,7 +662,7 @@ SELECT COLUMN_ADD( NULL, 'val', 'col'); ...@@ -657,7 +662,7 @@ SELECT COLUMN_ADD( NULL, 'val', 'col');
--echo # --echo #
SELECT hex(COLUMN_CREATE(REPEAT('a',255),1)); SELECT hex(COLUMN_CREATE(REPEAT('a',255),1));
--error ER_DYN_COL_DATA --error ER_DYN_COL_DATA
SELECT hex(COLUMN_CREATE(REPEAT('a',256),1)); SELECT hex(COLUMN_CREATE(REPEAT('a',65536),1));
--echo # --echo #
--echo # JSON conversion --echo # JSON conversion
...@@ -672,3 +677,37 @@ SELECT COLUMN_CHECK(COLUMN_CREATE(1,'a')); ...@@ -672,3 +677,37 @@ SELECT COLUMN_CHECK(COLUMN_CREATE(1,'a'));
SELECT COLUMN_CHECK('abracadabra'); SELECT COLUMN_CHECK('abracadabra');
SELECT COLUMN_CHECK(''); SELECT COLUMN_CHECK('');
SELECT COLUMN_CHECK(NULL); SELECT COLUMN_CHECK(NULL);
--echo #
--echo # escaping check
--echo #
select column_json(column_create("string", "'\"/\\`.,whatever")),hex(column_create("string", "'\"/\\`.,whatever"));
--echo #
--echo # embedding test
--echo #
select column_json(column_create("val", "val", "emb", column_create("val2", "val2")));
select column_json(column_create(1, "val", 2, column_create(3, "val2")));
--echo #
--echo # Time encoding
--echo #
select hex(column_create("t", "800:46:06.23434" AS time)) as hex,
column_json(column_create("t", "800:46:06.23434" AS time)) as json;
select hex(column_create(1, "800:46:06.23434" AS time)) as hex,
column_json(column_create(1, "800:46:06.23434" AS time)) as json;
select hex(column_create("t", "800:46:06" AS time)) as hex,
column_json(column_create("t", "800:46:06" AS time)) as json;
select hex(column_create(1, "800:46:06" AS time)) as hex,
column_json(column_create(1, "800:46:06" AS time)) as json;
select hex(column_create("t", "2012-12-21 10:46:06.23434" AS datetime)) as hex,
column_json(column_create("t", "2012-12-21 10:46:06.23434" AS datetime)) as json;
select hex(column_create(1, "2012-12-21 10:46:06.23434" AS datetime)) as hex,
column_json(column_create(1, "2012-12-21 10:46:06.23434" AS datetime)) as json;
select hex(column_create("t", "2012-12-21 10:46:06" AS datetime)) as hex,
column_json(column_create("t", "2012-12-21 10:46:06" AS datetime)) as json;
select hex(column_create(1, "2012-12-21 10:46:06" AS datetime)) as hex,
column_json(column_create(1, "2012-12-21 10:46:06" AS datetime)) as json;
This diff is collapsed.
...@@ -176,18 +176,19 @@ my_bool dynstr_append_os_quoted(DYNAMIC_STRING *str, const char *append, ...) ...@@ -176,18 +176,19 @@ my_bool dynstr_append_os_quoted(DYNAMIC_STRING *str, const char *append, ...)
} }
my_bool dynstr_append_quoted(DYNAMIC_STRING *str, my_bool dynstr_append_quoted(DYNAMIC_STRING *str,
const char *append, size_t len) const char *append, size_t len,
char quote)
{ {
uint additional= (str->alloc_increment ? str->alloc_increment : 10); uint additional= (str->alloc_increment ? str->alloc_increment : 10);
uint lim= additional; uint lim= additional;
uint i; uint i;
if (dynstr_realloc(str, len + additional + 2)) if (dynstr_realloc(str, len + additional + 2))
return TRUE; return TRUE;
str->str[str->length++]= '"'; str->str[str->length++]= quote;
for (i= 0; i < len; i++) for (i= 0; i < len; i++)
{ {
register char c= append[i]; register char c= append[i];
if (c == '"' || c == '\\') if (c == quote || c == '\\')
{ {
if (!lim) if (!lim)
{ {
...@@ -200,10 +201,11 @@ my_bool dynstr_append_quoted(DYNAMIC_STRING *str, ...@@ -200,10 +201,11 @@ my_bool dynstr_append_quoted(DYNAMIC_STRING *str,
} }
str->str[str->length++]= c; str->str[str->length++]= c;
} }
str->str[str->length++]= '"'; str->str[str->length++]= quote;
return FALSE; return FALSE;
} }
void dynstr_free(DYNAMIC_STRING *str) void dynstr_free(DYNAMIC_STRING *str)
{ {
my_free(str->str); my_free(str->str);
......
...@@ -6048,6 +6048,7 @@ Item* Item_equal::get_first(JOIN_TAB *context, Item *field_item) ...@@ -6048,6 +6048,7 @@ Item* Item_equal::get_first(JOIN_TAB *context, Item *field_item)
return NULL; return NULL;
} }
longlong Item_func_dyncol_check::val_int() longlong Item_func_dyncol_check::val_int()
{ {
char buff[STRING_BUFFER_USUAL_SIZE]; char buff[STRING_BUFFER_USUAL_SIZE];
...@@ -6062,7 +6063,7 @@ longlong Item_func_dyncol_check::val_int() ...@@ -6062,7 +6063,7 @@ longlong Item_func_dyncol_check::val_int()
col.length= str->length(); col.length= str->length();
/* We do not change the string, so could do this trick */ /* We do not change the string, so could do this trick */
col.str= (char *)str->ptr(); col.str= (char *)str->ptr();
rc= dynamic_column_check(&col); rc= mariadb_dyncol_check(&col);
if (rc < 0 && rc != ER_DYNCOL_FORMAT) if (rc < 0 && rc != ER_DYNCOL_FORMAT)
{ {
dynamic_column_error_message(rc); dynamic_column_error_message(rc);
...@@ -6127,8 +6128,8 @@ longlong Item_func_dyncol_exists::val_int() ...@@ -6127,8 +6128,8 @@ longlong Item_func_dyncol_exists::val_int()
/* We do not change the string, so could do this trick */ /* We do not change the string, so could do this trick */
col.str= (char *)str->ptr(); col.str= (char *)str->ptr();
rc= ((name == NULL) ? rc= ((name == NULL) ?
dynamic_column_exists(&col, (uint) num) : mariadb_dyncol_exists(&col, (uint) num) :
dynamic_column_exists_str(&col, name)); mariadb_dyncol_exists_named(&col, name));
if (rc < 0) if (rc < 0)
{ {
dynamic_column_error_message(rc); dynamic_column_error_message(rc);
......
...@@ -526,6 +526,54 @@ class Create_func_coercibility : public Create_func_arg1 ...@@ -526,6 +526,54 @@ class Create_func_coercibility : public Create_func_arg1
virtual ~Create_func_coercibility() {} 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 class Create_func_compress : public Create_func_arg1
{ {
...@@ -3108,6 +3156,38 @@ Create_func_coercibility::create_1_arg(THD *thd, Item *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; Create_func_concat Create_func_concat::s_singleton;
Item* Item*
...@@ -5245,6 +5325,10 @@ static Native_func_registry func_array[] = ...@@ -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("CHARACTER_LENGTH") }, BUILDER(Create_func_char_length)},
{ { C_STRING_WITH_LEN("CHAR_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("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("COMPRESS") }, BUILDER(Create_func_compress)},
{ { C_STRING_WITH_LEN("CONCAT") }, BUILDER(Create_func_concat)}, { { C_STRING_WITH_LEN("CONCAT") }, BUILDER(Create_func_concat)},
{ { C_STRING_WITH_LEN("CONCAT_WS") }, BUILDER(Create_func_concat_ws)}, { { C_STRING_WITH_LEN("CONCAT_WS") }, BUILDER(Create_func_concat_ws)},
...@@ -5720,11 +5804,6 @@ Item *create_func_dyncol_create(THD *thd, List<DYNCALL_CREATE_DEF> &list) ...@@ -5720,11 +5804,6 @@ Item *create_func_dyncol_create(THD *thd, List<DYNCALL_CREATE_DEF> &list)
return new (thd->mem_root) Item_func_dyncol_create(*args, dfs); 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, Item *create_func_dyncol_add(THD *thd, Item *str,
List<DYNCALL_CREATE_DEF> &list) List<DYNCALL_CREATE_DEF> &list)
{ {
......
...@@ -58,7 +58,7 @@ class Item_func :public Item_result_field ...@@ -58,7 +58,7 @@ class Item_func :public Item_result_field
NOW_FUNC, TRIG_COND_FUNC, NOW_FUNC, TRIG_COND_FUNC,
SUSERVAR_FUNC, GUSERVAR_FUNC, COLLATE_FUNC, SUSERVAR_FUNC, GUSERVAR_FUNC, COLLATE_FUNC,
EXTRACT_FUNC, CHAR_TYPECAST_FUNC, FUNC_SP, UDF_FUNC, EXTRACT_FUNC, CHAR_TYPECAST_FUNC, FUNC_SP, UDF_FUNC,
NEG_FUNC, GSYSVAR_FUNC }; NEG_FUNC, GSYSVAR_FUNC, DYNCOL };
enum optimize_type { OPTIMIZE_NONE,OPTIMIZE_KEY,OPTIMIZE_OP, OPTIMIZE_NULL, enum optimize_type { OPTIMIZE_NONE,OPTIMIZE_KEY,OPTIMIZE_OP, OPTIMIZE_NULL,
OPTIMIZE_EQUAL }; OPTIMIZE_EQUAL };
enum Type type() const { return FUNC_ITEM; } enum Type type() const { return FUNC_ITEM; }
......
This diff is collapsed.
...@@ -1001,10 +1001,10 @@ class Item_func_dyncol_create: public Item_str_func ...@@ -1001,10 +1001,10 @@ class Item_func_dyncol_create: public Item_str_func
protected: protected:
DYNCALL_CREATE_DEF *defs; DYNCALL_CREATE_DEF *defs;
DYNAMIC_COLUMN_VALUE *vals; DYNAMIC_COLUMN_VALUE *vals;
uchar *keys; uint *keys_num;
LEX_STRING *keys_str;
bool names, force_names; bool names, force_names;
bool prepare_arguments(bool force_names); bool prepare_arguments(bool force_names);
void cleanup_arguments();
void print_arguments(String *str, enum_query_type query_type); void print_arguments(String *str, enum_query_type query_type);
public: public:
Item_func_dyncol_create(List<Item> &args, DYNCALL_CREATE_DEF *dfs); Item_func_dyncol_create(List<Item> &args, DYNCALL_CREATE_DEF *dfs);
...@@ -1013,6 +1013,7 @@ class Item_func_dyncol_create: public Item_str_func ...@@ -1013,6 +1013,7 @@ class Item_func_dyncol_create: public Item_str_func
const char *func_name() const{ return "column_create"; } const char *func_name() const{ return "column_create"; }
String *val_str(String *); String *val_str(String *);
virtual void print(String *str, enum_query_type query_type); virtual void print(String *str, enum_query_type query_type);
virtual enum Functype functype() const { return DYNCOL; }
}; };
...@@ -1081,3 +1082,4 @@ class Item_func_dyncol_list: public Item_str_func ...@@ -1081,3 +1082,4 @@ class Item_func_dyncol_list: public Item_str_func
extern String my_empty_string; extern String my_empty_string;
#endif /* ITEM_STRFUNC_INCLUDED */ #endif /* ITEM_STRFUNC_INCLUDED */
...@@ -126,10 +126,7 @@ static SYMBOL symbols[] = { ...@@ -126,10 +126,7 @@ static SYMBOL symbols[] = {
{ "COLUMN_CHECK", SYM(COLUMN_CHECK_SYM)}, { "COLUMN_CHECK", SYM(COLUMN_CHECK_SYM)},
{ "COLUMN_CREATE", SYM(COLUMN_CREATE_SYM)}, { "COLUMN_CREATE", SYM(COLUMN_CREATE_SYM)},
{ "COLUMN_DELETE", SYM(COLUMN_DELETE_SYM)}, { "COLUMN_DELETE", SYM(COLUMN_DELETE_SYM)},
{ "COLUMN_EXISTS", SYM(COLUMN_EXISTS_SYM)},
{ "COLUMN_GET", SYM(COLUMN_GET_SYM)}, { "COLUMN_GET", SYM(COLUMN_GET_SYM)},
{ "COLUMN_JSON", SYM(COLUMN_JSON_SYM)},
{ "COLUMN_LIST", SYM(COLUMN_LIST_SYM)},
{ "COMMENT", SYM(COMMENT_SYM)}, { "COMMENT", SYM(COMMENT_SYM)},
{ "COMMIT", SYM(COMMIT_SYM)}, { "COMMIT", SYM(COMMIT_SYM)},
{ "COMMITTED", SYM(COMMITTED_SYM)}, { "COMMITTED", SYM(COMMITTED_SYM)},
......
...@@ -3872,10 +3872,10 @@ int JOIN_TAB_SCAN_MRR::next() ...@@ -3872,10 +3872,10 @@ int JOIN_TAB_SCAN_MRR::next()
int rc= join_tab->table->file->multi_range_read_next((range_id_t*)ptr) ? -1 : 0; int rc= join_tab->table->file->multi_range_read_next((range_id_t*)ptr) ? -1 : 0;
if (!rc) if (!rc)
{ {
/* /*
If a record in in an incremental cache contains no fields then the If a record in in an incremental cache contains no fields then the
association for the last record in cache will be equal to cache->end_pos association for the last record in cache will be equal to cache->end_pos
*/ */
/* /*
psergey: this makes no sense where HA_MRR_NO_ASSOC is used. psergey: this makes no sense where HA_MRR_NO_ASSOC is used.
DBUG_ASSERT(cache->buff <= (uchar *) (*ptr) && DBUG_ASSERT(cache->buff <= (uchar *) (*ptr) &&
......
...@@ -885,10 +885,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); ...@@ -885,10 +885,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
%token COLUMN_CHECK_SYM %token COLUMN_CHECK_SYM
%token COLUMN_CREATE_SYM %token COLUMN_CREATE_SYM
%token COLUMN_DELETE_SYM %token COLUMN_DELETE_SYM
%token COLUMN_EXISTS_SYM
%token COLUMN_GET_SYM %token COLUMN_GET_SYM
%token COLUMN_JSON_SYM
%token COLUMN_LIST_SYM
%token COLUMN_SYM /* SQL-2003-R */ %token COLUMN_SYM /* SQL-2003-R */
%token COLUMN_NAME_SYM /* SQL-2003-N */ %token COLUMN_NAME_SYM /* SQL-2003-N */
%token COMMENT_SYM %token COMMENT_SYM
...@@ -8807,20 +8804,6 @@ function_call_nonkeyword: ...@@ -8807,20 +8804,6 @@ function_call_nonkeyword:
if ($$ == NULL) if ($$ == NULL)
MYSQL_YYABORT; MYSQL_YYABORT;
} }
|
COLUMN_EXISTS_SYM '(' expr ',' expr ')'
{
$$= new (YYTHD->mem_root) Item_func_dyncol_exists($3, $5);
if ($$ == NULL)
MYSQL_YYABORT;
}
|
COLUMN_LIST_SYM '(' expr ')'
{
$$= new (YYTHD->mem_root) Item_func_dyncol_list($3);
if ($$ == NULL)
MYSQL_YYABORT;
}
| |
COLUMN_CREATE_SYM '(' dyncall_create_list ')' COLUMN_CREATE_SYM '(' dyncall_create_list ')'
{ {
...@@ -8828,13 +8811,6 @@ function_call_nonkeyword: ...@@ -8828,13 +8811,6 @@ function_call_nonkeyword:
if ($$ == NULL) if ($$ == NULL)
MYSQL_YYABORT; MYSQL_YYABORT;
} }
|
COLUMN_JSON_SYM '(' expr ')'
{
$$= create_func_dyncol_json(YYTHD, $3);
if ($$ == NULL)
MYSQL_YYABORT;
}
| |
COLUMN_GET_SYM '(' expr ',' expr AS cast_type ')' COLUMN_GET_SYM '(' expr ',' expr AS cast_type ')'
{ {
...@@ -12927,10 +12903,7 @@ keyword: ...@@ -12927,10 +12903,7 @@ keyword:
| COLUMN_CHECK_SYM {} | COLUMN_CHECK_SYM {}
| COLUMN_CREATE_SYM {} | COLUMN_CREATE_SYM {}
| COLUMN_DELETE_SYM {} | COLUMN_DELETE_SYM {}
| COLUMN_EXISTS_SYM {}
| COLUMN_GET_SYM {} | COLUMN_GET_SYM {}
| COLUMN_JSON_SYM {}
| COLUMN_LIST_SYM {}
| COMMENT_SYM {} | COMMENT_SYM {}
| COMMIT_SYM {} | COMMIT_SYM {}
| CONTAINS_SYM {} | CONTAINS_SYM {}
......
...@@ -13,9 +13,9 @@ SET(cassandra_sources ...@@ -13,9 +13,9 @@ SET(cassandra_sources
#INCLUDE_DIRECTORIES(BEFORE ${Boost_INCLUDE_DIRS}) #INCLUDE_DIRECTORIES(BEFORE ${Boost_INCLUDE_DIRS})
#INCLUDE_DIRECTORIES(AFTER /usr/local/include/thrift) INCLUDE_DIRECTORIES(AFTER /usr/local/include/thrift)
#INCLUDE_DIRECTORIES(AFTER /home/buildbot/build/thrift-inst/include/thrift/) #INCLUDE_DIRECTORIES(AFTER /home/buildbot/build/thrift-inst/include/thrift/)
INCLUDE_DIRECTORIES(AFTER /home/psergey/cassandra/thrift/include/thrift/) #INCLUDE_DIRECTORIES(AFTER /home/psergey/cassandra/thrift/include/thrift/)
# #
STRING(REPLACE "-fno-exceptions" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) STRING(REPLACE "-fno-exceptions" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
......
This diff is collapsed.
...@@ -37,6 +37,8 @@ typedef struct st_cassandra_share { ...@@ -37,6 +37,8 @@ typedef struct st_cassandra_share {
} CASSANDRA_SHARE; } CASSANDRA_SHARE;
class ColumnDataConverter; class ColumnDataConverter;
struct st_dynamic_column_value;
typedef struct st_dynamic_column_value DYNAMIC_COLUMN_VALUE;
struct ha_table_option_struct; struct ha_table_option_struct;
...@@ -45,7 +47,8 @@ struct st_dynamic_column_value; ...@@ -45,7 +47,8 @@ struct st_dynamic_column_value;
typedef bool (* CAS2DYN_CONVERTER)(const char *cass_data, typedef bool (* CAS2DYN_CONVERTER)(const char *cass_data,
int cass_data_len, int cass_data_len,
struct st_dynamic_column_value *value); struct st_dynamic_column_value *value,
MEM_ROOT *mem_root);
typedef bool (* DYN2CAS_CONVERTER)(struct st_dynamic_column_value *value, typedef bool (* DYN2CAS_CONVERTER)(struct st_dynamic_column_value *value,
char **cass_data, char **cass_data,
int *cass_data_len, int *cass_data_len,
...@@ -227,11 +230,14 @@ class ha_cassandra: public handler ...@@ -227,11 +230,14 @@ class ha_cassandra: public handler
bool source_exhausted; bool source_exhausted;
bool mrr_start_read(); bool mrr_start_read();
int check_field_options(Field **fields); int check_field_options(Field **fields);
int read_dyncol(DYNAMIC_ARRAY *vals, DYNAMIC_ARRAY *names, int read_dyncol(uint *count,
String *valcol, char **freenames); DYNAMIC_COLUMN_VALUE **vals, LEX_STRING **names,
int write_dynamic_row(DYNAMIC_ARRAY *names, DYNAMIC_ARRAY *vals); String *valcol);
void static free_dynamic_row(DYNAMIC_ARRAY *vals, DYNAMIC_ARRAY *names, int write_dynamic_row(uint count,
char *free_names); DYNAMIC_COLUMN_VALUE *vals,
LEX_STRING *names);
void static free_dynamic_row(DYNAMIC_COLUMN_VALUE **vals,
LEX_STRING **names);
CASSANDRA_TYPE_DEF * get_cassandra_field_def(char *cass_name, CASSANDRA_TYPE_DEF * get_cassandra_field_def(char *cass_name,
int cass_name_length); int cass_name_length);
public: public:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment