Bug#877920: postgresql-common: pg_upgradecluster 9.6 -> 10 fails (locale problem)

2017-10-07 Thread Christoph Berg
Re: Karsten Hilbert 2017-10-07 
<20171007155734.jf2q4cz3ghcdn...@hermes.hilbert.loc>
> Digging deeper: pg_upgradecluster does
>   $encoding comes from get_db_encoding
>   which also uses psql, which needs -X, too, in PgCommon.pm

Ah right - I already fixed that in the commit I pushed earlier today,
but didn't realize it was part of your problem.

https://anonscm.debian.org/cgit/pkg-postgresql/postgresql-common.git/commit/?id=d0dd4e1960be9e5bcaab2f8ec22a2a5b26b860ac

Thanks for confirming!

Christoph



Bug#877920: postgresql-common: pg_upgradecluster 9.6 -> 10 fails (locale problem)

2017-10-07 Thread Karsten Hilbert
On Sat, Oct 07, 2017 at 05:46:07PM +0200, Karsten Hilbert wrote:

> > Can you check if the upgrade works properly if you remove the
> > "unless"?
> > 
> >  chomp $ctype;
> >  chomp $collate;
> >  print STDERR "$ctype / $collate\n";
> >  return ($ctype, $collate);
> 
> Unfortunately not:
> 
>   root@hermes:~/bin# pg_upgradecluster 9.6 main
>   de_DE.UTF-8 / de_DE.UTF-8
>   0
>   Error: could not get cluster locales

Digging deeper: pg_upgradecluster does

unless ($encoding && $old_lc_ctype && $old_lc_collate) {...}

$encoding comes from get_db_encoding

which also uses psql, which needs -X, too, in PgCommon.pm

Et voila.

Karsten
-- 
GPG key ID E4071346 @ eu.pool.sks-keyservers.net
E167 67FD A291 2BEA 73BD  4537 78B9 A9F9 E407 1346



Bug#877920: postgresql-common: pg_upgradecluster 9.6 -> 10 fails (locale problem)

2017-10-07 Thread Christoph Berg
Re: Karsten Hilbert 2017-10-07 
<20171007154607.34udpgu2jxwsr...@hermes.hilbert.loc>
> >  chomp $ctype;
> >  chomp $collate;
> >  print STDERR "$ctype / $collate\n";
> >  return ($ctype, $collate);
> 
> Unfortunately not:
> 
>   root@hermes:~/bin# pg_upgradecluster 9.6 main
>   de_DE.UTF-8 / de_DE.UTF-8
>   0
>   Error: could not get cluster locales

This doesn't match the above code ("0"), did you edit the correct
file?

Christoph



Bug#877920: [Pkg-postgresql-public] Bug#877920: postgresql-common: pg_upgradecluster 9.6 -> 10 fails (locale problem)

2017-10-07 Thread Christoph Berg
Re: Karsten Hilbert 2017-10-07 
<20171007154139.bpvnx7477qcyh...@hermes.hilbert.loc>
>   condition: $? which is 0 which is "FALSE"

0 is a program exit code where 0 is true and everything else is false.
So yes, this is inverted logic.

Christoph



Bug#877920: postgresql-common: pg_upgradecluster 9.6 -> 10 fails (locale problem)

2017-10-07 Thread Karsten Hilbert
On Sat, Oct 07, 2017 at 04:40:24PM +0200, Christoph Berg wrote:

> Can you check if the upgrade works properly if you remove the
> "unless"?
> 
>  chomp $ctype;
>  chomp $collate;
>  print STDERR "$ctype / $collate\n";
>  return ($ctype, $collate);

Unfortunately not:

root@hermes:~/bin# pg_upgradecluster 9.6 main
de_DE.UTF-8 / de_DE.UTF-8
0
Error: could not get cluster locales

Karsten
-- 
GPG key ID E4071346 @ eu.pool.sks-keyservers.net
E167 67FD A291 2BEA 73BD  4537 78B9 A9F9 E407 1346



Bug#877920: postgresql-common: pg_upgradecluster 9.6 -> 10 fails (locale problem)

2017-10-07 Thread Karsten Hilbert
On Sat, Oct 07, 2017 at 05:34:15PM +0200, Christoph Berg wrote:

> Re: Karsten Hilbert 2017-10-07 
> <20171007152609.i4m5zc6yuol4j...@hermes.hilbert.loc>
 return ($ctype, $collate) unless $?;
