Re: converting text to bytea

2021-02-21 Thread Pavel Stehule
Hi po 22. 2. 2021 v 7:37 odesílatel Yambu napsal: > Hello > > This sounds simple, but im not getting the results when i cast text to > bytea like this first_name::bytea . Is there another way to do this? > You should to use convert_to function https://www.postgresql.org/docs/current/functions-

converting text to bytea

2021-02-21 Thread Yambu
Hello This sounds simple, but im not getting the results when i cast text to bytea like this first_name::bytea . Is there another way to do this? regards

Re: Script checking to see what database it's connected to

2021-02-21 Thread Thomas Kellerer
Julien Rouhaud schrieb am 22.02.2021 um 02:19: >> The output: >> $ psql12 -f test_pg.sql >> t >> connected to postgres >> got here >> psql:test_pg.sql:15: ERROR: syntax error at or near "exit" >> LINE 1: exit > > Well, the supported commands did work. You should probably look at > https://www.pos

Streaming replication between different OS

2021-02-21 Thread Atul Kumar
Hi, I have postgres 9.6 cluster running on Centos 6.8, so I just wanted to know that can I configure streaming replication with same postgres version i.e 9.6 running on centos 7. Suggestions are welcome as the Centos versions are different one is 6.8 and second one is 7. Also please let me know

Re: How to determine server's own IP address? inet_server_addr not working

2021-02-21 Thread Ian Lawrence Barwick
2021年2月22日(月) 8:42 David G. Johnston : > On Sun, Feb 21, 2021 at 4:38 PM Guyren Howe wrote: > >> The documentation says that inet_server_addr() does this, but on our >> servers it is returning nothing. >> > > "Returns the IP address on which the server accepted the current > connection, or NULL i

Re: Script checking to see what database it's connected to

2021-02-21 Thread Ron
On 2/21/21 7:19 PM, Julien Rouhaud wrote: [snip] Well, the supported commands did work. You should probably look at https://www.postgresql.org/docs/current/app-psql.html, you'd see that "exit" is not a supported command and you should instead use \q[uit]. I recommend looking at the semantics of

Re: Script checking to see what database it's connected to

2021-02-21 Thread Julien Rouhaud
On Mon, Feb 22, 2021 at 9:00 AM Ron wrote: > > On 2/21/21 5:26 PM, Julien Rouhaud wrote: > > On Mon, Feb 22, 2021 at 7:19 AM Ron wrote: > > Thus, I want to add a bit to the top of the script, something like this: > > \if :DBNAME = postgres > echo "must not run in postgres" > exit > \end

Re: Script checking to see what database it's connected to

2021-02-21 Thread Tim Cross
Rob Sargent writes: >>> >>> Take it up a notch? Write a script which takes the dbname and the >>> script name: >>> >>> /pcode/ >>> >>> #!/bin/bash -e >>> if [[ $# -ne 2 ]]; then echo "missing arg(s)"; exit 2; fi >>> dbn=$1; shift; >>> sql=$1; shift; >>> psql --dbname $dbn --file $sql >>> >>> /

Re: Script checking to see what database it's connected to

2021-02-21 Thread Ron
On 2/21/21 6:49 PM, Rob Sargent wrote: Take it up a notch?  Write a script which takes the dbname and the script name: /pcode/ #!/bin/bash -e if [[ $# -ne 2 ]]; then echo "missing arg(s)"; exit 2; fi dbn=$1; shift; sql=$1; shift; psql --dbname $dbn --file $sql /pcode/ I thought of that

Re: Script checking to see what database it's connected to

2021-02-21 Thread Ron
On 2/21/21 5:26 PM, Julien Rouhaud wrote: On Mon, Feb 22, 2021 at 7:19 AM Ron wrote: Thus, I want to add a bit to the top of the script, something like this: \if :DBNAME = postgres echo "must not run in postgres" exit \endif However, I can't seem to find the magic sauce. You have

Re: Script checking to see what database it's connected to

