Skip to content

Commit 5967dfd

Browse files
committed
MDEV-23154 Add a data type my_repertoire_t
1 parent d34eb4b commit 5967dfd

File tree

9 files changed

+47
-24
lines changed

9 files changed

+47
-24
lines changed

include/m_ctype.h

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -226,9 +226,14 @@ extern MY_UNI_CTYPE my_uni_ctype[256];
226226
#define MY_CHARSET_UNDEFINED 0
227227

228228
/* Character repertoire flags */
229-
#define MY_REPERTOIRE_ASCII 1 /* Pure ASCII U+0000..U+007F */
230-
#define MY_REPERTOIRE_EXTENDED 2 /* Extended characters: U+0080..U+FFFF */
231-
#define MY_REPERTOIRE_UNICODE30 3 /* ASCII | EXTENDED: U+0000..U+FFFF */
229+
typedef enum enum_repertoire_t
230+
{
231+
MY_REPERTOIRE_NONE= 0,
232+
MY_REPERTOIRE_ASCII= 1, /* Pure ASCII U+0000..U+007F */
233+
MY_REPERTOIRE_EXTENDED= 2, /* Extended characters: U+0080..U+FFFF */
234+
MY_REPERTOIRE_UNICODE30= 3 /* ASCII | EXTENDED: U+0000..U+FFFF */
235+
} my_repertoire_t;
236+
232237

233238
/* Flags for strxfrm */
234239
#define MY_STRXFRM_LEVEL1 0x00000001 /* for primary weights */
@@ -1420,14 +1425,15 @@ my_bool my_propagate_complex(CHARSET_INFO *cs, const uchar *str, size_t len);
14201425
typedef struct
14211426
{
14221427
size_t char_length;
1423-
uint repertoire;
1428+
my_repertoire_t repertoire;
14241429
} MY_STRING_METADATA;
14251430

14261431
void my_string_metadata_get(MY_STRING_METADATA *metadata,
14271432
CHARSET_INFO *cs, const char *str, size_t len);
1428-
uint my_string_repertoire(CHARSET_INFO *cs, const char *str, size_t len);
1433+
my_repertoire_t my_string_repertoire(CHARSET_INFO *cs,
1434+
const char *str, size_t len);
14291435
my_bool my_charset_is_ascii_based(CHARSET_INFO *cs);
1430-
uint my_charset_repertoire(CHARSET_INFO *cs);
1436+
my_repertoire_t my_charset_repertoire(CHARSET_INFO *cs);
14311437