> > 
> > Actually, isn't this inverted logic ?
> > 
> > It should return(...) unless $? actually is NOT zero ?
> 
> The extracted values should be returned if the last psql call exited
> with status 0. (Yes this function isn't the most pretty one. I'm
> inclined to rewrite the whole psql handling from scratch...)

I'll try to think it through although I am not a perl expert:

psql 

success

now $? is 0 (which is "FALSE")

return ($ctype, $collate) unless $?;

definition: statement unless condition

execute statement unless condition is true

condition: $? which is 0 which is "FALSE"

statement: "return" ($ctype, $collate)

hence: execute "return" unless "FALSE" is true

Won't work, right ?

It should be

return ($ctype, $collate) unless ($? != 0);

or am I mistaken ?

Karsten
-- 
GPG key ID E4071346 @ eu.pool.sks-keyservers.net
E167 67FD A291 2BEA 73BD  4537 78B9 A9F9 E407 1346



Bug#877920: [Pkg-postgresql-public] Bug#877920: postgresql-common: pg_upgradecluster 9.6 -> 10 fails (locale problem)

2017-10-07 Thread Christoph Berg
Re: Karsten Hilbert 2017-10-07 
<20171007152609.i4m5zc6yuol4j...@hermes.hilbert.loc>
> > > return ($ctype, $collate) unless $?;
> 
> Actually, isn't this inverted logic ?
> 
> It should return(...) unless $? actually is NOT zero ?

The extracted values should be returned if the last psql call exited
with status 0. (Yes this function isn't the most pretty one. I'm
inclined to rewrite the whole psql handling from scratch...)

Christoph



Bug#877920: [Pkg-postgresql-public] Bug#877920: postgresql-common: pg_upgradecluster 9.6 -> 10 fails (locale problem)

2017-10-07 Thread Karsten Hilbert
On Sat, Oct 07, 2017 at 04:40:24PM +0200, Christoph Berg wrote:

> > return ($ctype, $collate) unless $?;

Actually, isn't this inverted logic ?

It should return(...) unless $? actually is NOT zero ?

PSQL(1) 
PostgreSQL 9.6.5 Documentation  
  PSQL(1)

...

EXIT STATUS

psql returns 0 to the shell if it finished normally, 1 if a
fatal error of its own occurs (e.g. out of memory, file not
found), 2 if the connection to the server went bad and the
session was not interactive, and 3 if an error occurred in a
script and the variable ON_ERROR_STOP was set.

Karsten
-- 
GPG key ID E4071346 @ eu.pool.sks-keyservers.net
E167 67FD A291 2BEA 73BD  4537 78B9 A9F9 E407 1346



Bug#877920: postgresql-common: pg_upgradecluster 9.6 -> 10 fails (locale problem)

2017-10-07 Thread Karsten Hilbert
On Sat, Oct 07, 2017 at 04:40:24PM +0200, Christoph Berg wrote:

> Re: Karsten Hilbert 2017-10-07 
> <20171007132123.7eqyzz7455f5x...@hermes.hilbert.loc>
> > root@hermes:/usr/share/perl5# pg_upgradecluster 9.6 main
> > de_DE.UTF-8 / de_DE.UTF-8
> > Error: could not get cluster locales
> 
> Hmm. At least the uninitialized value warning is gone now.

Yes, it does get one step further.

> > chomp $ctype;
> > chomp $collate;
> > print STDERR "$ctype / $collate\n";
> > return ($ctype, $collate) unless $?;
> 
> I wonder why $? is non-zero even if the $collate extraction worked.

Strangely enough:

chomp $ctype;
chomp $collate;
print STDERR "$ctype / $collate\n";
print STDERR "$?\n";
return ($ctype, $collate) unless $?;
return (undef, undef);

produces this:

root@hermes:~# pg_upgradecluster 9.6 main
de_DE.UTF-8 / de_DE.UTF-8
0
Error: could not get cluster locales

> Can you check if the upgrade works properly if you remove the "unless"?

Will do.

Karsten
-- 
GPG key ID E4071346 @ eu.pool.sks-keyservers.net
E167 67FD A291 2BEA 73BD  4537 78B9 A9F9 E407 1346



Bug#877920: [Pkg-postgresql-public] Bug#877920: postgresql-common: pg_upgradecluster 9.6 -> 10 fails (locale problem)

