← Back to team overview

maria-developers team mailing list archive

Re: 81768c1: MDEV-5313 Improving audit plugin API.

 

Hi, Alexey!

On Jan 20, Alexey Botchkov wrote:
> +typedef struct st_mysql MYSQL;
> +typedef struct st_mysql_res MYSQL_RES;
> +typedef char **MYSQL_ROW;
> +
> +extern struct sql_service_st {
> +  MYSQL *(*sqls_init)(MYSQL *mysql);
> +  void (*sqls_close)(MYSQL *mysql);
> +  int (*sqls_real_query)(MYSQL *mysql, const char *q,
> +                        unsigned long length);
> +  unsigned long (*sqls_affected_rows)(MYSQL *mysql);
> +  uint (*sqls_errno)(MYSQL *mysql);
> +  const char *(*sqls_error)(MYSQL *mysql);
> +  MYSQL_RES *(*sqls_store_result)(MYSQL *mysql);
> +  void (*sqls_free_result)(MYSQL_RES *result);
> +  unsigned long (*sqls_num_rows)(MYSQL_RES *res);
> +  unsigned int (*sqls_num_fields)(MYSQL_RES *res);
> +  MYSQL_ROW (*sqls_fetch_row)(MYSQL_RES *result);
> +  unsigned long * (*sqls_fetch_lengths)(MYSQL_RES *result);
> +} *sql_service;

I'd say, if you're emulating  client C API, you don't need all these
sqls* functions. You basically only need one function, let's call it

  mysql_internal_connect()

which is a variant of mysql_real_connect() for running SQL internally in
the server. And it'll do

    mysql->methods= &internal_sql_methods;

which will be your callback table, you won't need a second one.
And after that mysql_* API functions will work normally.
At least those that you decide to support.

Alternatively you don't even need mysql_internal_connect(), you can
integrate it into CLI_MYSQL_REAL_CONNECT (just like you've done with
libmysqld.c:mysql_real_connect() calling cli_mysql_real_connect()).

Regards,
Sergei
Chief Architect MariaDB
and security@xxxxxxxxxxx