From owner-freebsd-bugbusters@FreeBSD.ORG Sun Mar 14 13:37:34 2004 Return-Path: Delivered-To: freebsd-bugbusters@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 80B8616A4CE for ; Sun, 14 Mar 2004 13:37:34 -0800 (PST) Received: from ppb-envlabs.com (unknown [209.208.86.146]) by mx1.FreeBSD.org (Postfix) with SMTP id C736843D45 for ; Sun, 14 Mar 2004 13:37:33 -0800 (PST) (envelope-from whitton@atlantic.net) Received: (qmail 23638 invoked from network); 14 Mar 2004 21:25:39 -0000 Received: from localhost (127.0.0.1) by ppb-envlabs.com with SMTP; 14 Mar 2004 21:25:39 -0000 Received: from [192.168.0.4] (invalid.168.192.in-addr.arpa [192.168.0.4]) by dns.intranet (VaMailArmor-2.0.1.16) id 23630-66F10B80; Sun, 14 Mar 2004 16:25:38 -0500 Mime-Version: 1.0 (Apple Message framework v612) To: bugbusters@FreeBSD.org Message-Id: Content-Type: multipart/mixed; boundary=Apple-Mail-2-61319299 From: Travis Whitton Date: Sun, 14 Mar 2004 16:37:30 -0500 X-Mailer: Apple Mail (2.612) X-AntiVirus: checked by Vexira MailArmor (version: 2.0.1.16; VAE: 6.24.0.6; VDF: 6.24.0.55; host: ppb-envlabs.com) Subject: dbf2mysql -q option broken with mysql323-server and above X-BeenThere: freebsd-bugbusters@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Coordination of the Problem Report handling effort. List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 14 Mar 2004 21:37:34 -0000 --Apple-Mail-2-61319299 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; format=flowed Versions of mysql greater than 3.23.49 and greater than 4.0.2 require the MYSQL_OPT_LOCAL_INFILE option in all clients attempting to load data from a file. This patch allows dbf2mysql to function properly with the mysql323-server port. The existing dbf2mysql does not allow quick inserts(the -q) flag, which offers up to a 2.5X speedup. The option to allow local inserts is enable with a new flag (-L). The attached path replaces the existing patch-ab for dbf2mysql-1.14. Thanks, Travis Whitton --Apple-Mail-2-61319299 Content-Transfer-Encoding: 7bit Content-Type: application/octet-stream; x-unix-mode=0644; name="patch-ab" Content-Disposition: attachment; filename=patch-ab --- dbf2mysql.c.orig Thu Mar 11 15:39:22 2004 +++ dbf2mysql.c Thu Mar 11 15:59:12 2004 @@ -9,6 +9,12 @@ Fixxed Quick mode insert for blank Numeric fields Modified to use -x flag to add _rec and _timestamp fields to start of record. ( only those lines immediately affect by if(express) (and getopt) ) + + Bart Friederichs (bart@friesoft.nl) feb 2003 + Added MYSQL_OPT_LOCAL_INFILE to options for compatibility with + MySQL >3.23.49 and >4.0.2, new option -L enables it + Replaced mysql_connect with mysql_real_connect, SQLsock isn't used anymore + */ #include #include @@ -25,7 +31,7 @@ #endif int verbose=0, upper=0, lower=0, create=0, fieldlow=0, var_chars=1; -int express=0; +int express=0, enable_local=0; int null_fields=0, trim=0, quick=0; char primary[11]; char *host = NULL; @@ -84,7 +90,7 @@ printf("dbf2mysql %s\n", VERSION); printf("usage: dbf2mysql [-h hostname] [-d dbase] [-t table] [-p primary key]\n"); printf(" [-o field[,field]] [-s oldname=newname[,oldname=newname]]\n"); - printf(" [-i field[,field]] [-c] [-f] [-F] [-n] [-r] [-u|-l] \n"); + printf(" [-i field[,field]] [-c] [-f] [-F] [-n] [-r] [-u|-l] [-L]\n"); printf(" [-v[v]] [-x] [-q] [-P password] [-U user] dbf-file\n"); } @@ -588,7 +594,7 @@ } if (mysql_query(SQLsock, query) == -1) { fprintf(stderr, - "Error sending LOAD DATA INFILE from file '%s'\n", datafile); + "Error sending LOAD DATA LOCAL INFILE from file '%s'\n", datafile); fprintf(stderr, "Detailed report: %s\n", mysql_error(SQLsock)); @@ -604,7 +610,7 @@ int main(int argc, char **argv) { int i; - MYSQL *SQLsock,mysql; + MYSQL mysql; extern int optind; extern char *optarg; char *query; @@ -612,7 +618,7 @@ primary[0] = '\0'; - while ((i = getopt(argc, argv, "xqfFrne:lucvi:h:p:d:t:s:o:U:P:")) != EOF) { + while ((i = getopt(argc, argv, "xqLfFrne:lucvi:h:p:d:t:s:o:U:P:")) != EOF) { switch (i) { case 'P': pass = (char *)strdup(optarg); @@ -679,6 +685,9 @@ case 'o': flist = (char *)strdup(optarg); break; + case 'L': + enable_local = 1; + break; case ':': usage(); printf("missing argument!\n"); @@ -717,6 +726,7 @@ table); printf("Number of records: %ld\n", dbh->db_records); } + if (verbose > 1) { printf("Name\t\t Length\tDisplay\t Type\n"); printf("-------------------------------------\n"); @@ -733,7 +743,20 @@ printf("Making connection to MySQL-server\n"); } - if (!(SQLsock = mysql_connect(&mysql,host,user,pass))) { + mysql_init(&mysql); + + if (enable_local == 1) { + if (verbose) { + printf("Setting MySQL option MYSQL_OPT_LOCAL_INFILE\n"); + } + + if (mysql_options(&mysql, MYSQL_OPT_LOCAL_INFILE, 0)) { + printf("Setting options failed."); + exit(1); + } + } + + if (!mysql_real_connect(&mysql,host,user,pass, dbase, 0, NULL,0)) { fprintf(stderr, "Couldn't get a connection with the "); fprintf(stderr, "designated host!\n"); fprintf(stderr, "Detailed report: %s\n", mysql_error(&mysql)); @@ -741,23 +764,12 @@ exit(1); } - if (verbose > 2) { - printf("Selecting database '%s'\n", dbase); - } - - if ((mysql_select_db(SQLsock, dbase)) == -1) { - fprintf(stderr, "Couldn't select database %s.\n", dbase); - fprintf(stderr, "Detailed report: %s\n", mysql_error(SQLsock)); - mysql_close(SQLsock); - dbf_close(&dbh); - exit(1); - } /* Substitute field names */ do_onlyfields(flist, dbh); do_substitute(subarg, dbh); if (!create) { - if (!check_table(SQLsock, table)) { + if (!check_table(&mysql, table)) { printf("Table does not exist!\n"); exit(1); } @@ -768,30 +780,30 @@ if (!(query = (char *)malloc(12 + strlen(table)))) { printf("Memory-allocation error in main (drop)!\n"); - mysql_close(SQLsock); + mysql_close(&mysql); dbf_close(&dbh); exit(1); } sprintf(query, "DROP TABLE %s", table); - mysql_query(SQLsock, query); + mysql_query(&mysql, query); free(query); /* Build a CREATE-clause */ - do_create(SQLsock, table, dbh); + do_create(&mysql, table, dbh); } /* Build an INSERT-clause */ if (create < 2) - do_inserts(SQLsock, table, dbh); + do_inserts(&mysql, table, dbh); if (verbose > 2) { printf("Closing up....\n"); } - mysql_close(SQLsock); + mysql_close(&mysql); dbf_close(&dbh); exit(0); } --Apple-Mail-2-61319299-- From owner-freebsd-bugbusters@FreeBSD.ORG Wed Mar 17 13:56:41 2004 Return-Path: Delivered-To: freebsd-bugbusters@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D996716A4E7 for ; Wed, 17 Mar 2004 13:56:41 -0800 (PST) Received: from mail24.e.nsc.no (mail24.e.nsc.no [193.213.115.24]) by mx1.FreeBSD.org (Postfix) with ESMTP id 122E443D31 for ; Wed, 17 Mar 2004 13:56:41 -0800 (PST) (envelope-from kris1976@mail24.e.nsc.no) Received: (from mailuser@localhost) by mail24.e.nsc.no (8.9.3p2/8.9.3) id WAA15393 for freebsd-bugbusters@freebsd.org; Wed, 17 Mar 2004 22:56:39 +0100 (MET) Date: Wed, 17 Mar 2004 22:56:39 +0100 (MET) Message-Id: <200403172156.WAA15393@mail24.e.nsc.no> To: freebsd-bugbusters@freebsd.org From: kris1976@online.no X-Loop: kris1976@online.no Precedence: junk Subject: Re: Re: Here X-BeenThere: freebsd-bugbusters@freebsd.org X-Mailman-Version: 2.1.1 List-Id: Coordination of the Problem Report handling effort. List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Mar 2004 21:56:42 -0000 automatik reply: Thanks for your email. I will answer you so fast its possible, or you can send me a SMS on mobilphone number +47 976 22 527 Kristian