mirror of
https://github.com/MariaDB/server.git
synced 2025-07-27 18:02:13 +03:00
SQL: start_end_t members as LEX_CSTRING
This commit is contained in:
@ -3,6 +3,7 @@
|
||||
|
||||
#include "table.h"
|
||||
#include "sql_class.h"
|
||||
#include "vers_string.h"
|
||||
|
||||
class MDL_auto_lock
|
||||
{
|
||||
@ -30,104 +31,6 @@ public:
|
||||
bool acquire_error() const { return error; }
|
||||
};
|
||||
|
||||
struct Compare_strncmp
|
||||
{
|
||||
int operator()(const LEX_STRING& a, const LEX_STRING& b) const
|
||||
{
|
||||
return strncmp(a.str, b.str, a.length);
|
||||
}
|
||||
static CHARSET_INFO* charset()
|
||||
{
|
||||
return system_charset_info;
|
||||
}
|
||||
};
|
||||
|
||||
template <CHARSET_INFO* &CS= system_charset_info>
|
||||
struct Compare_my_strcasecmp
|
||||
{
|
||||
int operator()(const LEX_STRING& a, const LEX_STRING& b) const
|
||||
{
|
||||
DBUG_ASSERT(a.str[a.length] == 0 && b.str[b.length] == 0);
|
||||
return my_strcasecmp(CS, a.str, b.str);
|
||||
}
|
||||
static CHARSET_INFO* charset()
|
||||
{
|
||||
return CS;
|
||||
}
|
||||
};
|
||||
|
||||
typedef Compare_my_strcasecmp<files_charset_info> Compare_fs;
|
||||
typedef Compare_my_strcasecmp<table_alias_charset> Compare_t;
|
||||
|
||||
struct LEX_STRING_u : public LEX_STRING
|
||||
{
|
||||
LEX_STRING_u()
|
||||
{
|
||||
str= NULL;
|
||||
LEX_STRING::length= 0;
|
||||
}
|
||||
LEX_STRING_u(const char *_str, uint32 _len, CHARSET_INFO *)
|
||||
{
|
||||
str= const_cast<char *>(_str);
|
||||
LEX_STRING::length= _len;
|
||||
}
|
||||
uint32 length() const
|
||||
{
|
||||
return LEX_STRING::length;
|
||||
}
|
||||
const char *ptr() const
|
||||
{
|
||||
return LEX_STRING::str;
|
||||
}
|
||||
const LEX_STRING& lex_string() const
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
template <class Compare= Compare_strncmp, class Storage= LEX_STRING_u>
|
||||
struct XString : public Storage
|
||||
{
|
||||
public:
|
||||
XString() {}
|
||||
XString(char *_str, size_t _len) :
|
||||
Storage(_str, _len, Compare::charset())
|
||||
{
|
||||
}
|
||||
XString(LEX_STRING& src) :
|
||||
Storage(src.str, src.length, Compare::charset())
|
||||
{
|
||||
}
|
||||
XString(char *_str) :
|
||||
Storage(_str, strlen(_str), Compare::charset())
|
||||
{
|
||||
}
|
||||
bool operator== (const XString& b) const
|
||||
{
|
||||
return Storage::length() == b.length() && 0 == Compare()(this->lex_string(), b.lex_string());
|
||||
}
|
||||
bool operator!= (const XString& b) const
|
||||
{
|
||||
return !(*this == b);
|
||||
}
|
||||
operator const char* () const
|
||||
{
|
||||
return Storage::ptr();
|
||||
}
|
||||
};
|
||||
|
||||
typedef XString<> LString;
|
||||
typedef XString<Compare_fs> LString_fs;
|
||||
|
||||
typedef XString<Compare_strncmp, String> SString;
|
||||
typedef XString<Compare_fs, String> SString_fs;
|
||||
typedef XString<Compare_t, String> SString_t;
|
||||
|
||||
|
||||
#define XSTRING_WITH_LEN(X) (X).ptr(), (X).length()
|
||||
#define DB_WITH_LEN(X) (X).db, (X).db_length
|
||||
#define TABLE_NAME_WITH_LEN(X) (X).table_name, (X).table_name_length
|
||||
|
||||
|
||||
class Local_da : public Diagnostics_area
|
||||
{
|
||||
|
Reference in New Issue
Block a user