Re: [GENERAL] 64 and 32 bit libpq

2017-02-12 Thread Steve Atkins

> On Feb 12, 2017, at 5:03 PM, Jerry LeVan  wrote:
> 
> Hello, I am trying to upgrade my postgresql ‘stuff’ to 64 bits from 32 bits.
> 
> I am running MaxOS Sierra.
> 
> I have built the 64 bit version of the server and have loaded
> my database into the new server ( 9.6.2 ). Everything seems to be working.
> 
> I have some legacy apps that are 32 bit and talk to the server 
> via libpq.dylib. They no longer work with a complaint about
> not finding a libpq with the right architecture.
> 
> Can I go back and do a 32 bit rebuild of everything and then
> take the 32 bit libpq and the 64 bit libpq and use lipo to
> glue them together and create a ‘fat’ libpq and replace the
> installed libpq? 
> 
> Is this a safe thing to do?

I've done it in the past (http://labs.wordtothewise.com/postgresql-osx/) and it
seemed to work fine.

Cheers,
  Steve

-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[GENERAL] 64 and 32 bit libpq

2017-02-12 Thread Jerry LeVan
Hello, I am trying to upgrade my postgresql ‘stuff’ to 64 bits from 32 bits.

I am running MaxOS Sierra.

I have built the 64 bit version of the server and have loaded
my database into the new server ( 9.6.2 ). Everything seems to be working.

I have some legacy apps that are 32 bit and talk to the server 
via libpq.dylib. They no longer work with a complaint about
not finding a libpq with the right architecture.

Can I go back and do a 32 bit rebuild of everything and then
take the 32 bit libpq and the 64 bit libpq and use lipo to
glue them together and create a ‘fat’ libpq and replace the
installed libpq? 

Is this a safe thing to do?

Thanks

Jerry






-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


Re: [GENERAL] configure can't find libcrypto on MacOS Sierra for pg 9.6.2

2017-02-12 Thread Adrian Klaver

On 02/12/2017 12:39 PM, Jerry LeVan wrote:

Sigh,

I will try to build without OpenSSL…


Of course there is another option, prebuilt binaries:

https://www.postgresql.org/download/macosx/



My database is seventeen years old, I don’t even remember
which Postgresql I started out with...

Jerry


On Feb 12, 2017, at 10:53 AM, Tom Lane  wrote:

Jerry LeVan  writes:

Hello, I am trying to build pg 9.6.2 on my MacOS Sierra but
configure is being balky


Hmm, I'm not really sure why it's failing at that step --- it gets past
that for me.  Possibly looking into config.log to see if there's a more
detailed error report would be illuminating.  However, trying to build
against Apple's openssl libraries is a lost cause anyway, because they
removed the header files in Sierra.  So it will fail when it gets to
header file checks; where it stops for me is

checking for openssl/ssl.h... no
configure: error: header file  is required for OpenSSL

AFAIK the only way forward is to install a complete OpenSSL installation
from source, or using MacPorts or brew or other tool-of-choice.

Apple would really like people to start using their SSL infrastructure.
That handwriting has been on the wall for years, but nobody's gotten
around to writing the necessary interface logic for Postgres.

regards, tom lane







--
Adrian Klaver
adrian.kla...@aklaver.com


--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


Re: [GENERAL] configure can't find libcrypto on MacOS Sierra for pg 9.6.2

2017-02-12 Thread Adrian Klaver

On 02/12/2017 12:39 PM, Jerry LeVan wrote:

Sigh,

I will try to build without OpenSSL…


I am not a Mac user, but from the below it does not seem that difficult 
to get around Apples decision:


https://solitum.net/openssl-os-x-el-capitan-and-brew/



My database is seventeen years old, I don’t even remember
which Postgresql I started out with...

Jerry


On Feb 12, 2017, at 10:53 AM, Tom Lane  wrote:

Jerry LeVan  writes:

Hello, I am trying to build pg 9.6.2 on my MacOS Sierra but
configure is being balky


Hmm, I'm not really sure why it's failing at that step --- it gets past
that for me.  Possibly looking into config.log to see if there's a more
detailed error report would be illuminating.  However, trying to build
against Apple's openssl libraries is a lost cause anyway, because they
removed the header files in Sierra.  So it will fail when it gets to
header file checks; where it stops for me is

checking for openssl/ssl.h... no
configure: error: header file  is required for OpenSSL

AFAIK the only way forward is to install a complete OpenSSL installation
from source, or using MacPorts or brew or other tool-of-choice.

Apple would really like people to start using their SSL infrastructure.
That handwriting has been on the wall for years, but nobody's gotten
around to writing the necessary interface logic for Postgres.

regards, tom lane







