Skip to content

Commit 6287e39

Browse files
committed
2 parents e7520d0 + b06cfc9 commit 6287e39

File tree

31 files changed

+65
-636
lines changed

31 files changed

+65
-636
lines changed

contrib/pg_tsdtm/pg_dtm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ bool DtmXidInMVCCSnapshot(TransactionId xid, Snapshot snapshot)
489489
static timestamp_t firstReportTime;
490490
static timestamp_t prevReportTime;
491491
static timestamp_t totalSleepTime;
492-
static timestamp_t mnxSleepTime;
492+
static timestamp_t maxSleepTime;
493493
#endif
494494
timestamp_t delay = MIN_WAIT_TIMEOUT;
495495
Assert(xid != InvalidTransactionId);

contrib/pg_tsdtm/tests/deploy/roles/postgres/tasks/main.yml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -83,18 +83,6 @@
8383
- stat: path={{pg_datadir}}/postmaster.pid
8484
register: pg_pidfile
8585

86-
# - name: stop postgres if it was running
87-
# command: "{{pg_dst}}/bin/pg_ctl stop -w -D {{pg_datadir}}"
88-
# environment:
89-
# LD_LIBRARY_PATH: "{{pg_dst}}/lib"
90-
# when: pg_pidfile.stat.exists
91-
92-
- name: stop postgres if it was running
93-
shell: "kill -9 `head -n 1 {{pg_datadir}}/postmaster.pid`"
94-
environment:
95-
LD_LIBRARY_PATH: "{{pg_dst}}/lib"
96-
when: pg_pidfile.stat.exists
97-
9886
- name: remove datadirs on datanodes
9987
command: "rm -rf {{pg_datadir}}"
10088
when: pg_destroy_and_init

src/backend/access/transam/clog.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,9 @@ static void TransactionIdSetStatusBit(TransactionId xid, XidStatus status,
9393
static void set_status_by_pages(int nsubxids, TransactionId *subxids,
9494
XidStatus status, XLogRecPtr lsn);
9595

96-
void
96+
void
9797
TransactionIdSetTreeStatus(TransactionId xid, int nsubxids,
98-
TransactionId *subxids, XidStatus status, XLogRecPtr lsn)
98+
TransactionId *subxids, XidStatus status, XLogRecPtr lsn)
9999
{
100100
return TM->SetTransactionStatus(xid, nsubxids, subxids, status, lsn);
101101
}
@@ -151,7 +151,7 @@ TransactionIdSetTreeStatus(TransactionId xid, int nsubxids,
151151
* but aren't yet in cache, as well as hinting pages not to fall out of
152152
* cache yet.
153153
*/
154-
void
154+
void
155155
PgTransactionIdSetTreeStatus(TransactionId xid, int nsubxids,
156156
TransactionId *subxids, XidStatus status, XLogRecPtr lsn)
157157
{

src/backend/access/transam/transam.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -256,12 +256,12 @@ TransactionIdIsKnownCompleted(TransactionId transactionId)
256256
* This commit operation is not guaranteed to be atomic, but if not, subxids
257257
* are correctly marked subcommit first.
258258
*/
259-
void
259+
void
260260
TransactionIdCommitTree(TransactionId xid, int nxids, TransactionId *xids)
261261
{
262262
TransactionIdSetTreeStatus(xid, nxids, xids,
263-
TRANSACTION_STATUS_COMMITTED,
264-
InvalidXLogRecPtr);
263+
TRANSACTION_STATUS_COMMITTED,
264+
InvalidXLogRecPtr);
265265
}
266266

267267
/*
@@ -273,7 +273,7 @@ TransactionIdAsyncCommitTree(TransactionId xid, int nxids, TransactionId *xids,
273273
XLogRecPtr lsn)
274274
{
275275
TransactionIdSetTreeStatus(xid, nxids, xids,
276-
TRANSACTION_STATUS_COMMITTED, lsn);
276+
TRANSACTION_STATUS_COMMITTED, lsn);
277277
}
278278

279279
/*

src/backend/access/transam/xact.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1273,9 +1273,8 @@ RecordTransactionCommit(void)
12731273
/*
12741274
* Now we may update the CLOG, if we wrote a COMMIT record above
12751275
*/
1276-
if (markXidCommitted) {
1276+
if (markXidCommitted)
12771277
TransactionIdCommitTree(xid, nchildren, children);
1278-
}
12791278
}
12801279
else
12811280
{
@@ -1297,9 +1296,8 @@ RecordTransactionCommit(void)
12971296
* XLOG. Instead, we store the LSN up to which the XLOG must be
12981297
* flushed before the CLOG may be updated.
12991298
*/
1300-
if (markXidCommitted) {
1299+
if (markXidCommitted)
13011300
TransactionIdAsyncCommitTree(xid, nchildren, children, XactLastRecEnd);
1302-
}
13031301
}
13041302

