As per Postgres Documentation - Once prepared, a transaction can later be committed or rolled back with COMMIT PREPARED or ROLLBACK PREPARED, respectively. Those commands can be issued from any session, not only the one that executed the original transaction.
I am trying to import data from csv into database tables and for this, I am using the
COPY tablename [ ( column [, ...] ) ]
FROM { 'filename' }
all this is done in a shell script.
Now the issue is that I am executing psql
command and passing this command as parameter via the -c
option ( I start transaction via the command
prepare transaction 'some-id'
in that command).
I want to create a Savepoint and rollback to it incase of any errors.
After a few other tasks in the shell script, I check for errors that the previous psql statement have produced and when I then try to rollback using the command
Prepared Rollback 'transaction-id'
( in separate psql command with sql statements
)
It reports "No "transaction-id" found
"
Am I getting the concept wrong or missing something in the process?
Is this happening because I am issuing psql
command multiple time and each is resulting in new transaction ?