2021-02-21 Thread Rob Sargent
Take it up a notch?  Write a script which takes the dbname and the script name: /pcode/ #!/bin/bash -e if [[ $# -ne 2 ]]; then echo "missing arg(s)"; exit 2; fi dbn=$1; shift; sql=$1; shift; psql --dbname $dbn --file $sql /pcode/ I thought of that, yet so earnestly want avoid Yet Anoth

Re: Script checking to see what database it's connected to

2021-02-21 Thread Ron
On 2/21/21 5:26 PM, Rob Sargent wrote: On 2/21/21 4:18 PM, Ron wrote: Postgresql 12.5 I've got scripts which can run on multiple database (dev, test, QA, Integration, Training, etc, etc), so of course I've got to run them like "psql my_db_name -f script.sql". Of course, I sometimes forge

Re: How to determine server's own IP address? inet_server_addr not working

2021-02-21 Thread David G. Johnston
On Sun, Feb 21, 2021 at 4:38 PM Guyren Howe wrote: > The documentation says that inet_server_addr() does this, but on our > servers it is returning nothing. > "Returns the IP address on which the server accepted the current connection, or NULL if the current connection is via a Unix-domain socke

How to determine server's own IP address? inet_server_addr not working

2021-02-21 Thread Guyren Howe
The documentation says that inet_server_addr() does this, but on our servers it is returning nothing.

Re: Script checking to see what database it's connected to

2021-02-21 Thread Rob Sargent
On 2/21/21 4:18 PM, Ron wrote: Postgresql 12.5 I've got scripts which can run on multiple database (dev, test, QA, Integration, Training, etc, etc), so of course I've got to run them like "psql my_db_name -f script.sql". Of course, I sometimes forget to specify the database name, and so

Re: Script checking to see what database it's connected to

2021-02-21 Thread Julien Rouhaud
On Mon, Feb 22, 2021 at 7:19 AM Ron wrote: > > Thus, I want to add a bit to the top of the script, something like this: > > \if :DBNAME = postgres > echo "must not run in postgres" > exit > \endif > > However, I can't seem to find the magic sauce. You have to use a dedicated variable.

Script checking to see what database it's connected to

2021-02-21 Thread Ron
Postgresql 12.5 I've got scripts which can run on multiple database (dev, test, QA, Integration, Training, etc, etc), so of course I've got to run them like "psql my_db_name -f script.sql". Of course, I sometimes forget to specify the database name, and so it fails. Thus, I want to add a b

Re: Please help to improve SELECT JOIN performance, EXPLAIN ANALYZE attached

2021-02-21 Thread Peter J. Holzer
On 2021-02-21 10:14:04 -0700, Michael Lewis wrote: > No issues for us. We have used a low sample rate of 1% or so and gotten some > very useful data. Oh, somehow I never noticed the auto_explain.sample_rate parameter in the docs. Good to know. hp -- _ | Peter J. Holzer| Story mu

Re: Please help to improve SELECT JOIN performance, EXPLAIN ANALYZE attached

2021-02-21 Thread Michael Lewis
No issues for us. We have used a low sample rate of 1% or so and gotten some very useful data. Particularly with logging nested statements so we can profile stored procs more easily than adding a large number of raise notice statements.

Re: Getting unexpected results from regexp_replace

2021-02-21 Thread Dan Nessett
Thanks. Doubling the backslashes did the trick. I tried to use the original expression without the E, but postgres threw an error and said to use the “E” version of the pattern. Dan > On Feb 21, 2021, at 8:50 AM, Tom Lane wrote: > > Dan Nessett writes: >> SELECT user_name, regexp_replace(use

Re: Getting unexpected results from regexp_replace

2021-02-21 Thread Tom Lane
Dan Nessett writes: > SELECT user_name, regexp_replace(user_email, E'\(.*\)', '') AS user_email, > family_list, street_address, city, state, zip, phone_list, email_list > FROM "household_data" > WHERE email_list != ‘'; Because you used E'...', the backslashes are eaten by the string literal pars

Getting unexpected results from regexp_replace

2021-02-21 Thread Dan Nessett
I freely admit this may be my problem. Writing regular expression patterns is more an art than a skill. However, I am getting an unexpected result from regex_replace(). I have a table that is partially defined as follows (names and email addresses hidden for privacy): user_name user_emai