Explorar o código

v.db.addtable: update and document table index

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@72946 15284696-431f-4ddb-bdfa-cd5b030d7da7
Markus Metz %!s(int64=6) %!d(string=hai) anos
pai
achega
e1ca756d53
Modificáronse 1 ficheiros con 4 adicións e 1 borrados
  1. 4 1
      scripts/v.db.addtable/v.db.addtable.py

+ 4 - 1
scripts/v.db.addtable/v.db.addtable.py

@@ -6,6 +6,7 @@
 # AUTHOR(S):    Markus Neteler
 #               Converted to Python by Glynn Clements
 #               Key column added by Martin Landa <landa.martin gmail.com>
+#               Table index added by Markus Metz
 # PURPOSE:      interface to db.execute to creates and add a new table to given vector map
 # COPYRIGHT:    (C) 2005, 2007, 2008, 2011  by Markus Neteler & the GRASS Development Team
 #
@@ -136,13 +137,15 @@ def main():
         except CalledModuleError:
             grass.fatal(_("Unable to create table <%s>") % table)
 
+	# create index, see db/driver/*/index.c
         if driver != "dbf":
-            sql = "CREATE UNIQUE INDEX IF NOT EXISTS %s_%s ON %s (%s)" % (table, key, table, key)
+            sql = "CREATE UNIQUE INDEX %s_%s ON %s (%s)" % (table, key, table, key)
             try:
 		grass.run_command('db.execute',
 				  database=database, driver=driver, sql=sql)
 	    except:
 		grass.warning(_("Unable to create index on table <%s>") % table)
+		pass
 
     # connect the map to the DB:
     if schema: