MCPcopy Create free account
hub / github.com/activeloopai/deeplake / check_column_exists

Function check_column_exists

cpp/deeplake_pg/utils.hpp:733–753  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

731}
732
733inline bool check_column_exists(const std::string& table_name,
734 const std::string& column_name,
735 const std::string& schema_name = "public")
736{
737 std::string query = fmt::format("SELECT 1 FROM information_schema.columns WHERE "
738 "table_schema = '{}' AND table_name = '{}' AND column_name = '{}'",
739 schema_name,
740 table_name,
741 column_name);
742 bool pushed_snapshot = false;
743 if (!ActiveSnapshotSet()) {
744 PushActiveSnapshot(GetTransactionSnapshot());
745 pushed_snapshot = true;
746 }
747 spi_connector connector;
748 bool exists = SPI_execute(query.c_str(), true, 0) == SPI_OK_SELECT && SPI_processed > 0;
749 if (pushed_snapshot) {
750 PopActiveSnapshot();
751 }
752 return exists;
753}
754
755} // namespace utils
756

Callers 1

load_table_metadataMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected