So I am reallly new to PostgreSQL and for the last 3 days I am stuck with this. I need to import a PostgreSQL Database. The database lies in a folder and has various .tab files. I have PostgreSQL 9.1 release. The database is imported by user postgres to which I granted all the possible privileges. I also granted all the possible privileges to the language.
The command that is run by a script is:
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;
The code is not mine. It is provided and works fine on my local machine (Ubuntu 12.04), importing the db without any problems, but has problems only on Ubuntu server (also 12.04).
This is the exception I keep getting:
@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
I also updated jdbc posgtres connector. The only difference between my local machine where everything works perfectly and the server is that I have java 1.7 on the local machine and not 1.6 but I do not think it can be the problem.
I have no idea what else I could try there...