14321438
uint my_strxfrm_flag_normalize(uint flags, uint nlevels);
14331439
void my_strxfrm_desc_and_reverse(uchar *str, uchar *strend,

sql/item.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2430,7 +2430,7 @@ bool DTCollation::aggregate(const DTCollation &dt, uint flags)
24302430
{
24312431
if (derivation == DERIVATION_EXPLICIT)
24322432
{
2433-
set(0, DERIVATION_NONE, 0);
2433+
set(0, DERIVATION_NONE, MY_REPERTOIRE_NONE);
24342434
return 1;
24352435
}
24362436
if (collation->state & MY_CS_BINSORT &&
@@ -3911,7 +3911,7 @@ Item_null::make_string_literal_concat(THD *thd, const LEX_CSTRING *str)
39113911
if (str->length)
39123912
{
39133913
CHARSET_INFO *cs= thd->variables.collation_connection;
3914-
uint repertoire= my_string_repertoire(cs, str->str, str->length);
3914+
my_repertoire_t repertoire= my_string_repertoire(cs, str->str, str->length);
39153915
return new (thd->mem_root) Item_string(thd,
39163916
str->str, (uint) str->length, cs,
39173917
DERIVATION_COERCIBLE, repertoire);

sql/item.h

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2767,12 +2767,15 @@ class Item_basic_value :public Item,
27672767
{
27682768
my_string_metadata_get(this, str->charset(), str->ptr(), str->length());
27692769
}
2770-
Metadata(const String *str, uint repertoire_arg)
2770+
Metadata(const String *str, my_repertoire_t repertoire_arg)
27712771
{
27722772
MY_STRING_METADATA::repertoire= repertoire_arg;
27732773
MY_STRING_METADATA::char_length= str->numchars();
27742774
}
2775-
uint repertoire() const { return MY_STRING_METADATA::repertoire; }
2775+
my_repertoire_t repertoire() const
2776+
{
2777+
return MY_STRING_METADATA::repertoire;
2778+
}
27762779
size_t char_length() const { return MY_STRING_METADATA::char_length; }
27772780
};
27782781
void fix_charset_and_length(CHARSET_INFO *cs,
@@ -4400,7 +4403,7 @@ class Item_string :public Item_literal
44004403
}
44014404
// Constructors with the item name set from its value
44024405
Item_string(THD *thd, const char *str, uint length, CHARSET_INFO *cs,
4403-
Derivation dv, uint repertoire)
4406+
Derivation dv, my_repertoire_t repertoire)
44044407
:Item_literal(thd)
44054408
{
44064409
str_value.set_or_copy_aligned(str, length, cs);
@@ -4414,7 +4417,7 @@ class Item_string :public Item_literal
44144417
fix_and_set_name_from_value(thd, dv, Metadata(&str_value));
44154418
}
44164419
Item_string(THD *thd, const String *str, CHARSET_INFO *tocs, uint *conv_errors,
4417-
Derivation dv, uint repertoire)
4420+
Derivation dv, my_repertoire_t repertoire)
44184421
:Item_literal(thd)
44194422
{
44204423
if (str_value.copy(str, tocs, conv_errors))
@@ -4432,7 +4435,7 @@ class Item_string :public Item_literal
44324435
set_name(thd, name_par);
44334436
}
44344437
Item_string(THD *thd, const LEX_CSTRING &name_par, const LEX_CSTRING &str,
4435-
CHARSET_INFO *cs, Derivation dv, uint repertoire)
4438+
CHARSET_INFO *cs, Derivation dv, my_repertoire_t repertoire)
44364439
:Item_literal(thd)
44374440
{
44384441
str_value.set_or_copy_aligned(str.str, str.length, cs);
@@ -4565,7 +4568,7 @@ class Item_static_string_func :public Item_string
45654568
Item_static_string_func(THD *thd, const LEX_CSTRING &name_par,
45664569
const String *str,
45674570
CHARSET_INFO *tocs, uint *conv_errors,
4568-
Derivation dv, uint repertoire):
4571+
Derivation dv, my_repertoire_t repertoire):
45694572
Item_string(thd, str, tocs, conv_errors, dv, repertoire),
45704573
func_name(name_par)
45714574
{}

sql/item_timefunc.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1742,7 +1742,7 @@ bool Item_func_date_format::fix_length_and_dec()
17421742

17431743
decimals=0;
17441744
CHARSET_INFO *cs= thd->variables.collation_connection;
1745-
uint32 repertoire= arg1->collation.repertoire;
1745+
my_repertoire_t repertoire= arg1->collation.repertoire;
17461746
if (!thd->variables.lc_time_names->is_ascii)
17471747
repertoire|= MY_REPERTOIRE_EXTENDED;
17481748
collation.set(cs, arg1->collation.derivation, repertoire);

