Skip to content

Commit 78c65b5

Browse files
author
monty@mishka.local
committed
Cleanups during review
Changed defaults option --instance to --defaults-group-suffix Changed option handling to allow --defaults-file, --defaults-extra-file and --defaults-group-suffix to be given in any order Changed MYSQL_INSTANCE to MYSQL_GROUP_SUFFIX mysql_print_defaults now understands --defaults-group-suffix Remove usage of my_tempnam() (not safe function) if( -> if ( and while( to while (
1 parent 774916a commit 78c65b5

33 files changed

+315
-469
lines changed

VC++Files/client/mysqlclient.dsp

-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

VC++Files/client/mysqlclient_ia64.dsp

-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

VC++Files/libmysql/libmysql.dsp

-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

VC++Files/libmysql/libmysql_ia64.dsp

-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

VC++Files/mysys/mysys.dsp

-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

VC++Files/mysys/mysys_ia64.dsp

-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/mysql.cc

+14-12
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
#include <locale.h>
4545
#endif
4646

47-
const char *VER= "14.11";
47+
const char *VER= "14.12";
4848

4949
/* Don't try to make a nice table if the data is too big */
5050
#define MAX_COLUMN_LENGTH 1024
@@ -340,16 +340,15 @@ static sig_handler mysql_end(int sig);
340340
int main(int argc,char *argv[])
341341
{
342342
char buff[80];
343-
char *defaults, *extra_defaults;
344-
char *emb_argv[3];
345-
int emb_argc= 1;
343+
char *defaults, *extra_defaults, *group_suffix;
344+
char *emb_argv[4];
345+
int emb_argc;
346346

347-
emb_argv[0]= argv[0];
348-
get_defaults_files(argc, argv, &defaults, &extra_defaults);
349-
if (defaults)
350-
emb_argv[emb_argc++]= defaults;
351-
if (extra_defaults)
352-
emb_argv[emb_argc++]= extra_defaults;
347+
/* Get --defaults-xxx args for mysql_server_init() */
348+
emb_argc= get_defaults_options(argc, argv, &defaults, &extra_defaults,
349+
&group_suffix)+1;
350+
memcpy((char*) emb_argv, (char*) argv, emb_argc * sizeof(*argv));
351+
emb_argv[emb_argc]= 0;
353352

354353
MY_INIT(argv[0]);
355354
DBUG_ENTER("main");
@@ -2060,6 +2059,7 @@ static void end_tee()
20602059
return;
20612060
}
20622061

2062+
20632063
static int
20642064
com_ego(String *buffer,char *line)
20652065
{
@@ -2071,8 +2071,10 @@ com_ego(String *buffer,char *line)
20712071
return result;
20722072
}
20732073

2074-
static char *fieldtype2str(enum enum_field_types type) {
2075-
switch(type) {
2074+
2075+
static const char *fieldtype2str(enum enum_field_types type)
2076+
{
2077+
switch (type) {
20762078
case FIELD_TYPE_BIT: return "BIT";
20772079
case FIELD_TYPE_BLOB: return "BLOB";
20782080
case FIELD_TYPE_DATE: return "DATE";

client/mysqldump.c

+8-5
Original file line numberDiff line numberDiff line change
@@ -1212,7 +1212,7 @@ static uint get_table_structure(char *table, char *db)
12121212
opt_quoted_table= quote_name(table, table_buff2, 0);
12131213

12141214
if (opt_order_by_primary)
1215-
order_by = primary_key_fields(opt_quoted_table);
1215+
order_by = primary_key_fields(result_table);
12161216

12171217
if (!opt_xml && !mysql_query_with_error_report(sock, 0, query_buff))
12181218
{
@@ -1272,7 +1272,7 @@ static uint get_table_structure(char *table, char *db)
12721272

12731273
/* Create temp table by selecting from the view */
12741274
my_snprintf(query_buff, sizeof(query_buff),
1275-
"CREATE TEMPORARY TABLE %s SELECT * FROM %s WHERE 0",
1275+
"CREATE TEMPORARY TABLE %s SELECT * FROM %s WHERE 0",
12761276
result_table, result_table);
12771277
if (mysql_query_with_error_report(sock, 0, query_buff))
12781278
{
@@ -1391,7 +1391,7 @@ static uint get_table_structure(char *table, char *db)
13911391
fprintf(sql_file, "\n--\n-- Table structure for table %s\n--\n\n",
13921392
result_table);
13931393
if (opt_drop)
1394-
fprintf(sql_file, "DROP TABLE IF EXISTS %s;\n",result_table);
1394+
fprintf(sql_file, "DROP TABLE IF EXISTS %s;\n", result_table);
13951395
if (!opt_xml)
13961396
fprintf(sql_file, "CREATE TABLE %s (\n", result_table);
13971397
else
@@ -2773,6 +2773,7 @@ static const char *check_if_ignore_table(const char *table_name)
27732773
or if there is some failure. It is better to continue to dump
27742774
the table unsorted, rather than exit without dumping the data.
27752775
*/
2776+
27762777
static char *primary_key_fields(const char *table_name)
27772778
{
27782779
MYSQL_RES *res = NULL;
@@ -2809,11 +2810,13 @@ static char *primary_key_fields(const char *table_name)
28092810
}
28102811

28112812
/* Build the ORDER BY clause result */
2812-
if (result_length) {
2813+
if (result_length)
2814+
{
28132815
char *end;
28142816
/* result (terminating \0 is already in result_length) */
28152817
result = my_malloc(result_length + 10, MYF(MY_WME));
2816-
if (!result) {
2818+
if (!result)
2819+
{
28172820
fprintf(stderr, "Error: Not enough memory to store ORDER BY clause\n");
28182821
goto cleanup;
28192822
}

extra/my_print_defaults.c

+24-22
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
/* Copyright (C) 2000 MySQL AB
23
34
This program is free software; you can redistribute it and/or modify
@@ -23,8 +24,10 @@
2324

2425
#include <my_global.h>
2526
#include <my_sys.h>
27+
#include <m_string.h>
2628
#include <my_getopt.h>
2729

30+
2831
const char *config_file="my"; /* Default config file */
2932
uint verbose= 0, opt_defaults_file_used= 0;
3033
const char *default_dbug_option="d:t:o,/tmp/my_print_defaults.trace";
@@ -48,6 +51,10 @@ static struct my_option my_long_options[] =
4851
"Read this file after the global /etc config file and before the config file in the users home directory.",
4952
(gptr*) &defaults_extra_file, (gptr*) &defaults_extra_file, 0, GET_STR,
5053
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
54+
{"defaults-group-suffix", 'g',
55+
"In addition to the given groups, read also groups with this suffix",
56+
(gptr*) &defaults_group_suffix, (gptr*) &defaults_group_suffix,
57+
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
5158
{"extra-file", 'e',
5259
"Synonym for --defaults-extra-file.",
5360
(gptr*) &defaults_extra_file, (gptr*) &defaults_extra_file, 0, GET_STR,
@@ -127,37 +134,32 @@ static int get_options(int *argc,char ***argv)
127134
return 0;
128135
}
129136

137+
130138
int main(int argc, char **argv)
131139
{
132-
int count, error;
133-
char **load_default_groups, *tmp_arguments[3],
134-
**argument, **arguments;
135-
char *defaults, *extra_defaults;
140+
int count, error, args_used;
141+
char **load_default_groups, *tmp_arguments[6];
142+
char **argument, **arguments, **org_argv;
143+
char *defaults, *extra_defaults, *group_suffix;
136144
MY_INIT(argv[0]);
137145

138-
get_defaults_files(argc, argv, &defaults, &extra_defaults);
146+
org_argv= argv;
147+
args_used= get_defaults_options(argc, argv, &defaults, &extra_defaults,
148+
&group_suffix);
139149

140-
/*
141-
** Check out the args
142-
*/
143-
if (!(load_default_groups=(char**) my_malloc((argc+2)*sizeof(char*),
150+
/* Copy defaults-xxx arguments & program name */
151+
count=args_used+1;
152+
arguments= tmp_arguments;
153+
memcpy((char*) arguments, (char*) org_argv, count * sizeof(*org_argv));
154+
arguments[count]= 0;
155+
156+
/* Check out the args */
157+
if (!(load_default_groups=(char**) my_malloc((argc+1)*sizeof(char*),
144158
MYF(MY_WME))))
145159
exit(1);
146160
if (get_options(&argc,&argv))
147161
exit(1);
148-
149-
for (count=0; *argv ; argv++,count++)
150-
load_default_groups[count]= *argv;
151-
load_default_groups[count]=0;
152-
153-
count=0;
154-
arguments=tmp_arguments;
155-
arguments[count++]=my_progname;
156-
if (extra_defaults)
157-
arguments[count++]= extra_defaults;
158-
if (defaults)
159-
arguments[count++]= defaults;
160-
arguments[count]= 0;
162+
memcpy((char*) load_default_groups, (char*) argv, (argc + 1) * sizeof(*argv));
161163

162164
if ((error= load_defaults(config_file, (const char **) load_default_groups,
163165
&count, &arguments)))

extra/replace.c

+11-10
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ register char **argv[];
175175
case 'I':
176176
case '?':
177177
help=1; /* Help text written */
178-
printf("%s Ver 1.3 for %s at %s\n",my_progname,SYSTEM_TYPE,
178+
printf("%s Ver 1.4 for %s at %s\n",my_progname,SYSTEM_TYPE,
179179
MACHINE_TYPE);
180180
if (version)
181181
break;
@@ -1048,23 +1048,25 @@ FILE *in,*out;
10481048
}
10491049

10501050

1051-
static int convert_file(rep,name)
1052-
REPLACE *rep;
1053-
my_string name;
1051+
static int convert_file(REPLACE *rep, my_string name)
10541052
{
10551053
int error;
10561054
FILE *in,*out;
1057-
char dir_buff[FN_REFLEN],*tempname;
1055+
char dir_buff[FN_REFLEN], tempname[FN_REFLEN];
1056+
File temp_file;
10581057
DBUG_ENTER("convert_file");
10591058

10601059
if (!(in=my_fopen(name,O_RDONLY,MYF(MY_WME))))
10611060
DBUG_RETURN(1);
10621061
dirname_part(dir_buff,name);
1063-
tempname=my_tempnam(dir_buff,"PR",MYF(MY_WME));
1064-
if (!(out=my_fopen(tempname,(int) (O_WRONLY | O_CREAT),
1065-
MYF(MY_WME))))
1062+
if ((temp_file= create_temp_file(tempname, dir_buff, "PR", O_WRONLY,
1063+
MYF(MY_WME))) < 0)
1064+
{
1065+
my_fclose(in,MYF(0));
1066+
DBUG_RETURN(1);
1067+
}
1068+
if (!(out= my_fdopen(temp_file, tempname, O_WRONLY, MYF(MY_WME))))
10661069
{
1067-
(*free)(tempname);
10681070
my_fclose(in,MYF(0));
10691071
DBUG_RETURN(1);
10701072
}
@@ -1076,7 +1078,6 @@ my_string name;
10761078
my_redel(name,tempname,MYF(MY_WME | MY_LINK_WARNING));
10771079
else
10781080
my_delete(tempname,MYF(MY_WME));
1079-
(*free)(tempname);
10801081
if (!silent && ! error)
10811082
{
10821083
if (updated)

include/config-win.h

+3
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,9 @@ inline double ulonglong2double(ulonglong value)
353353
#ifndef DEFAULT_HOME_ENV
354354
#define DEFAULT_HOME_ENV MYSQL_HOME
355355
#endif
356+
#ifndef DEFAULT_GROUP_SUFFIX_ENV
357+
#define DEFAULT_GROUP_SUFFIX_ENV MYSQL_GROUP_SUFFIX
358+
#endif
356359

357360
/* File name handling */
358361

include/my_sys.h

+4-3
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ extern my_bool NEAR my_disable_locking,NEAR my_disable_async_io,
263263
extern char wild_many,wild_one,wild_prefix;
264264
extern const char *charsets_dir;
265265
extern char *defaults_extra_file;
266-
extern const char *defaults_instance;
266+
extern const char *defaults_group_suffix;
267267

268268
extern my_bool timed_mutexes;
269269

@@ -785,8 +785,9 @@ extern void reset_root_defaults(MEM_ROOT *mem_root, uint block_size,
785785
extern char *strdup_root(MEM_ROOT *root,const char *str);
786786
extern char *strmake_root(MEM_ROOT *root,const char *str,uint len);
787787
extern char *memdup_root(MEM_ROOT *root,const char *str,uint len);
788-
extern void get_defaults_files(int argc, char **argv,
789-
char **defaults, char **extra_defaults);
788+
extern int get_defaults_options(int argc, char **argv,
789+
char **defaults, char **extra_defaults,
790+
char **group_suffix);
790791
extern int load_defaults(const char *conf_file, const char **groups,
791792
int *argc, char ***argv);
792793
extern int modify_defaults_file(const char *file_location, const char *option,

libmysql/Makefile.shared

+1
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ CLEANFILES = $(target_libadd) $(SHLIBOBJS) \
8484
DEFS = -DDEFAULT_CHARSET_HOME="\"$(MYSQLBASEdir)\"" \
8585
-DDATADIR="\"$(MYSQLDATAdir)\"" \
8686
-DDEFAULT_HOME_ENV=MYSQL_HOME \
87+
-DDEFAULT_GROUP_SUFFIX_ENV=MYSQL_GROUP_SUFFIX \
8788
-DSHAREDIR="\"$(MYSQLSHAREdir)\"" $(target_defs)
8889

8990
# The automatic dependencies miss this

mysys/Makefile.am

+2-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ libmysys_a_SOURCES = my_init.c my_getwd.c mf_getdate.c my_mmap.c \
4444
ptr_cmp.c mf_radix.c queues.c \
4545
tree.c list.c hash.c array.c string.c typelib.c \
4646
my_copy.c my_append.c my_lib.c \
47-
my_delete.c my_rename.c my_redel.c my_tempnam.c \
47+
my_delete.c my_rename.c my_redel.c \
4848
my_chsize.c my_lread.c my_lwrite.c my_clock.c \
4949
my_quick.c my_lockmem.c my_static.c \
5050
my_sync.c my_getopt.c my_mkdir.c \
@@ -68,6 +68,7 @@ DEFS = -DDEFAULT_BASEDIR=\"$(prefix)\" \
6868
-DDEFAULT_CHARSET_HOME="\"$(MYSQLBASEdir)\"" \
6969
-DSHAREDIR="\"$(MYSQLSHAREdir)\"" \
7070
-DDEFAULT_HOME_ENV=MYSQL_HOME \
71+
-DDEFAULT_GROUP_SUFFIX_ENV=MYSQL_GROUP_SUFFIX \
7172
@DEFS@
7273

7374
libmysys_a_DEPENDENCIES= @THREAD_LOBJECTS@

0 commit comments

Comments
 (0)