Coder Social home page Coder Social logo

Comments (3)

tianon avatar tianon commented on August 28, 2024

I'd tend to agree, but here's the counterargument:

$ docker run -it --rm debian:sid bash
root@95b748d48bdc:/# apt-get update && apt-get install -y postgresql
...
root@95b748d48bdc:/# /etc/init.d/postgresql start
[ ok ] Starting PostgreSQL 9.4 database server: main.
root@95b748d48bdc:/# su - postgres
postgres@95b748d48bdc:~$ psql
psql (9.4beta2)
Type "help" for help.

postgres=# \l
                             List of databases
   Name    |  Owner   | Encoding  | Collate | Ctype |   Access privileges   
-----------+----------+-----------+---------+-------+-----------------------
 postgres  | postgres | SQL_ASCII | C       | C     | 
 template0 | postgres | SQL_ASCII | C       | C     | =c/postgres          +
           |          |           |         |       | postgres=CTc/postgres
 template1 | postgres | SQL_ASCII | C       | C     | =c/postgres          +
           |          |           |         |       | postgres=CTc/postgres
(3 rows)

postgres=# 

from postgres.

jpetazzo avatar jpetazzo commented on August 28, 2024

I would prefer UTF8 too.

I just re-installed PostgreSQL on my machine; lo and behold:

jpetazzo@tarrasque:~$ sudo -u postgres psql -l
                                  List of databases
   Name    |  Owner   | Encoding |   Collate   |    Ctype    |   Access privileges   
-----------+----------+----------+-------------+-------------+-----------------------
 postgres  | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
 template0 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
           |          |          |             |             | postgres=CTc/postgres
 template1 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
           |          |          |             |             | postgres=CTc/postgres
(3 rows)

I believe that it defaults to SQL_ASCII, except if you have an UTF-8 locale; then it will default to that. I believe (but that's not backed by any hard data; just anecdotal experience) that everybody will use some kind of local locale, and that the vast majority (for some definition of "vast") of the installs out there will therefore have UTF8.

Now, to give you a more specific example: during the Docker training, we show an example involving Docker running a Rails app with a PostgreSQL backend. We are updating this to use the canon postgres image instead of our hackish training/postgres image; however, Rails complains because the DB is "only" SQL_ASCII. I'm trying to work around the issue by specifying the encoding in the database.yml; but it would be nice if it could work out of the box for most people.

from postgres.

tianon avatar tianon commented on August 28, 2024

Hmm, maybe it's based on LANG, even for the default install? We have C.UTF-8 in the base images, so it shouldn't be a "do you have UTF-8; ok we'll use it" issue, but it might be. Maybe we need to locale-gen en_US.UTF-8 in this image. Thanks for doing more testing on this, @jpetazzo!

from postgres.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.