Skip to content

Commit d078805

Browse files
Set timestamp during INSERT & IMPORT Commands
1 parent 9a1aba3 commit d078805

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

src/catalog/DatabaseCommand.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,16 @@ void InsertRecords::execute(Diagnostic&)
142142
}
143143
Tuple *args[] = { &tup };
144144
get_tuple(args);
145+
146+
/*----- set timestamps if available. -----*/
147+
auto it = std::find_if(T.cbegin_hidden(), T.end_hidden(),
148+
[&](const Attribute & attr) {
149+
return attr.name == C.pool("$ts_begin");
150+
});
151+
if (it != T.end_hidden()) {
152+
tup.set(it->id, Value(transaction()->start_time()));
153+
}
154+
145155
W.append(tup);
146156
}
147157
}

src/io/DSVReader.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,16 @@ void DSVReader::operator()(std::istream &in, const char *name)
121121
W = std::make_unique<StackMachine>(Interpreter::compile_store(S, store.memory().addr(), *layout,
122122
S, store.num_rows() - 1));
123123
}
124+
/*----- set timestamps if available. -----*/
125+
auto it = std::find_if(table.cbegin_hidden(), table.end_hidden(),
126+
[&](const Attribute & attr) {
127+
return attr.name == C.pool("$ts_begin");
128+
});
129+
if (this->transaction and it != table.end_hidden()) {
130+
col_idx = it->id;
131+
tup.set(col_idx, Value(transaction->start_time()));
132+
}
133+
124134
Tuple *args[] = { &tup };
125135
(*W)(args); // write tuple to store
126136
}

0 commit comments

Comments
 (0)