Deal of The Day! Hurry Up, Grab the Special Discount - Save 25% - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

PostgreSQL PGCES-02 Exam - Topic 2 Question 3 Discussion

Table "t1" is defined below. Table "t1" has a column "id" of type INTEGER, and a column "name" of type TEXT. t1: The following SQL is executed while client "A" is connected. BEGIN;SELECT * FROM t1 WHERE id = 2 FOR UPDATE; SELECT * FROM t1 WHERE id = 1 FOR UPDATE; -- (*) While the second 'SELECT' statement, shown with (*), is being executed, a separate client "B" connects and executes the following SQL. Select the correct statement about the execution results. UPDATE t1 SET name = 'turtle' WHERE id = 2; Note: the default transaction isolation level is set to "read committed".
B) The update process for client 'B' is blocked until the current transaction for client 'A' is finished.
A) The update process for client 'B' is blocked until the current connection for client 'A' is finished.
C) The 'UPDATE' process for client 'B' proceeds regardless of the condition of client 'A'.
D) The process of client 'B' immediately generates an error.
E) The processes for both clients are blocked, and an error stating that a deadlock has been detected is generated.

PostgreSQL PGCES-02 Exam - Topic 2 Question 3 Discussion

Actual exam question for PostgreSQL's PGCES-02 exam
Question #: 3
Topic #: 2
[All PGCES-02 Questions]

Table "t1" is defined below. Table "t1" has a column "id" of type INTEGER, and a column "name" of type TEXT. t1: The following SQL is executed while client "A" is connected. BEGIN;

SELECT * FROM t1 WHERE id = 2 FOR UPDATE; SELECT * FROM t1 WHERE id = 1 FOR UPDATE; -- (*) While the second 'SELECT' statement, shown with (*), is being executed, a separate client "B" connects and executes the following SQL. Select the correct statement about the execution results. UPDATE t1 SET name = 'turtle' WHERE id = 2; Note: the default transaction isolation level is set to "read committed".

Show Suggested Answer Hide Answer
Suggested Answer: B

Contribute your Thoughts:

0/2000 characters
Caitlin
8 months ago
E sounds like a stretch, deadlock isn't happening here.
upvoted 0 times
...
Isabella
8 months ago
I think C is wrong, B can't just proceed like that.
upvoted 0 times
...
Sharan
9 months ago
Wait, does that mean B can't update anything at all?
upvoted 0 times
...
Isadora
9 months ago
Totally agree, B will be blocked until A finishes.
upvoted 0 times
...
Meghann
9 months ago
Client A's transaction locks the row for id 2.
upvoted 0 times
...
Edna
9 months ago
I recall something about deadlocks, but I don't think that's happening here since client 'B' is just waiting on client 'A'.
upvoted 0 times
...
Gabriele
9 months ago
I'm not entirely sure, but I feel like client 'B' should be able to proceed since it's not trying to update the same row as client 'A'.
upvoted 0 times
...
Therese
9 months ago
I think the update from client 'B' might be blocked because client 'A' has a lock on the row with id = 2.
upvoted 0 times
...
Princess
9 months ago
I remember practicing a similar question where one transaction had to wait for another to finish. I think that applies here too.
upvoted 0 times
...
Levi
9 months ago
I'm pretty sure web spiders are used for indexing websites, so I'll go with option A.
upvoted 0 times
...
Yuette
9 months ago
This is a good test of my understanding of the cost of quality. I'll carefully consider each option and try to apply the definition I know to determine the best answer.
upvoted 0 times
...
Sylvia
10 months ago
I'm a bit unsure about this one. I want to make sure I'm not missing any details in the question.
upvoted 0 times
...

Save Cancel