patch to add -N to mdb-export

Terry Brown <[email protected]> Wed, 14 Jul 2010 10:43:54 -0500
Newsgroups gmane.comp.db.mdb-tools.devel
Message-ID <[email protected]>
mdb-export needs to support -N <namespace> to make it work with mdb-schema when the latter is using -N <namespace>.

It's a trivial thing to do, I've attached what I hope is a correctly formatted patch from `git diff -w` against a git clone from today, Jul 14 2010.  If this isn't the right place for the patch let me know.

Thanks for the great tool.

Cheers -Terry

------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first

_______________________________________________
mdbtools-dev mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mdbtools-dev
N_for_export.patch (text/x-patch, 1.5 KB)
diff --git a/src/util/mdb-export.c b/src/util/mdb-export.c
index a5ff4d5..41a2aa2 100644
--- a/src/util/mdb-export.c
+++ b/src/util/mdb-export.c
@@ -72,9 +72,10 @@ main(int argc, char **argv)
 	char quote_text = 1;
 	char *insert_dialect = NULL;
 	char sanitize = 0;
+	char *namespace = "";
 	int  opt;
 
-	while ((opt=getopt(argc, argv, "HQq:X:d:D:R:I:S"))!=-1) {
+	while ((opt=getopt(argc, argv, "HQq:X:d:D:R:I:N:S"))!=-1) {
 		switch (opt) {
 		case 'H':
 			header_row = 0;
@@ -104,6 +105,9 @@ main(int argc, char **argv)
 		case 'X':
 			escape_char = (char *) g_strdup(optarg);
 		break;
+		case 'N':
+			namespace = (char *) g_strdup(optarg);
+		break;
 		default:
 		break;
 		}
@@ -134,6 +138,7 @@ main(int argc, char **argv)
 		fprintf(stderr,"  -S             Sanitize names (replace spaces etc. with underscore)\n");
 		fprintf(stderr,"  -q <char>      Use <char> to wrap text-like fields. Default is \".\n");
 		fprintf(stderr,"  -X <char>      Use <char> to escape quoted characters within a field. Default is doubling.\n");
+		fprintf(stderr,"  -N <namespace> Prefix identifiers with namespace\n");
 		g_free (delimiter);
 		g_free (row_delimiter);
 		g_free (quote_char);
@@ -198,7 +203,7 @@ main(int argc, char **argv)
 				quoted_name = sanitize_name(argv[optind + 1]);
 			else
 				quoted_name = mdb->default_backend->quote_name(argv[optind + 1]);
-			fprintf(stdout, "INSERT INTO %s (", quoted_name);
+			fprintf(stdout, "INSERT INTO %s%s (", namespace, quoted_name);
 			free(quoted_name);
 			for (j=0;j<table->num_cols;j++) {
 				if (j>0) fprintf(stdout, ", ");