Well,

I downloaded osmosis via svn and had a look into the code.
I found only one section where the index is dropped.
The file is called IndexManager.java.

I changed the file locally so that the SQL Statement throws only then an 
exception, when something is going wrong during the drop, not when the index is 
not existing.

See below:
        private static final String[] PRE_LOAD_SQL = {
                "ALTER TABLE users DROP CONSTRAINT pk_users",
                "ALTER TABLE nodes DROP CONSTRAINT pk_nodes",
                "ALTER TABLE ways DROP CONSTRAINT pk_ways",
                "ALTER TABLE way_nodes DROP CONSTRAINT pk_way_nodes",
                "ALTER TABLE relations DROP CONSTRAINT pk_relations",
                "ALTER TABLE relation_members DROP CONSTRAINT 
pk_relation_members",
                "DROP INDEX IF EXISTS idx_nodes_geom",
                "DROP INDEX IF EXISTS idx_way_nodes_node_id",
                "DROP INDEX IF EXISTS idx_relation_members_member_id_and_type"
        };
        private static final String[] PRE_LOAD_SQL_WAY_BBOX = {
                "DROP INDEX IF EXISTS idx_ways_bbox"
        };
        private static final String[] PRE_LOAD_SQL_WAY_LINESTRING = {
                "DROP INDEX IF EXISTS idx_ways_linestring"
        };

I just changed the statements from "DROP INDEX xxx" to "DROP INDEX IF EXISTS 
xxx".
This helps for the first step.

But now I get an error that the file can not be copied, see here:
tho...@thomas-laptop:~/workspace/osmosis-SNAPSHOT-r24762M/bin$ ./osmosis --rb 
file="/Massenspeicher/bayern.osm.pbf" --wp user="osm" database="osmdb" 
password="xxx" validateSchemaVersion="no" nodeLocationStoreType="TempFile"
15.12.2010 17:42:00 org.openstreetmap.osmosis.core.Osmosis run
INFO: Osmosis Version SNAPSHOT-r24762
15.12.2010 17:42:01 org.openstreetmap.osmosis.core.Osmosis run
INFO: Preparing pipeline.
15.12.2010 17:42:01 org.openstreetmap.osmosis.core.Osmosis run
INFO: Launching pipeline execution.
15.12.2010 17:42:01 org.openstreetmap.osmosis.core.Osmosis run
INFO: Pipeline executing, waiting for completion.
15.12.2010 18:05:43 
org.openstreetmap.osmosis.core.pipeline.common.ActiveTaskManager 
waitForCompletion
SCHWERWIEGEND: Thread for task 1-rb failed
org.openstreetmap.osmosis.core.OsmosisRuntimeException: Unable to process COPY 
file /tmp/copy8342938904056522756n.
        at 
org.openstreetmap.osmosis.pgsnapshot.common.DatabaseContext.loadCopyFile(DatabaseContext.java:293)
        at 
org.openstreetmap.osmosis.pgsnapshot.v0_6.impl.CopyFilesetLoader.run(CopyFilesetLoader.java:97)
        at 
org.openstreetmap.osmosis.pgsnapshot.v0_6.PostgreSqlCopyWriter.complete(PostgreSqlCopyWriter.java:108)
        at 
crosby.binary.osmosis.OsmosisBinaryParser.complete(OsmosisBinaryParser.java:34)
        at crosby.binary.file.BlockInputStream.process(BlockInputStream.java:17)
        at crosby.binary.osmosis.OsmosisReader.run(OsmosisReader.java:37)
        at java.lang.Thread.run(Thread.java:662)
Caused by: org.postgresql.util.PSQLException: FEHLER: Spalte »tags« von 
Relation »nodes« existiert nicht
        at 
org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2062)
        at 
org.postgresql.core.v3.QueryExecutorImpl.processCopyResults(QueryExecutorImpl.java:929)
        at 
