[Tarantool-patches] [PATCH v3 16/20] sql: move sql_stmt_busy() declaration to box/execute.h

Sergey Ostanevich sergos at tarantool.org
Wed Dec 25 17:54:30 MSK 2019


Hi!

Thanks, LGTM.

Sergos

On 20 Dec 15:47, Nikita Pettik wrote:
> We are going to use it in box/execute.c and in SQL prepared statement
> cache implementation. So to avoid including whole sqlInt.h let's move it
> to relative small execute.h header. Let's also fix codestyle of this
> function.
> 
> Needed for #2592
> ---
>  src/box/execute.h     |  4 ++++
>  src/box/sql/sqlInt.h  |  3 ---
>  src/box/sql/vdbeapi.c | 10 ++++------
>  src/box/sql/vdbeaux.c |  1 +
>  4 files changed, 9 insertions(+), 9 deletions(-)
> 
> diff --git a/src/box/execute.h b/src/box/execute.h
> index f3d6c38b3..61c8e0281 100644
> --- a/src/box/execute.h
> +++ b/src/box/execute.h
> @@ -127,6 +127,10 @@ sql_stmt_est_size(const struct sql_stmt *stmt);
>  const char *
>  sql_stmt_query_str(const struct sql_stmt *stmt);
>  
> +/** Return true if statement executes right now. */
> +int
> +sql_stmt_busy(const struct sql_stmt *stmt);
> +
>  /**
>   * Prepare (compile into VDBE byte-code) statement.
>   *
> diff --git a/src/box/sql/sqlInt.h b/src/box/sql/sqlInt.h
> index 7dfc29809..cbe46e790 100644
> --- a/src/box/sql/sqlInt.h
> +++ b/src/box/sql/sqlInt.h
> @@ -718,9 +718,6 @@ sql_bind_parameter_name(const struct sql_stmt *stmt, int i);
>  int
>  sql_bind_ptr(struct sql_stmt *stmt, int i, void *ptr);
>  
> -int
> -sql_stmt_busy(sql_stmt *);
> -
>  int
>  sql_init_db(sql **db);
>  
> diff --git a/src/box/sql/vdbeapi.c b/src/box/sql/vdbeapi.c
> index 7278d2ab3..01185af5f 100644
> --- a/src/box/sql/vdbeapi.c
> +++ b/src/box/sql/vdbeapi.c
> @@ -1190,14 +1190,12 @@ sql_db_handle(sql_stmt * pStmt)
>  	return pStmt ? ((Vdbe *) pStmt)->db : 0;
>  }
>  
> -/*
> - * Return true if the prepared statement is in need of being reset.
> - */
>  int
> -sql_stmt_busy(sql_stmt * pStmt)
> +sql_stmt_busy(const struct sql_stmt *stmt)
>  {
> -	Vdbe *v = (Vdbe *) pStmt;
> -	return v != 0 && v->magic == VDBE_MAGIC_RUN && v->pc >= 0;
> +	assert(stmt != NULL);
> +	const struct Vdbe *v = (const struct Vdbe *) stmt;
> +	return v->magic == VDBE_MAGIC_RUN && v->pc >= 0;
>  }
>  
>  /*
> diff --git a/src/box/sql/vdbeaux.c b/src/box/sql/vdbeaux.c
> index 619105820..afe1ecb2a 100644
> --- a/src/box/sql/vdbeaux.c
> +++ b/src/box/sql/vdbeaux.c
> @@ -43,6 +43,7 @@
>  #include "sqlInt.h"
>  #include "vdbeInt.h"
>  #include "tarantoolInt.h"
> +#include "box/execute.h"
>  
>  /*
>   * Create a new virtual database engine.
> -- 
> 2.15.1
> 


More information about the Tarantool-patches mailing list