mirror of
https://github.com/MariaDB/server.git
synced 2026-10-23 18:49:29 +03:00
Remove the unscoped #pragma GCC diagnostic ignored "-Wdeprecated-declarations" from include/violite.h and replace all sprintf/vsprintf calls with snprintf/vsnprintf across the codebase. Where possible, pass actual buffer sizes as function parameters instead of using hardcoded constants or recomputing strlen(). Notable API changes: - get_date(): added to_len parameter for buffer size - nice_time(), end_timer() in client/mysql.cc: added buff_size - generate_new_name(): added name_size parameter - calc_md5(): added buffer_size parameter (fixes off-by-one) - MD5_HASH_TO_STRING macro: added _size parameter - Added MYSQL_UDF_MAX_RESULT_LENGTH constant in mysql_com.h Also fixed a pre-existing bug in sql/rpl_mi.cc where the ellipsis "..." was written to the wrong buffer (dbuff instead of buff). Vendored code is excluded: extra/readline, extra/wolfssl, wsrep-lib, libmariadb, storage/mroonga/vendor, zlib.
61 lines
1.6 KiB
C
61 lines
1.6 KiB
C
/* Copyright (c) 2000-2004 MySQL AB
|
|
Use is subject to license terms
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; version 2 of the License.
|
|
|
|
This program 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 General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program; if not, write to the Free Software
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include "mysql.h"
|
|
|
|
#define INSERT_QUERY "insert into test (name,num) values ('item %d', %d)"
|
|
|
|
|
|
int main(int argc, char **argv)
|
|
{
|
|
int count,num;
|
|
MYSQL *sock,mysql;
|
|
char qbuf[160];
|
|
|
|
if (argc != 3)
|
|
{
|
|
fprintf(stderr,"usage : insert_test <dbname> <Num>\n\n");
|
|
exit(1);
|
|
}
|
|
|
|
mysql_init(&mysql);
|
|
if (!(sock = mysql_real_connect(&mysql,NULL,NULL,NULL,argv[1],0,NULL,0)))
|
|
{
|
|
fprintf(stderr,"Couldn't connect to engine!\n%s\n",mysql_error(&mysql));
|
|
perror("");
|
|
exit(1);
|
|
}
|
|
mysql.reconnect= 1;
|
|
|
|
num = atoi(argv[2]);
|
|
count = 0;
|
|
while (count < num)
|
|
{
|
|
snprintf(qbuf,sizeof(qbuf),INSERT_QUERY,count,count);
|
|
if(mysql_query(sock,qbuf))
|
|
{
|
|
fprintf(stderr,"Query failed (%s)\n",mysql_error(sock));
|
|
exit(1);
|
|
}
|
|
count++;
|
|
}
|
|
mysql_close(sock);
|
|
exit(0);
|
|
return 0;
|
|
}
|