|
7 | 7 | * |
8 | 8 | * |
9 | 9 | * IDENTIFICATION |
10 | | - * $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.41 1999/06/10 14:17:06 vadim Exp $ |
| 10 | + * $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.42 1999/06/29 04:54:46 vadim Exp $ |
11 | 11 | * |
12 | 12 | * NOTES |
13 | 13 | *Transaction aborts can now occur two ways: |
|
158 | 158 | #include<commands/sequence.h> |
159 | 159 | #include<libpq/be-fsstubs.h> |
160 | 160 |
|
| 161 | +externboolSharedBufferChanged; |
| 162 | + |
161 | 163 | staticvoidAbortTransaction(void); |
162 | 164 | staticvoidAtAbort_Cache(void); |
163 | 165 | staticvoidAtAbort_Locks(void); |
@@ -618,30 +620,36 @@ RecordTransactionCommit() |
618 | 620 | */ |
619 | 621 | xid=GetCurrentTransactionId(); |
620 | 622 |
|
621 | | -/*---------------- |
| 623 | +/* |
622 | 624 | *flush the buffer manager pages. Note: if we have stable |
623 | 625 | *main memory, dirty shared buffers are not flushed |
624 | 626 | *plai 8/7/90 |
625 | | - * ---------------- |
626 | 627 | */ |
627 | 628 | leak=BufferPoolCheckLeak(); |
628 | | -FlushBufferPool(!TransactionFlushEnabled()); |
629 | | -if (leak) |
630 | | -ResetBufferPool(); |
631 | 629 |
|
632 | | -/* ---------------- |
633 | | - *have the transaction access methods record the status |
634 | | - *of this transaction id in the pg_log / pg_time relations. |
635 | | - * ---------------- |
| 630 | +/* |
| 631 | + * If no one shared buffer was changed by this transaction then |
| 632 | + * we don't flush shared buffers and don't record commit status. |
636 | 633 | */ |
637 | | -TransactionIdCommit(xid); |
| 634 | +if (SharedBufferChanged) |
| 635 | +{ |
| 636 | +FlushBufferPool(!TransactionFlushEnabled()); |
| 637 | +if (leak) |
| 638 | +ResetBufferPool(); |
| 639 | + |
| 640 | +/* |
| 641 | + *have the transaction access methods record the status |
| 642 | + *of this transaction id in the pg_log relation. |
| 643 | + */ |
| 644 | +TransactionIdCommit(xid); |
| 645 | + |
| 646 | +/* |
| 647 | + *Now write the log info to the disk too. |
| 648 | + */ |
| 649 | +leak=BufferPoolCheckLeak(); |
| 650 | +FlushBufferPool(!TransactionFlushEnabled()); |
| 651 | +} |
638 | 652 |
|
639 | | -/* ---------------- |
640 | | - *Now write the log/time info to the disk too. |
641 | | - * ---------------- |
642 | | - */ |
643 | | -leak=BufferPoolCheckLeak(); |
644 | | -FlushBufferPool(!TransactionFlushEnabled()); |
645 | 653 | if (leak) |
646 | 654 | ResetBufferPool(); |
647 | 655 | } |
@@ -731,19 +739,14 @@ RecordTransactionAbort() |
731 | 739 | */ |
732 | 740 | xid=GetCurrentTransactionId(); |
733 | 741 |
|
734 | | -/*---------------- |
735 | | - *havethe transaction access methods record the status |
736 | | - *of this transaction id in the pg_log/ pg_time relations. |
737 | | - *---------------- |
| 742 | +/* |
| 743 | + * Havethe transaction access methods record the status of |
| 744 | + * this transaction id in the pg_logrelation. We skip it |
| 745 | + *if no one shared buffer was changed by this transaction. |
738 | 746 | */ |
739 | | -TransactionIdAbort(xid); |
| 747 | +if (SharedBufferChanged) |
| 748 | +TransactionIdAbort(xid); |
740 | 749 |
|
741 | | -/* ---------------- |
742 | | - *flush the buffer manager pages. Note: if we have stable |
743 | | - *main memory, dirty shared buffers are not flushed |
744 | | - *plai 8/7/90 |
745 | | - * ---------------- |
746 | | - */ |
747 | 750 | ResetBufferPool(); |
748 | 751 | } |
749 | 752 |
|
@@ -965,6 +968,7 @@ CommitTransaction() |
965 | 968 | * ---------------- |
966 | 969 | */ |
967 | 970 | s->state=TRANS_DEFAULT; |
| 971 | +SharedBufferChanged= false;/* safest place to do it */ |
968 | 972 |
|
969 | 973 | } |
970 | 974 |
|
@@ -1028,6 +1032,7 @@ AbortTransaction() |
1028 | 1032 | * ---------------- |
1029 | 1033 | */ |
1030 | 1034 | s->state=TRANS_DEFAULT; |
| 1035 | +SharedBufferChanged= false;/* safest place to do it */ |
1031 | 1036 | } |
1032 | 1037 |
|
1033 | 1038 | /* -------------------------------- |
|