Sure, why not.
Thanks
Bambi
..
On 04/05/2007, at 11:04 AM, Doug Hardie wrote:
> I often load a database from a msqldump. The normal approach is to
> cat the file through msql which works just fine. However, that
> approach generates a lot of output that effectively hides any
> errors. Worse yet, there is no indication of which record caused
> an error so it can take many hours to figure out how to fix the
> problem.
>
> I recommend adding a -q option to msql that will basically cause it
> to only output error messages along with the query (generally an
> insert of update record). The following changes to msql seem to
> work fine for me:
>
> --- msql.c.orig Thu May 3 17:07:17 2007
> +++ msql.c Thu May 3 17:45:51 2007
> @@ -61,6 +61,7 @@
> **********************************************************************
> ****/
> char *msql_tmpnam();
> +int quiet = 0;
> /
> **********************************************************************
> ****
> ** PRIVATE ROUTINES
> @@ -215,15 +216,18 @@
> printf("\n\nERROR : ");
> fflush(stdout);
> write(fileno(stdout),error,strlen(error));
> + if (quiet)
> + printf ("\nQuery = ", q);
> printf("\n\n");
> return;
> }
> + if (!quiet)
> printf("\nQuery OK. row(s) modified or retrieved.\n\n",res);
> result = msqlStoreResult();
> if (!result)
> {
> - printf("\n\n");
> + if (!quiet) printf("\n\n");
> return;
> }
> @@ -415,7 +419,7 @@
> extern int optind;
> extern char *optarg;
> - while((c=getopt(argc,argv,"f:h:"))!= -1)
> + while((c=getopt(argc,argv,"f:h:q"))!= -1)
> {
> switch(c)
> {
> @@ -433,6 +437,10 @@
> confFile = optarg;
> break;
> + case 'q':
> + quiet ++;
> + break;
> +
> case '?':
> errFlag++;
> break;
> @@ -483,12 +491,13 @@
> ** Run in interactive mode like the ingres/postgres monitor
> */
> + if (!quiet)
> printf("Welcome to the miniSQL monitor. Type \\h for help.\n\n");
>
> inchar = EOF+1;
> (void)bzero(qbuf,sizeof(qbuf));
> cp = qbuf;
> - printf("\nmSQL > ");
> + if (!quiet) printf("\nmSQL > ");
> fflush(stdout);
> while(!feof(stdin))
> {
> @@ -496,6 +505,7 @@
> qLen ++;
> if (qLen == MSQL_PKT_LEN)
> {
> + if (quiet) printf ("\nQuery = ", inString);
> printf("\n\n\nError : Query text too long ( > bytes!)\n\n",
> MSQL_PKT_LEN);
> printf("Check your query to ensure that there isn't an unclosed
> text field.\n\n");
> exit(1);
> @@ -518,7 +528,7 @@
> case 'h':
> help();
> newQ = 1;
> - printf("\nmSQL > ");
> + if (!quiet) printf("\nmSQL > ");
> prompt=0;
> break;
> case 'g':
> @@ -526,7 +536,7 @@
> newQ = 1;
> qLen = 0;
> inString = 0;
> - printf("\nmSQL > ");
> + if (!quiet) printf("\nmSQL > ");
> prompt=0;
> break;
> case 'e':
> @@ -534,7 +544,7 @@
> printf("Query buffer\n");
> printf("------------\n");
> printf("\n[continue]\n",qbuf);
> - printf(" -> ");
> + if (!quiet) printf(" -> ");
> prompt=0;
> cp = qbuf + strlen(qbuf);
> qLen = strlen(qbuf);
> @@ -548,13 +558,13 @@
> printf("\nQuery buffer\n");
> printf("------------\n");
> printf("\n[continue]\n",qbuf);
> - printf(" -> ");
> + if (!quiet) printf(" -> ");
> prompt=0;
> break;
> default:
> printf("\n\nUnknown command.\n\n");
> newQ = 1;
> - printf("\nmSQL > ");
> + if (!quiet) printf("\nmSQL > ");
> prompt=0;
> break;
> }
> @@ -595,7 +605,7 @@
> {
> if (prompt)
> {
> - printf(" -> ");
> + if (!quiet) printf(" -> ");
> }
> else
> {
>
> -----------------------------------------------------------------
> This is the Mini SQL Mailing List operated by Hughes Technologies
> To unsubscribe, go to http://www.Hughes.com.au/extras/email/
>
-----------------------------------------------------------------
This is the Mini SQL Mailing List operated by Hughes Technologies
To unsubscribe, go to http://www.Hughes.com.au/extras/email/
This archive was generated by hypermail 2b30 : Fri Jun 01 2007 - 00:20:01 PDT