Some postgresql installations have non-UTF client locale set as default (this is common for multi-charset language envirioments, such as Russian).

Attached patch sets client encoding to UTF8 explicitly

Files: 
CommentFileSizeAuthor
#12 pgsql-utf8.patch741 bytesandypost
Passed: 11364 passes, 0 fails, 0 exceptions View
#10 pgsql-utf8.patch751 bytesandypost
Failed: Failed to install HEAD. View
#5 pg_utf8.diff793 bytesandypost
Failed: Invalid PHP syntax. View
drupal-65-pgsql-utf8.diff371 bytesAlex_Tutubalin
Failed: Failed to apply patch. View

Comments

Alex_Tutubalin’s picture

Status: Active » Needs review
andypost’s picture

Version: 6.5 » 6.x-dev
Status: Needs review » Reviewed & tested by the community

Works on 2 live sites!

In database.mysql.inc and database.mysqli.inc

function db_connect($url) {
....
  // Force UTF-8.
  mysql_query('SET NAMES "utf8"', $connection);
  return $connection;
}

So it's required for postgresql!

Gábor Hojtsy’s picture

Version: 6.x-dev » 7.x-dev
Status: Reviewed & tested by the community » Patch (to be ported)

Thanks, committed to Drupal 6. Is this still applicable to Drupal 7? (If not, please put back to "6.x", "fixed").

Crell’s picture

Status: Patch (to be ported) » Needs work

Yes I think it does apply to Postgres on D7 as well. It should be a trivial patch for someone to write. See the new MySQL driver for the one-line example. It should be nearly identical.

andypost’s picture

Status: Needs work » Needs review
FileSize
793 bytes
Failed: Invalid PHP syntax. View

D7 patch here

Status: Needs review » Needs work

The last submitted patch failed testing.

andypost’s picture

Status: Needs work » Needs review

What's up? It's so trivial to be erroneus

Status: Needs review » Needs work

The last submitted patch failed testing.

emi_bcn’s picture

Hi again, Alex!
Any news on it? Will it be introduced to HEAD?

I'll do some testes and rework soon, cause I also think pgsql is much better than mysql. Table corruptions are so common on my site... :(

+Subscribing

andypost’s picture

Status: Needs work » Needs review
FileSize
751 bytes
Failed: Failed to install HEAD. View

So here re-roll for new DB layer

Damien Tournoud’s picture

Status: Needs review » Needs work

In [1], two syntaxes are described:

  • SET CLIENT_ENCODING TO 'value';
  • and the standard SQL form SET NAMES 'value';

I would rather go with the standard form, which we use on MySQL already. Either way, this needs work.

[1] http://www.postgresql.org/docs/8.3/static/multibyte.html

andypost’s picture

Status: Needs work » Needs review
FileSize
741 bytes
Passed: 11364 passes, 0 fails, 0 exceptions View

so here is SET NAMES as in Mysql

Dries’s picture

I'd like the PostgreSQL maintainers (DamZ or fiasco) to approve this.

Damien Tournoud’s picture

Status: Needs review » Reviewed & tested by the community

Make sense to me, thanks @andypost.

Dries’s picture

Status: Reviewed & tested by the community » Fixed

Committed to CVS HEAD. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.