Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion duckdb
Submodule duckdb updated 1273 files
2 changes: 1 addition & 1 deletion extension-ci-tools
2 changes: 1 addition & 1 deletion src/include/postgres_binary_copy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class PostgresBinaryCopyFunction : public CopyFunction {
PostgresBinaryCopyFunction();

static unique_ptr<FunctionData> PostgresBinaryWriteBind(ClientContext &context, CopyFunctionBindInput &input,
const vector<string> &names,
const vector<Identifier> &names,
const vector<LogicalType> &sql_types);

static unique_ptr<GlobalFunctionData>
Expand Down
4 changes: 2 additions & 2 deletions src/include/storage/postgres_index_entry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ class PostgresIndexEntry : public IndexCatalogEntry {
string table_name;

public:
string GetSchemaName() const override;
string GetTableName() const override;
Identifier GetSchemaName() const override;
Identifier GetTableName() const override;
};

} // namespace duckdb
2 changes: 1 addition & 1 deletion src/include/storage/postgres_secret_storage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class PostgresSecretStorage : public SecretStorage {
unique_ptr<SecretEntry> StoreSecret(unique_ptr<const BaseSecret> secret, OnCreateConflict on_conflict,
optional_ptr<CatalogTransaction> transaction = nullptr) override;
vector<SecretEntry> AllSecrets(optional_ptr<CatalogTransaction> transaction = nullptr) override;
void DropSecretByName(const string &name, OnEntryNotFound on_entry_not_found,
void DropSecretByName(const Identifier &name, OnEntryNotFound on_entry_not_found,
optional_ptr<CatalogTransaction> transaction = nullptr) override;
SecretMatch LookupSecret(const string &path, const string &type,
optional_ptr<CatalogTransaction> transaction = nullptr) override;
Expand Down
6 changes: 3 additions & 3 deletions src/include/storage/postgres_table_entry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ struct PostgresTableInfo {
create_info->columns.SetAllowDuplicates(true);
}
PostgresTableInfo(const string &schema, const string &table) {
create_info = make_uniq<CreateTableInfo>(string(), schema, table);
create_info = make_uniq<CreateTableInfo>(Identifier(), Identifier(schema), Identifier(table));
create_info->columns.SetAllowDuplicates(true);
}
PostgresTableInfo(const SchemaCatalogEntry &schema, const string &table) {
create_info = make_uniq<CreateTableInfo>((SchemaCatalogEntry &)schema, table);
create_info = make_uniq<CreateTableInfo>((SchemaCatalogEntry &)schema, Identifier(table));
create_info->columns.SetAllowDuplicates(true);
}

const string &GetTableName() const {
return create_info->table;
return create_info->table.GetIdentifierName();
}

unique_ptr<CreateTableInfo> create_info;
Expand Down
2 changes: 1 addition & 1 deletion src/postgres_aws.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ std::string PostgresAws::GenerateRdsAuthToken(AttachedDatabase &attached_db,
}

static std::string ExtractString(const KeyValueSecret &kv, const std::string name) {
Value val = kv.TryGetValue(name);
Value val = kv.TryGetValue(Identifier(name));
if (val.IsNull()) {
return std::string();
}
Expand Down
4 changes: 2 additions & 2 deletions src/postgres_binary_copy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ struct PostgresBinaryWriteBindData : public TableFunctionData {};

unique_ptr<FunctionData> PostgresBinaryCopyFunction::PostgresBinaryWriteBind(ClientContext &context,
CopyFunctionBindInput &input,
const vector<string> &names,
const vector<Identifier> &names,
const vector<LogicalType> &sql_types) {
return make_uniq<PostgresBinaryWriteBindData>();
}
Expand Down Expand Up @@ -172,7 +172,7 @@ static unique_ptr<FunctionData> ReadPostgresBinaryBind(ClientContext &context, T
auto col_type_str = column_map[i].GetValue<string>();
auto col_type = TransformStringToLogicalType(col_type_str, context);

names.push_back(col_name);
names.push_back(col_name.GetIdentifierName());
return_types.push_back(col_type);
result->postgres_types.push_back(PostgresUtils::CreateEmptyPostgresType(col_type));
}
Expand Down
2 changes: 1 addition & 1 deletion src/postgres_execute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ static duckdb::unique_ptr<FunctionData> PGExecuteBind(ClientContext &context, Ta
// look up the database to query
auto db_name = input.inputs[0].GetValue<string>();
auto &db_manager = DatabaseManager::Get(context);
auto db = db_manager.GetDatabase(context, db_name);
auto db = db_manager.GetDatabase(context, Identifier(db_name));
if (!db) {
throw BinderException("Failed to find attached database \"%s\" referenced in postgres_query", db_name);
}
Expand Down
2 changes: 1 addition & 1 deletion src/postgres_query.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ static unique_ptr<FunctionData> PGQueryBind(ClientContext &context, TableFunctio
// look up the database to query
auto db_name = input.inputs[0].GetValue<string>();
auto &db_manager = DatabaseManager::Get(context);
auto db = db_manager.GetDatabase(context, db_name);
auto db = db_manager.GetDatabase(context, Identifier(db_name));
if (!db) {
throw BinderException("Failed to find attached database \"%s\" referenced in postgres_query", db_name);
}
Expand Down
2 changes: 1 addition & 1 deletion src/postgres_scanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ static unique_ptr<FunctionData> PostgresBind(ClientContext &context, TableFuncti

bind_data->postgres_types = info->postgres_types;
for (auto &col : info->create_info->columns.Logical()) {
names.push_back(col.GetName());
names.push_back(col.GetName().GetIdentifierName());
return_types.push_back(col.GetType());
}
bind_data->names = info->postgres_names;
Expand Down
6 changes: 3 additions & 3 deletions src/postgres_secrets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,18 +112,18 @@ unique_ptr<BaseSecret> PostgresSecrets::CreateFunction(ClientContext &context, C
std::find(other_option_names.begin(), other_option_names.end(), name) == other_option_names.end()) {
throw InternalException("Unknown named parameter for a Postgres secret: '" + named_param.first + "'");
}
result->secret_map[name] = named_param.second.ToString();
result->secret_map[Identifier(name)] = named_param.second.ToString();
}
result->redact_keys = {"password", "sslpassword", "oauth_client_secret", "uri"};
return std::move(result);
}

void PostgresSecrets::SetSecretParameters(CreateSecretFunction &function) {
for (const std::string &name : connection_option_names) {
function.named_parameters[name] = LogicalType::VARCHAR;
function.named_parameters[Identifier(name)] = LogicalType::VARCHAR;
}
for (auto &en : connection_option_aliases) {
function.named_parameters[en.first] = LogicalType::VARCHAR;
function.named_parameters[Identifier(en.first)] = LogicalType::VARCHAR;
}
// other options
function.named_parameters["uri"] = LogicalType::VARCHAR;
Expand Down
9 changes: 5 additions & 4 deletions src/postgres_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,11 +249,12 @@ LogicalType PostgresUtils::TypeToLogicalType(optional_ptr<PostgresTransaction> t
throw InternalException("Context is destroyed!?");
}
optional_ptr<SchemaCatalogEntry> lookup_schema =
type_info.type_schema != schema->name
? schema->ParentCatalog().GetSchema(*context, type_info.type_schema, OnEntryNotFound::THROW_EXCEPTION)
Identifier(type_info.type_schema) != schema->name
? schema->ParentCatalog().GetSchema(*context, Identifier(type_info.type_schema),
OnEntryNotFound::THROW_EXCEPTION)
: schema.get();
auto entry = lookup_schema->GetEntry(CatalogTransaction(lookup_schema->ParentCatalog(), *context),
CatalogType::TYPE_ENTRY, pgtypename);
CatalogType::TYPE_ENTRY, Identifier(pgtypename));
if (!entry) {
// unsupported so fallback to varchar
postgres_type.info = PostgresTypeAnnotation::CAST_TO_VARCHAR;
Expand Down Expand Up @@ -555,7 +556,7 @@ string PostgresUtils::EscapeConnectionString(const string &input) {
}

string PostgresUtils::ExtractConnectionOption(const KeyValueSecret &kv_secret, const string &name) {
Value input_val = kv_secret.TryGetValue(name);
Value input_val = kv_secret.TryGetValue(Identifier(name));
if (input_val.IsNull()) {
// not provided
return string();
Expand Down
6 changes: 3 additions & 3 deletions src/storage/postgres_catalog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ string PostgresCatalog::CreateConnectionString(optional_ptr<SecretEntry> secret_
if (!uri_val.IsNull()) {
// no other options can be specified along with the URI
for (const string &opt_name : PostgresSecrets::ConnectionOptionNames()) {
if (!kv_secret.TryGetValue(opt_name).IsNull()) {
if (!kv_secret.TryGetValue(Identifier(opt_name)).IsNull()) {
throw BinderException("Options with name \"%s\" cannot be specified when 'URI' option is specified",
opt_name);
}
Expand Down Expand Up @@ -175,7 +175,7 @@ void PostgresCatalog::Initialize(bool load_builtin) {

optional_ptr<CatalogEntry> PostgresCatalog::CreateSchema(CatalogTransaction transaction, CreateSchemaInfo &info) {
auto &postgres_transaction = PostgresTransaction::Get(transaction.GetContext(), *this);
auto entry = schemas.GetEntry(transaction.GetContext(), postgres_transaction, info.schema);
auto entry = schemas.GetEntry(transaction.GetContext(), postgres_transaction, info.schema.GetIdentifierName());
if (entry) {
switch (info.on_conflict) {
case OnCreateConflict::REPLACE_ON_CONFLICT: {
Expand Down Expand Up @@ -259,7 +259,7 @@ void PostgresCatalog::RegisterSecretStorage() {
auto connection = connection_pool->GetConnection();
bool secret_storage_table_exists = secret_storage_table.Exists(connection.GetConnection());

string attached_database_name = GetAttached().GetName();
string attached_database_name = GetAttached().GetName().GetIdentifierName();

if (!secret_storage_table_exists) {
if (!secret_storage_table.specified_explicitly) {
Expand Down
6 changes: 3 additions & 3 deletions src/storage/postgres_catalog_set.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,17 @@ void PostgresCatalogSet::DropEntry(PostgresTransaction &transaction, DropInfo &i
drop_query += " IF EXISTS ";
}
if (!info.schema.empty()) {
drop_query += PostgresUtils::WriteIdentifier(info.schema) + ".";
drop_query += PostgresUtils::WriteIdentifier(info.schema.GetIdentifierName()) + ".";
}
drop_query += PostgresUtils::WriteIdentifier(info.name);
drop_query += PostgresUtils::WriteIdentifier(info.name.GetIdentifierName());
if (info.cascade) {
drop_query += "CASCADE";
}
transaction.Query(drop_query);

// erase the entry from the catalog set
lock_guard<mutex> l(entry_lock);
entries.erase(info.name);
entries.erase(info.name.GetIdentifierName());
}

void PostgresCatalogSet::Scan(ClientContext &context, PostgresTransaction &transaction,
Expand Down
6 changes: 3 additions & 3 deletions src/storage/postgres_configure_pool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ struct ConfigurePoolBindData : public TableFunctionData {
std::pair<std::string, bool> health_check_query;

static Value Lookup(const named_parameter_map_t &map, const std::string &key) {
auto it = map.find(key);
auto it = map.find(Identifier(key));
if (it == map.end()) {
return Value();
}
Expand Down Expand Up @@ -156,10 +156,10 @@ static void ConfigurePoolFunction(ClientContext &context, TableFunctionInput &in
if (catalog.GetCatalogType() != "postgres") {
continue;
}
if (!bdata.catalog_name.second && catalog.GetName() != bdata.catalog_name.first) {
if (!bdata.catalog_name.second && catalog.GetName() != Identifier(bdata.catalog_name.first)) {
continue;
}
cat_names.push_back(catalog.GetName());
cat_names.push_back(catalog.GetName().GetIdentifierName());
shared_ptr<PostgresConnectionPool> pool = catalog.Cast<PostgresCatalog>().GetConnectionPoolPtr();
pools.emplace_back(std::move(pool));
}
Expand Down
6 changes: 3 additions & 3 deletions src/storage/postgres_delete.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ PostgresDelete::PostgresDelete(PhysicalPlan &physical_plan, LogicalOperator &op,
string GetDeleteSQL(const PostgresTableEntry &table, const string &ctid_list) {
string result;
result = "DELETE FROM ";
result += PostgresUtils::WriteIdentifier(table.schema.name) + ".";
result += PostgresUtils::QuotePostgresIdentifier(table.name);
result += PostgresUtils::WriteIdentifier(table.schema.name.GetIdentifierName()) + ".";
result += PostgresUtils::QuotePostgresIdentifier(table.name.GetIdentifierName());
result += " WHERE ctid IN (" + ctid_list + ")";
return result;
}
Expand Down Expand Up @@ -115,7 +115,7 @@ string PostgresDelete::GetName() const {

InsertionOrderPreservingMap<string> PostgresDelete::ParamsToString() const {
InsertionOrderPreservingMap<string> result;
result["Table Name"] = table.name;
result["Table Name"] = table.name.GetIdentifierName();
return result;
}

Expand Down
6 changes: 3 additions & 3 deletions src/storage/postgres_index_entry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ PostgresIndexEntry::PostgresIndexEntry(Catalog &catalog, SchemaCatalogEntry &sch
: IndexCatalogEntry(catalog, schema, info), table_name(std::move(table_name_p)) {
}

string PostgresIndexEntry::GetSchemaName() const {
Identifier PostgresIndexEntry::GetSchemaName() const {
return schema.name;
}

string PostgresIndexEntry::GetTableName() const {
return table_name;
Identifier PostgresIndexEntry::GetTableName() const {
return Identifier(table_name);
}

} // namespace duckdb
13 changes: 7 additions & 6 deletions src/storage/postgres_index_set.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ void PostgresIndexSet::LoadEntries(ClientContext &context, PostgresTransaction &
auto index_name = result.GetString(row, 2);
CreateIndexInfo info;
info.schema = schema.name;
info.table = table_name;
info.index_name = index_name;
info.table = Identifier(table_name);
info.index_name = Identifier(index_name);
auto index_entry = make_shared_ptr<PostgresIndexEntry>(catalog, schema, info, table_name);
CreateEntry(transaction, std::move(index_entry));
}
Expand All @@ -65,10 +65,10 @@ string PGGetCreateIndexSQL(CreateIndexInfo &info, TableCatalogEntry &tbl) {
sql += " UNIQUE";
}
sql += " INDEX ";
sql += PostgresUtils::QuotePostgresIdentifier(info.index_name);
sql += PostgresUtils::QuotePostgresIdentifier(info.index_name.GetIdentifierName());
sql += " ON ";
sql += PostgresUtils::QuotePostgresIdentifier(tbl.schema.name) + ".";
sql += PostgresUtils::QuotePostgresIdentifier(tbl.name);
sql += PostgresUtils::QuotePostgresIdentifier(tbl.schema.name.GetIdentifierName()) + ".";
sql += PostgresUtils::QuotePostgresIdentifier(tbl.name.GetIdentifierName());
sql += "(";
for (idx_t i = 0; i < info.parsed_expressions.size(); i++) {
if (i > 0) {
Expand All @@ -84,7 +84,8 @@ string PGGetCreateIndexSQL(CreateIndexInfo &info, TableCatalogEntry &tbl) {
optional_ptr<CatalogEntry> PostgresIndexSet::CreateIndex(PostgresTransaction &transaction, CreateIndexInfo &info,
TableCatalogEntry &table) {
transaction.Query(PGGetCreateIndexSQL(info, table));
auto index_entry = make_shared_ptr<PostgresIndexEntry>(schema.ParentCatalog(), schema, info, table.name);
auto index_entry =
make_shared_ptr<PostgresIndexEntry>(schema.ParentCatalog(), schema, info, table.name.GetIdentifierName());
return CreateEntry(transaction, std::move(index_entry));
}

Expand Down
14 changes: 8 additions & 6 deletions src/storage/postgres_insert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ vector<string> GetInsertColumns(const PostgresInsert &insert, PostgresTableEntry
}
for (idx_t c = 0; c < column_count; c++) {
auto &col = columns.GetColumn(column_indexes[c]);
column_names.push_back(col.GetName());
column_names.push_back(col.GetName().GetIdentifierName());
}
}
return column_names;
Expand All @@ -95,7 +95,8 @@ unique_ptr<GlobalSinkState> PostgresInsert::GetGlobalSinkState(ClientContext &co
auto &insert_column_names = result->insert_column_names;
if (!insert_columns.empty()) {
for (auto &str : insert_columns) {
auto index = insert_table->GetColumnIndex(str, true);
Identifier col_identifier(str);
auto index = insert_table->GetColumnIndex(col_identifier, true);
if (!index.IsValid()) {
insert_column_names.push_back(str);
} else {
Expand All @@ -115,8 +116,9 @@ SinkResultType PostgresInsert::Sink(ExecutionContext &context, DataChunk &chunk,
auto &connection = transaction.GetConnection();
if (!gstate.copy_is_active) {
// copy hasn't started yet
connection.BeginCopyTo(context.client, gstate.copy_state, gstate.format, gstate.table.schema.name,
gstate.table.name, gstate.insert_column_names);
connection.BeginCopyTo(context.client, gstate.copy_state, gstate.format,
gstate.table.schema.name.GetIdentifierName(), gstate.table.name.GetIdentifierName(),
gstate.insert_column_names);
gstate.copy_is_active = true;
}
connection.CopyChunk(context.client, gstate.copy_state, chunk, gstate.varchar_chunk);
Expand Down Expand Up @@ -166,7 +168,7 @@ string PostgresInsert::GetName() const {

InsertionOrderPreservingMap<string> PostgresInsert::ParamsToString() const {
InsertionOrderPreservingMap<string> result;
result["Table Name"] = table ? table->name : info->Base().table;
result["Table Name"] = table ? table->name.GetIdentifierName() : info->Base().table.GetIdentifierName();
return result;
}

Expand Down Expand Up @@ -219,7 +221,7 @@ bool PostgresCatalog::IsPostgresScan(const string &name) {
void PostgresCatalog::MaterializePostgresScans(PhysicalOperator &op) {
if (op.type == PhysicalOperatorType::TABLE_SCAN) {
auto &table_scan = op.Cast<PhysicalTableScan>();
if (PostgresCatalog::IsPostgresScan(table_scan.function.name)) {
if (PostgresCatalog::IsPostgresScan(table_scan.function.name.GetIdentifierName())) {
auto &bind_data = table_scan.bind_data->Cast<PostgresBindData>();
bind_data.requires_materialization = true;
bind_data.max_threads = 1;
Expand Down
2 changes: 1 addition & 1 deletion src/storage/postgres_optimizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ static void GatherPostgresScans(LogicalOperator &op, PostgresOperators &result)
if (op.type == LogicalOperatorType::LOGICAL_GET) {
auto &get = op.Cast<LogicalGet>();
auto &table_scan = get.function;
if (!PostgresCatalog::IsPostgresScan(table_scan.name)) {
if (!PostgresCatalog::IsPostgresScan(table_scan.name.GetIdentifierName())) {
// not a postgres scan - skip
return;
}
Expand Down
Loading
Loading