Skip to content
Merged
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 1752 files
2 changes: 1 addition & 1 deletion extension-ci-tools
4 changes: 2 additions & 2 deletions src/include/storage/sqlite_index_entry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ class SQLiteIndexEntry : public IndexCatalogEntry {
string table_name;

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

} // namespace duckdb
6 changes: 3 additions & 3 deletions src/sqlite_db.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ void SQLiteDB::GetTableInfo(const string &table_name, ColumnList &columns, vecto
SQLiteStatement stmt;

idx_t primary_key_index = idx_t(-1);
vector<string> primary_keys;
vector<Identifier> primary_keys;

bool found = false;

Expand All @@ -191,9 +191,9 @@ void SQLiteDB::GetTableInfo(const string &table_name, ColumnList &columns, vecto

if (pk) {
primary_key_index = cid;
primary_keys.push_back(sqlite_colname);
primary_keys.emplace_back(sqlite_colname);
}
ColumnDefinition column(std::move(sqlite_colname), std::move(column_type));
ColumnDefinition column(Identifier(std::move(sqlite_colname)), std::move(column_type));
if (!default_value.empty() && default_value != "\"\"") {
auto expressions = Parser::ParseExpressionList(default_value);
if (expressions.empty()) {
Expand Down
4 changes: 2 additions & 2 deletions src/sqlite_scanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ static unique_ptr<FunctionData> SqliteBind(ClientContext &context, TableFunction
}
db.GetTableInfo(result->table_name, columns, constraints, result->all_varchar);
for (auto &column : columns.Logical()) {
names.push_back(column.GetName());
names.emplace_back(column.GetName().GetIdentifierName());
return_types.push_back(column.GetType());
}

Expand Down Expand Up @@ -427,7 +427,7 @@ static void AttachFunction(ClientContext &context, TableFunctionInput &data_p, D
auto tables = db.GetTables();
for (auto &table_name : tables) {
dconn.TableFunction("sqlite_scan", {Value(data.file_name), Value(table_name)})
->CreateView(table_name, data.overwrite, false);
->CreateView(Identifier(table_name), data.overwrite, false);
}
}
{
Expand Down
6 changes: 3 additions & 3 deletions src/storage/sqlite_delete.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ SourceResultType SQLiteDelete::GetDataInternal(ExecutionContext &context, DataCh
if (!insert_gstate.delete_done) {
if (!insert_gstate.statement.IsOpen()) {
auto &transaction = SQLiteTransaction::Get(context.client, insert_gstate.table.catalog);
insert_gstate.statement = transaction.GetDB().Prepare(GetDeleteSQL(insert_gstate.table.name));
insert_gstate.statement = transaction.GetDB().Prepare(GetDeleteSQL(insert_gstate.table.name.GetIdentifierName()));
}
for (auto row_id : insert_gstate.rowids) {
insert_gstate.statement.Bind<int64_t>(0, row_id);
Expand All @@ -94,7 +94,7 @@ string SQLiteDelete::GetName() const {

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

Expand All @@ -107,7 +107,7 @@ PhysicalOperator &SQLiteCatalog::PlanDelete(ClientContext &context, PhysicalPlan
throw BinderException("RETURNING clause not yet supported for deletion of a SQLite table");
}
auto &bound_ref = op.expressions[0]->Cast<BoundReferenceExpression>();
auto &delete_op = planner.Make<SQLiteDelete>(op, op.table, bound_ref.index);
auto &delete_op = planner.Make<SQLiteDelete>(op, op.table, bound_ref.Index());
delete_op.children.push_back(plan);
return delete_op;
}
Expand Down
6 changes: 3 additions & 3 deletions src/storage/sqlite_index_entry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ SQLiteIndexEntry::SQLiteIndexEntry(Catalog &catalog, SchemaCatalogEntry &schema,
: IndexCatalogEntry(catalog, schema, info), table_name(std::move(table_name_p)) {
}

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

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

} // namespace duckdb
6 changes: 3 additions & 3 deletions src/storage/sqlite_insert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class SQLiteInsertGlobalState : public GlobalSinkState {

string GetInsertSQL(const SQLiteInsert &insert, SQLiteTableEntry *entry) {
string result;
result = "INSERT INTO " + KeywordHelper::WriteOptionallyQuoted(entry->name);
result = "INSERT INTO " + KeywordHelper::WriteOptionallyQuoted(entry->name.GetIdentifierName());
auto &columns = entry->GetColumns();
idx_t column_count;
if (!insert.column_index_map.empty()) {
Expand All @@ -63,7 +63,7 @@ string GetInsertSQL(const SQLiteInsert &insert, SQLiteTableEntry *entry) {
result += ", ";
}
auto &col = columns.GetColumn(column_indexes[c]);
result += KeywordHelper::WriteOptionallyQuoted(col.GetName());
result += KeywordHelper::WriteOptionallyQuoted(col.GetName().GetIdentifierName());
}
result += ")";
} else {
Expand Down Expand Up @@ -136,7 +136,7 @@ string SQLiteInsert::GetName() const {

InsertionOrderPreservingMap<string> SQLiteInsert::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
2 changes: 1 addition & 1 deletion src/storage/sqlite_query.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ static unique_ptr<FunctionData> SQLiteQueryBind(ClientContext &context, TableFun
// 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 sqlite_query", db_name);
}
Expand Down
44 changes: 22 additions & 22 deletions src/storage/sqlite_schema_entry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ string GetCreateTableSQL(CreateTableInfo &info) {
if (info.on_conflict == OnCreateConflict::IGNORE_ON_CONFLICT) {
ss << "IF NOT EXISTS ";
}
ss << KeywordHelper::WriteOptionallyQuoted(info.table);
ss << KeywordHelper::WriteOptionallyQuoted(info.table.GetIdentifierName());
ss << TableCatalogEntry::ColumnsToSQL(info.columns, info.constraints);
ss << ";";
return ss.str();
Expand All @@ -46,7 +46,7 @@ string GetCreateTableSQL(CreateTableInfo &info) {
void SQLiteSchemaEntry::TryDropEntry(ClientContext &context, CatalogType catalog_type, const string &name) {
DropInfo info;
info.type = catalog_type;
info.name = name;
info.name = Identifier(name);
info.cascade = false;
info.if_not_found = OnEntryNotFound::RETURN_NULL;
DropEntry(context, info);
Expand All @@ -58,7 +58,7 @@ optional_ptr<CatalogEntry> SQLiteSchemaEntry::CreateTable(CatalogTransaction tra
auto table_name = base_info.table;
if (base_info.on_conflict == OnCreateConflict::REPLACE_ON_CONFLICT) {
// CREATE OR REPLACE - drop any existing entries first (if any)
TryDropEntry(transaction.GetContext(), CatalogType::TABLE_ENTRY, table_name);
TryDropEntry(transaction.GetContext(), CatalogType::TABLE_ENTRY, table_name.GetIdentifierName());
}

sqlite_transaction.GetDB().Execute(GetCreateTableSQL(base_info));
Expand Down Expand Up @@ -89,9 +89,9 @@ string GetCreateIndexSQL(CreateIndexInfo &info, TableCatalogEntry &tbl) {
if (info.on_conflict == OnCreateConflict::IGNORE_ON_CONFLICT) {
sql += " IF NOT EXISTS ";
}
sql += KeywordHelper::WriteOptionallyQuoted(info.index_name);
sql += KeywordHelper::WriteOptionallyQuoted(info.index_name.GetIdentifierName());
sql += " ON ";
sql += KeywordHelper::WriteOptionallyQuoted(tbl.name);
sql += KeywordHelper::WriteOptionallyQuoted(tbl.name.GetIdentifierName());
sql += "(";
for (idx_t i = 0; i < info.parsed_expressions.size(); i++) {
if (i > 0) {
Expand All @@ -117,7 +117,7 @@ string GetCreateViewSQL(CreateViewInfo &info) {
if (info.on_conflict == OnCreateConflict::IGNORE_ON_CONFLICT) {
sql += "IF NOT EXISTS ";
}
sql += KeywordHelper::WriteOptionallyQuoted(info.view_name);
sql += KeywordHelper::WriteOptionallyQuoted(info.view_name.GetIdentifierName());
sql += " ";
if (!info.aliases.empty()) {
sql += "(";
Expand All @@ -126,7 +126,7 @@ string GetCreateViewSQL(CreateViewInfo &info) {
sql += ", ";
}
auto &alias = info.aliases[i];
sql += KeywordHelper::WriteOptionallyQuoted(alias);
sql += KeywordHelper::WriteOptionallyQuoted(alias.GetIdentifierName());
}
sql += ") ";
}
Expand All @@ -142,7 +142,7 @@ optional_ptr<CatalogEntry> SQLiteSchemaEntry::CreateView(CatalogTransaction tran
}
if (info.on_conflict == OnCreateConflict::REPLACE_ON_CONFLICT) {
// CREATE OR REPLACE - drop any existing entries first (if any)
TryDropEntry(transaction.GetContext(), CatalogType::VIEW_ENTRY, info.view_name);
TryDropEntry(transaction.GetContext(), CatalogType::VIEW_ENTRY, info.view_name.GetIdentifierName());
}
auto &sqlite_transaction = GetSQLiteTransaction(transaction);
sqlite_transaction.GetDB().Execute(GetCreateViewSQL(info));
Expand Down Expand Up @@ -179,47 +179,47 @@ optional_ptr<CatalogEntry> SQLiteSchemaEntry::CreateType(CatalogTransaction tran

void SQLiteSchemaEntry::AlterTable(SQLiteTransaction &sqlite_transaction, RenameTableInfo &info) {
string sql = "ALTER TABLE ";
sql += KeywordHelper::WriteOptionallyQuoted(info.name);
sql += KeywordHelper::WriteOptionallyQuoted(info.name.GetIdentifierName());
sql += " RENAME TO ";
sql += KeywordHelper::WriteOptionallyQuoted(info.new_table_name);
sql += KeywordHelper::WriteOptionallyQuoted(info.new_table_name.GetIdentifierName());
sqlite_transaction.GetDB().Execute(sql);
}

void SQLiteSchemaEntry::AlterTable(SQLiteTransaction &sqlite_transaction, RenameColumnInfo &info) {
string sql = "ALTER TABLE ";
sql += KeywordHelper::WriteOptionallyQuoted(info.name);
sql += KeywordHelper::WriteOptionallyQuoted(info.name.GetIdentifierName());
sql += " RENAME COLUMN ";
sql += KeywordHelper::WriteOptionallyQuoted(info.old_name);
sql += KeywordHelper::WriteOptionallyQuoted(info.old_name.GetIdentifierName());
sql += " TO ";
sql += KeywordHelper::WriteOptionallyQuoted(info.new_name);
sql += KeywordHelper::WriteOptionallyQuoted(info.new_name.GetIdentifierName());
sqlite_transaction.GetDB().Execute(sql);
}

void SQLiteSchemaEntry::AlterTable(SQLiteTransaction &sqlite_transaction, AddColumnInfo &info) {
if (info.if_column_not_exists) {
if (sqlite_transaction.GetDB().ColumnExists(info.name, info.new_column.GetName())) {
if (sqlite_transaction.GetDB().ColumnExists(info.name.GetIdentifierName(), info.new_column.GetName().GetIdentifierName())) {
return;
}
}
string sql = "ALTER TABLE ";
sql += KeywordHelper::WriteOptionallyQuoted(info.name);
sql += KeywordHelper::WriteOptionallyQuoted(info.name.GetIdentifierName());
sql += " ADD COLUMN ";
sql += KeywordHelper::WriteOptionallyQuoted(info.new_column.Name());
sql += KeywordHelper::WriteOptionallyQuoted(info.new_column.Name().GetIdentifierName());
sql += " ";
sql += info.new_column.Type().ToString();
sqlite_transaction.GetDB().Execute(sql);
}

void SQLiteSchemaEntry::AlterTable(SQLiteTransaction &sqlite_transaction, RemoveColumnInfo &info) {
if (info.if_column_exists) {
if (!sqlite_transaction.GetDB().ColumnExists(info.name, info.removed_column)) {
if (!sqlite_transaction.GetDB().ColumnExists(info.name.GetIdentifierName(), info.removed_column.GetIdentifierName())) {
return;
}
}
string sql = "ALTER TABLE ";
sql += KeywordHelper::WriteOptionallyQuoted(info.name);
sql += KeywordHelper::WriteOptionallyQuoted(info.name.GetIdentifierName());
sql += " DROP COLUMN ";
sql += KeywordHelper::WriteOptionallyQuoted(info.removed_column);
sql += KeywordHelper::WriteOptionallyQuoted(info.removed_column.GetIdentifierName());
sqlite_transaction.GetDB().Execute(sql);
}

Expand Down Expand Up @@ -247,7 +247,7 @@ void SQLiteSchemaEntry::Alter(CatalogTransaction catalog_transaction, AlterInfo
"support RENAME TABLE, RENAME COLUMN, "
"ADD COLUMN and DROP COLUMN");
}
transaction.ClearTableEntry(info.name);
transaction.ClearTableEntry(info.name.GetIdentifierName());
}

void SQLiteSchemaEntry::Scan(ClientContext &context, CatalogType type,
Expand All @@ -269,7 +269,7 @@ void SQLiteSchemaEntry::Scan(ClientContext &context, CatalogType type,
return;
}
for (auto &entry_name : entries) {
callback(*GetEntry(GetCatalogTransaction(context), type, entry_name));
callback(*GetEntry(GetCatalogTransaction(context), type, Identifier(entry_name)));
}
}
void SQLiteSchemaEntry::Scan(CatalogType type, const std::function<void(CatalogEntry &)> &callback) {
Expand All @@ -294,7 +294,7 @@ void SQLiteSchemaEntry::DropEntry(ClientContext &context, DropInfo &info) {
throw InternalException("Failed to drop entry \"%s\" - could not find entry", info.name);
}
auto &transaction = SQLiteTransaction::Get(context, catalog);
transaction.DropEntry(info.type, info.name, info.cascade);
transaction.DropEntry(info.type, info.name.GetIdentifierName(), info.cascade);
}

optional_ptr<CatalogEntry> SQLiteSchemaEntry::LookupEntry(CatalogTransaction transaction,
Expand Down
10 changes: 5 additions & 5 deletions src/storage/sqlite_table_entry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,18 @@ void SQLiteTableEntry::BindUpdateConstraints(Binder &, LogicalGet &, LogicalProj
TableFunction SQLiteTableEntry::GetScanFunction(ClientContext &context, unique_ptr<FunctionData> &bind_data) {
auto result = make_uniq<SqliteBindData>();
for (auto &col : columns.Logical()) {
result->names.push_back(col.GetName());
result->names.emplace_back(col.GetName().GetIdentifierName());
result->types.push_back(col.GetType());
}
auto &sqlite_catalog = catalog.Cast<SQLiteCatalog>();
result->file_name = sqlite_catalog.path;
result->table_name = name;
result->table_name = name.GetIdentifierName();
result->all_varchar = all_varchar;

auto &transaction = Transaction::Get(context, catalog).Cast<SQLiteTransaction>();
auto &db = transaction.GetDB();

if (!db.GetRowIdInfo(name, result->row_id_info)) {
if (!db.GetRowIdInfo(name.GetIdentifierName(), result->row_id_info)) {
result->rows_per_group = optional_idx();
}

Expand Down Expand Up @@ -71,14 +71,14 @@ TableStorageInfo SQLiteTableEntry::GetStorageInfo(ClientContext &context) {
TableStorageInfo result;

RowIdInfo info;
if (!db.GetRowIdInfo(name, info)) {
if (!db.GetRowIdInfo(name.GetIdentifierName(), info)) {
// probably
result.cardinality = 10000;
} else {
result.cardinality = info.max_rowid.GetIndex() - info.min_rowid.GetIndex();
}

result.index_info = db.GetIndexInfo(name);
result.index_info = db.GetIndexInfo(name.GetIdentifierName());
return result;
}

Expand Down
6 changes: 3 additions & 3 deletions src/storage/sqlite_transaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ void ExtractColumnIds(const ParsedExpression &expr, TableCatalogEntry &table, Cr
if (expr.GetExpressionType() == ExpressionType::COLUMN_REF) {
auto &colref = expr.Cast<ColumnRefExpression>();
auto &colname = colref.GetColumnName();
auto &column_def = table.GetColumn(colname);
auto &column_def = table.GetColumn(Identifier(colname));
auto index = column_def.Oid();
if (std::find(info.column_ids.begin(), info.column_ids.end(), index) == info.column_ids.end()) {
info.column_ids.push_back(index);
Expand Down Expand Up @@ -156,7 +156,7 @@ optional_ptr<CatalogEntry> SQLiteTransaction::GetCatalogEntry(const string &entr
unique_ptr<CatalogEntry> result;
switch (type) {
case CatalogType::TABLE_ENTRY: {
CreateTableInfo info(sqlite_catalog.GetMainSchema(), entry_name);
CreateTableInfo info(sqlite_catalog.GetMainSchema(), Identifier(entry_name));
bool all_varchar = false;
Value sqlite_all_varchar;
if (context.lock()->TryGetCurrentSetting("sqlite_all_varchar", sqlite_all_varchar)) {
Expand All @@ -177,7 +177,7 @@ optional_ptr<CatalogEntry> SQLiteTransaction::GetCatalogEntry(const string &entr
view_info = CreateViewInfo::FromCreateView(*context.lock(), sqlite_catalog.GetMainSchema(), sql);
} catch (std::exception &ex) {
auto view_sql = ExtractSelectStatement(sql);
auto catalog_name = StringUtil::Replace(sqlite_catalog.GetName(), "\"", "\"\"");
auto catalog_name = StringUtil::Replace(sqlite_catalog.GetName().GetIdentifierName(), "\"", "\"\"");
auto escaped_view_sql = StringUtil::Replace(view_sql, "'", "''");
auto view_def = StringUtil::Format("CREATE VIEW %s AS FROM sqlite_query(\"%s\", '%s')", entry_name,
catalog_name, escaped_view_sql);
Expand Down
6 changes: 3 additions & 3 deletions src/storage/sqlite_update.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ class SQLiteUpdateGlobalState : public GlobalSinkState {

string GetUpdateSQL(SQLiteTableEntry &table, const vector<PhysicalIndex> &index) {
string result;
result = "UPDATE " + KeywordHelper::WriteOptionallyQuoted(table.name);
result = "UPDATE " + KeywordHelper::WriteOptionallyQuoted(table.name.GetIdentifierName());
result += " SET ";
for (idx_t i = 0; i < index.size(); i++) {
if (i > 0) {
result += ", ";
}
auto &col = table.GetColumn(LogicalIndex(index[i].index));
result += KeywordHelper::WriteOptionallyQuoted(col.GetName());
result += KeywordHelper::WriteOptionallyQuoted(col.GetName().GetIdentifierName());
result += " = ?";
}
result += " WHERE rowid = ?";
Expand Down Expand Up @@ -99,7 +99,7 @@ string SQLiteUpdate::GetName() const {

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

Expand Down