Skip to content

Commit

Permalink
cleanup (patch provided by Alexander Barkov)
Browse files Browse the repository at this point in the history
move function prototypes used in mariadb_lib.c and mariadb_stmt.c
to include/ma_priv.h
  • Loading branch information
9EOR9 committed Jan 20, 2020
1 parent ffbdaaa commit a1283d0
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 16 deletions.
31 changes: 31 additions & 0 deletions include/ma_priv.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/****************************************************************************
Copyright (C) 2020 MariaDB Corporation
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not see <http://www.gnu.org/licenses>
or write to the Free Software Foundation, Inc.,
51 Franklin St., Fifth Floor, Boston, MA 02110, USA
Part of this code includes code from the PHP project which
is freely available from http://www.php.net
*****************************************************************************/
#ifndef MA_PRIV_H
#define MA_PRIV_H

void free_rows(MYSQL_DATA *cur);
int ma_multi_command(MYSQL *mysql, enum enum_multi_status status);
MYSQL_FIELD * unpack_fields(MYSQL_DATA *data,
MA_MEM_ROOT *alloc,uint fields,
my_bool default_value);

#endif
16 changes: 6 additions & 10 deletions libmariadb/mariadb_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <ma_string.h>
#include <mariadb_ctype.h>
#include <ma_common.h>
#include "ma_priv.h"
#include "ma_context.h"
#include "mysql.h"
#include "mariadb_version.h"
Expand Down Expand Up @@ -771,7 +772,7 @@ static size_t rset_field_offsets[]= {

MYSQL_FIELD *
unpack_fields(MYSQL_DATA *data,MA_MEM_ROOT *alloc,uint fields,
my_bool default_value, my_bool long_flag_protocol __attribute__((unused)))
my_bool default_value)
{
MYSQL_ROWS *row;
MYSQL_FIELD *field,*result;
Expand Down Expand Up @@ -2195,9 +2196,7 @@ int mthd_my_read_query_result(MYSQL *mysql)
if (!(fields=mysql->methods->db_read_rows(mysql,(MYSQL_FIELD*) 0,8)))
return(-1);
if (!(mysql->fields=unpack_fields(fields,&mysql->field_alloc,
(uint) field_count,1,
(my_bool) test(mysql->server_capabilities &
CLIENT_LONG_FLAG))))
(uint) field_count, 1)))
return(-1);
mysql->status=MYSQL_STATUS_GET_RESULT;
mysql->field_count=field_count;
Expand Down Expand Up @@ -2528,9 +2527,7 @@ mysql_list_fields(MYSQL *mysql, const char *table, const char *wild)
result->eof=1;
result->field_count = (uint) query->rows;
result->fields= unpack_fields(query,&result->field_alloc,
result->field_count,1,
(my_bool) test(mysql->server_capabilities &
CLIENT_LONG_FLAG));
result->field_count, 1);
if (result->fields)
return(result);

Expand All @@ -2555,9 +2552,8 @@ mysql_list_processes(MYSQL *mysql)
field_count=(uint) net_field_length(&pos);
if (!(fields = mysql->methods->db_read_rows(mysql,(MYSQL_FIELD*) 0,5)))
return(NULL);
if (!(mysql->fields=unpack_fields(fields,&mysql->field_alloc,field_count,0,
(my_bool) test(mysql->server_capabilities &
CLIENT_LONG_FLAG))))
if (!(mysql->fields=unpack_fields(fields, &mysql->field_alloc,
field_count, 0)))
return(NULL);
mysql->status=MYSQL_STATUS_GET_RESULT;
mysql->field_count=field_count;
Expand Down
9 changes: 3 additions & 6 deletions libmariadb/mariadb_stmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@
#include <time.h>
#include <mysql/client_plugin.h>
#include <ma_common.h>
#include "ma_priv.h"


#define UPDATE_STMT_ERROR(stmt)\
SET_CLIENT_STMT_ERROR((stmt), (stmt)->mysql->net.last_errno, (stmt)->mysql->net.sqlstate, (stmt)->mysql->net.last_error)
Expand All @@ -75,10 +77,6 @@ typedef struct
MA_MEM_ROOT fields_ma_alloc_root;
} MADB_STMT_EXTENSION;

MYSQL_DATA *read_rows(MYSQL *mysql,MYSQL_FIELD *mysql_fields, uint fields);
void free_rows(MYSQL_DATA *cur);
int ma_multi_command(MYSQL *mysql, enum enum_multi_status status);
MYSQL_FIELD * unpack_fields(MYSQL_DATA *data,MA_MEM_ROOT *alloc,uint fields, my_bool default_value, my_bool long_flag_protocol);
static my_bool net_stmt_close(MYSQL_STMT *stmt, my_bool remove);

static my_bool is_not_null= 0;
Expand Down Expand Up @@ -1598,8 +1596,7 @@ my_bool mthd_stmt_get_result_metadata(MYSQL_STMT *stmt)
if (!(result= stmt->mysql->methods->db_read_rows(stmt->mysql, (MYSQL_FIELD *)0, 7)))
return(1);
if (!(stmt->fields= unpack_fields(result,fields_ma_alloc_root,
stmt->field_count, 0,
stmt->mysql->server_capabilities & CLIENT_LONG_FLAG)))
stmt->field_count, 0)))
return(1);
return(0);
}
Expand Down

0 comments on commit a1283d0

Please sign in to comment.