繁体   English   中英

在Ubuntu服务器上导入PostgreSQL数据库

[英]Importing of a PostgreSQL DB on Ubuntu Server

所以我真的是PostgreSQL的新手,在过去的三天里,我一直坚持这一点。 我需要导入PostgreSQL数据库。 该数据库位于一个文件夹中,并具有各种.tab文件。 我有PostgreSQL 9.1版本。 数据库由我授予所有可能特权的用户postgres导入。 我还授予了该语言所有可能的特权。

脚本运行的命令是:

    CREATE OR REPLACE FUNCTION unique_toplevel_corpus_name() RETURNS TRIGGER AS $$
DECLARE
        count INTEGER := 0;
BEGIN
        IF NEW.top_level = 'y' THEN
                PERFORM * FROM corpus WHERE corpus.name = NEW.name AND corpus.t$
                GET DIAGNOSTICS count = ROW_COUNT;
                IF count != 0 THEN
                        RAISE EXCEPTION 'conflicting top-level corpus found: %'$
                END IF;
        END IF;
        RETURN NEW;
END;
$$ language plpgsql;

该代码不是我的。 它已提供并且可以在我的本地计算机(Ubuntu 12.04)上正常工作,导入数据库没有任何问题,但是仅在Ubuntu服务器(也就是12.04)上有问题。

这是我不断得到的例外:

@valian:/opt/annis/annis-service-2.2.1/bin$ ./annis-admin.sh import /home/FilesForAnnis/Korpora/relANNIS/relANNIS/
19:38:45.755 CorpusAdministration INFO: Importing corpus from: /home/FilesForAnnis/Korpora/relANNIS/relANNIS/
19:38:45.758 SpringAnnisAdministrationDao INFO: creating staging area
19:38:45.788 SpringAnnisAdministrationDao INFO: bulk-loading data
19:38:46.236 SpringAnnisAdministrationDao INFO: computing top-level corpus
Exception in thread "main" org.springframework.jdbc.BadSqlGrammarException: StatementCallback; bad SQL grammar [-- find the top-level corpus
ALTER TABLE _corpus ADD top_level boolean;
CREATE TRIGGER unique_toplevel_corpus_name BEFORE UPDATE ON _corpus FOR EACH ROW EXECUTE PROCEDURE unique_toplevel_corpus_name();
UPDATE _corpus SET top_level = 'n';
UPDATE _corpus SET top_level = 'y' WHERE pre = (SELECT min(pre) FROM _corpus);

-- add the toplevel corpus to the node table
CREATE INDEX tmp_corpus_toplevel ON _corpus (id) WHERE top_level = 'y';
ALTER TABLE _node ADD toplevel_corpus bigint;
UPDATE _node SET toplevel_corpus = _corpus.id FROM _corpus WHERE _corpus.top_level = 'y';
DROP INDEX tmp_corpus_toplevel;
]; nested exception is org.postgresql.util.PSQLException: ERROR: function unique_toplevel_corpus_name() does not exist
    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.execute(JdbcTemplate.java:427)
    at annis.administration.SpringAnnisAdministrationDao.executeSqlFromScript(SpringAnnisAdministrationDao.java:617)
    at annis.administration.SpringAnnisAdministrationDao.executeSqlFromScript(SpringAnnisAdministrationDao.java:608)
    at annis.administration.SpringAnnisAdministrationDao.computeTopLevelCorpus(SpringAnnisAdministrationDao.java:226)
    at annis.administration.CorpusAdministration.importCorpora(CorpusAdministration.java:85)
    at annis.administration.CorpusAdministration$$FastClassByCGLIB$$ce864c53.invoke(<generated>)
    at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:191)
    at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:688)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
    at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:621)
    at annis.administration.CorpusAdministration$$EnhancerByCGLIB$$b6899e79.importCorpora(<generated>)
    at annis.administration.AnnisAdminRunner.doImport(AnnisAdminRunner.java:176)
    at annis.administration.AnnisAdminRunner.run(AnnisAdminRunner.java:74)
    at annis.administration.AnnisAdminRunner.main(AnnisAdminRunner.java:49)
Caused by: org.postgresql.util.PSQLException: ERROR: function unique_toplevel_corpus_name() does not exist
    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.execute(AbstractJdbc2Statement.java:345)
    at org.springframework.jdbc.core.JdbcTemplate$1ExecuteStatementCallback.doInStatement(JdbcTemplate.java:420)
    at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:395)
... 16 more

我还更新了jdbc posgtres连接器。 我的本地机器(服务器可以正常运行)与服务器之间的唯一区别是,我在本地计算机上安装了Java 1.7,而不是1.6,但是我认为这可能不是问题。

我不知道还有什么可以尝试的...

这不是Ubuntu的问题。 这是数据库导入的问题。 您的数据库导入错误表明您缺少触发器功能。

另外,我知道代码不是您的。 在某种程度上,您可以用部分唯一索引替换触发器,但是您的性能会好很多。

如果该代码不是您的代码,则您将需要跟进该代码的编写者,以了解该函数为何不存在的原因,但是当您这样做时,您可能希望跟进他们,以使用以下代码替换触发器:

 CREATE UNIQUE INDEX ON corpus(name) WHERE corpus.t;

这样会更好,并且更易于维护。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM