crdb_internal.scan(span: bytes[]) → tuple{bytes AS key, bytes AS value} | Returns the raw keys and values from the specified span
+crdb_internal.scan(span: bytes[]) → tuple{bytes AS key, bytes AS value, string AS ts} | Returns the raw keys and values from the specified span
| Stable |
-crdb_internal.scan(start_key: bytes, end_key: bytes) → tuple{bytes AS key, bytes AS value} | Returns the raw keys and values from the specified span
+crdb_internal.scan(start_key: bytes, end_key: bytes) → tuple{bytes AS key, bytes AS value, string AS ts} | Returns the raw keys and values with their timestamp from the specified span
| Stable |
crdb_internal.testing_callback(name: string) → int | For internal CRDB testing only. The function calls a callback identified by name registered with the server by the test.
| Volatile |
@@ -3081,7 +3081,7 @@ active for the current transaction.
| Volatile |
crdb_internal.lease_holder(key: bytes) → int | This function is used to fetch the leaseholder corresponding to a request key
| Volatile |
-crdb_internal.list_sql_keys_in_range(range_id: int) → tuple{string AS key, string AS value} | Returns all SQL K/V pairs within the requested range.
+crdb_internal.list_sql_keys_in_range(range_id: int) → tuple{string AS key, string AS value, string AS ts} | Returns all SQL K/V pairs within the requested range.
| Volatile |
crdb_internal.locality_value(key: string) → string | Returns the value of the specified locality key.
| Stable |
diff --git a/pkg/sql/sem/builtins/fixed_oids.go b/pkg/sql/sem/builtins/fixed_oids.go
index e99911d76694..bb2f7b3abfdb 100644
--- a/pkg/sql/sem/builtins/fixed_oids.go
+++ b/pkg/sql/sem/builtins/fixed_oids.go
@@ -424,7 +424,7 @@ var builtinOidsBySignature = map[string]oid.Oid{
`crdb_internal.kv_set_queue_active(queue_name: string, active: bool) -> bool`: 1383,
`crdb_internal.kv_set_queue_active(queue_name: string, active: bool, store_id: int) -> bool`: 1384,
`crdb_internal.lease_holder(key: bytes) -> int`: 1316,
- `crdb_internal.list_sql_keys_in_range(range_id: int) -> tuple{string AS key, string AS value}`: 348,
+ `crdb_internal.list_sql_keys_in_range(range_id: int) -> tuple{string AS key, string AS value, string AS ts}`: 348,
`crdb_internal.locality_value(key: string) -> string`: 1292,
`crdb_internal.merge_statement_stats(input: jsonb[]) -> jsonb`: 1277,
`crdb_internal.merge_stats_metadata(input: jsonb[]) -> jsonb`: 1279,
@@ -466,8 +466,8 @@ var builtinOidsBySignature = map[string]oid.Oid{
`crdb_internal.revalidate_unique_constraints_in_table(table_name: string) -> void`: 1380,
`crdb_internal.round_decimal_values(val: decimal, scale: int) -> decimal`: 1342,
`crdb_internal.round_decimal_values(val: decimal[], scale: int) -> decimal[]`: 1343,
- `crdb_internal.scan(start_key: bytes, end_key: bytes) -> tuple{bytes AS key, bytes AS value}`: 315,
- `crdb_internal.scan(span: bytes[]) -> tuple{bytes AS key, bytes AS value}`: 316,
+ `crdb_internal.scan(start_key: bytes, end_key: bytes) -> tuple{bytes AS key, bytes AS value, string AS ts}`: 315,
+ `crdb_internal.scan(span: bytes[]) -> tuple{bytes AS key, bytes AS value, string AS ts}`: 316,
`crdb_internal.schedule_sql_stats_compaction() -> bool`: 1377,
`crdb_internal.serialize_session() -> bytes`: 1370,
`crdb_internal.set_compaction_concurrency(node_id: int, store_id: int, compaction_concurrency: int) -> bool`: 1389,
diff --git a/pkg/sql/sem/builtins/generator_builtins.go b/pkg/sql/sem/builtins/generator_builtins.go
index af5509acd9f1..d149d441315b 100644
--- a/pkg/sql/sem/builtins/generator_builtins.go
+++ b/pkg/sql/sem/builtins/generator_builtins.go
@@ -136,7 +136,7 @@ var generators = map[string]builtinDefinition{
EndKey: endKey,
}), nil
},
- "Returns the raw keys and values from the specified span",
+ "Returns the raw keys and values with their timestamp from the specified span",
volatility.Stable,
),
makeGeneratorOverload(
@@ -2065,13 +2065,13 @@ const spanKeyIteratorChunkBytes = 8 << 20 // 8MiB
var rangeKeyIteratorType = types.MakeLabeledTuple(
// TODO(rohany): These could be bytes if we don't want to display the
// prettified versions of the key and value.
- []*types.T{types.String, types.String},
- []string{"key", "value"},
+ []*types.T{types.String, types.String, types.String},
+ []string{"key", "value", "ts"},
)
var spanKeyIteratorType = types.MakeLabeledTuple(
- []*types.T{types.Bytes, types.Bytes},
- []string{"key", "value"},
+ []*types.T{types.Bytes, types.Bytes, types.String},
+ []string{"key", "value", "ts"},
)
// spanKeyIterator is a ValueGenerator that iterates over all
@@ -2092,7 +2092,7 @@ type spanKeyIterator struct {
// index maintains the current position of the iterator in kvs.
index int
// A buffer to avoid allocating an array on every call to Values().
- buf [2]tree.Datum
+ buf [3]tree.Datum
}
func newSpanKeyIterator(evalCtx *eval.Context, span roachpb.Span) *spanKeyIterator {
@@ -2166,6 +2166,7 @@ func (sp *spanKeyIterator) Values() (tree.Datums, error) {
kv := sp.kvs[sp.index]
sp.buf[0] = tree.NewDBytes(tree.DBytes(kv.Key))
sp.buf[1] = tree.NewDBytes(tree.DBytes(kv.Value.RawBytes))
+ sp.buf[2] = tree.NewDString(kv.Value.Timestamp.String())
return sp.buf[:], nil
}
@@ -2234,6 +2235,7 @@ func (rk *rangeKeyIterator) Values() (tree.Datums, error) {
kv := rk.kvs[rk.index]
rk.buf[0] = tree.NewDString(kv.Key.String())
rk.buf[1] = tree.NewDString(kv.Value.PrettyPrint())
+ rk.buf[2] = tree.NewDString(kv.Value.Timestamp.String())
return rk.buf[:], nil
}
| |