Autonomy Software C++ 24.5.1
Welcome to the Autonomy Software repository of the Mars Rover Design Team (MRDT) at Missouri University of Science and Technology (Missouri S&T)! API reference contains the source code and other resources for the development of the autonomy software for our Mars rover. The Autonomy Software project aims to compete in the University Rover Challenge (URC) by demonstrating advanced autonomous capabilities and robust navigation algorithms.
Loading...
Searching...
No Matches
duckdb::SequenceCatalogEntry Class Reference

A sequence catalog entry. More...

Inheritance diagram for duckdb::SequenceCatalogEntry:
Collaboration diagram for duckdb::SequenceCatalogEntry:

Public Member Functions

 SequenceCatalogEntry (Catalog &catalog, SchemaCatalogEntry &schema, CreateSequenceInfo &info)
 Create a real TableCatalogEntry and initialize storage for it.
 
unique_ptr< CatalogEntryCopy (ClientContext &context) const override
 
unique_ptr< CreateInfoGetInfo () const override
 
SequenceData GetData () const
 
int64_t CurrentValue ()
 
int64_t NextValue (DuckTransaction &transaction)
 
void ReplayValue (uint64_t usage_count, int64_t counter)
 
string ToSQL () const override
 Convert the catalog entry to a SQL string that can be used to re-construct the catalog entry.
 
- Public Member Functions inherited from duckdb::StandardEntry
 StandardEntry (CatalogType type, SchemaCatalogEntry &schema, Catalog &catalog, string name)
 
SchemaCatalogEntryParentSchema () override
 
const SchemaCatalogEntryParentSchema () const override
 
- Public Member Functions inherited from duckdb::InCatalogEntry
 InCatalogEntry (CatalogType type, Catalog &catalog, string name)
 
CatalogParentCatalog () override
 
const CatalogParentCatalog () const override
 
void Verify (Catalog &catalog) override
 
- Public Member Functions inherited from duckdb::CatalogEntry
 CatalogEntry (CatalogType type, Catalog &catalog, string name)
 
 CatalogEntry (CatalogType type, string name, idx_t oid)
 
virtual unique_ptr< CatalogEntryAlterEntry (ClientContext &context, AlterInfo &info)
 
virtual unique_ptr< CatalogEntryAlterEntry (CatalogTransaction transaction, AlterInfo &info)
 
virtual void UndoAlter (ClientContext &context, AlterInfo &info)
 
virtual void Rollback (CatalogEntry &prev_entry)
 
virtual void OnDrop ()
 
virtual void SetAsRoot ()
 Sets the CatalogEntry as the new root entry (i.e. the newest entry)
 
void Serialize (Serializer &serializer) const
 
void SetChild (unique_ptr< CatalogEntry > child)
 
unique_ptr< CatalogEntryTakeChild ()
 
bool HasChild () const
 
bool HasParent () const
 
CatalogEntryChild ()
 
CatalogEntryParent ()
 
const CatalogEntryParent () const
 
template<class TARGET >
TARGETCast ()
 
template<class TARGET >
const TARGETCast () const
 

Static Public Attributes

static constexpr const CatalogType Type = CatalogType::SEQUENCE_ENTRY
 
static constexpr const charName = "sequence"
 

Private Attributes

mutex lock
 Lock for getting a value on the sequence.
 
SequenceData data
 Sequence data.
 

Additional Inherited Members

- Static Public Member Functions inherited from duckdb::CatalogEntry
static unique_ptr< CreateInfoDeserialize (Deserializer &deserializer)
 
- Public Attributes inherited from duckdb::StandardEntry
SchemaCatalogEntryschema
 The schema the entry belongs to.
 
LogicalDependencyList dependencies
 The dependencies of the entry, can be empty.
 
- Public Attributes inherited from duckdb::InCatalogEntry
Catalogcatalog
 The catalog the entry belongs to.
 
- Public Attributes inherited from duckdb::CatalogEntry
idx_t oid
 The oid of the entry.
 
CatalogType type
 The type of this catalog entry.
 
optional_ptr< CatalogSetset
 Reference to the catalog set this entry is stored in.
 
string name
 The name of the entry.
 
bool deleted
 Whether or not the object is deleted.
 
bool temporary
 Whether or not the object is temporary and should not be added to the WAL.
 
bool internal
 Whether or not the entry is an internal entry (cannot be deleted, not dumped, etc)
 
atomic< transaction_ttimestamp
 Timestamp at which the catalog entry was created.
 
Value comment
 (optional) comment on this entry
 
InsertionOrderPreservingMap< string > tags
 (optional) extra data associated with this entry
 

Detailed Description

A sequence catalog entry.

Constructor & Destructor Documentation

◆ SequenceCatalogEntry()

duckdb::SequenceCatalogEntry::SequenceCatalogEntry ( Catalog catalog,
SchemaCatalogEntry schema,
CreateSequenceInfo info 
)

Create a real TableCatalogEntry and initialize storage for it.

20260 : StandardEntry(CatalogType::SEQUENCE_ENTRY, schema, catalog, info.name), data(info) {
20261 this->temporary = info.temporary;
20262 this->comment = info.comment;
20263 this->tags = info.tags;
20264}
InsertionOrderPreservingMap< string > tags
(optional) extra data associated with this entry
Definition duckdb.hpp:6323
Value comment
(optional) comment on this entry
Definition duckdb.hpp:6321
bool temporary
Whether or not the object is temporary and should not be added to the WAL.
Definition duckdb.hpp:6315
Catalog & catalog
The catalog the entry belongs to.
Definition duckdb.hpp:6387
SequenceData data
Sequence data.
Definition duckdb.hpp:29020
SchemaCatalogEntry & schema
The schema the entry belongs to.
Definition duckdb.hpp:28008