org.postgresql.core.v3.QueryExecutorImpl.startCopy(QueryExecutorImpl.java:713)
        at org.postgresql.copy.CopyManager.copyIn(CopyManager.java:52)
        at org.postgresql.copy.CopyManager.copyIn(CopyManager.java:176)
        at org.postgresql.copy.CopyManager.copyIn(CopyManager.java:161)
        at 
org.openstreetmap.osmosis.pgsnapshot.common.DatabaseContext.loadCopyFile(DatabaseContext.java:282)
        ... 6 more
15.12.2010 18:05:43 org.openstreetmap.osmosis.core.Osmosis main
SCHWERWIEGEND: Execution aborted.
org.openstreetmap.osmosis.core.OsmosisRuntimeException: One or more tasks 
failed.
        at 
org.openstreetmap.osmosis.core.pipeline.common.Pipeline.waitForCompletion(Pipeline.java:146)
        at org.openstreetmap.osmosis.core.Osmosis.run(Osmosis.java:92)
        at org.openstreetmap.osmosis.core.Osmosis.main(Osmosis.java:37)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at 
org.codehaus.plexus.classworlds.launcher.Launcher.launchStandard(Launcher.java:329)
        at 
org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:239)
        at 
org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
        at 
org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
        at org.codehaus.classworlds.Launcher.main(Launcher.java:31)
tho...@thomas-laptop:~/workspace/osmosis-SNAPSHOT-r24762M/bin$

I have no idea what's going wrong here, maybe I have to debug osmosis, but to 
set up the right configuration for debugging will take a while.

Any hints are welcome.

Thomas

-------- Original-Nachricht --------
> Datum: Wed, 15 Dec 2010 11:06:11 +0100
> Von: "Thomas Schreiner" <schreiner.tho...@gmx.net>
> An: osmosis-dev@openstreetmap.org
> Betreff: [osmosis-dev] Problem with pbf import into a postgres DB

