0
Sometimes I need to enter a field or index or make some more critical modification and often ask everyone to leave the base before I execute the command.
This command on my machine even with the application runs normally, but when I run on the server the command hangs until everyone leaves, I saw that it depends on the tables in use.
You can not know which users are using which tables, even because I use a single user for connection and the application is very dynamic.
I know that some commands will not be good because it requires exclusive access to table.
Have a check if a certain table is in use and the command I’m about to execute may get stuck?
For example in a table with a Bytea type field I tried to add another field with the table in use, even though a simple varchar field may be null it does not let, even leaving the screen that uses said table and closing the table the command continues hanging until you exit the application, ie disconnecting even.
Related: https://pt.wikipedia.org/wiki/Problema_da_parada, https://en.wikipedia.org/wiki/Halting_problem
– Miguel
Vichi, rsrsr, is @Miguel, sometimes we think like the user, "this problem seems to me simple to solve is just to do this or that", when in fact we are creating a monster, in my head maybe something like "prepare" would solve, but I saw that the thing is more ugly than it seems.
– Marcelo
I launched the question because I also use Mysql and in it I can give the commands quietly that it does not lock, but in a forum explained to me that Mysql works differently from Postgresql, so I did not launch the comparison here.
– Marcelo
Basically, you can’t predict the outcome of a program without running it. But I don’t know if the solution to this is there, maybe going another way
– Miguel
You’d have to see how you’re doing it. Here in mine, I use only one user too, and even with connected clients, I make table changes, no problems
– Rovann Linhalis
I can make changes, the problem is being when the table has a bytea field, then it does not let do... I assume that it should read tables with bytea differently so the restriction, for example Firebird seems to me to store Blob fields in separate file so reading is different. The command is simple: ALTER TABLE public.table ADD COLUMN logo Character Varying(200);
– Marcelo
yes, blob and text fields, not stored in the tuple, are pointers that point to the data... but in my tables I have bytea fields too, and the changes I do normally... so I found it strange
– Rovann Linhalis
You work with Delphi, use Cacheupdates = True ? If yes can be this, but I have no way to work with Cacheupdate
– Marcelo
no... have application in C# (winforms), ASP.NET and ASP.NET Core
– Rovann Linhalis
Anyway, you could force the termination of the user session:
select pg_terminate_backend(PID) from pg_stat_activity where datname = 'banco'
– Rovann Linhalis