INFO: The new Git default branch name is "main". Details here: https://about.gitlab.com/blog/2021/03/10/new-git-default-branch-name/

Commit 9dc1f0f5 authored by Matteo Quintiliani's avatar Matteo Quintiliani
Browse files

Merge branch 'release/1.0.3'

parents bb8acae6 605d195a
......@@ -9,9 +9,9 @@ m4_define([full_package_name], [mysql_printf])
dnl These three define the plug-in version number
m4_define([major_version], [1])
m4_define([minor_version], [0])
m4_define([micro_version], [2])
m4_define([micro_version], [3])
# Comment build_version for stable release
# m4_define([build_version], [rc1])
# m4_define([build_version], [dev])
m4_ifdef([build_version], [
m4_define([version],
......
......@@ -44,6 +44,8 @@
#define DELIMITER_CHAR_DEFAULT ';'
#define DEBUG_PREFIX_COMMENT "#"
typedef struct {
char *str_sql;
char *filename_sql;
......@@ -60,7 +62,8 @@ typedef struct {
char *dbname;
char *hostname;
long dbport;
int flag_add_comments;
int flag_debugmsg;
char *debugpref;
int flag_multifiles;
int flag_appendfile;
} MYSQL_FORMAT_PARAMS;
......@@ -83,6 +86,7 @@ const MYSQL_FORMAT_PARAMS MYSQL_FORMAT_PARAMS_DEFAULT =
NULL,
0,
0,
NULL,
0,
0
};
......@@ -126,9 +130,8 @@ int main(int argc, char **argv)
const char *dbname = NULL;
long dbport = 0;
const char sep_char = '#';
const char *sepline_major = "################################################################################################\n";
const char *sepline_minor = "=========================================================\n";
const char *sepline_major = "================================================================================================";
const char *sepline_minor = "------------------------------------------------------------------------------------------------";
char *query = NULL;
char *str_format = NULL;
......@@ -189,12 +192,12 @@ int main(int argc, char **argv)
}
/* Start comment in output */
if(params.flag_add_comments) {
printf("%c%s", sep_char, sepline_major);
if(params.flag_debugmsg) {
printf("%s %s\n", params.debugpref, sepline_major);
}
if(params.flag_add_comments) {
printf("%c %s-%s libconfig: %s\n", sep_char,
if(params.flag_debugmsg) {
printf("%s %s-%s libconfig: %s\n", params.debugpref,
PACKAGE_NAME, PACKAGE_VERSION,
#ifdef HAVE_LIBCONFIG
"yes"
......@@ -203,10 +206,7 @@ int main(int argc, char **argv)
#endif
);
printf("%c Date: %s", sep_char, ctime(&now));
printf("%c file_sql : %s\n", sep_char, params.filename_sql);
printf("%c file_format: %s\n", sep_char, params.filename_format);
printf("%c outputdir: %s\n", sep_char, params.outputdir);
printf("%s Date: %s", params.debugpref, ctime(&now));
}
if(params.hostname || params.dbname) {
......@@ -296,34 +296,38 @@ int main(int argc, char **argv)
if(res) {
if(params.flag_add_comments) {
if(params.flag_debugmsg) {
#ifdef HAVE_LIBCONFIG
printf("%c dbconfname: %s\n", sep_char, dbconfname);
printf("%s dbconfname: %s\n", params.debugpref, dbconfname);
#endif
printf("%c hostname: %s; dbport: %ld; dbname: %s; username: %s.\n", sep_char, hostname, dbport, dbname, username);
printf("%c mysql_get_client_info() : %s\n", sep_char, mysql_get_client_info());
printf("%c mysql_get_client_version(): %ld\n", sep_char, mysql_get_client_version());
printf("%s hostname: %s; dbport: %ld; dbname: %s; username: %s.\n", params.debugpref, hostname, dbport, dbname, username);
printf("%s mysql_get_client_info() : %s\n", params.debugpref, mysql_get_client_info());
printf("%s mysql_get_client_version(): %ld\n", params.debugpref, mysql_get_client_version());
/* Print server info after mysql_real_connect() */
printf("%c mysql_get_host_info() : %s\n", sep_char, mysql_get_host_info(mysql));
printf("%c mysql_get_proto_info() : %d\n", sep_char, mysql_get_proto_info(mysql));
printf("%c mysql_get_server_info() : %s\n", sep_char, mysql_get_server_info(mysql));
printf("%c mysql_get_server_version(): %ld\n", sep_char, mysql_get_server_version(mysql));
printf("%c mysql_stat() : %s\n", sep_char, mysql_stat(mysql));
printf("%s mysql_get_host_info() : %s\n", params.debugpref, mysql_get_host_info(mysql));
printf("%s mysql_get_proto_info() : %d\n", params.debugpref, mysql_get_proto_info(mysql));
printf("%s mysql_get_server_info() : %s\n", params.debugpref, mysql_get_server_info(mysql));
printf("%s mysql_get_server_version(): %ld\n", params.debugpref, mysql_get_server_version(mysql));
printf("%s mysql_stat() : %s\n", params.debugpref, mysql_stat(mysql));
printf("%s file_sql : %s\n", params.debugpref, params.filename_sql);
printf("%s file_format: %s\n", params.debugpref, params.filename_format);
printf("%s outputdir: %s\n", params.debugpref, params.outputdir);
/* Print query with # after each newline */
query_length = strlen(query);
printf("%c %s", sep_char, sepline_minor);
printf("%c ", sep_char);
printf("%s %s\n", params.debugpref, sepline_minor);
printf("%s Query : ", params.debugpref);
for(i=0; i < query_length; i++) {
printf("%c", query[i]);
if(query[i] == '\n') {
printf("%c ", sep_char);
printf("%s ", params.debugpref);
}
}
printf("%s", sepline_minor);
printf("\n");
printf("%c ", sep_char);
printf("%s Fields: ", params.debugpref);
while((field = mysql_fetch_field(res)))
{
printf("{%s}%c", field->name, params.delimiter);
......@@ -332,8 +336,8 @@ int main(int argc, char **argv)
}
/* End comment in output */
if(params.flag_add_comments) {
printf("%c%s", sep_char, sepline_major);
if(params.flag_debugmsg) {
printf("%s %s\n", params.debugpref, sepline_major);
}
num_fields = mysql_num_fields(res);
......@@ -653,20 +657,21 @@ int mysql_printf_getopt_long(int argc, char **argv, MYSQL_FORMAT_PARAMS *params)
/* Following are flags */
{"multifiles", no_argument, NULL, 'm'},
{"appendfile", no_argument, NULL, 'a'},
{"addcomment", no_argument, NULL, 'c'},
{"debugmsg", no_argument, NULL, 'g'},
{"debugpref", required_argument, NULL, 'x'},
{"help", no_argument, NULL, 'H'},
{"version", no_argument, NULL, 'V'},
{0, 0, 0, 0}
};
int option_index = 0;
#define MAX_LEN_OPTSTR 256
char optstr[MAX_LEN_OPTSTR] = "h:u:p:d:P:";
#ifdef HAVE_LIBCONFIG
strcat(optstr, "C:D:");
#endif
strcat(optstr, "F:f:e:S:s:o:macHV");
int option_index = 0;
strcat(optstr, "F:f:e:S:s:o:x:magHV");
/* if there is no arguments provided */
if(argc == 1) {
......@@ -682,10 +687,11 @@ int mysql_printf_getopt_long(int argc, char **argv, MYSQL_FORMAT_PARAMS *params)
one_time_option[i] = 0;
}
/* init params */
memcpy(params, &MYSQL_FORMAT_PARAMS_DEFAULT, sizeof(MYSQL_FORMAT_PARAMS_DEFAULT));
params->debugpref = DEBUG_PREFIX_COMMENT;
while ( (c = getopt_long (argc, argv, optstr, long_options, &option_index)) != -1) {
/* BE CAREFUL if use synonym options !!! */
......@@ -791,8 +797,13 @@ int mysql_printf_getopt_long(int argc, char **argv, MYSQL_FORMAT_PARAMS *params)
params->flag_appendfile = 1;
break;
case 'c':
params->flag_add_comments = 1;
case 'g':
params->flag_debugmsg = 1;
break;
case 'x':
params->flag_debugmsg = 1;
params->debugpref = optarg;
break;
case 'H':
......@@ -978,10 +989,16 @@ Advanced arguments:\n\
printf("\
\n\
Other arguments:\n\
-c, --addcomment Add comment in output, prefix # as first character.\n\
-c, --debugmsg Add debug messages in output as comment.\n\
Default prefix comment line is the character '%s'.\n\
You can change the prefix by option --debugpref.\n\
-x, --debugpref=string Change prefix string for comment line.\n\
This option automatically enables option -c.\n\
-V, --version Print tool version.\n\
-H, --help Print this help.\n\
");
",
DEBUG_PREFIX_COMMENT
);
mysql_printf_author_support();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment