issues when installing postgres

2018-05-08 Thread Antonio Silva
Hello!

I bought a new computer and I installed Ubuntu 18.04 and after PostgreSQL.
sudo apt install postgresql postgresql-contrib pgadmin3

Nevertheless I had some issues with configuration files and decided to
uninstall it completely
sudo apt purge postgresql postgresql-contrib pgadmin3

When I installed it again I notice that postgresql.conf and pg_hba.conf
were the oldies files. Then I uninstall Postgres once more and removed the
directory /etc/postgresql/

After a new install I noticed that the directory /etc/postgresql/ was
completely empty - it was not created again. There are no more
postgresql.conf and pg_hba.conf files. I could find only
postgresql.conf.sample and pg_hba.conf.sample at /usr/share/postgresql/10

/etc/init.d/postgresql status says that Postgres is running fine

● postgresql.service - PostgreSQL RDBMS
Loaded: loaded (/lib/systemd/system/postgresql.service; enabled; vendor
preset: enabled)
Active: active (exited) since Tue 2018-05-08 10:43:23 -03; 1h 55min ago
Process: 6451 ExecStart=/bin/true (code=exited, status=0/SUCCESS)
Main PID: 6451 (code=exited, status=0/SUCCESS)

What should I have to do to heve the folder /etc/postgresql/10/ ... and all
its files agais?

I really appreciate any help. Thanks in advance.

All the best

-- 
Antônio Olinto Ávila da Silva


Re: issues when installing postgres

2018-05-09 Thread Antonio Silva
Hello Adrian

Are you using the Ubuntu or Postgres repos?
> I'm using the Ubuntu repos

Can you connect to Postgres using psql?
> No I cannot

Thanks

Antonio


2018-05-09 10:36 GMT-03:00 Adrian Klaver :

> On 05/08/2018 05:54 PM, Antonio Silva wrote:
>
>> Hello!
>>
>>
> Comments inline.
>
> I bought a new computer and I installed Ubuntu 18.04 and after PostgreSQL.
>> sudo apt install postgresql postgresql-contrib pgadmin3
>>
>
> Are you using the Ubuntu or Postgres repos?
>
>
>> Nevertheless I had some issues with configuration files and decided to
>> uninstall it completely
>> sudo apt purge postgresql postgresql-contrib pgadmin3
>>
>> When I installed it again I notice that postgresql.conf and pg_hba.conf
>> were the oldies files. Then I uninstall Postgres once more and removed the
>> directory /etc/postgresql/
>>
>> After a new install I noticed that the directory /etc/postgresql/ was
>> completely empty - it was not created again. There are no more
>> postgresql.conf and pg_hba.conf files. I could find only
>> postgresql.conf.sample and pg_hba.conf.sample at /usr/share/postgresql/10
>>
>> /etc/init.d/postgresql status says that Postgres is running fine
>>
>
> Can you connect to Postgres using psql?
>
>
>> ● postgresql.service - PostgreSQL RDBMS
>> Loaded: loaded (/lib/systemd/system/postgresql.service; enabled; vendor
>> preset: enabled)
>> Active: active (exited) since Tue 2018-05-08 10:43:23 -03; 1h 55min ago
>> Process: 6451 ExecStart=/bin/true (code=exited, status=0/SUCCESS)
>> Main PID: 6451 (code=exited, status=0/SUCCESS)
>>
>
> To be running the server would need its conf files somewhere.
>
>
>> What should I have to do to heve the folder /etc/postgresql/10/ ... and
>> all
>> its files agais?
>>
>
> If you are going to use the packages then yes.
>
>
>
>
>> I really appreciate any help. Thanks in advance.
>>
>> All the best
>>
>> --
>> Antônio Olinto Ávila da Silva
>>
>>
>
> --
> Adrian Klaver
> adrian.kla...@aklaver.com
>


Re: issues when installing postgres

2018-05-10 Thread Antonio Silva
Dear Tim and Adrian

Thanks for your attention.

Finally I solved the problem. In addition to deleting files as suggested it
seems to be important to *remove postgres user and group* (userdel -r
postgres, groupdel postgres) before the new install.

https://stackoverflow.com/questions/2748607/how-to-thoroughly-purge-and-reinstall-postgresql-on-ubuntu

And life goes on ...

All the best

Antonio Olinto


2018-05-09 21:15 GMT-03:00 Tim Cross :

