Skip to content

Commit 8e8d0fc

Browse files
committed
Better MySQL options
1 parent 3047b17 commit 8e8d0fc

File tree

11 files changed

+46
-24
lines changed

11 files changed

+46
-24
lines changed

bin/aix/convH

0 Bytes
Binary file not shown.

bin/aix/mqsmfcsv

1.07 KB
Binary file not shown.

bin/linux/mqsmfcsv

28 Bytes
Binary file not shown.

bin/win/mqsmfcsv.exe

512 Bytes
Binary file not shown.

mqsmfcsv.doc

0 Bytes
Binary file not shown.

src/mqsmf.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ BOOL streamOutput = FALSE;
120120
BOOL streamInput = TRUE;
121121
char *ddlTemplateOpen = NULL;
122122
char *ddlTemplateClose = NULL;
123+
char *ddlQuote = "";
123124
commonFields_t commonF = {0};
124125
enum outputFormat_e outputFormat = OF_CSV;
125126
FILE *infoStream;
@@ -244,13 +245,25 @@ int main( int argc, char *argv[] )
244245
/******************************************************************/
245246
/* Parse command-line parameters */
246247
/******************************************************************/
247-
while((c = mqgetopt(argc, argv, "acd:e:f:h:i:m:o:p:rst:")) != EOF)
248+
while((c = mqgetopt(argc, argv, "ab:cd:e:f:h:i:m:o:p:rst:")) != EOF)
248249
{
249250
switch(c)
250251
{
251252
case 'a':
252253
append = TRUE;
253254
break;
255+
case 'b': /* 'b' for dataBase */
256+
for (i=0;i<strlen(mqoptarg);i++)
257+
mqoptarg[i] = toupper(mqoptarg[i]);
258+
if (!strcmp(mqoptarg,"MYSQL")) {
259+
ddlQuote="`";
260+
ddlTemplateOpen = "-";
261+
} else if (!strcmp(mqoptarg,"DB2")) {
262+
ddlQuote="";
263+
} else {
264+
error = TRUE;
265+
}
266+
break;
254267
case 'c':
255268
resumeCheckPoint = TRUE;
256269
append = TRUE;
@@ -1325,10 +1338,12 @@ static void Usage(void)
13251338
fprintf(infoStream,"Usage: mqsmfcsv [-o <output dir>] [-a] [ -d <level> ]\n");
13261339
fprintf(infoStream," [-h yes|no] [ -i <input file> [-m <max records>]\n");
13271340
fprintf(infoStream," [-f RDW | NORDW | JSON | SQL | CSV ] \n");
1341+
fprintf(infoStream," [-b Db2 | MySQL ] \n");
13281342
fprintf(infoStream," [-p <template DDL file prefix> ] \n");
13291343
fprintf(infoStream," [-e <template DDL file ending> ] \n");
13301344
fprintf(infoStream," [-r] [-c] [-t <ticker>]\n");
13311345
fprintf(infoStream," -a Append to files if they exist. Default is overwrite.\n");
1346+
fprintf(infoStream," -b <Database> Database DDL format can be Db2 or MySQL. Default is Db2.\n");
13321347
fprintf(infoStream," -c Recover after aborted run by using the checkpoint.\n");
13331348
fprintf(infoStream," -d <Level> Debug by dumping binary records (Level = 1 or 2).\n");
13341349
fprintf(infoStream," -f File formats. Default to RDW for input, CSV for output.\n");

src/mqsmf.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,7 @@ extern char tmpHead[];
439439
extern FILE *infoStream;
440440
extern char *ddlTemplateOpen;
441441
extern char *ddlTemplateClose;
442+
extern char *ddlQuote;
442443

443444
enum outputFormat_e { OF_CSV=0, OF_SQL=1, OF_JSON=2 };
444445
extern enum outputFormat_e outputFormat;

src/printQMST.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,23 @@ void printQMST(qmst *p)
1919
{
2020
SMFPRINTSTART("QMST", p, conv16(p->qmstll));
2121

22-
ADDS32("MQOpen",p->qmstopen);
23-
ADDS32("MQClose",p->qmstclos);
24-
ADDS32("MQGet ",p->qmstget );
25-
ADDS32("MQPut" ,p->qmstput );
26-
ADDS32("MQPut1",p->qmstput1);
27-
ADDS32("MQInq ",p->qmstinq );
22+
ADDS32("Open",p->qmstopen);
23+
ADDS32("Close",p->qmstclos);
24+
ADDS32("Get ",p->qmstget );
25+
ADDS32("Put" ,p->qmstput );
26+
ADDS32("Put1",p->qmstput1);
27+
ADDS32("Inq ",p->qmstinq );
2828
ADDS32("Inql",p->qmstinql);
29-
ADDS32("MQSet ",p->qmstset );
29+
ADDS32("Set ",p->qmstset );
3030
ADDS32("Endw",p->qmstendw);
3131
ADDS32("Close_Handles",p->qmstcalh);
3232
if (conv16(p->qmstll) > offsetof(qmst, qmstsub))/* Fields added for V7.0 API calls*/
3333
{
34-
ADDS32("MQSub" ,p->qmstsub);
35-
ADDS32("MQSubReq",p->qmstsubr);
36-
ADDS32("MQCB " ,p->qmstcb);
37-
ADDS32("MQCTL " ,p->qmstctl);
38-
ADDS32("MQStatus",p->qmststus);
34+
ADDS32("Sub" ,p->qmstsub);
35+
ADDS32("SubReq",p->qmstsubr);
36+
ADDS32("CB " ,p->qmstcb);
37+
ADDS32("CTL " ,p->qmstctl);
38+
ADDS32("Status",p->qmststus);
3939
ADDS32("Pubs" ,p->qmstpubs);
4040
}
4141
#if CSQDSMF_VERSION >= 903

src/printWQ.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ void printWQ(wq *p)
4646
/*--------------------------------------------------------*/
4747
/* Object information */
4848
/*--------------------------------------------------------*/
49-
ADDSTR("QueueType" ,strMQQT(conv32(p->qtype)),16);
50-
ADDSTR("IndexType",strMQIT(conv32(p->indxtype)),16);
49+
ADDSTR("Queue" ,strMQQT(conv32(p->qtype)),16);
50+
ADDSTR("Index",strMQIT(conv32(p->indxtype)),16);
5151
ADDSTR("Scope",strMQQSGD(conv32(p->qsgdisp)),16);
5252

5353
/*--------------------------------------------------------*/

src/smfDDL.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -173,37 +173,37 @@ void printDDL(char *name, int type, int len)
173173
case DDL_I:
174174
/* SQL Integer is a 'signed 32-bit' when sometimes we need unsigned */
175175
/* So make it a big int always */
176-
fprintf(fp,"%s %s \t BIGINT \n",comma,formatDDL(nameCopy));
176+
fprintf(fp,"%s %s%s%s \t BIGINT \n",comma,ddlQuote,formatDDL(nameCopy),ddlQuote);
177177
break;
178178
case DDL_I64:
179-
fprintf(fp,"%s %s \t BIGINT\n",comma,formatDDL(nameCopy));
179+
fprintf(fp,"%s %s%s%s \t BIGINT\n",comma,ddlQuote,formatDDL(nameCopy),ddlQuote);
180180
break;
181181
case DDL_C:
182182
if (!strcmp(name,"Date")) /* special case for CommonHeader field*/
183183
{
184-
fprintf(fp,"%s %s \t DATE \n",comma,formatDDL(nameCopy));
184+
fprintf(fp,"%s %s%s%s \t DATE \n",comma,ddlQuote,formatDDL(nameCopy),ddlQuote);
185185
}
186186
else
187187
{
188-
fprintf(fp,"%s %s \t CHAR(%d)\n",comma,formatDDL(nameCopy),len);
188+
fprintf(fp,"%s %s%s%s \t CHAR(%d)\n",comma,ddlQuote,formatDDL(nameCopy),ddlQuote,len);
189189
}
190190
break;
191191
case DDL_SUS: /* a seconds/microseconds field */
192192
p = strstr(nameCopy,"(US)");
193193
if (p) *p = 0;
194-
fprintf(fp,"%s %s_us \t BIGINT\n",comma,formatDDL(nameCopy));
194+
fprintf(fp,"%s %s%s_us%s \t BIGINT\n",comma,ddlQuote,formatDDL(nameCopy),ddlQuote);
195195
break;
196196

197197
case DDL_DATE:
198198
p = strstr(nameCopy," (DATE)");
199199
if (p) *p = 0; /* remove the "(DATE)" bit */
200-
fprintf(fp,"%s %s_Date \t DATE\n",comma,formatDDL(nameCopy));
200+
fprintf(fp,"%s %s%s_Date%s \t DATE\n",comma,ddlQuote,formatDDL(nameCopy),ddlQuote);
201201
break;
202202
case DDL_TIME:
203203
p = strstr(nameCopy," (TIME)");
204204
if (p)
205205
*p = 0;
206-
fprintf(fp,"%s %s_Time \t CHAR(19)\n",comma,formatDDL(nameCopy));
206+
fprintf(fp,"%s %s%s_Time%s \t CHAR(19)\n",comma,ddlQuote,formatDDL(nameCopy),ddlQuote);
207207
break;
208208
}
209209

@@ -220,7 +220,7 @@ static char nameNoDup[COL_HEAD_LEN];
220220
char *formatDDL(char *name)
221221
{
222222
/* Leave room for _DATE etc as prefix */
223-
return formatDDLMaxLength(name,27);
223+
return formatDDLMaxLength(name,27);
224224
}
225225

226226
char *formatDDLMaxLength(char *name,int maxLength)

testing/load-mysql.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
# You will need to modify variables such as where the formatted csv files
44
# have been created, and which database/schema to work with.
55

6-
# Set credentials
6+
# Set credentials - there are better and more secure ways to
7+
# handle authentication for MySQL but this is simplest as the demonstration.
78
user="root"
89
pw="Passw0rd!"
910

@@ -18,6 +19,11 @@ schema="MQSMF"
1819
# a new database.
1920

2021
# Run the DDL to create the tables
22+
# In this script we start from scratch with a new DB.
23+
mysql -u $user --password=$pw --force << EOF
24+
DROP DATABASE $schema;
25+
CREATE DATABASE $schema;
26+
EOF
2127
mysql -u $user --password=$pw --force < SMF-MQTABLES.ddl
2228

2329
# And import all the data files

0 commit comments

Comments
 (0)