Hi, ================= Table1 column1 | column2 1 | 20 2 | 30 3 | 40 3 | 40 4 | 50 ================= And suppose that the following 100th transaction was committed: UPDATE Table1 Then, the augmented transaction log file will generate the following log entry for the above committed transaction: Committed Transaction ID = 100 Rollback SQL Statements = - DELETE FROM Table1 WHERE column1 = 2 AND column2 = 30 - INSERT INTO TABLE Table1 VALUES(column1, column2) (10, 20) - DELETE FROM Table1 WHERE column1 = 3 AND column2 = 40 - INSERT INTO TABLE Table1 VALUES(column1, column2) (10, 20) - DELETE FROM Table1 WHERE column1 = 4 AND column2 = 50 - INSERT INTO TABLE Table1 VALUES(column1, column2) (10, 20) Note that the above Rollback SQL statements are in the simplest forms without involving any complex SQL operations such as JOIN or sub-queries. Also note that we cannot create the above Rollback SQL statements purely based on original consecutive SQL transactions, because we don't know which rows of Table1 will need to be DELETED without actually scanning the entire Table1 and evaluating Transction #100's WHERE clause (i.e., colum2 > 20) on every single row of Table1. Therefore, to generate a list of simple Rollback SQL statements like the above, we have no choice but to embed this logging feature in the PostgreSQL's source code where the WAL(Write-Ahead Log) file is being updated. Since the current PostgreSQL doesn't support this feature, I plan to implement the above feature in the source code. But I have never worked on PostgreSQL source code in my life, and I wonder if anybody could give me a hint on which source code files (and functions) are about recording redo records in the WAL file. In particular, when the SQL server records the information of updated block location & values into the WAL file for each SQL statement that modifies any relations, we can additionally make the SQL server also write the list of the simplest INSERT & DELETE SQL statements that effectively enforces such SQL table write operations. If such an SQL-level inforcement information is available in the WAL file, one can easily conjecture what will be the corresponding Rollback (i.e., inverse) SQL statements from there.
|
- Logging the feature of SQL-level read/write commits Ronny Ko
- Re: Logging the feature of SQL-level read/write commi... Tomas Vondra
- Re: Logging the feature of SQL-level read/write commi... legrand legrand
- Re: Logging the feature of SQL-level read/write commi... Bruce Momjian
- RE: Re: Logging the feature of SQL-level read/write c... Ronny Ko
- RE: Re: Logging the feature of SQL-level read/wri... legrand legrand