>
>
> On 10 May 2018 at 09:45, Adrian Klaver  wrote:
>
>> On 05/09/2018 02:47 PM, Antonio Silva wrote:
>>
>>> Hello Adrian
>>>
>>> Are you using the Ubuntu or Postgres repos?
>>>  > I'm using the Ubuntu repos
>>>
>>> Can you connect to Postgres using psql?
>>>  > No I cannot
>>>
>>
>> What does ps ax | grep post show?
>>
>> My guess is you are going to have to reinstall Postgres.
>>
>>
>>> Thanks
>>>
>>> Antonio
>>>
>>>
>>> 2018-05-09 10:36 GMT-03:00 Adrian Klaver >> <mailto:adrian.kla...@aklaver.com>>:
>>>
>>>
>>> On 05/08/2018 05:54 PM, Antonio Silva wrote:
>>>
>>> Hello!
>>>
>>>
>>> Comments inline.
>>>
>>> I bought a new computer and I installed Ubuntu 18.04 and after
>>> PostgreSQL.
>>> sudo apt install postgresql postgresql-contrib pgadmin3
>>>
>>>
>>> Are you using the Ubuntu or Postgres repos?
>>>
>>>
>>> Nevertheless I had some issues with configuration files and
>>> decided to
>>> uninstall it completely
>>> sudo apt purge postgresql postgresql-contrib pgadmin3
>>>
>>> When I installed it again I notice that postgresql.conf and
>>> pg_hba.conf
>>> were the oldies files. Then I uninstall Postgres once more and
>>> removed the
>>> directory /etc/postgresql/
>>>
>>> After a new install I noticed that the directory
>>> /etc/postgresql/ was
>>> completely empty - it was not created again. There are no more
>>> postgresql.conf and pg_hba.conf files. I could find only
>>> postgresql.conf.sample and pg_hba.conf.sample at
>>> /usr/share/postgresql/10
>>>
>>> /etc/init.d/postgresql status says that Postgres is running fine
>>>
>>>
>>> Can you connect to Postgres using psql?
>>>
>>>
>>> ● postgresql.service - PostgreSQL RDBMS
>>> Loaded: loaded (/lib/systemd/system/postgresql.service; enabled;
>>> vendor
>>> preset: enabled)
>>> Active: active (exited) since Tue 2018-05-08 10:43:23 -03; 1h
>>> 55min ago
>>> Process: 6451 ExecStart=/bin/true (code=exited, status=0/SUCCESS)
>>> Main PID: 6451 (code=exited, status=0/SUCCESS)
>>>
>>>
>>> To be running the server would need its conf files somewhere.
>>>
>>>
>>> What should I have to do to heve the folder /etc/postgresql/10/
>>> ... and all
>>> its files agais?
>>>
>>>
>>> If you are going to use the packages then yes.
>>>
>>>
>>>
>>>
>>> I really appreciate any help. Thanks in advance.
>>>
>>> All the best
>>>
>>> -- Antônio Olinto Ávila da Silva
>>>
>>>
>>>
>>> -- Adrian Klaver
>>> adrian.kla...@aklaver.com <mailto:adrian.kla...@aklaver.com>
>>>
>>>
>>>
>>
>> --
>> Adrian Klaver
>> adrian.kla...@aklaver.com
>>
>>
> Probably not relevant, but I noticed your also installing pgadmin3. I
> don't believe pgadmin3 will work with Postgres 10. You need pgadmin4, which
> isn't available as a package on ubuntu 18.04.
>
> Also, be aware that Ubuntu has also been pushing 'snaps', so make sure
> that Postgres hasn't been installed as a snap package (I think the command
> is snap lis). I recall when I tried to install postgres in 17.10, which I
> did from the 'software centre' on ubuntu, it initially installed it as a
> snap. I had to remove the snap and then use apt to get the normal deb
> package install.  the snap package system does not use the normal locations
> for config files.
>
> This could also be a ubuntu 18.04 issue. This version was only released a
> couple of weeks ago and it is the first version which has Postgres 10 as
> the default.  I would try the following
>
> 1. use systemctl to stop postgresql service
> 2. remove all postgres packages making sure all config files are also
> removed
> 3. Use synaptic to make sure all postgres package and associated config
> files have been removed.
> 4. Reboot
> 5. run apt update and then apt upgrade
> 6 re-install using apt (not the software centre).
>
>
>
> --
> regards,
>
> Tim
>
> --
> Tim Cross
>
>


using replace function

2019-11-28 Thread Antonio Silva
Hello list

I want to replace a string (not a substring) in a field but making sure
that the string in the full field.

In the example below since 'blue' is not the full text in 'blue shark'
there should not have a replacement.

How to say "replace only with 'blue' if it is the full string in the field".

With REPLACE I get:

SELECT REPLACE('blue shark','blue','blue fish');
 replace
-
 blue fish shark
(1 row)

but I would like to get:

SELECT REPLACE('blue shark','blue','blue fish');
  replace

 blue shark
(1 row)

Thanks a lot

Antonio Olinto


Re: using replace function

2019-12-02 Thread Antonio Silva
Hi Osvaldo, Rod, David and Tom

Thanks for your attention.  Lastly it is not that difficult.

For me the more natural way is Rod's suggestion, to use replace with where.
I don't know why I didn't think of this solution.

The usage of regexp_replace is very nice too and I will take a time to
learn it.

Thanks a lot to you all

Antonio

Em sex., 29 de nov. de 2019 às 01:22, Tom Lane  escreveu:

> "David G. Johnston"  writes:
> > On Thursday, November 28, 2019, Rob Sargent 
> wrote:
> >> I want to replace a string (not a substring) in a field but making sure
> >> that the string in the full field.
>
> > I’d probably do something like:
> > Select case when a.col = ‘value’ then ‘new value’ else a.col end from a;
>
> Yeah, this.  You could wrap it up in a SQL function if you want the
> same level of notational convenience as replace().
>
> Another possibility is regexp_replace with an anchored pattern, but
> that would potentially require escaping regexp metacharacters in the
> pattern, so the PITA factor is high.  And I doubt it'd be faster than
> the CASE solution.
>
> regards, tom lane
>


-- 
Antônio Olinto Ávila da Silva
Biólogo / Oceanógrafo
Instituto de Pesca (Fisheries Institute)
São Paulo, Brasil