From nobody@FreeBSD.org  Tue Nov 30 02:02:00 2010
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 299CF1065670
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 30 Nov 2010 02:02:00 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (unknown [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id 178348FC08
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 30 Nov 2010 02:02:00 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.4/8.14.4) with ESMTP id oAU21xXQ027346
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 30 Nov 2010 02:01:59 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.4/8.14.4/Submit) id oAU21xXB027345;
	Tue, 30 Nov 2010 02:01:59 GMT
	(envelope-from nobody)
Message-Id: <201011300201.oAU21xXB027345@red.freebsd.org>
Date: Tue, 30 Nov 2010 02:01:59 GMT
From: Miroslav Lachman <000.fbsd@quip.cz>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [patch] databases/dbf2mysql can be compiled with current MySQL client library
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         152693
>Category:       ports
>Synopsis:       [patch] databases/dbf2mysql can be compiled with current MySQL client library
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    beech
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Nov 30 02:10:12 UTC 2010
>Closed-Date:    Sat Dec 04 21:22:34 UTC 2010
>Last-Modified:  Sat Dec  4 21:30:11 UTC 2010
>Originator:     Miroslav Lachman
>Release:        FreeBSD 7.3-RELEASE-p2 i386
>Organization:
codeLab.cz
>Environment:
7.3-RELEASE-p2 FreeBSD 7.3-RELEASE-p2 #0: Mon Jul 12 19:04:04 UTC 2010     root@i386-builder.daemonology.net:/usr/obj/usr/src/sys/GENERIC  i386
>Description:
The port databases/dbf2mysql has hardoced dependency on mysql-client-3.23.59.n.20050301_2 which is too old in these days and can't be compiled with newer gcc.

root@roxy dbf2mysql/# make
===>  Extracting for dbf2mysql-1.14_2
=> MD5 Checksum OK for dbf2mysql-1.14.tar.gz.
=> SHA256 Checksum OK for dbf2mysql-1.14.tar.gz.
===>  Patching for dbf2mysql-1.14_2
===>  Applying FreeBSD patches for dbf2mysql-1.14_2
===>   dbf2mysql-1.14_2 depends on shared library: mysqlclient.10 - not found
===>    Verifying install for mysqlclient.10 in /usr/ports/databases/mysql323-client
===>  mysql-client-3.23.59.n.20050301_2 obsolete and does not build with gcc4.2; use mysql 5 or later.
*** Error code 1

Stop in /usr/ports/databases/mysql323-client.
*** Error code 1

Stop in /usr/ports/databases/dbf2mysql. 



It is better to make it compilable with current versions of MySQL client library (5.0 or 5.1 for example) and use generic:

USE_MYSQL=	yes

instead of

LIB_DEPENDS=	mysqlclient.10:${PORTSDIR}/databases/mysql323-client
>How-To-Repeat:
Try to build and use dbf2mysql in todays systems (GCC 4.2, MySQL 5.0.x etc.)
>Fix:
The problem is first discussed here
http://lists.freebsd.org/pipermail/freebsd-ports/2010-November/064714.html

And working patch is attached. 
Now it works with MySQL 5.0.90 client library.

Patch attached with submission follows:

Index: databases/dbf2mysql/Makefile
===================================================================
--- Makefile.orig	2010-11-28 18:34:26.000000000 +0100
+++ Makefile	2010-11-28 19:11:05.000000000 +0100
@@ -18,7 +18,7 @@
 MAINTAINER=	ports@FreeBSD.org
 COMMENT=	Programs to convert .dbf files to MySQL tables and vice versa
 
-LIB_DEPENDS=	mysqlclient.10:${PORTSDIR}/databases/mysql323-client
+USE_MYSQL=	yes
 
 PORTDOCS=	README
 



Index: databases/dbf2mysql/work/dbf2mysql-1.14/mysql2dbf.c
===================================================================
--- mysql2dbf.c.orig	2010-11-28 19:46:34.000000000 +0100
+++ mysql2dbf.c	2010-11-28 21:23:22.000000000 +0100
@@ -1,6 +1,11 @@
 /*	utility to read out an mySQL-table, and store it into a DBF-file
 
 	M. Boekhold (boekhold@cindy.et.tudelft.nl) April 1996
+
+	M. Lachman Nov 2010
+	Replaced mysql_connect with mysql_real_connect, SQLsock isn't used anymore
+	Can be compiled with MySQL client 5.0.x
+
 */
 
 #include <stdio.h>
@@ -47,7 +52,7 @@
 
 int main(int argc, char **argv) {
 	int             i;
-	MYSQL		*SQLsock,mysql;
+	MYSQL		mysql;
 	extern int      optind;
 	extern char     *optarg;
 	char            *query = NULL;
@@ -148,7 +153,9 @@
 		printf("Making connection with mySQL-server\n");
 	}
 
-    if (!(SQLsock = mysql_connect(&mysql,host,user,pass))) {
+    mysql_init(&mysql);
+
+    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));
@@ -157,37 +164,24 @@
         exit(1);
     }
 
-    if (verbose > 1) {
-        printf("Selecting database\n");
-    }
-
-    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));
-        close(dbh->db_fd);
-        free(dbh);
-        mysql_close(SQLsock);
-        exit(1);
-    }
-
 	if (verbose > 1) {
 		printf("Sending query\n");
 	}
 	
 
-	if (mysql_query(SQLsock, query) == -1) {
+	if (mysql_query(&mysql, query) == -1) {
 		fprintf(stderr, "Error sending query.\nDetailed report: %s\n",
-				mysql_error(SQLsock));
+				mysql_error(&mysql));
 		if (verbose > 1) {
 			fprintf(stderr, "%s\n", query);
 		}
-		mysql_close(SQLsock);
+		mysql_close(&mysql);
 		close(dbh->db_fd);
 		free(dbh);
 		exit(1);
 	}
 
-	qres            = mysql_store_result(SQLsock);
+	qres            = mysql_store_result(&mysql);
 	numfields       = mysql_num_fields(qres);
 	numrows			= mysql_num_rows(qres);
 
@@ -303,7 +297,7 @@
 	}
 				
 	mysql_free_result(qres);
-	mysql_close(SQLsock);
+	mysql_close(&mysql);
 	close(dbh->db_fd);
 	free(dbh);
 	exit(0);


>Release-Note:
>Audit-Trail:

From: Miroslav Lachman <000.fbsd@quip.cz>
To: freebsd-gnats-submit@FreeBSD.org
Cc:  
Subject: Re: ports/152693: [patch] databases/dbf2mysql can be compiled with
 current MySQL client library
Date: Thu, 02 Dec 2010 12:29:24 +0100

 There are additional improvements from Debian's patch
 http://www.mail-archive.com/debian-bugs-dist@lists.debian.org/msg787955.html
 
 It adds support for charset settings.
 
 But charset support is incomplete, it needs CHARACTER SET in LOAD DATA 
 query:
 
 sprintf (query, "LOAD DATA LOCAL INFILE '%s' REPLACE INTO table %s 
 CHARACTER SET %s FIELDS TERMINATED BY ',' ENCLOSED BY ''''", datafile, 
 table, charset);
 
 If somebody is willing to test & committ it, I can produce the patches 
 for FreeBSD ports system. Just let me know.
 
 Miroslav Lachman
Responsible-Changed-From-To: freebsd-ports-bugs->beech 
Responsible-Changed-By: beech 
Responsible-Changed-When: Fri Dec 3 23:23:51 UTC 2010 
Responsible-Changed-Why:  
I'll take it. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=152693 
State-Changed-From-To: open->closed 
State-Changed-By: beech 
State-Changed-When: Sat Dec 4 21:22:17 UTC 2010 
State-Changed-Why:  
Committed, Thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=152693 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: ports/152693: commit references a PR
Date: Sat,  4 Dec 2010 21:21:18 +0000 (UTC)

 beech       2010-12-04 21:21:14 UTC
 
   FreeBSD ports repository
 
   Modified files:
     databases/dbf2mysql  Makefile 
   Added files:
     databases/dbf2mysql/files patch-mysql2dbf.c 
   Log:
   Fix can be compiled with current MySQL client library
   
   PR:             ports/152693
   Submitted by:   Miroslav Lachman (000.fbsd@quip.cz) (maintainer)
   Approved by:    itetcu (mentor) (implicit)
   
   Revision  Changes    Path
   1.16      +1 -1      ports/databases/dbf2mysql/Makefile
   1.1       +88 -0     ports/databases/dbf2mysql/files/patch-mysql2dbf.c (new)
 _______________________________________________
 cvs-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/cvs-all
 To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
 
>Unformatted:
