Hi Sergei,

I was doing some work within sql_acl.cc, having to refactor a bit of logic regarding USER_RESOURCES and SSL related stuff and I'm thinking of making use of std::string instead of const char* to remove the need for checking NULL pointers.

I noticed that we generally do not make any use of std::string within the server code, apart from storage engines. The use cases are not performance sensitive so any overhead caused by std::string I think is smaller than the benefit of not having if (!NULL) statements everywhere.

I know that it is obviously based on the final result, but if it is a definite no from the start, I'll implement things using regular C pointers.

Also, this is only for the new things I'm implementing, I'm not planning on refactoring everything.

Sample code where we can avoid ifs:

    case SSL_TYPE_SPECIFIED:
      table->field[next_field]->store(STRING_WITH_LEN("SPECIFIED"),
                                      &my_charset_latin1);
      table->field[next_field+1]->store("", 0, &my_charset_latin1);
      table->field[next_field+2]->store("", 0, &my_charset_latin1);
      table->field[next_field+3]->store("", 0, &my_charset_latin1);
      if (lex->ssl_cipher)
        table->field[next_field+1]->store(lex->ssl_cipher,
                                strlen(lex->ssl_cipher), system_charset_info);
      if (lex->x509_issuer)
        table->field[next_field+2]->store(lex->x509_issuer,
                                strlen(lex->x509_issuer), system_charset_info);
      if (lex->x509_subject)
        table->field[next_field+3]->store(lex->x509_subject,
                                strlen(lex->x509_subject), system_charset_info);
 
This just becomes:
    case SSL_TYPE_SPECIFIED:
      table->field[next_field]->store(STRING_WITH_LEN("SPECIFIED"),
                                      &my_charset_latin1);
      table->field[next_field+1]->store(ssl_cipher.c_str(), ssl_cipher.size(), &my_charset_latin1);
      table->field[next_field+2]->store(x509_issuer.c_str(), x509_issuer.size(), &my_charset_latin1);
      table->field[next_field+3]->store(x509_subject.c_str(), x509_subject.size(), &my_charset_latin1);
 
Thoughts?

Regards,
Vicentiu