Member Function Documentation

◆ Copy()

unique_ptr< CatalogEntry > duckdb::SequenceCatalogEntry::Copy ( ClientContext context) const
overridevirtual

Reimplemented from duckdb::CatalogEntry.

20266 {
20267 auto info_copy = GetInfo();
20268 auto &cast_info = info_copy->Cast<CreateSequenceInfo>();
20269
20270 auto result = make_uniq<SequenceCatalogEntry>(catalog, schema, cast_info);
20271 result->data = GetData();
20272
20273 return std::move(result);
20274}

◆ GetInfo()

unique_ptr< CreateInfo > duckdb::SequenceCatalogEntry::GetInfo ( ) const
overridevirtual

Reimplemented from duckdb::CatalogEntry.

20327 {
20328 auto seq_data = GetData();
20329
20330 auto result = make_uniq<CreateSequenceInfo>();
20331 result->catalog = catalog.GetName();
20332 result->schema = schema.name;
20333 result->name = name;
20334 result->usage_count = seq_data.usage_count;
20335 result->increment = seq_data.increment;
20336 result->min_value = seq_data.min_value;
20337 result->max_value = seq_data.max_value;
20338 result->start_value = seq_data.counter;
20339 result->cycle = seq_data.cycle;
20340 result->dependencies = dependencies;
20341 result->comment = comment;
20342 result->tags = tags;
20343 return std::move(result);
20344}
string name
The name of the entry.
Definition duckdb.hpp:6311
DUCKDB_API const string & GetName() const
Returns the catalog name - based on how the catalog was attached.
Definition duckdb.cpp:7165
LogicalDependencyList dependencies
The dependencies of the entry, can be empty.
Definition duckdb.hpp:28010

◆ GetData()

SequenceData duckdb::SequenceCatalogEntry::GetData ( ) const
20276 {
20277 lock_guard<mutex> seqlock(lock);
20278 return data;
20279}
mutex lock
Lock for getting a value on the sequence.
Definition duckdb.hpp:29018

◆ CurrentValue()

int64_t duckdb::SequenceCatalogEntry::CurrentValue ( )
20281 {
20282 lock_guard<mutex> seqlock(lock);
20283 int64_t result;
20284 if (data.usage_count == 0u) {
20285 throw SequenceException("currval: sequence is not yet defined in this session");
20286 }
20287 result = data.last_value;
20288 return result;
20289}
::int64_t int64_t
uint64_t usage_count
The amount of times the sequence has been used.
Definition duckdb.hpp:28978
int64_t last_value
The most recently returned value.
Definition duckdb.hpp:28982

◆ NextValue()

int64_t duckdb::SequenceCatalogEntry::NextValue ( DuckTransaction transaction)
20291 {
20292 lock_guard<mutex> seqlock(lock);
20293 int64_t result;
20294 result = data.counter;
20295 bool overflow = !TryAddOperator::Operation(data.counter, data.increment, data.counter);
20296 if (data.cycle) {
20297 if (overflow) {
20299 } else if (data.counter < data.min_value) {
20301 } else if (data.counter > data.max_value) {
20303 }
20304 } else {
20305 if (result < data.min_value || (overflow && data.increment < 0)) {
20306 throw SequenceException("nextval: reached minimum value of sequence \"%s\" (%lld)", name, data.min_value);
20307 }
20308 if (result > data.max_value || overflow) {
20309 throw SequenceException("nextval: reached maximum value of sequence \"%s\" (%lld)", name, data.max_value);
20310 }
20311 }
20312 data.last_value = result;
20313 data.usage_count++;
20314 if (!temporary) {
20315 transaction.PushSequenceUsage(*this, data);
20316 }
20317 return result;
20318}
int64_t increment
The increment value.
Definition duckdb.hpp:28984
int64_t min_value
The minimum value of the sequence.
Definition duckdb.hpp:28988
int64_t max_value
The maximum value of the sequence.
Definition duckdb.hpp:28990
int64_t counter
The sequence counter.
Definition duckdb.hpp:28980
bool cycle
Whether or not the sequence cycles.
Definition duckdb.hpp:28992

◆ ReplayValue()

void duckdb::SequenceCatalogEntry::ReplayValue ( uint64_t  usage_count,
int64_t  counter 
)
20320 {
20321 if (v_usage_count > data.usage_count) {
20322 data.usage_count = v_usage_count;
20323 data.counter = v_counter;
20324 }
20325}

◆ ToSQL()

string duckdb::SequenceCatalogEntry::ToSQL ( ) const
overridevirtual

Convert the catalog entry to a SQL string that can be used to re-construct the catalog entry.

Reimplemented from duckdb::CatalogEntry.

20346 {
20347 auto seq_data = GetData();
20348
20350 ss << "CREATE SEQUENCE ";
20351 ss << name;
20352 ss << " INCREMENT BY " << seq_data.increment;
20353 ss << " MINVALUE " << seq_data.min_value;
20354 ss << " MAXVALUE " << seq_data.max_value;
20355 ss << " START " << seq_data.counter;
20356 ss << " " << (seq_data.cycle ? "CYCLE" : "NO CYCLE") << ";";
20357 return ss.str();
20358}
Definition duckdb.hpp:960

The documentation for this class was generated from the following files: