Index: trunk/base/portmgr/PortIndex2MySQL.tcl
===================================================================
--- trunk/base/portmgr/PortIndex2MySQL.tcl	(revision 28226)
+++ trunk/base/portmgr/PortIndex2MySQL.tcl	(revision 28262)
@@ -83,9 +83,8 @@
 set dbcmd [macports::findBinary mysql5]
 set dbhost 127.0.0.1
-set dbname macports
 set dbuser macports
 set passwdfile [file join . password_file]
 set dbpasswd [getpasswd $passwdfile]
-set dbcmdargs "-h $dbhost -u $dbuser -p$dbpasswd $dbname"
+set dbname macports
 
 # Flat text file to which sql statements are written.
@@ -106,25 +105,25 @@
 # Initial creation of database tables: log, portfiles, categories, maintainers, dependencies, variants and platforms.
 # Do we need any other?
-puts $sqlfile_fd "DROP TABLE log"
-puts $sqlfile_fd "CREATE TABLE IF NOT EXISTS log (activity VARCHAR(255), activity_time TIMESTAMP(14))"
-puts $sqlfile_fd "INSERT INTO log VALUES ('update', NOW())"
-
-puts $sqlfile_fd "DROP TABLE portfiles"
-puts $sqlfile_fd "CREATE TABLE portfiles (name VARCHAR(255) PRIMARY KEY NOT NULL, path VARCHAR(255), version VARCHAR(255),  description TEXT)"
-
-puts $sqlfile_fd "DROP TABLE IF EXISTS categories"
-puts $sqlfile_fd "CREATE TABLE categories (portfile VARCHAR(255), category VARCHAR(255), is_primary INTEGER)"
-
-puts $sqlfile_fd "DROP TABLE IF EXISTS maintainers"
-puts $sqlfile_fd "CREATE TABLE maintainers (portfile VARCHAR(255), maintainer VARCHAR(255), is_primary INTEGER)"
-
-puts $sqlfile_fd "DROP TABLE IF EXISTS dependencies"
-puts $sqlfile_fd "CREATE TABLE dependencies (portfile VARCHAR(255), library VARCHAR(255))"
-
-puts $sqlfile_fd "DROP TABLE IF EXISTS variants"
-puts $sqlfile_fd "CREATE TABLE variants (portfile VARCHAR(255), variant VARCHAR(255))"
-
-puts $sqlfile_fd "DROP TABLE IF EXISTS platforms"
-puts $sqlfile_fd "CREATE TABLE platforms (portfile VARCHAR(255), platform VARCHAR(255))"
+puts $sqlfile_fd "DROP TABLE IF EXISTS log;"
+puts $sqlfile_fd "CREATE TABLE IF NOT EXISTS log (activity VARCHAR(255), activity_time TIMESTAMP(14));"
+puts $sqlfile_fd "INSERT INTO log VALUES ('update', NOW());"
+
+puts $sqlfile_fd "DROP TABLE IF EXISTS portfiles;"
+puts $sqlfile_fd "CREATE TABLE portfiles (name VARCHAR(255) PRIMARY KEY NOT NULL, path VARCHAR(255), version VARCHAR(255),  description TEXT);"
+
+puts $sqlfile_fd "DROP TABLE IF EXISTS categories;"
+puts $sqlfile_fd "CREATE TABLE categories (portfile VARCHAR(255), category VARCHAR(255), is_primary INTEGER);"
+
+puts $sqlfile_fd "DROP TABLE IF EXISTS maintainers;"
+puts $sqlfile_fd "CREATE TABLE maintainers (portfile VARCHAR(255), maintainer VARCHAR(255), is_primary INTEGER);"
+
+puts $sqlfile_fd "DROP TABLE IF EXISTS dependencies;"
+puts $sqlfile_fd "CREATE TABLE dependencies (portfile VARCHAR(255), library VARCHAR(255));"
+
+puts $sqlfile_fd "DROP TABLE IF EXISTS variants;"
+puts $sqlfile_fd "CREATE TABLE variants (portfile VARCHAR(255), variant VARCHAR(255));"
+
+puts $sqlfile_fd "DROP TABLE IF EXISTS platforms;"
+puts $sqlfile_fd "CREATE TABLE platforms (portfile VARCHAR(255), platform VARCHAR(255));"
 
 
@@ -190,43 +189,43 @@
 	}
 
-	puts $sqlfile_fd "INSERT INTO portfiles VALUES ('$portname', '$portdir', '$portversion', '$description')"
+	puts $sqlfile_fd "INSERT INTO portfiles VALUES ('$portname', '$portdir', '$portversion', '$description');"
 
 	set primary 1
 	foreach category $categories {
-		set category [sql_escape $category]
-		puts $sqlfile_fd "INSERT INTO categories VALUES ('$portname', '$category', $primary)"
-		incr primary
+            set category [sql_escape $category]
+            puts $sqlfile_fd "INSERT INTO categories VALUES ('$portname', '$category', $primary);"
+            incr primary
 	}
 	
 	set primary 1
 	foreach maintainer $maintainers {
-		set maintainer [sql_escape $maintainer]
-		puts $sqlfile_fd "INSERT INTO maintainers VALUES ('$portname', '$maintainer', $primary)"
-		incr primary
+            set maintainer [sql_escape $maintainer]
+            puts $sqlfile_fd "INSERT INTO maintainers VALUES ('$portname', '$maintainer', $primary);"
+            incr primary
 	}
 
         foreach build_dep $depends_build {
             set build_dep [sql_escape $build_dep]
-            puts $sqlfile_fd "INSERT INTO dependencies VALUES ('$portname', '$build_dep')"
+            puts $sqlfile_fd "INSERT INTO dependencies VALUES ('$portname', '$build_dep');"
         }
 
 	foreach lib $depends_lib {
-		set lib [sql_escape $lib]
-		puts $sqlfile_fd "INSERT INTO dependencies VALUES ('$portname', '$lib')"
+            set lib [sql_escape $lib]
+            puts $sqlfile_fd "INSERT INTO dependencies VALUES ('$portname', '$lib');"
 	}
 
         foreach run_dep $depends_run {
             set run_dep [sql_escape $run_dep]
-            puts $sqlfile_fd "INSERT INTO dependencies VALUES ('$portname', '$run_dep')"
+            puts $sqlfile_fd "INSERT INTO dependencies VALUES ('$portname', '$run_dep');"
         }
 
 	foreach variant $variants {
-		set variant [sql_escape $variant]
-		puts $sqlfile_fd "INSERT INTO variants VALUES ('$portname', '$variant')"
+            set variant [sql_escape $variant]
+            puts $sqlfile_fd "INSERT INTO variants VALUES ('$portname', '$variant');"
 	}
 
 	foreach platform $platforms {
-		set platform [sql_escape $platform]
-		puts $sqlfile_fd "INSERT INTO platforms VALUES ('$portname', '$platform')"
+            set platform [sql_escape $platform]
+            puts $sqlfile_fd "INSERT INTO platforms VALUES ('$portname', '$platform');"
 	}
 
@@ -240,5 +239,5 @@
     exit 1
 }
-if {[catch {exec $dbcmd $dbcmdargs <@ $sqlfile_fd} errstr]} {
+if {[catch {exec -- $dbcmd --host=$dbhost --user=$dbuser --password=$dbpasswd --database=$dbname <@ $sqlfile_fd} errstr]} {
     ui_error "${::errorCode}: $errstr"
     exit 1