--
Adrian Klaver
adrian.kla...@aklaver.com


--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


Re: [GENERAL] configure can't find libcrypto on MacOS Sierra for pg 9.6.2

2017-02-12 Thread Jerry LeVan
Sigh,

I will try to build without OpenSSL…

My database is seventeen years old, I don’t even remember
which Postgresql I started out with...

Jerry

> On Feb 12, 2017, at 10:53 AM, Tom Lane  wrote:
> 
> Jerry LeVan  writes:
>> Hello, I am trying to build pg 9.6.2 on my MacOS Sierra but
>> configure is being balky
> 
> Hmm, I'm not really sure why it's failing at that step --- it gets past
> that for me.  Possibly looking into config.log to see if there's a more
> detailed error report would be illuminating.  However, trying to build
> against Apple's openssl libraries is a lost cause anyway, because they
> removed the header files in Sierra.  So it will fail when it gets to
> header file checks; where it stops for me is
> 
> checking for openssl/ssl.h... no
> configure: error: header file  is required for OpenSSL
> 
> AFAIK the only way forward is to install a complete OpenSSL installation
> from source, or using MacPorts or brew or other tool-of-choice.
> 
> Apple would really like people to start using their SSL infrastructure.
> That handwriting has been on the wall for years, but nobody's gotten
> around to writing the necessary interface logic for Postgres.
> 
>   regards, tom lane



-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


Re: [GENERAL] Custom shuffle function stopped working in 9.6

2017-02-12 Thread Francisco Olarte
On Sat, Feb 11, 2017 at 5:37 PM, Alexander Farber
 wrote:
...
> after switching to 9.6.2 from 9.5.3 the following custom function has
> stopped working:
> CREATE OR REPLACE FUNCTION words_shuffle(in_array varchar[])
> RETURNS varchar[] AS
> Any suggestions for a better shuffling function please?

I've seen several sugestions and hints, but seem no one sugested the
classical shuffling algorithm. Even when of the solutions seems to be
not guaranteed to stop.

An easy way to shuffle is swap every element with a random one from
its position to the start or end ( NOT a random one on the array, this
will give you N^N combinations on an N element array, which does not
evenly divide the N! permutations on an array ( see at end ) ) ( of
course even my version is not going to give you that given random() is
not perfect, but it will be a bit better ).

Not having access to a server I've just tried this on 9.3 on sqlfiddlle:

CREATE OR REPLACE FUNCTION words_shuffle(in_array varchar[])
RETURNS varchar[] AS
$$
declare
   a varchar[]:=in_array;
   n integer:=array_length(a,1);
   tmp varchar;
   r integer;
 begin
for i in reverse n..2 loop
  r := floor(random()*i) + 1;
  tmp=a[i]; a[i]=a[r]; a[r]=tmp;
end loop;
return a;
 end
$$
LANGUAGE plpgsql volatile

As you can see I do it from the end swapping it with elements from the
start ( this way I swap i in the range 1..i, instead of i, n wich is a
little harder to debug ). I stop at 2 because element 1 can only be
swapped with itself. I've marked it volatile as it returns different
things each time you call it. My tests show it working, but it may
have some problems with the type conversions, as I'm not used to do
this kind of code in plpgsql, but you can get the idea.

Francisco Olarte.

P.S.:
-- shufflings of three elements, with any or from its pos to the end:


Swapping with any element in the array
0,0,0: abc =>swap(0,0)=> abc =>swap(1,0)=> bac =>swap(2,0)=> cab
0,0,1: abc =>swap(0,0)=> abc =>swap(1,0)=> bac =>swap(2,1)=> bca
0,0,2: abc =>swap(0,0)=> abc =>swap(1,0)=> bac =>swap(2,2)=> bac
0,1,0: abc =>swap(0,0)=> abc =>swap(1,1)=> abc =>swap(2,0)=> cba
0,1,1: abc =>swap(0,0)=> abc =>swap(1,1)=> abc =>swap(2,1)=> acb
0,1,2: abc =>swap(0,0)=> abc =>swap(1,1)=> abc =>swap(2,2)=> abc
0,2,0: abc =>swap(0,0)=> abc =>swap(1,2)=> acb =>swap(2,0)=> bca
0,2,1: abc =>swap(0,0)=> abc =>swap(1,2)=> acb =>swap(2,1)=> abc
0,2,2: abc =>swap(0,0)=> abc =>swap(1,2)=> acb =>swap(2,2)=> acb
1,0,0: abc =>swap(0,1)=> bac =>swap(1,0)=> abc =>swap(2,0)=> cba
1,0,1: abc =>swap(0,1)=> bac =>swap(1,0)=> abc =>swap(2,1)=> acb
1,0,2: abc =>swap(0,1)=> bac =>swap(1,0)=> abc =>swap(2,2)=> abc
1,1,0: abc =>swap(0,1)=> bac =>swap(1,1)=> bac =>swap(2,0)=> cab
1,1,1: abc =>swap(0,1)=> bac =>swap(1,1)=> bac =>swap(2,1)=> bca
1,1,2: abc =>swap(0,1)=> bac =>swap(1,1)=> bac =>swap(2,2)=> bac
1,2,0: abc =>swap(0,1)=> bac =>swap(1,2)=> bca =>swap(2,0)=> acb
1,2,1: abc =>swap(0,1)=> bac =>swap(1,2)=> bca =>swap(2,1)=> bac
1,2,2: abc =>swap(0,1)=> bac =>swap(1,2)=> bca =>swap(2,2)=> bca
2,0,0: abc =>swap(0,2)=> cba =>swap(1,0)=> bca =>swap(2,0)=> acb
2,0,1: abc =>swap(0,2)=> cba =>swap(1,0)=> bca =>swap(2,1)=> bac
2,0,2: abc =>swap(0,2)=> cba =>swap(1,0)=> bca =>swap(2,2)=> bca
2,1,0: abc =>swap(0,2)=> cba =>swap(1,1)=> cba =>swap(2,0)=> abc
2,1,1: abc =>swap(0,2)=> cba =>swap(1,1)=> cba =>swap(2,1)=> cab
2,1,2: abc =>swap(0,2)=> cba =>swap(1,1)=> cba =>swap(2,2)=> cba
2,2,0: abc =>swap(0,2)=> cba =>swap(1,2)=> cab =>swap(2,0)=> bac
2,2,1: abc =>swap(0,2)=> cba =>swap(1,2)=> cab =>swap(2,1)=> cba
2,2,2: abc =>swap(0,2)=> cba =>swap(1,2)=> cab =>swap(2,2)=> cab
F(abc) = 4
F(acb) = 5
F(bac) = 5
F(bca) = 5
F(cab) = 4
F(cba) = 4
Swapping from its own position in the array to the end ( last can be
omitted, of course )
0,1,2: abc =>swap(0,0)=> abc =>swap(1,1)=> abc =>swap(2,2)=> abc
0,2,2: abc =>swap(0,0)=> abc =>swap(1,2)=> acb =>swap(2,2)=> acb
1,1,2: abc =>swap(0,1)=> bac =>swap(1,1)=> bac =>swap(2,2)=> bac
1,2,2: abc =>swap(0,1)=> bac =>swap(1,2)=> bca =>swap(2,2)=> bca
2,1,2: abc =>swap(0,2)=> cba =>swap(1,1)=> cba =>swap(2,2)=> cba
2,2,2: abc =>swap(0,2)=> cba =>swap(1,2)=> cab =>swap(2,2)=> cab
F(abc) = 1
F(acb) = 1
F(bac) = 1
F(bca) = 1
F(cab) = 1
F(cba) = 1


-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


Re: [GENERAL] Causeless CPU load waves in backend, on windows, 9.5.5 (EDB binary).

2017-02-12 Thread Nikolai Zhubr

Hello all,

In order to locate the problem more precisely, I'd like to prepare a 
test, involving some ping-like communication between the server and a 
test client. That is, I'd like to repeatedly send something valid to the 
server and get some valid replies from it, but without any kind of real 
activity happening on the server. I've looked through the main loop in 
PostgresMain() but could not find any suitable candidates.


Any thoughts?

Thank you.

Nikolai


03.02.2017 16:30, I wrote:
[...]

Ok, secure_read() is likely irrelevant too.

I think what happened after I inserted "Sleep(15)" into secure_read() is
that this "Sleep(15)" was essentially added into the main "for(;;)" loop
of PostgresMain (through ReadCommand), introducing an artifical
additional CPU relaxation step along with every incoming query and
therefore just masking a real CPU eater.

So probably I'll have to somehow profile this "for(;;)" in PostgresMain.


Thank you.

Nikolai





--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


Re: [GENERAL] configure can't find libcrypto on MacOS Sierra for pg 9.6.2

2017-02-12 Thread Tom Lane
Jerry LeVan  writes:
> Hello, I am trying to build pg 9.6.2 on my MacOS Sierra but
> configure is being balky

Hmm, I'm not really sure why it's failing at that step --- it gets past
that for me.  Possibly looking into config.log to see if there's a more
detailed error report would be illuminating.  However, trying to build
against Apple's openssl libraries is a lost cause anyway, because they
removed the header files in Sierra.  So it will fail when it gets to
header file checks; where it stops for me is

checking for openssl/ssl.h... no
configure: error: header file  is required for OpenSSL

