Re: Insert records in the tavke only if they are not exist - Mailing list pgsql-general

From Igor Korot
Subject Re: Insert records in the tavke only if they are not exist
Date
Msg-id CA+FnnTwbmWABiTHxdc5sJ1ffWHoYkZuhzPqmfRmCJ7qLbEuAdQ@mail.gmail.com
Whole thread Raw
In response to Re: Insert records in the tavke only if they are not exist  ("David G. Johnston" <david.g.johnston@gmail.com>)
List pgsql-general
Hi, Dvid,

On Fri, Dec 6, 2024, 9:55 PM David G. Johnston <david.g.johnston@gmail.com> wrote:
On Friday, December 6, 2024, Igor Korot <ikorot01@gmail.com> wrote:
When my application starts up, ot creates some tables and insert records in them.

When the app starts for the second time it should check if the tables and the records in them are exist and skip the process.

Everything is good, except what if I have a connection from 2 different users?

I can run this inside transaction, but will this be enough? Will stating transaction lock the DB and the second user will wait for transaction to complete?


Seems like letting the create table fail would be a reliable way to determine what is happening.  But this procedure overall just seems better avoided.  Can’t you just run an installer/updater separate from running the application?

Interesting idea bout the installer.
Except those tables will contain some additional info about the schema and the application.

So if I create/remove new table, either in my app or from psql the record will need to be inserted/deleted.

Thank you.


David J.

pgsql-general by date:

Previous
From: "David G. Johnston"
Date:
Subject: Re: Insert records in the tavke only if they are not exist
Next
From: Adrian Klaver
Date:
Subject: Re: Insert records in the tavke only if they are not exist