sql/sql_class.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2493,7 +2493,8 @@ bool THD::to_ident_sys_alloc(Lex_ident_sys_st *to, const Lex_ident_cli_st *ident
24932493

24942494

24952495
Item_basic_constant *
2496-
THD::make_string_literal(const char *str, size_t length, uint repertoire)
2496+
THD::make_string_literal(const char *str, size_t length,
2497+
my_repertoire_t repertoire)
24972498
{
24982499
if (!length && (variables.sql_mode & MODE_EMPTY_STRING_IS_NULL))
24992500
return new (mem_root) Item_null(this, 0, variables.collation_connection);

sql/sql_class.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3935,10 +3935,10 @@ class THD: public THD_count, /* this must be first */
39353935
@param repertoire - the repertoire of the string
39363936
*/
39373937
Item_basic_constant *make_string_literal(const char *str, size_t length,
3938-
uint repertoire);
3938+
my_repertoire_t repertoire);
39393939
Item_basic_constant *make_string_literal(const Lex_string_with_metadata_st &str)
39403940
{
3941-
uint repertoire= str.repertoire(variables.character_set_client);
3941+
my_repertoire_t repertoire= str.repertoire(variables.character_set_client);
39423942
return make_string_literal(str.str, str.length, repertoire);
39433943
}
39443944
Item_basic_constant *make_string_literal_nchar(const Lex_string_with_metadata_st &str);

sql/sql_lex.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,13 @@ struct Lex_string_with_metadata_st: public LEX_CSTRING
8585
bool is_quoted() const { return m_quote != '\0'; }
8686
char quote() const { return m_quote; }
8787
// Get string repertoire by the 8-bit flag and the character set
88-
uint repertoire(CHARSET_INFO *cs) const
88+
my_repertoire_t repertoire(CHARSET_INFO *cs) const
8989
{
9090
return !m_is_8bit && my_charset_is_ascii_based(cs) ?
9191
MY_REPERTOIRE_ASCII : MY_REPERTOIRE_UNICODE30;
9292
}
9393
// Get string repertoire by the 8-bit flag, for ASCII-based character sets
94-
uint repertoire() const
94+
my_repertoire_t repertoire() const
9595
{
9696
return !m_is_8bit ? MY_REPERTOIRE_ASCII : MY_REPERTOIRE_UNICODE30;
9797
}

sql/sql_locale.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class MY_LOCALE
6060
grouping(grouping_par),
6161
errmsgs(errmsgs_par)
6262
{}
63-
uint repertoire() const
63+
my_repertoire_t repertoire() const
6464
{ return is_ascii ? MY_REPERTOIRE_ASCII : MY_REPERTOIRE_EXTENDED; }
6565
};
6666
/* Exported variables */

sql/sql_type.h

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2712,6 +2712,19 @@ class Timestamp_or_zero_datetime_native_null: public Timestamp_or_zero_datetime_
27122712
#define MY_REPERTOIRE_NUMERIC MY_REPERTOIRE_ASCII
27132713

27142714

2715+
static inline my_repertoire_t operator|(const my_repertoire_t a,
2716+
const my_repertoire_t b)
2717+
{
2718+
return (my_repertoire_t) ((uint) a | (uint) b);
2719+
}
2720+
2721+
static inline my_repertoire_t &operator|=(my_repertoire_t &a,
2722+
const my_repertoire_t b)
2723+
{
2724+
return a= (my_repertoire_t) ((uint) a | (uint) b);
2725+
}
2726+
2727+
27152728
enum Derivation
27162729
{
27172730
DERIVATION_IGNORABLE= 6,
@@ -2733,7 +2746,7 @@ class DTCollation {
27332746
public:
27342747
CHARSET_INFO *collation;
27352748
enum Derivation derivation;
2736-
uint repertoire;
2749+
my_repertoire_t repertoire;
27372750

27382751
void set_repertoire_from_charset(CHARSET_INFO *cs)
27392752
{
@@ -2769,7 +2782,7 @@ class DTCollation {
27692782
}
27702783
DTCollation(CHARSET_INFO *collation_arg,
27712784
Derivation derivation_arg,
2772-
uint repertoire_arg)
2785+
my_repertoire_t repertoire_arg)
27732786
:collation(collation_arg),
27742787
derivation(derivation_arg),
27752788
repertoire(repertoire_arg)
@@ -2786,7 +2799,7 @@ class DTCollation {
27862799
}
27872800
void set(CHARSET_INFO *collation_arg,
27882801
Derivation derivation_arg,
2789-
uint repertoire_arg)
2802+
my_repertoire_t repertoire_arg)
27902803
{
27912804
collation= collation_arg;
27922805
derivation= derivation_arg;

0 commit comments

Comments
 (0)