AFAIK the only way forward is to install a complete OpenSSL installation
from source, or using MacPorts or brew or other tool-of-choice.

Apple would really like people to start using their SSL infrastructure.
That handwriting has been on the wall for years, but nobody's gotten
around to writing the necessary interface logic for Postgres.

regards, tom lane


-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


Re: [GENERAL] configure can't find libcrypto on MacOS Sierra for pg 9.6.2

2017-02-12 Thread Adrian Klaver

On 02/12/2017 06:56 AM, Jerry LeVan wrote:

Hello, I am trying to build pg 9.6.2 on my MacOS Sierra but
configure is being balky

configure:9494: checking for CRYPTO_new_ex_data in -lcrypto
configure:9519: gcc -o conftest -Wall -Wmissing-prototypes -Wpointer-arith 
-Wdeclaration-after-statement -Wendif-labels -Wmissing-for
mat-attribute -Wformat-security -fno-strict-aliasing -fwrapv 
-Wno-unused-command-line-argument -O2 conftest.c -lcrypto  -lz -ledi
t -lm  >&5
ld: library not found for -lcrypto
clang: error: linker command failed with exit code 1 (use -v to see invocation)
configure:9519: $? = 1

but libcrypto is present:
eagle:Desktop postgres$ ls -al /usr/lib/libcrypto*
-rwxr-xr-x  1 root  wheel  2043536 Dec 10 04:53 /usr/lib/libcrypto.0.9.7.dylib
-rwxr-xr-x  1 root  wheel  2681408 Dec 10 04:53 /usr/lib/libcrypto.0.9.8.dylib
-rw-r--r--  1 root  wheel  4209728 Dec 10 04:53 /usr/lib/libcrypto.35.dylib
lrwxr-xr-x  1 root  wheel   21 Sep 24 13:20 /usr/lib/libcrypto.dylib -> 
libcrypto.0.9.8.dylib

The config.log file for 9.3.2 passes the test.

And for the 9.3.2 image:
eagle:Desktop postgres$ otool -L /usr/local/bin/postgres
/usr/local/bin/postgres:
/usr/lib/libssl.0.9.8.dylib (compatibility version 0.9.8, current 
version 50.0.0)
/usr/lib/libcrypto.0.9.8.dylib (compatibility version 0.9.8, current 
version 50.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current 
version 1197.1.1)
eagle:Desktop postgres$

Any suggestions?


Not a suggestion, but a question:

What are the full command line invocations to configure for 9.3 and 9.6?

Now a suggestion, do you have the openssl devel package installed?



Thanks

Jerry




--
Adrian Klaver
adrian.kla...@aklaver.com


--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[GENERAL] configure can't find libcrypto on MacOS Sierra for pg 9.6.2

2017-02-12 Thread Jerry LeVan
Hello, I am trying to build pg 9.6.2 on my MacOS Sierra but
configure is being balky

configure:9494: checking for CRYPTO_new_ex_data in -lcrypto
configure:9519: gcc -o conftest -Wall -Wmissing-prototypes -Wpointer-arith 
-Wdeclaration-after-statement -Wendif-labels -Wmissing-for
mat-attribute -Wformat-security -fno-strict-aliasing -fwrapv 
-Wno-unused-command-line-argument -O2 conftest.c -lcrypto  -lz -ledi
t -lm  >&5
ld: library not found for -lcrypto
clang: error: linker command failed with exit code 1 (use -v to see invocation)
configure:9519: $? = 1

but libcrypto is present:
eagle:Desktop postgres$ ls -al /usr/lib/libcrypto*
-rwxr-xr-x  1 root  wheel  2043536 Dec 10 04:53 /usr/lib/libcrypto.0.9.7.dylib
-rwxr-xr-x  1 root  wheel  2681408 Dec 10 04:53 /usr/lib/libcrypto.0.9.8.dylib
-rw-r--r--  1 root  wheel  4209728 Dec 10 04:53 /usr/lib/libcrypto.35.dylib
lrwxr-xr-x  1 root  wheel   21 Sep 24 13:20 /usr/lib/libcrypto.dylib -> 
libcrypto.0.9.8.dylib

The config.log file for 9.3.2 passes the test.

And for the 9.3.2 image:
eagle:Desktop postgres$ otool -L /usr/local/bin/postgres
/usr/local/bin/postgres:
/usr/lib/libssl.0.9.8.dylib (compatibility version 0.9.8, current 
version 50.0.0)
/usr/lib/libcrypto.0.9.8.dylib (compatibility version 0.9.8, current 
version 50.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current 
version 1197.1.1)
eagle:Desktop postgres$ 

Any suggestions?

Thanks

Jerry

-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general