[MDEV-13245] Add struct AUTHID Created: 2017-07-05  Updated: 2017-07-05  Resolved: 2017-07-05

Status: Closed
Project: MariaDB Server
Component/s: OTHER
Affects Version/s: 10.3
Fix Version/s: 10.3.1

Type: Bug Priority: Major
Reporter: Alexander Barkov Assignee: Alexander Barkov
Resolution: Fixed Votes: 0
Labels: refactoring


 Description   

We'll move the members "LEX_CSTRING user" and "LEX_CSTRING host" and associated methods from LEX_USER to a separate structure:

struct AUTHID
{
  LEX_CSTRING user, host;
  void init() { memset(this, 0, sizeof(*this)); }
  void copy(MEM_ROOT *root, const LEX_CSTRING *usr, const LEX_CSTRING *host);
  bool is_role() const { return user.str[0] && !host.str[0]; }
  void set_lex_string(LEX_CSTRING *l, char *buf)
  {
    if (is_role())
      *l= user;
    else
    {
      l->str= buf;
      l->length= strxmov(buf, user.str, "@", host.str, NullS) - buf;
    }
  }
};

and derive LEX_USER from it:

struct LEX_USER: public AUTHID
{
  LEX_CSTRING plugin, auth;
  LEX_CSTRING pwtext, pwhash;
  void reset_auth()
  {
    pwtext.length= pwhash.length= plugin.length= auth.length= 0;
    pwtext.str= pwhash.str= 0;
    plugin.str= auth.str= "";
  }
};

This will allow to declare (variables and members) and pass user and host as a single structure.
Deriving LEX_USER from the new structure AUTHID will minimize code changes.



 Comments   
Comment by Alexander Barkov [ 2017-07-05 ]

Pushed into bb-10.2-ext

Generated at Thu Feb 08 08:04:03 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.