1

So this morning I couldn't install Postgres 9.1 from the Ubuntu repo. I tried installing 9.2 from postgres repo, but if failed with the same error. The error trace is really uninformative (I don't even know what is the source of this error). Google didn't tell me anything as well.

It failed during installation with the same error, and I tried to create the cluster manually. But...

root@Ubuntu-1304-raring-64-minimal /home/tmp # pg_createcluster 9.2 main --start
Creating new cluster (configuration: /etc/postgresql/9.2/main, data:                 /var/lib/postgresql/9.2/main)...
FATAL:  syntax error at line 5067: unexpected character ";"
child process exited with exit code 1
initdb: removing contents of data directory "/var/lib/postgresql/9.2/main"
Error: initdb failed

What is wrong?

2
  • You don't have pg9.1 from ubuntu nor pg9.2 from pgdg, so what postgres packages do you have? Can you show the result of COLUMNS=200 dpkg -l 'postgres*' Commented Jul 18, 2013 at 11:42
  • sure, the log is quite long so I pasted it here: dpaste.com/1311318 (and here's the error traceback: dpaste.com/1311319) Commented Jul 20, 2013 at 7:21

2 Answers 2

1

According to this output from dpkg -l 'postgres*':

ii  postgresql-9.2                               9.2.4-1.pgdg12.4+1          amd64                       object-relational SQL database, version 9.2 server
un  postgresql-client                                                                              (no description available)
ii  postgresql-client-9.1                        9.1.9-1ubuntu1              amd64                       front-end programs for PostgreSQL 9.1
ii  postgresql-client-9.2                        9.2.4-1.pgdg12.4+1          amd64                       front-end programs for PostgreSQL 9.2
ii  postgresql-client-common                     140                         all                         manager for multiple PostgreSQL client versions
ii  postgresql-common                            140                         all              

postgresql-9.2 is already installed (see the ii flags in the leftmost column), as well as the client tools for 9.1 and 9.2 from a mix of pgdg and ubuntu repositories.

Anyway, the error encountered by pg_createcluster is quite unusual. From the output, especially the line number, it would seem that the underlying initdb fails when playing the postgres.bki file.

For 9.2, this file is: /usr/share/postgresql/9.2/postgres.bki. It contains low-level commands in a sql-like dialect to populate the cluster with pre-initialized data (template databases, pre-defined types and views, etc.)

It's hard to imagine that this file would be corrupted, especially since you have a similar problem when installing 9.1 that comes with a different postgres.bki file right from the package.

Still you may check just in case what's at line 5067 and around. In my build directory for 9.2.4, I have this:

insert OID = 1 ( template1 10 ENCODING "LC_COLLATE" "LC_CTYPE" t t -1 0 0 1663 _null_)

And there isn't a ; character anywhere in the entire file.

Other than that, you may want to remove the entire postgresql installation to restart from a clean base:

# purge client packages
dpkg --purge postgresql-client-9.1 postgresql-client-9.2 postgresql-client-common
# purge server packages
dpkg --purge postgresql-9.2 postgresql-common
Sign up to request clarification or add additional context in comments.

3 Comments

wow Daniel thank you, it makes sense! Now when I know the file, I'll be able to figure out the cause of that error.
So it was because of the invalid locale settings... I've added lines ending with ';' in the /etc/environment, just as for a usual bash file, but it seems I should avoid typing ';' there
Good to know but still weird. When confronted with invalid locale settings, pg_createcluster normally immediately fails with perl warnings followed by Error: The locale requested by the environment is invalid
0

You're... trying to install postgres?

Either one of these commands should get you on your way:

sudo apt-get install postgresql-9.1
sudo apt-get install postgresql-9.2

Here's the download page

If those commands returned an error, the error response would be helpful information to include in your question.

I'm afraid I've never tried manually creating the clusters before, so I'm probably not of much help.

2 Comments

Yes, I tried to install it just as you wrote, and looked like the installer was attempting to create a cluster by itself. So here's the full log: dpaste.com/1311319
@Spaceman: yes, the creation of a main cluster is a normal step of an installation, and is what fails in your case.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.