> Hello,
> 
> I've downloaded the osmosis version 0.38 (latest).
> I try to import a pbf file downloaded from download.geofabrik.de.
> 
> I will always get an exception, that an index can not be dropped. Why.
> See the details below.
> 
> tho...@thomas-laptop:~/workspace/osmosis-0.38/bin$ ./osmosis --rb
> file="/Massenspeicher/bayern.osm.pbf" --wp user="osm" database="osmdb"
> password="xxx" validateSchemaVersion="no" nodeLocationStoreType="TempFile"
> 15.12.2010 00:59:04 org.openstreetmap.osmosis.core.Osmosis run
> INFO: Osmosis Version 0.38
> 15.12.2010 00:59:04 org.openstreetmap.osmosis.core.Osmosis run
> INFO: Preparing pipeline.
> 15.12.2010 00:59:04 org.openstreetmap.osmosis.core.Osmosis run
> INFO: Launching pipeline execution.
> 15.12.2010 00:59:04 org.openstreetmap.osmosis.core.Osmosis run
> INFO: Pipeline executing, waiting for completion.
> 15.12.2010 01:45:34
> org.springframework.beans.factory.xml.XmlBeanDefinitionReader 
> loadBeanDefinitions
> INFO: Loading XML bean definitions from class path resource
> [org/springframework/jdbc/support/sql-error-codes.xml]
> 15.12.2010 01:45:35 org.springframework.jdbc.support.SQLErrorCodesFactory
> <init>
> INFO: SQLErrorCodes loaded: [DB2, Derby, H2, HSQL, Informix, MS-SQL,
> MySQL, Oracle, PostgreSQL, Sybase]
> 15.12.2010 01:45:35
> org.openstreetmap.osmosis.core.pipeline.common.ActiveTaskManager 
> waitForCompletion
> SCHWERWIEGEND: Thread for task 1-rb failed
> org.springframework.jdbc.BadSqlGrammarException: StatementCallback; bad
> SQL grammar [DROP INDEX idx_relation_members_member_id_and_type]; nested
> exception is org.postgresql.util.PSQLException: FEHLER: Index
> »idx_relation_members_member_id_and_type« existiert nicht
>       at
> org.springframework.jdbc.support.SQLStateSQLExceptionTranslator.doTranslate(SQLStateSQLExceptionTranslator.java:98)
>       at
> org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72)
>       at
> org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
>       at
> org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
>       at
> org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:406)
>       at
> org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:518)
>       at
> org.springframework.jdbc.core.simple.SimpleJdbcTemplate.update(SimpleJdbcTemplate.java:248)
>       at
> org.openstreetmap.osmosis.pgsnapshot.v0_6.impl.IndexManager.prepareForLoad(IndexManager.java:103)
>       at
> org.openstreetmap.osmosis.pgsnapshot.v0_6.impl.CopyFilesetLoader.run(CopyFilesetLoader.java:92)
>       at
> org.openstreetmap.osmosis.pgsnapshot.v0_6.PostgreSqlCopyWriter.complete(PostgreSqlCopyWriter.java:108)
>       at
> crosby.binary.osmosis.OsmosisBinaryParser.complete(OsmosisBinaryParser.java:33)
>       at crosby.binary.file.BlockInputStream.process(BlockInputStream.java:17)
>       at crosby.binary.osmosis.OsmosisReader.run(OsmosisReader.java:36)
>       at java.lang.Thread.run(Thread.java:662)
> Caused by: org.postgresql.util.PSQLException: FEHLER: Index
> »idx_relation_members_member_id_and_type« existiert nicht
>       at
> org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2062)
>       at
> org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1795)
>       at
> org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:257)
>       at
> org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:479)
>       at
> org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:353)
>       at
> org.postgresql.jdbc2.AbstractJdbc2Statement.executeUpdate(AbstractJdbc2Statement.java:299)
>       at
> org.apache.commons.dbcp.DelegatingStatement.executeUpdate(DelegatingStatement.java:228)
>       at
> org.apache.commons.dbcp.DelegatingStatement.executeUpdate(DelegatingStatement.java:228)
>       at
> org.springframework.jdbc.core.JdbcTemplate$1UpdateStatementCallback.doInStatement(JdbcTemplate.java:508)
>       at
> org.springframework.jdbc.core.JdbcTemplate$1UpdateStatementCallback.doInStatement(JdbcTemplate.java:1)
>       at
> org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:395)
>       ... 9 more
> 15.12.2010 01:45:35 org.openstreetmap.osmosis.core.Osmosis main
> SCHWERWIEGEND: Execution aborted.
> org.openstreetmap.osmosis.core.OsmosisRuntimeException: One or more tasks
> failed.
>       at
> org.openstreetmap.osmosis.core.pipeline.common.Pipeline.waitForCompletion(Pipeline.java:146)
>       at org.openstreetmap.osmosis.core.Osmosis.run(Osmosis.java:92)
>       at org.openstreetmap.osmosis.core.Osmosis.main(Osmosis.java:37)
>       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>       at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>       at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>       at java.lang.reflect.Method.invoke(Method.java:597)
>       at
> org.codehaus.plexus.classworlds.launcher.Launcher.launchStandard(Launcher.java:329)
>       at
> org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:239)
>       at
> org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
>       at
> org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
>       at org.codehaus.classworlds.Launcher.main(Launcher.java:31)
> tho...@thomas-laptop:~/workspace/osmosis-0.38/bin$ 
> 
> 
> Thanks for you help.
> 
> Thomas
> -- 
> Neu: GMX De-Mail - Einfach wie E-Mail, sicher wie ein Brief!  
> Jetzt De-Mail-Adresse reservieren: http://portal.gmx.net/de/go/demail
> 
> _______________________________________________
> osmosis-dev mailing list
> osmosis-dev@openstreetmap.org
> http://lists.openstreetmap.org/listinfo/osmosis-dev

-- 
Neu: GMX De-Mail - Einfach wie E-Mail, sicher wie ein Brief!  
Jetzt De-Mail-Adresse reservieren: http://portal.gmx.net/de/go/demail

_______________________________________________
osmosis-dev mailing list
osmosis-dev@openstreetmap.org
http://lists.openstreetmap.org/listinfo/osmosis-dev

Reply via email to