2017-10-07 Thread Christoph Berg
Re: Karsten Hilbert 2017-10-07 
<20171007132123.7eqyzz7455f5x...@hermes.hilbert.loc>
>   root@hermes:/usr/share/perl5# pg_upgradecluster 9.6 main
>   de_DE.UTF-8 / de_DE.UTF-8
>   Error: could not get cluster locales

Hmm. At least the uninitialized value warning is gone now.

> I also added a print statement:
> 
> chomp $ctype;
> chomp $collate;
> print STDERR "$ctype / $collate\n";
> return ($ctype, $collate) unless $?;
> return (undef, undef);
> 
> which produces the 
> 
>   de_DE.UTF-8 / de_DE.UTF-8

I wonder why $? is non-zero even if the $collate extraction worked.
Can you check if the upgrade works properly if you remove the
"unless"?

 chomp $ctype;
 chomp $collate;
 print STDERR "$ctype / $collate\n";
 return ($ctype, $collate);

Christoph



Bug#877920: [Pkg-postgresql-public] Bug#877920: postgresql-common: pg_upgradecluster 9.6 -> 10 fails (locale problem)

2017-10-07 Thread Karsten Hilbert
On Sat, Oct 07, 2017 at 02:11:14PM +0200, Christoph Berg wrote:

> > postgres@hermes:~$ psql -d template1
> > Ausgabeformat ist »wrapped«.
> 
> PgCommon.pm doesn't use 'psql -X' so your (or postgres') .psqlrc might
> be getting in the way. Could you try the upgrade again after moving
> .psqlrc away, or (better) adding an 'X' to PgCommon.pm lines 935 and
> 939?
> 
> open PSQL, '-|', $psql, '-h', $socketdir, '-p', $port, '-XAtc',

Done:

root@hermes:/usr/share/perl5# pg_upgradecluster 9.6 main
de_DE.UTF-8 / de_DE.UTF-8
Error: could not get cluster locales

I also added a print statement:

chomp $ctype;
chomp $collate;
print STDERR "$ctype / $collate\n";
return ($ctype, $collate) unless $?;
return (undef, undef);

which produces the 

de_DE.UTF-8 / de_DE.UTF-8

...

What else can I do ?

Karsten
-- 
GPG key ID E4071346 @ eu.pool.sks-keyservers.net
E167 67FD A291 2BEA 73BD  4537 78B9 A9F9 E407 1346



Bug#877920: [Pkg-postgresql-public] Bug#877920: postgresql-common: pg_upgradecluster 9.6 -> 10 fails (locale problem)

2017-10-07 Thread Christoph Berg
Re: Karsten Hilbert 2017-10-07 
<20171007104018.ax3cv7dwqg4s3...@hermes.hilbert.loc>
> Thanks for your response !

Thanks!

>   postgres@hermes:~$ psql -d template1
>   Ausgabeformat ist »wrapped«.

PgCommon.pm doesn't use 'psql -X' so your (or postgres') .psqlrc might
be getting in the way. Could you try the upgrade again after moving
.psqlrc away, or (better) adding an 'X' to PgCommon.pm lines 935 and
939?

open PSQL, '-|', $psql, '-h', $socketdir, '-p', $port, '-XAtc',
 ^
Christoph



Bug#877920: postgresql-common: pg_upgradecluster 9.6 -> 10 fails (locale problem)

2017-10-07 Thread Karsten Hilbert
Thanks for your response !

> could you provide the output of 'psql -l' for the old cluster?

Sure:

postgres@hermes:~$ psql -l
Ausgabeformat ist »wrapped«.
  Liste der Datenbanken
Name| Eigentümer | Kodierung | Sortierfolge | Zeichentyp  |  
Zugriffsprivilegien

++---+--+-+---
 akonadi| postgres   | UTF8  | de_DE.UTF-8  | de_DE.UTF-8 |
 gnumed_v20 | gm-dbo | UTF8  | de_DE.UTF-8  | de_DE.UTF-8 |
 gnumed_v21 | gm-dbo | UTF8  | de_DE.UTF-8  | de_DE.UTF-8 |
 gnumed_v22 | gm-dbo | UTF8  | de_DE.UTF-8  | de_DE.UTF-8 |
 orthanc_db | orthanc| UTF8  | de_DE.UTF-8  | de_DE.UTF-8 |
 postgres   | postgres   | UTF8  | de_DE.UTF-8  | de_DE.UTF-8 |
 template0  | postgres   | UTF8  | de_DE.UTF-8  | de_DE.UTF-8 | 
=c/postgres  +
||   |  | | 
postgres=CTc/postgres
 template1  | postgres   | UTF8  | de_DE.UTF-8  | de_DE.UTF-8 | 
postgres=CTc/postgres+
||   |  | | 
=c/postgres
(8 Zeilen)

> Also, please run
> 
>  SHOW lc_ctype;
>  SHOW lc_collate;
> 
> in the old cluster's template1 database.

postgres@hermes:~$ psql -d template1
Ausgabeformat ist »wrapped«.
psql (10.0, Server 9.6.5)
Geben Sie »help« für Hilfe ein.

template1=# show lc_ctype;
  lc_ctype
-
 de_DE.UTF-8
(1 Zeile)

template1=# show lc_collate;
 lc_collate
-
 de_DE.UTF-8
(1 Zeile)

HTH,
Karsten



Bug#877920: postgresql-common: pg_upgradecluster 9.6 -> 10 fails (locale problem)

2017-10-07 Thread Christoph Berg
Control: tags -1 moreinfo

Re: Karsten Hilbert 2017-10-07 
<150737030347.16226.787705667158988632.report...@hermes.hilbert.loc>
>   Use of uninitialized value $ctype in scalar chomp at 
> /usr/share/perl5/PgCommon.pm line 947.
>   Use of uninitialized value $collate in scalar chomp at 
> /usr/share/perl5/PgCommon.pm line 948.
>   Error: could not get cluster locales
>   root@hermes:~/bin#
> 
> Anything else I can provide ?

Hi,

could you provide the output of 'psql -l' for the old cluster?
Also, please run

 SHOW lc_ctype;
 SHOW lc_collate;

in the old cluster's template1 database.

Christoph



Bug#877920: postgresql-common: pg_upgradecluster 9.6 -> 10 fails (locale problem)

2017-10-07 Thread Karsten Hilbert
Package: postgresql-common
Version: 186
Severity: important

Hello,

when upgrading

Ver Cluster Port Status OwnerData directory   Log file
9.6 main5432 online postgres /var/lib/postgresql/9.6/main 
/var/log/postgresql/postgresql-9.6-main.log

like so:

root@hermes:~/bin# pg_upgradecluster 9.6 main

the following happens:

Use of uninitialized value $ctype in scalar chomp at 
/usr/share/perl5/PgCommon.pm line 947.
Use of uninitialized value $collate in scalar chomp at 
/usr/share/perl5/PgCommon.pm line 948.
Error: could not get cluster locales
root@hermes:~/bin#

Anything else I can provide ?

Karsten


-- System Information:
Debian Release: buster/sid
  APT prefers testing
  APT policy: (990, 'testing'), (500, 'stable-updates'), (500, 'unstable'), 
(500, 'stable'), (1, 'experimental')
Architecture: i386 (i686)

Kernel: Linux 4.13.0-trunk-686-pae (SMP w/2 CPU cores)
Locale: LANG=de_DE.UTF-8, LC_CTYPE=de_DE.UTF-8 (charmap=UTF-8), 
LANGUAGE=de_DE.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages postgresql-common depends on:
ii  adduser   3.116
ii  debconf   1.5.63
ii  init-system-helpers   1.49
ii  lsb-base  9.20170808
ii  postgresql-client-common  186
ii  procps2:3.3.12-3
ii  ssl-cert  1.0.39
ii  ucf   3.0036

Versions of packages postgresql-common recommends:
ii  logrotate  3.11.0-0.1

Versions of packages postgresql-common suggests:
ii  libjson-perl  2.94-1

-- Configuration Files:
/etc/postgresql-common/createcluster.conf changed:
initdb_options = '-k'
ssl = on
cluster_name = '%v/%c'
stats_temp_directory = '/var/run/postgresql/%v-%c.pg_stat_tmp'
log_line_prefix = '%%m [%%p] %%q%%u@%%d '
add_include_dir = 'conf.d'
include_dir '/etc/postgresql-common/createcluster.d'


-- debconf information:
  postgresql-common/catversion-bump:
  postgresql-common/ssl: true
* postgresql-common/obsolete-major: