MCPcopy Create free account
hub / github.com/LadybugDB/ladybug / printSchema

Method printSchema

tools/shell/embedded_shell.cpp:1601–1637  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1599}
1600
1601void EmbeddedShell::printSchema() {
1602 std::stringstream ss;
1603 auto clientContext = conn->getClientContext();
1604 bool transactionStarted = false;
1605 if (transaction::Transaction::Get(*clientContext) == NULL) {
1606 transaction::TransactionContext::Get(*clientContext)
1607 ->beginReadTransaction(); // start transaction to get schema
1608 transactionStarted = true;
1609 }
1610 auto extensionCypher = extension::ExtensionManager::Get(*clientContext)->toCypher();
1611 if (!extensionCypher.empty()) {
1612 ss << extensionCypher << std::endl;
1613 }
1614 const auto catalog = catalog::Catalog::Get(*clientContext);
1615 auto transaction = transaction::Transaction::Get(*clientContext);
1616 catalog::ToCypherInfo toCypherInfo;
1617 for (const auto& nodeTableEntry :
1618 catalog->getNodeTableEntries(transaction, false /* useInternal */)) {
1619 ss << nodeTableEntry->toCypher(toCypherInfo) << std::endl;
1620 }
1621 catalog::RelGroupToCypherInfo relTableToCypherInfo(clientContext);
1622 for (const auto& entry : catalog->getRelGroupEntries(transaction, false /* useInternal */)) {
1623 ss << entry->toCypher(relTableToCypherInfo) << std::endl;
1624 }
1625 catalog::RelGroupToCypherInfo relGroupToCypherInfo(clientContext);
1626 for (const auto sequenceEntry : catalog->getSequenceEntries(transaction)) {
1627 ss << sequenceEntry->toCypher(relGroupToCypherInfo) << std::endl;
1628 }
1629 for (auto macroName : catalog->getMacroNames(transaction)) {
1630 ss << catalog->getScalarMacroFunction(transaction, macroName)->toCypher(macroName)
1631 << std::endl;
1632 }
1633 if (transactionStarted) {
1634 transaction::TransactionContext::Get(*clientContext)->commit();
1635 }
1636 printf("%s", ss.str().c_str());
1637}
1638
1639} // namespace main
1640} // namespace lbug

Callers

nothing calls this directly

Calls 10

beginReadTransactionMethod · 0.80
getNodeTableEntriesMethod · 0.80
getRelGroupEntriesMethod · 0.80
getSequenceEntriesMethod · 0.80
getMacroNamesMethod · 0.80
getClientContextMethod · 0.45
toCypherMethod · 0.45
emptyMethod · 0.45
commitMethod · 0.45

Tested by

no test coverage detected