13051303
/*
@@ -5372,7 +5370,7 @@ xact_redo_commit(xl_xact_parsed_commit *parsed,
53725370
* recovered. It's unlikely but it's good to be safe.
53735371
*/
53745372
TransactionIdAsyncCommitTree(
5375-
xid, parsed->nsubxacts, parsed->subxacts, lsn);
5373+
xid, parsed->nsubxacts, parsed->subxacts, lsn);
53765374

53775375
/*
53785376
* We must mark clog before we update the ProcArray.
@@ -5399,6 +5397,7 @@ xact_redo_commit(xl_xact_parsed_commit *parsed,
53995397
*/
54005398
StandbyReleaseLockTree(xid, 0, NULL);
54015399
}
5400+
54025401
if (parsed->xinfo & XACT_XINFO_HAS_ORIGIN)
54035402
{
54045403
/* recover apply progress */
@@ -5609,8 +5608,9 @@ xact_redo(XLogReaderState *record)
56095608
elog(PANIC, "xact_redo: unknown op code %u", info);
56105609
}
56115610

5612-
void MarkAsAborted()
5611+
void
5612+
MarkAsAborted()
56135613
{
5614-
CurrentTransactionState->state = TRANS_INPROGRESS;
5615-
CurrentTransactionState->blockState = TBLOCK_STARTED;
5614+
CurrentTransactionState->state = TRANS_INPROGRESS;
5615+
CurrentTransactionState->blockState = TBLOCK_STARTED;
56165616
}

src/backend/access/transam/xtm.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ TransactionId PgGetGlobalTransactionId(void)
2525

2626
bool PgDetectGlobalDeadLock(PGPROC* proc)
2727
{
28-
return false;
28+
return false;
2929
}
3030

3131
char const* PgGetTransactionManagerName(void)
@@ -42,7 +42,7 @@ TransactionManager PgTM = {
4242
PgTransactionIdIsInProgress,
4343
PgGetGlobalTransactionId,
4444
PgXidInMVCCSnapshot,
45-
PgDetectGlobalDeadLock,
45+
PgDetectGlobalDeadLock,
4646
PgGetTransactionManagerName
4747
};
4848

src/backend/commands/indexcmds.c

Lines changed: 0 additions & 158 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
#include "commands/tablespace.h"
3535
#include "mb/pg_wchar.h"
3636
#include "miscadmin.h"
37-
#include "funcapi.h"
3837
#include "nodes/nodeFuncs.h"
3938
#include "optimizer/clauses.h"
4039
#include "optimizer/planner.h"
@@ -53,9 +52,6 @@
5352
#include "utils/snapmgr.h"
5453
#include "utils/syscache.h"
5554
#include "utils/tqual.h"
56-
#include "utils/ruleutils.h"
57-
#include "executor/executor.h"
58-
#include "executor/spi.h"
5955

6056

6157
/* non-export function prototypes */
@@ -284,160 +280,6 @@ CheckIndexCompatible(Oid oldId,
284280
return ret;
285281
}
286282

