Skip to content

Commit d90068d

Browse files
committed
Support Update
1 parent 3fdb4a8 commit d90068d

File tree

3 files changed

+46
-11
lines changed

3 files changed

+46
-11
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ GEN_KEYWORDLIST = $(PERL) -I ./tools/ ./tools/gen_keywordlist.pl
137137
GEN_KEYWORDLIST_DEPS = ./tools/gen_keywordlist.pl tools/PerfectHash.pm
138138

139139
ag_include_dir = $(srcdir)/src/include
140-
PG_CPPFLAGS = -w -I$(ag_include_dir) -I$(ag_include_dir)/parser -I$(POSTGIS_DIR) -I$(POSTGIS_DIR)/liblwgeom -I/home/v-innisjosh/postgres/contrib/ltree
140+
PG_CPPFLAGS = -w -I$(ag_include_dir) -I$(ag_include_dir)/parser -I$(POSTGIS_DIR) -I$(POSTGIS_DIR)/liblwgeom -I/home/josh/postgres/contrib/ltree
141141
PG_LDFLAGS = -lgeos_c
142142
SHLIB_LINK= $(POSTGIS_DIR)/liblwgeom/.libs/liblwgeom.a -Wl,--no-as-needed -Wl,-l:postgis-3.so -Wl,-l:ltree.so
143143

regress/sql/vertex_am.sql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,7 @@ VALUES ('1'::postgraph.graphid, postgraph.gtype_build_map('id', 1));
3636

3737
SELECT * FROM vertex_am_tst;
3838

39+
UPDATE vertex_am_tst SET id = '2'::postgraph.graphid;
3940

41+
42+
SELECT * FROM vertex_am_tst;

src/backend/access/vertex_heap/vertex_heapam_handler.c

Lines changed: 42 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2044,13 +2044,24 @@ bool vertex_index_fetch_tuple(struct IndexFetchTableData *scan,
20442044
* according to `snapshot`. If a tuple was found and passed the visibility
20452045
* test, returns true, false otherwise.
20462046
*/
2047-
bool vertex_tuple_fetch_row_version(Relation rel, ItemPointer tid,
2047+
bool vertex_tuple_fetch_row_version(Relation relation, ItemPointer tid,
20482048
Snapshot snapshot, TupleTableSlot *slot) {
2049-
ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
2050-
errmsg_internal("vertex_parallelscan_reinitialize not implemented")));
2051-
2049+
BufferHeapTupleTableSlot *bslot = (BufferHeapTupleTableSlot *) slot;
2050+
Buffer buffer;
20522051

2053-
return false;
2052+
Assert(TTS_IS_BUFFERTUPLE(slot));
2053+
2054+
bslot->base.tupdata.t_self = *tid;
2055+
if (heap_fetch(relation, snapshot, &bslot->base.tupdata, &buffer))
2056+
{
2057+
/* store in slot, transferring existing pin */
2058+
ExecStorePinnedBufferHeapTuple(&bslot->base.tupdata, slot, buffer);
2059+
slot->tts_tableOid = RelationGetRelid(relation);
2060+
2061+
return true;
2062+
}
2063+
2064+
return false;
20542065
}
20552066

20562067
/*
@@ -2569,16 +2580,37 @@ TM_Result vertex_tuple_delete(Relation relation, ItemPointer tid, CommandId cid,
25692580
}
25702581

25712582
/* see table_tuple_update() for reference about parameters */
2572-
TM_Result vertex_tuple_update(Relation rel, ItemPointer otid, TupleTableSlot *slot,
2583+
TM_Result vertex_tuple_update(Relation relation, ItemPointer otid, TupleTableSlot *slot,
25732584
CommandId cid, Snapshot snapshot, Snapshot crosscheck,
25742585
bool wait, TM_FailureData *tmfd, LockTupleMode *lockmode,
25752586
bool *update_indexes) {
25762587

2577-
ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
2578-
errmsg_internal("vertex_parallelscan_reinitialize not implemented")));
2579-
2588+
bool shouldFree = true;
2589+
HeapTuple tuple = ExecFetchSlotHeapTuple(slot, true, &shouldFree);
2590+
TM_Result result;
2591+
2592+
/* Update the tuple with table oid */
2593+
slot->tts_tableOid = RelationGetRelid(relation);
2594+
tuple->t_tableOid = slot->tts_tableOid;
2595+
2596+
result = heap_update(relation, otid, tuple, cid, crosscheck, wait,
2597+
tmfd, lockmode);
2598+
ItemPointerCopy(&tuple->t_self, &slot->tts_tid);
2599+
2600+
/*
2601+
* Decide whether new index entries are needed for the tuple
2602+
*
2603+
* Note: heap_update returns the tid (location) of the new tuple in the
2604+
* t_self field.
2605+
*
2606+
* If it's a HOT update, we mustn't insert new index entries.
2607+
*/
2608+
*update_indexes = result == TM_Ok && !HeapTupleIsHeapOnly(tuple);
2609+
2610+
if (shouldFree)
2611+
pfree(tuple);
25802612

2581-
return 0;
2613+
return result;
25822614
}
25832615

25842616
/* see table_tuple_lock() for reference about parameters */

0 commit comments

Comments
 (0)