287-
static void
288-
UpdateIndex(Oid indexRelationId, Node* whereClause)
289-
{
290-
Datum values[Natts_pg_index];
291-
bool isnull[Natts_pg_index];
292-
HeapTuple oldTuple;
293-
HeapTuple newTuple;
294-
Relation pg_index;
295-
296-
pg_index = heap_open(IndexRelationId, RowExclusiveLock);
297-
oldTuple = SearchSysCacheCopy1(INDEXRELID, ObjectIdGetDatum(indexRelationId));
298-
if (!HeapTupleIsValid(oldTuple))
299-
elog(ERROR, "cache lookup failed for index %u", indexRelationId);
300-
301-
heap_deform_tuple(oldTuple, RelationGetDescr(pg_index), values, isnull);
302-
values[Anum_pg_index_indpred - 1] = CStringGetTextDatum(nodeToString(whereClause));
303-
isnull[Anum_pg_index_indpred - 1] = false;
304-
newTuple = heap_form_tuple(RelationGetDescr(pg_index), values, isnull);
305-
simple_heap_update(pg_index, &oldTuple->t_self, newTuple);
306-
CatalogUpdateIndexes(pg_index, newTuple);
307-
heap_freetuple(newTuple);
308-
heap_freetuple(oldTuple);
309-
heap_close(pg_index, NoLock);
310-
}
311-
312-
void
313-
AlterIndex(Oid indexRelationId, IndexStmt *stmt)
314-
{
315-
char* select;
316-
Oid heapRelationId;
317-
IndexUniqueCheck checkUnique;
318-
Datum values[INDEX_MAX_KEYS];
319-
bool isnull[INDEX_MAX_KEYS];
320-
Relation heapRelation;
321-
Relation indexRelation;
322-
SPIPlanPtr plan;
323-
Portal portal;
324-
HeapTuple tuple;
325-
TupleTableSlot *slot;
326-
ItemPointer tupleid;
327-
IndexInfo *indexInfo;
328-
EState *estate;
329-
Oid namespaceId;
330-
List* deparseCtx;
331-
char* oldIndexPredicate;
332-
char* newIndexPredicate;
333-
char* relationName;
334-
335-
Assert(stmt->whereClause);
336-
CheckPredicate((Expr *) stmt->whereClause);
337-
338-
/* Open and lock the parent heap relation */
339-
heapRelationId = IndexGetRelation(indexRelationId, false);
340-
heapRelation = heap_open(heapRelationId, AccessShareLock);
341-
342-
/* Open the target index relation */
343-
/* indexRelation = index_open(indexRelationId, RowExclusiveLock); */
344-
indexRelation = index_open(indexRelationId, ShareUpdateExclusiveLock);
345-
/* indexRelation = index_open(indexRelationId, AccessShareLock); */
346-
namespaceId = RelationGetNamespace(indexRelation);
347-
348-
indexInfo = BuildIndexInfo(indexRelation);
349-
Assert(!indexInfo->ii_ExclusionOps);
350-
351-
/*
352-
* Generate the constraint and default execution states
353-
*/
354-
estate = CreateExecutorState();
355-
356-
checkUnique = indexRelation->rd_index->indisunique ? UNIQUE_CHECK_YES : UNIQUE_CHECK_NO;
357-
358-
slot = MakeSingleTupleTableSlot(RelationGetDescr(heapRelation));
359-
360-
deparseCtx = deparse_context_for(RelationGetRelationName(heapRelation), heapRelationId);
361-
relationName = quote_qualified_identifier(get_namespace_name(namespaceId),
362-
get_rel_name(heapRelationId)),
363-
newIndexPredicate = deparse_expression(stmt->whereClause, deparseCtx, false, false);
364-
oldIndexPredicate = indexInfo->ii_Predicate
365-
? deparse_expression((Node*)make_ands_explicit(indexInfo->ii_Predicate), deparseCtx, false, false)
366-
: "true";
367-
368-
SPI_connect();
369-
370-
select = psprintf("select * from %s where %s and not (%s) limit 1",
371-
relationName, oldIndexPredicate, newIndexPredicate);
372-
if (SPI_execute(select, true, 1) != SPI_OK_SELECT)
373-
{
374-
ereport(ERROR,
375-
(errcode(ERRCODE_INVALID_CURSOR_STATE),
376-
errmsg("Failed to execute statement %s", select)));
377-
}
378-
if (SPI_processed) {
379-
/* There is no way in Postgres to exclude records from index, so we have to completelty rebuild index in this case */
380-
bool relpersistence = indexRelation->rd_rel->relpersistence;
381-
index_close(indexRelation, NoLock);
382-
indexRelation->rd_indpred = make_ands_implicit((Expr *) stmt->whereClause);
383-
indexRelation = NULL;
384-
UpdateIndex(indexRelationId, stmt->whereClause);
385-
reindex_index(indexRelationId, false, relpersistence, 0);
386-
} else {
387-
select = psprintf("select * from %s where %s and not (%s)",
388-
relationName, newIndexPredicate, oldIndexPredicate);
389-
plan = SPI_prepare(select, 0, NULL);
390-
if (plan == NULL) {
391-
ereport(ERROR,
392-
(errcode(ERRCODE_INVALID_CURSOR_STATE),
393-
errmsg("Failed to preapre statement %s", select)));
394-
}
395-
portal = SPI_cursor_open(NULL, plan, NULL, NULL, true);
396-
if (portal == NULL) {
397-
ereport(ERROR,
398-
(errcode(ERRCODE_INVALID_CURSOR_STATE),
399-
errmsg("Failed to open cursor for %s", select)));
400-
}
401-
while (true)
402-
{
403-
SPI_cursor_fetch(portal, true, 1);
404-
if (!SPI_processed) {
405-
break;
406-
}
407-
tuple = SPI_tuptable->vals[0];
408-
tupleid = &tuple->t_data->t_ctid;
409-
ExecStoreTuple(tuple, slot, InvalidBuffer, false);
410-
411-
FormIndexDatum(indexInfo,
412-
slot,
413-
estate,
414-
values,
415-
isnull);
416-
index_insert(indexRelation, /* index relation */
417-
values, /* array of index Datums */
418-
isnull, /* null flags */
419-
tupleid, /* tid of heap tuple */
420-
heapRelation, /* heap relation */
421-
checkUnique); /* type of uniqueness check to do */
422-
423-
SPI_freetuple(tuple);
424-
SPI_freetuptable(SPI_tuptable);
425-
}
426-
SPI_cursor_close(portal);
427-
428-
UpdateIndex(indexRelationId, stmt->whereClause);
429-
}
430-
SPI_finish();
431-
432-
ExecDropSingleTupleTableSlot(slot);
433-
FreeExecutorState(estate);
434-
435-
heap_close(heapRelation, NoLock);
436-
if (indexRelation) {
437-
index_close(indexRelation, NoLock);
438-
}
439-
}
440-
441283
/*
442284
* DefineIndex
443285
* Creates a new index.

src/backend/nodes/copyfuncs.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3128,7 +3128,6 @@ _copyIndexStmt(const IndexStmt *from)
31283128
COPY_SCALAR_FIELD(transformed);
31293129
COPY_SCALAR_FIELD(concurrent);
31303130
COPY_SCALAR_FIELD(if_not_exists);
3131-
COPY_SCALAR_FIELD(is_alter);
31323131

31333132
return newnode;
31343133
}

src/backend/nodes/equalfuncs.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1243,7 +1243,6 @@ _equalIndexStmt(const IndexStmt *a, const IndexStmt *b)
12431243
COMPARE_SCALAR_FIELD(transformed);
12441244
COMPARE_SCALAR_FIELD(concurrent);
12451245
COMPARE_SCALAR_FIELD(if_not_exists);
1246-
COMPARE_SCALAR_FIELD(is_alter);
12471246

12481247
return true;
12491248
}

src/backend/nodes/outfuncs.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2191,7 +2191,6 @@ _outIndexStmt(StringInfo str, const IndexStmt *node)
21912191
WRITE_BOOL_FIELD(transformed);
21922192
WRITE_BOOL_FIELD(concurrent);
21932193
WRITE_BOOL_FIELD(if_not_exists);
2194-
WRITE_BOOL_FIELD(is_alter);
21952194
}
21962195

21972196
static void

src/backend/optimizer/path/costsize.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@
8989
#include "optimizer/placeholder.h"
9090
#include "optimizer/plancat.h"
9191
#include "optimizer/planmain.h"
92-
#include "optimizer/predtest.h"
9392
#include "optimizer/restrictinfo.h"
9493
#include "parser/parsetree.h"
9594
#include "utils/lsyscache.h"
@@ -430,7 +429,7 @@ cost_index(IndexPath *path, PlannerInfo *root, double loop_count)
430429
path->path.rows = path->path.param_info->ppi_rows;
431430
/* qpquals come from the rel's restriction clauses and ppi_clauses */
432431
qpquals = list_concat(
433-
extract_nonindex_conditions(path->indexrinfos,
432+
extract_nonindex_conditions(baserel->baserestrictinfo,
434433
path->indexquals),
435434
extract_nonindex_conditions(path->path.param_info->ppi_clauses,
436435
path->indexquals));
@@ -439,7 +438,7 @@ cost_index(IndexPath *path, PlannerInfo *root, double loop_count)
439438
{
440439
path->path.rows = baserel->rows;
441440
/* qpquals come from just the rel's restriction clauses */
442-
qpquals = extract_nonindex_conditions(path->indexrinfos,
441+
qpquals = extract_nonindex_conditions(baserel->baserestrictinfo,
443442
path->indexquals);
444443
}
445444

@@ -640,7 +639,6 @@ extract_nonindex_conditions(List *qual_clauses, List *indexquals)
640639
continue; /* simple duplicate */
641640
if (is_redundant_derived_clause(rinfo, indexquals))
642641
continue; /* derived from same EquivalenceClass */
643-
644642
/* ... skip the predicate proof attempts createplan.c will try ... */
645643
result = lappend(result, rinfo);
646644
}

0 commit comments

Comments
 (0)