mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 12:07:45 +00:00
AK+Everywhere: Rename String to DeprecatedString
We have a new, improved string type coming up in AK (OOM aware, no null state), and while it's going to use UTF-8, the name UTF8String is a mouthful - so let's free up the String name by renaming the existing class. Making the old one have an annoying name will hopefully also help with quick adoption :^)
This commit is contained in:
parent
f74251606d
commit
6e19ab2bbc
2006 changed files with 11635 additions and 11636 deletions
|
@ -8,11 +8,11 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/NonnullRefPtr.h>
|
||||
#include <AK/NonnullRefPtrVector.h>
|
||||
#include <AK/RefCounted.h>
|
||||
#include <AK/RefPtr.h>
|
||||
#include <AK/String.h>
|
||||
#include <LibSQL/AST/Token.h>
|
||||
#include <LibSQL/Forward.h>
|
||||
#include <LibSQL/Result.h>
|
||||
|
@ -55,53 +55,53 @@ private:
|
|||
|
||||
class TypeName : public ASTNode {
|
||||
public:
|
||||
TypeName(String name, NonnullRefPtrVector<SignedNumber> signed_numbers)
|
||||
TypeName(DeprecatedString name, NonnullRefPtrVector<SignedNumber> signed_numbers)
|
||||
: m_name(move(name))
|
||||
, m_signed_numbers(move(signed_numbers))
|
||||
{
|
||||
VERIFY(m_signed_numbers.size() <= 2);
|
||||
}
|
||||
|
||||
String const& name() const { return m_name; }
|
||||
DeprecatedString const& name() const { return m_name; }
|
||||
NonnullRefPtrVector<SignedNumber> const& signed_numbers() const { return m_signed_numbers; }
|
||||
|
||||
private:
|
||||
String m_name;
|
||||
DeprecatedString m_name;
|
||||
NonnullRefPtrVector<SignedNumber> m_signed_numbers;
|
||||
};
|
||||
|
||||
class ColumnDefinition : public ASTNode {
|
||||
public:
|
||||
ColumnDefinition(String name, NonnullRefPtr<TypeName> type_name)
|
||||
ColumnDefinition(DeprecatedString name, NonnullRefPtr<TypeName> type_name)
|
||||
: m_name(move(name))
|
||||
, m_type_name(move(type_name))
|
||||
{
|
||||
}
|
||||
|
||||
String const& name() const { return m_name; }
|
||||
DeprecatedString const& name() const { return m_name; }
|
||||
NonnullRefPtr<TypeName> const& type_name() const { return m_type_name; }
|
||||
|
||||
private:
|
||||
String m_name;
|
||||
DeprecatedString m_name;
|
||||
NonnullRefPtr<TypeName> m_type_name;
|
||||
};
|
||||
|
||||
class CommonTableExpression : public ASTNode {
|
||||
public:
|
||||
CommonTableExpression(String table_name, Vector<String> column_names, NonnullRefPtr<Select> select_statement)
|
||||
CommonTableExpression(DeprecatedString table_name, Vector<DeprecatedString> column_names, NonnullRefPtr<Select> select_statement)
|
||||
: m_table_name(move(table_name))
|
||||
, m_column_names(move(column_names))
|
||||
, m_select_statement(move(select_statement))
|
||||
{
|
||||
}
|
||||
|
||||
String const& table_name() const { return m_table_name; }
|
||||
Vector<String> const& column_names() const { return m_column_names; }
|
||||
DeprecatedString const& table_name() const { return m_table_name; }
|
||||
Vector<DeprecatedString> const& column_names() const { return m_column_names; }
|
||||
NonnullRefPtr<Select> const& select_statement() const { return m_select_statement; }
|
||||
|
||||
private:
|
||||
String m_table_name;
|
||||
Vector<String> m_column_names;
|
||||
DeprecatedString m_table_name;
|
||||
Vector<DeprecatedString> m_column_names;
|
||||
NonnullRefPtr<Select> m_select_statement;
|
||||
};
|
||||
|
||||
|
@ -124,28 +124,28 @@ private:
|
|||
|
||||
class QualifiedTableName : public ASTNode {
|
||||
public:
|
||||
QualifiedTableName(String schema_name, String table_name, String alias)
|
||||
QualifiedTableName(DeprecatedString schema_name, DeprecatedString table_name, DeprecatedString alias)
|
||||
: m_schema_name(move(schema_name))
|
||||
, m_table_name(move(table_name))
|
||||
, m_alias(move(alias))
|
||||
{
|
||||
}
|
||||
|
||||
String const& schema_name() const { return m_schema_name; }
|
||||
String const& table_name() const { return m_table_name; }
|
||||
String const& alias() const { return m_alias; }
|
||||
DeprecatedString const& schema_name() const { return m_schema_name; }
|
||||
DeprecatedString const& table_name() const { return m_table_name; }
|
||||
DeprecatedString const& alias() const { return m_alias; }
|
||||
|
||||
private:
|
||||
String m_schema_name;
|
||||
String m_table_name;
|
||||
String m_alias;
|
||||
DeprecatedString m_schema_name;
|
||||
DeprecatedString m_table_name;
|
||||
DeprecatedString m_alias;
|
||||
};
|
||||
|
||||
class ReturningClause : public ASTNode {
|
||||
public:
|
||||
struct ColumnClause {
|
||||
NonnullRefPtr<Expression> expression;
|
||||
String column_alias;
|
||||
DeprecatedString column_alias;
|
||||
};
|
||||
|
||||
ReturningClause() = default;
|
||||
|
@ -172,13 +172,13 @@ class ResultColumn : public ASTNode {
|
|||
public:
|
||||
ResultColumn() = default;
|
||||
|
||||
explicit ResultColumn(String table_name)
|
||||
explicit ResultColumn(DeprecatedString table_name)
|
||||
: m_type(ResultType::Table)
|
||||
, m_table_name(move(table_name))
|
||||
{
|
||||
}
|
||||
|
||||
ResultColumn(NonnullRefPtr<Expression> expression, String column_alias)
|
||||
ResultColumn(NonnullRefPtr<Expression> expression, DeprecatedString column_alias)
|
||||
: m_type(ResultType::Expression)
|
||||
, m_expression(move(expression))
|
||||
, m_column_alias(move(column_alias))
|
||||
|
@ -188,19 +188,19 @@ public:
|
|||
ResultType type() const { return m_type; }
|
||||
|
||||
bool select_from_table() const { return !m_table_name.is_null(); }
|
||||
String const& table_name() const { return m_table_name; }
|
||||
DeprecatedString const& table_name() const { return m_table_name; }
|
||||
|
||||
bool select_from_expression() const { return !m_expression.is_null(); }
|
||||
RefPtr<Expression> const& expression() const { return m_expression; }
|
||||
String const& column_alias() const { return m_column_alias; }
|
||||
DeprecatedString const& column_alias() const { return m_column_alias; }
|
||||
|
||||
private:
|
||||
ResultType m_type { ResultType::All };
|
||||
|
||||
String m_table_name {};
|
||||
DeprecatedString m_table_name {};
|
||||
|
||||
RefPtr<Expression> m_expression {};
|
||||
String m_column_alias {};
|
||||
DeprecatedString m_column_alias {};
|
||||
};
|
||||
|
||||
class GroupByClause : public ASTNode {
|
||||
|
@ -224,7 +224,7 @@ class TableOrSubquery : public ASTNode {
|
|||
public:
|
||||
TableOrSubquery() = default;
|
||||
|
||||
TableOrSubquery(String schema_name, String table_name, String table_alias)
|
||||
TableOrSubquery(DeprecatedString schema_name, DeprecatedString table_name, DeprecatedString table_alias)
|
||||
: m_is_table(true)
|
||||
, m_schema_name(move(schema_name))
|
||||
, m_table_name(move(table_name))
|
||||
|
@ -239,18 +239,18 @@ public:
|
|||
}
|
||||
|
||||
bool is_table() const { return m_is_table; }
|
||||
String const& schema_name() const { return m_schema_name; }
|
||||
String const& table_name() const { return m_table_name; }
|
||||
String const& table_alias() const { return m_table_alias; }
|
||||
DeprecatedString const& schema_name() const { return m_schema_name; }
|
||||
DeprecatedString const& table_name() const { return m_table_name; }
|
||||
DeprecatedString const& table_alias() const { return m_table_alias; }
|
||||
|
||||
bool is_subquery() const { return m_is_subquery; }
|
||||
NonnullRefPtrVector<TableOrSubquery> const& subqueries() const { return m_subqueries; }
|
||||
|
||||
private:
|
||||
bool m_is_table { false };
|
||||
String m_schema_name {};
|
||||
String m_table_name {};
|
||||
String m_table_alias {};
|
||||
DeprecatedString m_schema_name {};
|
||||
DeprecatedString m_table_name {};
|
||||
DeprecatedString m_table_alias {};
|
||||
|
||||
bool m_is_subquery { false };
|
||||
NonnullRefPtrVector<TableOrSubquery> m_subqueries {};
|
||||
|
@ -258,7 +258,7 @@ private:
|
|||
|
||||
class OrderingTerm : public ASTNode {
|
||||
public:
|
||||
OrderingTerm(NonnullRefPtr<Expression> expression, String collation_name, Order order, Nulls nulls)
|
||||
OrderingTerm(NonnullRefPtr<Expression> expression, DeprecatedString collation_name, Order order, Nulls nulls)
|
||||
: m_expression(move(expression))
|
||||
, m_collation_name(move(collation_name))
|
||||
, m_order(order)
|
||||
|
@ -267,13 +267,13 @@ public:
|
|||
}
|
||||
|
||||
NonnullRefPtr<Expression> const& expression() const { return m_expression; }
|
||||
String const& collation_name() const { return m_collation_name; }
|
||||
DeprecatedString const& collation_name() const { return m_collation_name; }
|
||||
Order order() const { return m_order; }
|
||||
Nulls nulls() const { return m_nulls; }
|
||||
|
||||
private:
|
||||
NonnullRefPtr<Expression> m_expression;
|
||||
String m_collation_name;
|
||||
DeprecatedString m_collation_name;
|
||||
Order m_order;
|
||||
Nulls m_nulls;
|
||||
};
|
||||
|
@ -331,29 +331,29 @@ private:
|
|||
|
||||
class StringLiteral : public Expression {
|
||||
public:
|
||||
explicit StringLiteral(String value)
|
||||
explicit StringLiteral(DeprecatedString value)
|
||||
: m_value(move(value))
|
||||
{
|
||||
}
|
||||
|
||||
String const& value() const { return m_value; }
|
||||
DeprecatedString const& value() const { return m_value; }
|
||||
virtual ResultOr<Value> evaluate(ExecutionContext&) const override;
|
||||
|
||||
private:
|
||||
String m_value;
|
||||
DeprecatedString m_value;
|
||||
};
|
||||
|
||||
class BlobLiteral : public Expression {
|
||||
public:
|
||||
explicit BlobLiteral(String value)
|
||||
explicit BlobLiteral(DeprecatedString value)
|
||||
: m_value(move(value))
|
||||
{
|
||||
}
|
||||
|
||||
String const& value() const { return m_value; }
|
||||
DeprecatedString const& value() const { return m_value; }
|
||||
|
||||
private:
|
||||
String m_value;
|
||||
DeprecatedString m_value;
|
||||
};
|
||||
|
||||
class NullLiteral : public Expression {
|
||||
|
@ -425,22 +425,22 @@ private:
|
|||
|
||||
class ColumnNameExpression : public Expression {
|
||||
public:
|
||||
ColumnNameExpression(String schema_name, String table_name, String column_name)
|
||||
ColumnNameExpression(DeprecatedString schema_name, DeprecatedString table_name, DeprecatedString column_name)
|
||||
: m_schema_name(move(schema_name))
|
||||
, m_table_name(move(table_name))
|
||||
, m_column_name(move(column_name))
|
||||
{
|
||||
}
|
||||
|
||||
String const& schema_name() const { return m_schema_name; }
|
||||
String const& table_name() const { return m_table_name; }
|
||||
String const& column_name() const { return m_column_name; }
|
||||
DeprecatedString const& schema_name() const { return m_schema_name; }
|
||||
DeprecatedString const& table_name() const { return m_table_name; }
|
||||
DeprecatedString const& column_name() const { return m_column_name; }
|
||||
virtual ResultOr<Value> evaluate(ExecutionContext&) const override;
|
||||
|
||||
private:
|
||||
String m_schema_name;
|
||||
String m_table_name;
|
||||
String m_column_name;
|
||||
DeprecatedString m_schema_name;
|
||||
DeprecatedString m_table_name;
|
||||
DeprecatedString m_column_name;
|
||||
};
|
||||
|
||||
#define __enum_UnaryOperator(S) \
|
||||
|
@ -611,16 +611,16 @@ private:
|
|||
|
||||
class CollateExpression : public NestedExpression {
|
||||
public:
|
||||
CollateExpression(NonnullRefPtr<Expression> expression, String collation_name)
|
||||
CollateExpression(NonnullRefPtr<Expression> expression, DeprecatedString collation_name)
|
||||
: NestedExpression(move(expression))
|
||||
, m_collation_name(move(collation_name))
|
||||
{
|
||||
}
|
||||
|
||||
String const& collation_name() const { return m_collation_name; }
|
||||
DeprecatedString const& collation_name() const { return m_collation_name; }
|
||||
|
||||
private:
|
||||
String m_collation_name;
|
||||
DeprecatedString m_collation_name;
|
||||
};
|
||||
|
||||
enum class MatchOperator {
|
||||
|
@ -708,19 +708,19 @@ private:
|
|||
|
||||
class InTableExpression : public InvertibleNestedExpression {
|
||||
public:
|
||||
InTableExpression(NonnullRefPtr<Expression> expression, String schema_name, String table_name, bool invert_expression)
|
||||
InTableExpression(NonnullRefPtr<Expression> expression, DeprecatedString schema_name, DeprecatedString table_name, bool invert_expression)
|
||||
: InvertibleNestedExpression(move(expression), invert_expression)
|
||||
, m_schema_name(move(schema_name))
|
||||
, m_table_name(move(table_name))
|
||||
{
|
||||
}
|
||||
|
||||
String const& schema_name() const { return m_schema_name; }
|
||||
String const& table_name() const { return m_table_name; }
|
||||
DeprecatedString const& schema_name() const { return m_schema_name; }
|
||||
DeprecatedString const& table_name() const { return m_table_name; }
|
||||
|
||||
private:
|
||||
String m_schema_name;
|
||||
String m_table_name;
|
||||
DeprecatedString m_schema_name;
|
||||
DeprecatedString m_table_name;
|
||||
};
|
||||
|
||||
//==================================================================================================
|
||||
|
@ -742,25 +742,25 @@ class ErrorStatement final : public Statement {
|
|||
|
||||
class CreateSchema : public Statement {
|
||||
public:
|
||||
CreateSchema(String schema_name, bool is_error_if_schema_exists)
|
||||
CreateSchema(DeprecatedString schema_name, bool is_error_if_schema_exists)
|
||||
: m_schema_name(move(schema_name))
|
||||
, m_is_error_if_schema_exists(is_error_if_schema_exists)
|
||||
{
|
||||
}
|
||||
|
||||
String const& schema_name() const { return m_schema_name; }
|
||||
DeprecatedString const& schema_name() const { return m_schema_name; }
|
||||
bool is_error_if_schema_exists() const { return m_is_error_if_schema_exists; }
|
||||
|
||||
ResultOr<ResultSet> execute(ExecutionContext&) const override;
|
||||
|
||||
private:
|
||||
String m_schema_name;
|
||||
DeprecatedString m_schema_name;
|
||||
bool m_is_error_if_schema_exists;
|
||||
};
|
||||
|
||||
class CreateTable : public Statement {
|
||||
public:
|
||||
CreateTable(String schema_name, String table_name, RefPtr<Select> select_statement, bool is_temporary, bool is_error_if_table_exists)
|
||||
CreateTable(DeprecatedString schema_name, DeprecatedString table_name, RefPtr<Select> select_statement, bool is_temporary, bool is_error_if_table_exists)
|
||||
: m_schema_name(move(schema_name))
|
||||
, m_table_name(move(table_name))
|
||||
, m_select_statement(move(select_statement))
|
||||
|
@ -769,7 +769,7 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
CreateTable(String schema_name, String table_name, NonnullRefPtrVector<ColumnDefinition> columns, bool is_temporary, bool is_error_if_table_exists)
|
||||
CreateTable(DeprecatedString schema_name, DeprecatedString table_name, NonnullRefPtrVector<ColumnDefinition> columns, bool is_temporary, bool is_error_if_table_exists)
|
||||
: m_schema_name(move(schema_name))
|
||||
, m_table_name(move(table_name))
|
||||
, m_columns(move(columns))
|
||||
|
@ -778,8 +778,8 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
String const& schema_name() const { return m_schema_name; }
|
||||
String const& table_name() const { return m_table_name; }
|
||||
DeprecatedString const& schema_name() const { return m_schema_name; }
|
||||
DeprecatedString const& table_name() const { return m_table_name; }
|
||||
|
||||
bool has_selection() const { return !m_select_statement.is_null(); }
|
||||
RefPtr<Select> const& select_statement() const { return m_select_statement; }
|
||||
|
@ -793,8 +793,8 @@ public:
|
|||
ResultOr<ResultSet> execute(ExecutionContext&) const override;
|
||||
|
||||
private:
|
||||
String m_schema_name;
|
||||
String m_table_name;
|
||||
DeprecatedString m_schema_name;
|
||||
DeprecatedString m_table_name;
|
||||
RefPtr<Select> m_select_statement;
|
||||
NonnullRefPtrVector<ColumnDefinition> m_columns;
|
||||
bool m_is_temporary;
|
||||
|
@ -803,55 +803,55 @@ private:
|
|||
|
||||
class AlterTable : public Statement {
|
||||
public:
|
||||
String const& schema_name() const { return m_schema_name; }
|
||||
String const& table_name() const { return m_table_name; }
|
||||
DeprecatedString const& schema_name() const { return m_schema_name; }
|
||||
DeprecatedString const& table_name() const { return m_table_name; }
|
||||
|
||||
protected:
|
||||
AlterTable(String schema_name, String table_name)
|
||||
AlterTable(DeprecatedString schema_name, DeprecatedString table_name)
|
||||
: m_schema_name(move(schema_name))
|
||||
, m_table_name(move(table_name))
|
||||
{
|
||||
}
|
||||
|
||||
private:
|
||||
String m_schema_name;
|
||||
String m_table_name;
|
||||
DeprecatedString m_schema_name;
|
||||
DeprecatedString m_table_name;
|
||||
};
|
||||
|
||||
class RenameTable : public AlterTable {
|
||||
public:
|
||||
RenameTable(String schema_name, String table_name, String new_table_name)
|
||||
RenameTable(DeprecatedString schema_name, DeprecatedString table_name, DeprecatedString new_table_name)
|
||||
: AlterTable(move(schema_name), move(table_name))
|
||||
, m_new_table_name(move(new_table_name))
|
||||
{
|
||||
}
|
||||
|
||||
String const& new_table_name() const { return m_new_table_name; }
|
||||
DeprecatedString const& new_table_name() const { return m_new_table_name; }
|
||||
|
||||
private:
|
||||
String m_new_table_name;
|
||||
DeprecatedString m_new_table_name;
|
||||
};
|
||||
|
||||
class RenameColumn : public AlterTable {
|
||||
public:
|
||||
RenameColumn(String schema_name, String table_name, String column_name, String new_column_name)
|
||||
RenameColumn(DeprecatedString schema_name, DeprecatedString table_name, DeprecatedString column_name, DeprecatedString new_column_name)
|
||||
: AlterTable(move(schema_name), move(table_name))
|
||||
, m_column_name(move(column_name))
|
||||
, m_new_column_name(move(new_column_name))
|
||||
{
|
||||
}
|
||||
|
||||
String const& column_name() const { return m_column_name; }
|
||||
String const& new_column_name() const { return m_new_column_name; }
|
||||
DeprecatedString const& column_name() const { return m_column_name; }
|
||||
DeprecatedString const& new_column_name() const { return m_new_column_name; }
|
||||
|
||||
private:
|
||||
String m_column_name;
|
||||
String m_new_column_name;
|
||||
DeprecatedString m_column_name;
|
||||
DeprecatedString m_new_column_name;
|
||||
};
|
||||
|
||||
class AddColumn : public AlterTable {
|
||||
public:
|
||||
AddColumn(String schema_name, String table_name, NonnullRefPtr<ColumnDefinition> column)
|
||||
AddColumn(DeprecatedString schema_name, DeprecatedString table_name, NonnullRefPtr<ColumnDefinition> column)
|
||||
: AlterTable(move(schema_name), move(table_name))
|
||||
, m_column(move(column))
|
||||
{
|
||||
|
@ -865,34 +865,34 @@ private:
|
|||
|
||||
class DropColumn : public AlterTable {
|
||||
public:
|
||||
DropColumn(String schema_name, String table_name, String column_name)
|
||||
DropColumn(DeprecatedString schema_name, DeprecatedString table_name, DeprecatedString column_name)
|
||||
: AlterTable(move(schema_name), move(table_name))
|
||||
, m_column_name(move(column_name))
|
||||
{
|
||||
}
|
||||
|
||||
String const& column_name() const { return m_column_name; }
|
||||
DeprecatedString const& column_name() const { return m_column_name; }
|
||||
|
||||
private:
|
||||
String m_column_name;
|
||||
DeprecatedString m_column_name;
|
||||
};
|
||||
|
||||
class DropTable : public Statement {
|
||||
public:
|
||||
DropTable(String schema_name, String table_name, bool is_error_if_table_does_not_exist)
|
||||
DropTable(DeprecatedString schema_name, DeprecatedString table_name, bool is_error_if_table_does_not_exist)
|
||||
: m_schema_name(move(schema_name))
|
||||
, m_table_name(move(table_name))
|
||||
, m_is_error_if_table_does_not_exist(is_error_if_table_does_not_exist)
|
||||
{
|
||||
}
|
||||
|
||||
String const& schema_name() const { return m_schema_name; }
|
||||
String const& table_name() const { return m_table_name; }
|
||||
DeprecatedString const& schema_name() const { return m_schema_name; }
|
||||
DeprecatedString const& table_name() const { return m_table_name; }
|
||||
bool is_error_if_table_does_not_exist() const { return m_is_error_if_table_does_not_exist; }
|
||||
|
||||
private:
|
||||
String m_schema_name;
|
||||
String m_table_name;
|
||||
DeprecatedString m_schema_name;
|
||||
DeprecatedString m_table_name;
|
||||
bool m_is_error_if_table_does_not_exist;
|
||||
};
|
||||
|
||||
|
@ -906,7 +906,7 @@ enum class ConflictResolution {
|
|||
|
||||
class Insert : public Statement {
|
||||
public:
|
||||
Insert(RefPtr<CommonTableExpressionList> common_table_expression_list, ConflictResolution conflict_resolution, String schema_name, String table_name, String alias, Vector<String> column_names, NonnullRefPtrVector<ChainedExpression> chained_expressions)
|
||||
Insert(RefPtr<CommonTableExpressionList> common_table_expression_list, ConflictResolution conflict_resolution, DeprecatedString schema_name, DeprecatedString table_name, DeprecatedString alias, Vector<DeprecatedString> column_names, NonnullRefPtrVector<ChainedExpression> chained_expressions)
|
||||
: m_common_table_expression_list(move(common_table_expression_list))
|
||||
, m_conflict_resolution(conflict_resolution)
|
||||
, m_schema_name(move(schema_name))
|
||||
|
@ -917,7 +917,7 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
Insert(RefPtr<CommonTableExpressionList> common_table_expression_list, ConflictResolution conflict_resolution, String schema_name, String table_name, String alias, Vector<String> column_names, RefPtr<Select> select_statement)
|
||||
Insert(RefPtr<CommonTableExpressionList> common_table_expression_list, ConflictResolution conflict_resolution, DeprecatedString schema_name, DeprecatedString table_name, DeprecatedString alias, Vector<DeprecatedString> column_names, RefPtr<Select> select_statement)
|
||||
: m_common_table_expression_list(move(common_table_expression_list))
|
||||
, m_conflict_resolution(conflict_resolution)
|
||||
, m_schema_name(move(schema_name))
|
||||
|
@ -928,7 +928,7 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
Insert(RefPtr<CommonTableExpressionList> common_table_expression_list, ConflictResolution conflict_resolution, String schema_name, String table_name, String alias, Vector<String> column_names)
|
||||
Insert(RefPtr<CommonTableExpressionList> common_table_expression_list, ConflictResolution conflict_resolution, DeprecatedString schema_name, DeprecatedString table_name, DeprecatedString alias, Vector<DeprecatedString> column_names)
|
||||
: m_common_table_expression_list(move(common_table_expression_list))
|
||||
, m_conflict_resolution(conflict_resolution)
|
||||
, m_schema_name(move(schema_name))
|
||||
|
@ -940,10 +940,10 @@ public:
|
|||
|
||||
RefPtr<CommonTableExpressionList> const& common_table_expression_list() const { return m_common_table_expression_list; }
|
||||
ConflictResolution conflict_resolution() const { return m_conflict_resolution; }
|
||||
String const& schema_name() const { return m_schema_name; }
|
||||
String const& table_name() const { return m_table_name; }
|
||||
String const& alias() const { return m_alias; }
|
||||
Vector<String> const& column_names() const { return m_column_names; }
|
||||
DeprecatedString const& schema_name() const { return m_schema_name; }
|
||||
DeprecatedString const& table_name() const { return m_table_name; }
|
||||
DeprecatedString const& alias() const { return m_alias; }
|
||||
Vector<DeprecatedString> const& column_names() const { return m_column_names; }
|
||||
|
||||
bool default_values() const { return !has_expressions() && !has_selection(); };
|
||||
|
||||
|
@ -958,10 +958,10 @@ public:
|
|||
private:
|
||||
RefPtr<CommonTableExpressionList> m_common_table_expression_list;
|
||||
ConflictResolution m_conflict_resolution;
|
||||
String m_schema_name;
|
||||
String m_table_name;
|
||||
String m_alias;
|
||||
Vector<String> m_column_names;
|
||||
DeprecatedString m_schema_name;
|
||||
DeprecatedString m_table_name;
|
||||
DeprecatedString m_alias;
|
||||
Vector<DeprecatedString> m_column_names;
|
||||
NonnullRefPtrVector<ChainedExpression> m_chained_expressions;
|
||||
RefPtr<Select> m_select_statement;
|
||||
};
|
||||
|
@ -969,7 +969,7 @@ private:
|
|||
class Update : public Statement {
|
||||
public:
|
||||
struct UpdateColumns {
|
||||
Vector<String> column_names;
|
||||
Vector<DeprecatedString> column_names;
|
||||
NonnullRefPtr<Expression> expression;
|
||||
};
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ ResultOr<ResultSet> Insert::execute(ExecutionContext& context) const
|
|||
auto values = row_value.to_vector().release_value();
|
||||
|
||||
if (m_column_names.is_empty() && values.size() != row.size())
|
||||
return Result { SQLCommand::Insert, SQLErrorCode::InvalidNumberOfValues, String::empty() };
|
||||
return Result { SQLCommand::Insert, SQLErrorCode::InvalidNumberOfValues, DeprecatedString::empty() };
|
||||
|
||||
for (auto ix = 0u; ix < values.size(); ix++) {
|
||||
auto input_value_type = values[ix].type();
|
||||
|
|
|
@ -11,9 +11,9 @@
|
|||
|
||||
namespace SQL::AST {
|
||||
|
||||
HashMap<String, TokenType> Lexer::s_keywords;
|
||||
HashMap<DeprecatedString, TokenType> Lexer::s_keywords;
|
||||
HashMap<char, TokenType> Lexer::s_one_char_tokens;
|
||||
HashMap<String, TokenType> Lexer::s_two_char_tokens;
|
||||
HashMap<DeprecatedString, TokenType> Lexer::s_two_char_tokens;
|
||||
|
||||
Lexer::Lexer(StringView source)
|
||||
: m_source(source)
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
#pragma once
|
||||
|
||||
#include "Token.h"
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/HashMap.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/StringView.h>
|
||||
|
||||
namespace SQL::AST {
|
||||
|
@ -46,9 +46,9 @@ private:
|
|||
bool is_line_break() const;
|
||||
bool is_eof() const;
|
||||
|
||||
static HashMap<String, TokenType> s_keywords;
|
||||
static HashMap<DeprecatedString, TokenType> s_keywords;
|
||||
static HashMap<char, TokenType> s_one_char_tokens;
|
||||
static HashMap<String, TokenType> s_two_char_tokens;
|
||||
static HashMap<DeprecatedString, TokenType> s_two_char_tokens;
|
||||
|
||||
StringView m_source;
|
||||
size_t m_line_number { 1 };
|
||||
|
|
|
@ -91,7 +91,7 @@ NonnullRefPtr<CreateSchema> Parser::parse_create_schema_statement()
|
|||
is_error_if_exists = false;
|
||||
}
|
||||
|
||||
String schema_name = consume(TokenType::Identifier).value();
|
||||
DeprecatedString schema_name = consume(TokenType::Identifier).value();
|
||||
return create_ast_node<CreateSchema>(move(schema_name), is_error_if_exists);
|
||||
}
|
||||
|
||||
|
@ -112,8 +112,8 @@ NonnullRefPtr<CreateTable> Parser::parse_create_table_statement()
|
|||
is_error_if_table_exists = false;
|
||||
}
|
||||
|
||||
String schema_name;
|
||||
String table_name;
|
||||
DeprecatedString schema_name;
|
||||
DeprecatedString table_name;
|
||||
parse_schema_and_table_name(schema_name, table_name);
|
||||
|
||||
if (consume_if(TokenType::As)) {
|
||||
|
@ -135,8 +135,8 @@ NonnullRefPtr<AlterTable> Parser::parse_alter_table_statement()
|
|||
consume(TokenType::Alter);
|
||||
consume(TokenType::Table);
|
||||
|
||||
String schema_name;
|
||||
String table_name;
|
||||
DeprecatedString schema_name;
|
||||
DeprecatedString table_name;
|
||||
parse_schema_and_table_name(schema_name, table_name);
|
||||
|
||||
if (consume_if(TokenType::Add)) {
|
||||
|
@ -177,8 +177,8 @@ NonnullRefPtr<DropTable> Parser::parse_drop_table_statement()
|
|||
is_error_if_table_does_not_exist = false;
|
||||
}
|
||||
|
||||
String schema_name;
|
||||
String table_name;
|
||||
DeprecatedString schema_name;
|
||||
DeprecatedString table_name;
|
||||
parse_schema_and_table_name(schema_name, table_name);
|
||||
|
||||
return create_ast_node<DropTable>(move(schema_name), move(table_name), is_error_if_table_does_not_exist);
|
||||
|
@ -201,15 +201,15 @@ NonnullRefPtr<Insert> Parser::parse_insert_statement(RefPtr<CommonTableExpressio
|
|||
auto conflict_resolution = parse_conflict_resolution();
|
||||
consume(TokenType::Into);
|
||||
|
||||
String schema_name;
|
||||
String table_name;
|
||||
DeprecatedString schema_name;
|
||||
DeprecatedString table_name;
|
||||
parse_schema_and_table_name(schema_name, table_name);
|
||||
|
||||
String alias;
|
||||
DeprecatedString alias;
|
||||
if (consume_if(TokenType::As))
|
||||
alias = consume(TokenType::Identifier).value();
|
||||
|
||||
Vector<String> column_names;
|
||||
Vector<DeprecatedString> column_names;
|
||||
if (match(TokenType::ParenOpen))
|
||||
parse_comma_separated_list(true, [&]() { column_names.append(consume(TokenType::Identifier).value()); });
|
||||
|
||||
|
@ -260,7 +260,7 @@ NonnullRefPtr<Update> Parser::parse_update_statement(RefPtr<CommonTableExpressio
|
|||
|
||||
Vector<Update::UpdateColumns> update_columns;
|
||||
parse_comma_separated_list(false, [&]() {
|
||||
Vector<String> column_names;
|
||||
Vector<DeprecatedString> column_names;
|
||||
if (match(TokenType::ParenOpen)) {
|
||||
parse_comma_separated_list(true, [&]() { column_names.append(consume(TokenType::Identifier).value()); });
|
||||
} else {
|
||||
|
@ -391,7 +391,7 @@ RefPtr<CommonTableExpressionList> Parser::parse_common_table_expression_list()
|
|||
NonnullRefPtr<Expression> Parser::parse_expression()
|
||||
{
|
||||
if (++m_parser_state.m_current_expression_depth > Limits::maximum_expression_tree_depth) {
|
||||
syntax_error(String::formatted("Exceeded maximum expression tree depth of {}", Limits::maximum_expression_tree_depth));
|
||||
syntax_error(DeprecatedString::formatted("Exceeded maximum expression tree depth of {}", Limits::maximum_expression_tree_depth));
|
||||
return create_ast_node<ErrorExpression>();
|
||||
}
|
||||
|
||||
|
@ -528,23 +528,23 @@ RefPtr<Expression> Parser::parse_literal_value_expression()
|
|||
return {};
|
||||
}
|
||||
|
||||
RefPtr<Expression> Parser::parse_column_name_expression(String with_parsed_identifier, bool with_parsed_period)
|
||||
RefPtr<Expression> Parser::parse_column_name_expression(DeprecatedString with_parsed_identifier, bool with_parsed_period)
|
||||
{
|
||||
if (with_parsed_identifier.is_null() && !match(TokenType::Identifier))
|
||||
return {};
|
||||
|
||||
String first_identifier;
|
||||
DeprecatedString first_identifier;
|
||||
if (with_parsed_identifier.is_null())
|
||||
first_identifier = consume(TokenType::Identifier).value();
|
||||
else
|
||||
first_identifier = move(with_parsed_identifier);
|
||||
|
||||
String schema_name;
|
||||
String table_name;
|
||||
String column_name;
|
||||
DeprecatedString schema_name;
|
||||
DeprecatedString table_name;
|
||||
DeprecatedString column_name;
|
||||
|
||||
if (with_parsed_period || consume_if(TokenType::Period)) {
|
||||
String second_identifier = consume(TokenType::Identifier).value();
|
||||
DeprecatedString second_identifier = consume(TokenType::Identifier).value();
|
||||
|
||||
if (consume_if(TokenType::Period)) {
|
||||
schema_name = move(first_identifier);
|
||||
|
@ -726,7 +726,7 @@ RefPtr<Expression> Parser::parse_collate_expression(NonnullRefPtr<Expression> ex
|
|||
return {};
|
||||
|
||||
consume();
|
||||
String collation_name = consume(TokenType::Identifier).value();
|
||||
DeprecatedString collation_name = consume(TokenType::Identifier).value();
|
||||
|
||||
return create_ast_node<CollateExpression>(move(expression), move(collation_name));
|
||||
}
|
||||
|
@ -843,8 +843,8 @@ RefPtr<Expression> Parser::parse_in_expression(NonnullRefPtr<Expression> express
|
|||
return create_ast_node<InChainedExpression>(move(expression), move(chain), invert_expression);
|
||||
}
|
||||
|
||||
String schema_name;
|
||||
String table_name;
|
||||
DeprecatedString schema_name;
|
||||
DeprecatedString table_name;
|
||||
parse_schema_and_table_name(schema_name, table_name);
|
||||
|
||||
if (match(TokenType::ParenOpen)) {
|
||||
|
@ -912,7 +912,7 @@ NonnullRefPtr<CommonTableExpression> Parser::parse_common_table_expression()
|
|||
// https://sqlite.org/syntax/common-table-expression.html
|
||||
auto table_name = consume(TokenType::Identifier).value();
|
||||
|
||||
Vector<String> column_names;
|
||||
Vector<DeprecatedString> column_names;
|
||||
if (match(TokenType::ParenOpen))
|
||||
parse_comma_separated_list(true, [&]() { column_names.append(consume(TokenType::Identifier).value()); });
|
||||
|
||||
|
@ -927,11 +927,11 @@ NonnullRefPtr<CommonTableExpression> Parser::parse_common_table_expression()
|
|||
NonnullRefPtr<QualifiedTableName> Parser::parse_qualified_table_name()
|
||||
{
|
||||
// https://sqlite.org/syntax/qualified-table-name.html
|
||||
String schema_name;
|
||||
String table_name;
|
||||
DeprecatedString schema_name;
|
||||
DeprecatedString table_name;
|
||||
parse_schema_and_table_name(schema_name, table_name);
|
||||
|
||||
String alias;
|
||||
DeprecatedString alias;
|
||||
if (consume_if(TokenType::As))
|
||||
alias = consume(TokenType::Identifier).value();
|
||||
|
||||
|
@ -955,7 +955,7 @@ NonnullRefPtr<ReturningClause> Parser::parse_returning_clause()
|
|||
parse_comma_separated_list(false, [&]() {
|
||||
auto expression = parse_expression();
|
||||
|
||||
String column_alias;
|
||||
DeprecatedString column_alias;
|
||||
if (consume_if(TokenType::As) || match(TokenType::Identifier))
|
||||
column_alias = consume(TokenType::Identifier).value();
|
||||
|
||||
|
@ -974,7 +974,7 @@ NonnullRefPtr<ResultColumn> Parser::parse_result_column()
|
|||
// If we match an identifier now, we don't know whether it is a table-name of the form "table-name.*", or if it is the start of a
|
||||
// column-name-expression, until we try to parse the asterisk. So if we consume an identifier and a period, but don't find an
|
||||
// asterisk, hold onto that information to form a column-name-expression later.
|
||||
String table_name;
|
||||
DeprecatedString table_name;
|
||||
bool parsed_period = false;
|
||||
|
||||
if (match(TokenType::Identifier)) {
|
||||
|
@ -988,7 +988,7 @@ NonnullRefPtr<ResultColumn> Parser::parse_result_column()
|
|||
? parse_expression()
|
||||
: static_cast<NonnullRefPtr<Expression>>(*parse_column_name_expression(move(table_name), parsed_period));
|
||||
|
||||
String column_alias;
|
||||
DeprecatedString column_alias;
|
||||
if (consume_if(TokenType::As) || match(TokenType::Identifier))
|
||||
column_alias = consume(TokenType::Identifier).value();
|
||||
|
||||
|
@ -998,17 +998,17 @@ NonnullRefPtr<ResultColumn> Parser::parse_result_column()
|
|||
NonnullRefPtr<TableOrSubquery> Parser::parse_table_or_subquery()
|
||||
{
|
||||
if (++m_parser_state.m_current_subquery_depth > Limits::maximum_subquery_depth)
|
||||
syntax_error(String::formatted("Exceeded maximum subquery depth of {}", Limits::maximum_subquery_depth));
|
||||
syntax_error(DeprecatedString::formatted("Exceeded maximum subquery depth of {}", Limits::maximum_subquery_depth));
|
||||
|
||||
ScopeGuard guard([&]() { --m_parser_state.m_current_subquery_depth; });
|
||||
|
||||
// https://sqlite.org/syntax/table-or-subquery.html
|
||||
if (match(TokenType::Identifier)) {
|
||||
String schema_name;
|
||||
String table_name;
|
||||
DeprecatedString schema_name;
|
||||
DeprecatedString table_name;
|
||||
parse_schema_and_table_name(schema_name, table_name);
|
||||
|
||||
String table_alias;
|
||||
DeprecatedString table_alias;
|
||||
if (consume_if(TokenType::As) || match(TokenType::Identifier))
|
||||
table_alias = consume(TokenType::Identifier).value();
|
||||
|
||||
|
@ -1028,7 +1028,7 @@ NonnullRefPtr<OrderingTerm> Parser::parse_ordering_term()
|
|||
// https://sqlite.org/syntax/ordering-term.html
|
||||
auto expression = parse_expression();
|
||||
|
||||
String collation_name;
|
||||
DeprecatedString collation_name;
|
||||
if (is<CollateExpression>(*expression)) {
|
||||
auto const& collate = static_cast<CollateExpression const&>(*expression);
|
||||
collation_name = collate.collation_name();
|
||||
|
@ -1053,9 +1053,9 @@ NonnullRefPtr<OrderingTerm> Parser::parse_ordering_term()
|
|||
return create_ast_node<OrderingTerm>(move(expression), move(collation_name), order, nulls);
|
||||
}
|
||||
|
||||
void Parser::parse_schema_and_table_name(String& schema_name, String& table_name)
|
||||
void Parser::parse_schema_and_table_name(DeprecatedString& schema_name, DeprecatedString& table_name)
|
||||
{
|
||||
String schema_or_table_name = consume(TokenType::Identifier).value();
|
||||
DeprecatedString schema_or_table_name = consume(TokenType::Identifier).value();
|
||||
|
||||
if (consume_if(TokenType::Period)) {
|
||||
schema_name = move(schema_or_table_name);
|
||||
|
@ -1117,10 +1117,10 @@ bool Parser::match(TokenType type) const
|
|||
|
||||
void Parser::expected(StringView what)
|
||||
{
|
||||
syntax_error(String::formatted("Unexpected token {}, expected {}", m_parser_state.m_token.name(), what));
|
||||
syntax_error(DeprecatedString::formatted("Unexpected token {}, expected {}", m_parser_state.m_token.name(), what));
|
||||
}
|
||||
|
||||
void Parser::syntax_error(String message)
|
||||
void Parser::syntax_error(DeprecatedString message)
|
||||
{
|
||||
m_parser_state.m_errors.append({ move(message), position() });
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/String.h>
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/StringView.h>
|
||||
#include <LibSQL/AST/AST.h>
|
||||
#include <LibSQL/AST/Lexer.h>
|
||||
|
@ -23,12 +23,12 @@ constexpr size_t maximum_subquery_depth = 100;
|
|||
|
||||
class Parser {
|
||||
struct Error {
|
||||
String message;
|
||||
DeprecatedString message;
|
||||
SourcePosition position;
|
||||
|
||||
String to_string() const
|
||||
DeprecatedString to_string() const
|
||||
{
|
||||
return String::formatted("{} (line: {}, column: {})", message, position.line, position.column);
|
||||
return DeprecatedString::formatted("{} (line: {}, column: {})", message, position.line, position.column);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -71,7 +71,7 @@ private:
|
|||
NonnullRefPtr<Expression> parse_secondary_expression(NonnullRefPtr<Expression> primary);
|
||||
bool match_secondary_expression() const;
|
||||
RefPtr<Expression> parse_literal_value_expression();
|
||||
RefPtr<Expression> parse_column_name_expression(String with_parsed_identifier = {}, bool with_parsed_period = false);
|
||||
RefPtr<Expression> parse_column_name_expression(DeprecatedString with_parsed_identifier = {}, bool with_parsed_period = false);
|
||||
RefPtr<Expression> parse_unary_operator_expression();
|
||||
RefPtr<Expression> parse_binary_operator_expression(NonnullRefPtr<Expression> lhs);
|
||||
RefPtr<Expression> parse_chained_expression();
|
||||
|
@ -94,7 +94,7 @@ private:
|
|||
NonnullRefPtr<ResultColumn> parse_result_column();
|
||||
NonnullRefPtr<TableOrSubquery> parse_table_or_subquery();
|
||||
NonnullRefPtr<OrderingTerm> parse_ordering_term();
|
||||
void parse_schema_and_table_name(String& schema_name, String& table_name);
|
||||
void parse_schema_and_table_name(DeprecatedString& schema_name, DeprecatedString& table_name);
|
||||
ConflictResolution parse_conflict_resolution();
|
||||
|
||||
template<typename ParseCallback>
|
||||
|
@ -122,7 +122,7 @@ private:
|
|||
bool match(TokenType type) const;
|
||||
|
||||
void expected(StringView what);
|
||||
void syntax_error(String message);
|
||||
void syntax_error(DeprecatedString message);
|
||||
|
||||
SourcePosition position() const;
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#include "Token.h"
|
||||
#include <AK/Assertions.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
namespace SQL::AST {
|
||||
|
@ -40,7 +40,7 @@ TokenCategory Token::category(TokenType type)
|
|||
double Token::double_value() const
|
||||
{
|
||||
VERIFY(type() == TokenType::NumericLiteral);
|
||||
String value(m_value);
|
||||
DeprecatedString value(m_value);
|
||||
|
||||
if (value[0] == '0' && value.length() >= 2) {
|
||||
if (value[1] == 'x' || value[1] == 'X')
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/HashMap.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/StringView.h>
|
||||
|
||||
namespace SQL::AST {
|
||||
|
@ -221,7 +221,7 @@ struct SourcePosition {
|
|||
|
||||
class Token {
|
||||
public:
|
||||
Token(TokenType type, String value, SourcePosition start_position, SourcePosition end_position)
|
||||
Token(TokenType type, DeprecatedString value, SourcePosition start_position, SourcePosition end_position)
|
||||
: m_type(type)
|
||||
, m_value(move(value))
|
||||
, m_start_position(start_position)
|
||||
|
@ -236,7 +236,7 @@ public:
|
|||
TokenType type() const { return m_type; }
|
||||
TokenCategory category() const { return category(m_type); }
|
||||
|
||||
String const& value() const { return m_value; }
|
||||
DeprecatedString const& value() const { return m_value; }
|
||||
double double_value() const;
|
||||
|
||||
SourcePosition const& start_position() const { return m_start_position; }
|
||||
|
@ -244,7 +244,7 @@ public:
|
|||
|
||||
private:
|
||||
TokenType m_type;
|
||||
String m_value;
|
||||
DeprecatedString m_value;
|
||||
SourcePosition m_start_position;
|
||||
SourcePosition m_end_position;
|
||||
};
|
||||
|
|
|
@ -6,12 +6,12 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/Function.h>
|
||||
#include <AK/NonnullRefPtr.h>
|
||||
#include <AK/NonnullRefPtrVector.h>
|
||||
#include <AK/Optional.h>
|
||||
#include <AK/RefPtr.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/Object.h>
|
||||
|
@ -77,7 +77,7 @@ public:
|
|||
|
||||
private:
|
||||
TreeNode(BTree&, TreeNode*, DownPointer&, u32 = 0);
|
||||
void dump_if(int, String&& = "");
|
||||
void dump_if(int, DeprecatedString&& = "");
|
||||
bool insert_in_leaf(Key const&);
|
||||
void just_insert(Key const&, TreeNode* = nullptr);
|
||||
void split();
|
||||
|
|
|
@ -5,9 +5,9 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/Format.h>
|
||||
#include <AK/RefPtr.h>
|
||||
#include <AK/String.h>
|
||||
|
||||
#include <LibSQL/BTree.h>
|
||||
#include <LibSQL/Database.h>
|
||||
|
@ -18,7 +18,7 @@
|
|||
|
||||
namespace SQL {
|
||||
|
||||
Database::Database(String name)
|
||||
Database::Database(DeprecatedString name)
|
||||
: m_heap(Heap::construct(move(name)))
|
||||
, m_serializer(m_heap)
|
||||
{
|
||||
|
@ -92,14 +92,14 @@ ResultOr<void> Database::add_schema(SchemaDef const& schema)
|
|||
return {};
|
||||
}
|
||||
|
||||
Key Database::get_schema_key(String const& schema_name)
|
||||
Key Database::get_schema_key(DeprecatedString const& schema_name)
|
||||
{
|
||||
auto key = SchemaDef::make_key();
|
||||
key["schema_name"] = schema_name;
|
||||
return key;
|
||||
}
|
||||
|
||||
ResultOr<NonnullRefPtr<SchemaDef>> Database::get_schema(String const& schema)
|
||||
ResultOr<NonnullRefPtr<SchemaDef>> Database::get_schema(DeprecatedString const& schema)
|
||||
{
|
||||
VERIFY(is_open());
|
||||
|
||||
|
@ -135,14 +135,14 @@ ResultOr<void> Database::add_table(TableDef& table)
|
|||
return {};
|
||||
}
|
||||
|
||||
Key Database::get_table_key(String const& schema_name, String const& table_name)
|
||||
Key Database::get_table_key(DeprecatedString const& schema_name, DeprecatedString const& table_name)
|
||||
{
|
||||
auto key = TableDef::make_key(get_schema_key(schema_name));
|
||||
key["table_name"] = table_name;
|
||||
return key;
|
||||
}
|
||||
|
||||
ResultOr<NonnullRefPtr<TableDef>> Database::get_table(String const& schema, String const& name)
|
||||
ResultOr<NonnullRefPtr<TableDef>> Database::get_table(DeprecatedString const& schema, DeprecatedString const& name)
|
||||
{
|
||||
VERIFY(is_open());
|
||||
|
||||
|
@ -156,7 +156,7 @@ ResultOr<NonnullRefPtr<TableDef>> Database::get_table(String const& schema, Stri
|
|||
|
||||
auto table_iterator = m_tables->find(key);
|
||||
if (table_iterator.is_end() || (*table_iterator != key))
|
||||
return Result { SQLCommand::Unknown, SQLErrorCode::TableDoesNotExist, String::formatted("{}.{}", schema_name, name) };
|
||||
return Result { SQLCommand::Unknown, SQLErrorCode::TableDoesNotExist, DeprecatedString::formatted("{}.{}", schema_name, name) };
|
||||
|
||||
auto schema_def = TRY(get_schema(schema));
|
||||
auto table_def = TableDef::construct(schema_def, name);
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/RefPtr.h>
|
||||
#include <AK/String.h>
|
||||
#include <LibCore/Object.h>
|
||||
#include <LibSQL/Forward.h>
|
||||
#include <LibSQL/Heap.h>
|
||||
|
@ -34,12 +34,12 @@ public:
|
|||
ErrorOr<void> commit();
|
||||
|
||||
ResultOr<void> add_schema(SchemaDef const&);
|
||||
static Key get_schema_key(String const&);
|
||||
ResultOr<NonnullRefPtr<SchemaDef>> get_schema(String const&);
|
||||
static Key get_schema_key(DeprecatedString const&);
|
||||
ResultOr<NonnullRefPtr<SchemaDef>> get_schema(DeprecatedString const&);
|
||||
|
||||
ResultOr<void> add_table(TableDef& table);
|
||||
static Key get_table_key(String const&, String const&);
|
||||
ResultOr<NonnullRefPtr<TableDef>> get_table(String const&, String const&);
|
||||
static Key get_table_key(DeprecatedString const&, DeprecatedString const&);
|
||||
ResultOr<NonnullRefPtr<TableDef>> get_table(DeprecatedString const&, DeprecatedString const&);
|
||||
|
||||
ErrorOr<Vector<Row>> select_all(TableDef const&);
|
||||
ErrorOr<Vector<Row>> match(TableDef const&, Key const&);
|
||||
|
@ -48,7 +48,7 @@ public:
|
|||
ErrorOr<void> update(Row&);
|
||||
|
||||
private:
|
||||
explicit Database(String);
|
||||
explicit Database(DeprecatedString);
|
||||
|
||||
bool m_open { false };
|
||||
NonnullRefPtr<Heap> m_heap;
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/Format.h>
|
||||
#include <AK/QuickSort.h>
|
||||
#include <AK/String.h>
|
||||
#include <LibCore/IODevice.h>
|
||||
#include <LibSQL/Heap.h>
|
||||
#include <LibSQL/Serializer.h>
|
||||
|
@ -15,7 +15,7 @@
|
|||
|
||||
namespace SQL {
|
||||
|
||||
Heap::Heap(String file_name)
|
||||
Heap::Heap(DeprecatedString file_name)
|
||||
{
|
||||
set_name(move(file_name));
|
||||
}
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
|
||||
#include <AK/Array.h>
|
||||
#include <AK/Debug.h>
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/HashMap.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <LibCore/Object.h>
|
||||
#include <LibCore/Stream.h>
|
||||
|
@ -89,7 +89,7 @@ public:
|
|||
ErrorOr<void> flush();
|
||||
|
||||
private:
|
||||
explicit Heap(String);
|
||||
explicit Heap(DeprecatedString);
|
||||
|
||||
ErrorOr<void> write_block(u32, ByteBuffer&);
|
||||
ErrorOr<void> seek_block(u32);
|
||||
|
|
|
@ -15,7 +15,7 @@ u32 Relation::hash() const
|
|||
return key().hash();
|
||||
}
|
||||
|
||||
SchemaDef::SchemaDef(String name)
|
||||
SchemaDef::SchemaDef(DeprecatedString name)
|
||||
: Relation(move(name))
|
||||
{
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ NonnullRefPtr<IndexDef> SchemaDef::index_def()
|
|||
return s_index_def;
|
||||
}
|
||||
|
||||
ColumnDef::ColumnDef(Relation* parent, size_t column_number, String name, SQLType sql_type)
|
||||
ColumnDef::ColumnDef(Relation* parent, size_t column_number, DeprecatedString name, SQLType sql_type)
|
||||
: Relation(move(name), parent)
|
||||
, m_index(column_number)
|
||||
, m_type(sql_type)
|
||||
|
@ -90,25 +90,25 @@ NonnullRefPtr<IndexDef> ColumnDef::index_def()
|
|||
return s_index_def;
|
||||
}
|
||||
|
||||
KeyPartDef::KeyPartDef(IndexDef* index, String name, SQLType sql_type, Order sort_order)
|
||||
KeyPartDef::KeyPartDef(IndexDef* index, DeprecatedString name, SQLType sql_type, Order sort_order)
|
||||
: ColumnDef(index, index->size(), move(name), sql_type)
|
||||
, m_sort_order(sort_order)
|
||||
{
|
||||
}
|
||||
|
||||
IndexDef::IndexDef(TableDef* table, String name, bool unique, u32 pointer)
|
||||
IndexDef::IndexDef(TableDef* table, DeprecatedString name, bool unique, u32 pointer)
|
||||
: Relation(move(name), pointer, table)
|
||||
, m_key_definition()
|
||||
, m_unique(unique)
|
||||
{
|
||||
}
|
||||
|
||||
IndexDef::IndexDef(String name, bool unique, u32 pointer)
|
||||
IndexDef::IndexDef(DeprecatedString name, bool unique, u32 pointer)
|
||||
: IndexDef(nullptr, move(name), unique, pointer)
|
||||
{
|
||||
}
|
||||
|
||||
void IndexDef::append_column(String name, SQLType sql_type, Order sort_order)
|
||||
void IndexDef::append_column(DeprecatedString name, SQLType sql_type, Order sort_order)
|
||||
{
|
||||
auto part = KeyPartDef::construct(this, move(name), sql_type, sort_order);
|
||||
m_key_definition.append(part);
|
||||
|
@ -150,7 +150,7 @@ NonnullRefPtr<IndexDef> IndexDef::index_def()
|
|||
return s_index_def;
|
||||
}
|
||||
|
||||
TableDef::TableDef(SchemaDef* schema, String name)
|
||||
TableDef::TableDef(SchemaDef* schema, DeprecatedString name)
|
||||
: Relation(move(name), schema)
|
||||
, m_columns()
|
||||
, m_indexes()
|
||||
|
@ -175,7 +175,7 @@ Key TableDef::key() const
|
|||
return key;
|
||||
}
|
||||
|
||||
void TableDef::append_column(String name, SQLType sql_type)
|
||||
void TableDef::append_column(DeprecatedString name, SQLType sql_type)
|
||||
{
|
||||
auto column = ColumnDef::construct(this, num_columns(), move(name), sql_type);
|
||||
m_columns.append(column);
|
||||
|
|
|
@ -6,11 +6,11 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/NonnullOwnPtr.h>
|
||||
#include <AK/NonnullOwnPtrVector.h>
|
||||
#include <AK/NonnullRefPtr.h>
|
||||
#include <AK/Result.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <LibCore/Object.h>
|
||||
#include <LibSQL/Forward.h>
|
||||
|
@ -36,14 +36,14 @@ public:
|
|||
Relation const* parent_relation() const { return dynamic_cast<Relation const*>(parent()); }
|
||||
|
||||
protected:
|
||||
Relation(String name, u32 pointer, Relation* parent = nullptr)
|
||||
Relation(DeprecatedString name, u32 pointer, Relation* parent = nullptr)
|
||||
: Core::Object(parent)
|
||||
, m_pointer(pointer)
|
||||
{
|
||||
set_name(move(name));
|
||||
}
|
||||
|
||||
explicit Relation(String name, Relation* parent = nullptr)
|
||||
explicit Relation(DeprecatedString name, Relation* parent = nullptr)
|
||||
: Core::Object(parent)
|
||||
, m_pointer(0)
|
||||
{
|
||||
|
@ -63,7 +63,7 @@ public:
|
|||
static Key make_key();
|
||||
|
||||
private:
|
||||
explicit SchemaDef(String);
|
||||
explicit SchemaDef(DeprecatedString);
|
||||
explicit SchemaDef(Key const&);
|
||||
};
|
||||
|
||||
|
@ -83,7 +83,7 @@ public:
|
|||
static Key make_key(TableDef const&);
|
||||
|
||||
protected:
|
||||
ColumnDef(Relation*, size_t, String, SQLType);
|
||||
ColumnDef(Relation*, size_t, DeprecatedString, SQLType);
|
||||
|
||||
private:
|
||||
size_t m_index;
|
||||
|
@ -99,7 +99,7 @@ public:
|
|||
Order sort_order() const { return m_sort_order; }
|
||||
|
||||
private:
|
||||
KeyPartDef(IndexDef*, String, SQLType, Order = Order::Ascending);
|
||||
KeyPartDef(IndexDef*, DeprecatedString, SQLType, Order = Order::Ascending);
|
||||
|
||||
Order m_sort_order { Order::Ascending };
|
||||
};
|
||||
|
@ -113,15 +113,15 @@ public:
|
|||
NonnullRefPtrVector<KeyPartDef> const& key_definition() const { return m_key_definition; }
|
||||
bool unique() const { return m_unique; }
|
||||
[[nodiscard]] size_t size() const { return m_key_definition.size(); }
|
||||
void append_column(String, SQLType, Order = Order::Ascending);
|
||||
void append_column(DeprecatedString, SQLType, Order = Order::Ascending);
|
||||
Key key() const override;
|
||||
[[nodiscard]] NonnullRefPtr<TupleDescriptor> to_tuple_descriptor() const;
|
||||
static NonnullRefPtr<IndexDef> index_def();
|
||||
static Key make_key(TableDef const& table_def);
|
||||
|
||||
private:
|
||||
IndexDef(TableDef*, String, bool unique = true, u32 pointer = 0);
|
||||
explicit IndexDef(String, bool unique = true, u32 pointer = 0);
|
||||
IndexDef(TableDef*, DeprecatedString, bool unique = true, u32 pointer = 0);
|
||||
explicit IndexDef(DeprecatedString, bool unique = true, u32 pointer = 0);
|
||||
|
||||
NonnullRefPtrVector<KeyPartDef> m_key_definition;
|
||||
bool m_unique { false };
|
||||
|
@ -134,7 +134,7 @@ class TableDef : public Relation {
|
|||
|
||||
public:
|
||||
Key key() const override;
|
||||
void append_column(String, SQLType);
|
||||
void append_column(DeprecatedString, SQLType);
|
||||
void append_column(Key const&);
|
||||
size_t num_columns() { return m_columns.size(); }
|
||||
size_t num_indexes() { return m_indexes.size(); }
|
||||
|
@ -147,7 +147,7 @@ public:
|
|||
static Key make_key(Key const& schema_key);
|
||||
|
||||
private:
|
||||
explicit TableDef(SchemaDef*, String);
|
||||
explicit TableDef(SchemaDef*, DeprecatedString);
|
||||
|
||||
NonnullRefPtrVector<ColumnDef> m_columns;
|
||||
NonnullRefPtrVector<IndexDef> m_indexes;
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
namespace SQL {
|
||||
|
||||
String Result::error_string() const
|
||||
DeprecatedString Result::error_string() const
|
||||
{
|
||||
VERIFY(is_error());
|
||||
|
||||
|
|
|
@ -84,7 +84,7 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
ALWAYS_INLINE Result(SQLCommand command, SQLErrorCode error, String error_message)
|
||||
ALWAYS_INLINE Result(SQLCommand command, SQLErrorCode error, DeprecatedString error_message)
|
||||
: m_command(command)
|
||||
, m_error(error)
|
||||
, m_error_message(move(error_message))
|
||||
|
@ -102,7 +102,7 @@ public:
|
|||
|
||||
SQLCommand command() const { return m_command; }
|
||||
SQLErrorCode error() const { return m_error; }
|
||||
String error_string() const;
|
||||
DeprecatedString error_string() const;
|
||||
|
||||
// These are for compatibility with the TRY() macro in AK.
|
||||
[[nodiscard]] bool is_error() const { return m_error != SQLErrorCode::NoError; }
|
||||
|
@ -122,7 +122,7 @@ private:
|
|||
SQLCommand m_command { SQLCommand::Unknown };
|
||||
|
||||
SQLErrorCode m_error { SQLErrorCode::NoError };
|
||||
Optional<String> m_error_message {};
|
||||
Optional<DeprecatedString> m_error_message {};
|
||||
};
|
||||
|
||||
template<typename ValueType>
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
namespace SQL {
|
||||
|
||||
void SQLClient::connected(int connection_id, String const& connected_to_database)
|
||||
void SQLClient::connected(int connection_id, DeprecatedString const& connected_to_database)
|
||||
{
|
||||
if (on_connected)
|
||||
on_connected(connection_id, connected_to_database);
|
||||
|
@ -21,7 +21,7 @@ void SQLClient::disconnected(int connection_id)
|
|||
on_disconnected(connection_id);
|
||||
}
|
||||
|
||||
void SQLClient::connection_error(int connection_id, int code, String const& message)
|
||||
void SQLClient::connection_error(int connection_id, int code, DeprecatedString const& message)
|
||||
{
|
||||
if (on_connection_error)
|
||||
on_connection_error(connection_id, code, message);
|
||||
|
@ -29,7 +29,7 @@ void SQLClient::connection_error(int connection_id, int code, String const& mess
|
|||
warnln("Connection error for connection_id {}: {} ({})", connection_id, message, code);
|
||||
}
|
||||
|
||||
void SQLClient::execution_error(int statement_id, int code, String const& message)
|
||||
void SQLClient::execution_error(int statement_id, int code, DeprecatedString const& message)
|
||||
{
|
||||
if (on_execution_error)
|
||||
on_execution_error(statement_id, code, message);
|
||||
|
@ -45,7 +45,7 @@ void SQLClient::execution_success(int statement_id, bool has_results, int create
|
|||
outln("{} row(s) created, {} updated, {} deleted", created, updated, deleted);
|
||||
}
|
||||
|
||||
void SQLClient::next_result(int statement_id, Vector<String> const& row)
|
||||
void SQLClient::next_result(int statement_id, Vector<DeprecatedString> const& row)
|
||||
{
|
||||
if (on_next_result) {
|
||||
on_next_result(statement_id, row);
|
||||
|
|
|
@ -19,12 +19,12 @@ class SQLClient
|
|||
IPC_CLIENT_CONNECTION(SQLClient, "/tmp/session/%sid/portal/sql"sv)
|
||||
virtual ~SQLClient() = default;
|
||||
|
||||
Function<void(int, String const&)> on_connected;
|
||||
Function<void(int, DeprecatedString const&)> on_connected;
|
||||
Function<void(int)> on_disconnected;
|
||||
Function<void(int, int, String const&)> on_connection_error;
|
||||
Function<void(int, int, String const&)> on_execution_error;
|
||||
Function<void(int, int, DeprecatedString const&)> on_connection_error;
|
||||
Function<void(int, int, DeprecatedString const&)> on_execution_error;
|
||||
Function<void(int, bool, int, int, int)> on_execution_success;
|
||||
Function<void(int, Vector<String> const&)> on_next_result;
|
||||
Function<void(int, Vector<DeprecatedString> const&)> on_next_result;
|
||||
Function<void(int, int)> on_results_exhausted;
|
||||
|
||||
private:
|
||||
|
@ -33,12 +33,12 @@ private:
|
|||
{
|
||||
}
|
||||
|
||||
virtual void connected(int connection_id, String const& connected_to_database) override;
|
||||
virtual void connection_error(int connection_id, int code, String const& message) override;
|
||||
virtual void connected(int connection_id, DeprecatedString const& connected_to_database) override;
|
||||
virtual void connection_error(int connection_id, int code, DeprecatedString const& message) override;
|
||||
virtual void execution_success(int statement_id, bool has_results, int created, int updated, int deleted) override;
|
||||
virtual void next_result(int statement_id, Vector<String> const&) override;
|
||||
virtual void next_result(int statement_id, Vector<DeprecatedString> const&) override;
|
||||
virtual void results_exhausted(int statement_id, int total_rows) override;
|
||||
virtual void execution_error(int statement_id, int code, String const& message) override;
|
||||
virtual void execution_error(int statement_id, int code, DeprecatedString const& message) override;
|
||||
virtual void disconnected(int connection_id) override;
|
||||
};
|
||||
|
||||
|
|
|
@ -8,18 +8,18 @@
|
|||
|
||||
namespace SQL {
|
||||
|
||||
void Serializer::serialize(String const& text)
|
||||
void Serializer::serialize(DeprecatedString const& text)
|
||||
{
|
||||
serialize<u32>((u32)text.length());
|
||||
if (!text.is_empty())
|
||||
write((u8 const*)text.characters(), text.length());
|
||||
}
|
||||
|
||||
void Serializer::deserialize_to(String& text)
|
||||
void Serializer::deserialize_to(DeprecatedString& text)
|
||||
{
|
||||
auto length = deserialize<u32>();
|
||||
if (length > 0) {
|
||||
text = String(reinterpret_cast<char const*>(read(length)), length);
|
||||
text = DeprecatedString(reinterpret_cast<char const*>(read(length)), length);
|
||||
} else {
|
||||
text = "";
|
||||
}
|
||||
|
|
|
@ -8,9 +8,9 @@
|
|||
|
||||
#include <AK/ByteBuffer.h>
|
||||
#include <AK/Debug.h>
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/Format.h>
|
||||
#include <AK/ScopeGuard.h>
|
||||
#include <AK/String.h>
|
||||
#include <LibSQL/Forward.h>
|
||||
#include <LibSQL/Heap.h>
|
||||
#include <string.h>
|
||||
|
@ -70,7 +70,7 @@ public:
|
|||
t.deserialize(*this);
|
||||
}
|
||||
|
||||
void deserialize_to(String& text);
|
||||
void deserialize_to(DeprecatedString& text);
|
||||
|
||||
template<typename T, typename... Args>
|
||||
NonnullOwnPtr<T> make_and_deserialize(Args&&... args)
|
||||
|
@ -105,7 +105,7 @@ public:
|
|||
t.serialize(*this);
|
||||
}
|
||||
|
||||
void serialize(String const&);
|
||||
void serialize(DeprecatedString const&);
|
||||
|
||||
template<typename T>
|
||||
bool serialize_and_write(T const& t)
|
||||
|
@ -154,13 +154,13 @@ private:
|
|||
return buffer_ptr;
|
||||
}
|
||||
|
||||
static void dump(u8 const* ptr, size_t sz, String const& prefix)
|
||||
static void dump(u8 const* ptr, size_t sz, DeprecatedString const& prefix)
|
||||
{
|
||||
StringBuilder builder;
|
||||
builder.appendff("{0} {1:04x} | ", prefix, sz);
|
||||
Vector<String> bytes;
|
||||
Vector<DeprecatedString> bytes;
|
||||
for (auto ix = 0u; ix < sz; ++ix) {
|
||||
bytes.append(String::formatted("{0:02x}", *(ptr + ix)));
|
||||
bytes.append(DeprecatedString::formatted("{0:02x}", *(ptr + ix)));
|
||||
}
|
||||
StringBuilder bytes_builder;
|
||||
bytes_builder.join(' ', bytes);
|
||||
|
|
|
@ -209,40 +209,40 @@ TreeNode* TreeNode::down_node(size_t ix)
|
|||
|
||||
TreeNode* TreeNode::node_for(Key const& key)
|
||||
{
|
||||
dump_if(SQL_DEBUG, String::formatted("node_for(Key {})", key.to_string()));
|
||||
dump_if(SQL_DEBUG, DeprecatedString::formatted("node_for(Key {})", key.to_string()));
|
||||
if (is_leaf())
|
||||
return this;
|
||||
for (size_t ix = 0; ix < size(); ix++) {
|
||||
if (key < m_entries[ix]) {
|
||||
dbgln_if(SQL_DEBUG, "[{}] {} < {} v{}",
|
||||
pointer(), (String)key, (String)m_entries[ix], m_down[ix].pointer());
|
||||
pointer(), (DeprecatedString)key, (DeprecatedString)m_entries[ix], m_down[ix].pointer());
|
||||
return down_node(ix)->node_for(key);
|
||||
}
|
||||
}
|
||||
dbgln_if(SQL_DEBUG, "[#{}] {} >= {} v{}",
|
||||
pointer(), key.to_string(), (String)m_entries[size() - 1], m_down[size()].pointer());
|
||||
pointer(), key.to_string(), (DeprecatedString)m_entries[size() - 1], m_down[size()].pointer());
|
||||
return down_node(size())->node_for(key);
|
||||
}
|
||||
|
||||
Optional<u32> TreeNode::get(Key& key)
|
||||
{
|
||||
dump_if(SQL_DEBUG, String::formatted("get({})", key.to_string()));
|
||||
dump_if(SQL_DEBUG, DeprecatedString::formatted("get({})", key.to_string()));
|
||||
for (auto ix = 0u; ix < size(); ix++) {
|
||||
if (key < m_entries[ix]) {
|
||||
if (is_leaf()) {
|
||||
dbgln_if(SQL_DEBUG, "[#{}] {} < {} -> 0",
|
||||
pointer(), key.to_string(), (String)m_entries[ix]);
|
||||
pointer(), key.to_string(), (DeprecatedString)m_entries[ix]);
|
||||
return {};
|
||||
} else {
|
||||
dbgln_if(SQL_DEBUG, "[{}] {} < {} ({} -> {})",
|
||||
pointer(), key.to_string(), (String)m_entries[ix],
|
||||
pointer(), key.to_string(), (DeprecatedString)m_entries[ix],
|
||||
ix, m_down[ix].pointer());
|
||||
return down_node(ix)->get(key);
|
||||
}
|
||||
}
|
||||
if (key == m_entries[ix]) {
|
||||
dbgln_if(SQL_DEBUG, "[#{}] {} == {} -> {}",
|
||||
pointer(), key.to_string(), (String)m_entries[ix],
|
||||
pointer(), key.to_string(), (DeprecatedString)m_entries[ix],
|
||||
m_entries[ix].pointer());
|
||||
key.set_pointer(m_entries[ix].pointer());
|
||||
return m_entries[ix].pointer();
|
||||
|
@ -254,11 +254,11 @@ Optional<u32> TreeNode::get(Key& key)
|
|||
}
|
||||
if (is_leaf()) {
|
||||
dbgln_if(SQL_DEBUG, "[#{}] {} > {} -> 0",
|
||||
pointer(), key.to_string(), (String)m_entries[size() - 1]);
|
||||
pointer(), key.to_string(), (DeprecatedString)m_entries[size() - 1]);
|
||||
return {};
|
||||
}
|
||||
dbgln_if(SQL_DEBUG, "[#{}] {} > {} ({} -> {})",
|
||||
pointer(), key.to_string(), (String)m_entries[size() - 1],
|
||||
pointer(), key.to_string(), (DeprecatedString)m_entries[size() - 1],
|
||||
size(), m_down[size()].pointer());
|
||||
return down_node(size())->get(key);
|
||||
}
|
||||
|
@ -266,7 +266,7 @@ Optional<u32> TreeNode::get(Key& key)
|
|||
void TreeNode::just_insert(Key const& key, TreeNode* right)
|
||||
{
|
||||
dbgln_if(SQL_DEBUG, "[#{}] just_insert({}, right = {})",
|
||||
pointer(), (String)key, (right) ? right->pointer() : 0);
|
||||
pointer(), (DeprecatedString)key, (right) ? right->pointer() : 0);
|
||||
dump_if(SQL_DEBUG, "Before");
|
||||
for (auto ix = 0u; ix < size(); ix++) {
|
||||
if (key < m_entries[ix]) {
|
||||
|
@ -334,7 +334,7 @@ void TreeNode::split()
|
|||
m_up->just_insert(median, new_node);
|
||||
}
|
||||
|
||||
void TreeNode::dump_if(int flag, String&& msg)
|
||||
void TreeNode::dump_if(int flag, DeprecatedString&& msg)
|
||||
{
|
||||
if (!flag)
|
||||
return;
|
||||
|
@ -352,7 +352,7 @@ void TreeNode::dump_if(int flag, String&& msg)
|
|||
builder.appendff("[v{}] ", m_down[ix].pointer());
|
||||
else
|
||||
VERIFY(m_down[ix].pointer() == 0);
|
||||
builder.appendff("'{}' ", (String)m_entries[ix]);
|
||||
builder.appendff("'{}' ", (DeprecatedString)m_entries[ix]);
|
||||
}
|
||||
if (!is_leaf()) {
|
||||
builder.appendff("[v{}]", m_down[size()].pointer());
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#include <cstring>
|
||||
|
||||
#include <AK/String.h>
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <LibSQL/Serializer.h>
|
||||
#include <LibSQL/Tuple.h>
|
||||
|
@ -90,14 +90,14 @@ Optional<size_t> Tuple::index_of(StringView name) const
|
|||
return {};
|
||||
}
|
||||
|
||||
Value const& Tuple::operator[](String const& name) const
|
||||
Value const& Tuple::operator[](DeprecatedString const& name) const
|
||||
{
|
||||
auto index = index_of(name);
|
||||
VERIFY(index.has_value());
|
||||
return (*this)[index.value()];
|
||||
}
|
||||
|
||||
Value& Tuple::operator[](String const& name)
|
||||
Value& Tuple::operator[](DeprecatedString const& name)
|
||||
{
|
||||
auto index = index_of(name);
|
||||
VERIFY(index.has_value());
|
||||
|
@ -161,7 +161,7 @@ size_t Tuple::length() const
|
|||
return len;
|
||||
}
|
||||
|
||||
String Tuple::to_string() const
|
||||
DeprecatedString Tuple::to_string() const
|
||||
{
|
||||
StringBuilder builder;
|
||||
for (auto& part : m_data) {
|
||||
|
@ -176,9 +176,9 @@ String Tuple::to_string() const
|
|||
return builder.build();
|
||||
}
|
||||
|
||||
Vector<String> Tuple::to_string_vector() const
|
||||
Vector<DeprecatedString> Tuple::to_string_vector() const
|
||||
{
|
||||
Vector<String> ret;
|
||||
Vector<DeprecatedString> ret;
|
||||
for (auto& value : m_data) {
|
||||
ret.append(value.to_string());
|
||||
}
|
||||
|
|
|
@ -35,9 +35,9 @@ public:
|
|||
|
||||
Tuple& operator=(Tuple const&);
|
||||
|
||||
[[nodiscard]] String to_string() const;
|
||||
explicit operator String() const { return to_string(); }
|
||||
[[nodiscard]] Vector<String> to_string_vector() const;
|
||||
[[nodiscard]] DeprecatedString to_string() const;
|
||||
explicit operator DeprecatedString() const { return to_string(); }
|
||||
[[nodiscard]] Vector<DeprecatedString> to_string_vector() const;
|
||||
|
||||
bool operator<(Tuple const& other) const { return compare(other) < 0; }
|
||||
bool operator<=(Tuple const& other) const { return compare(other) <= 0; }
|
||||
|
@ -47,12 +47,12 @@ public:
|
|||
bool operator>=(Tuple const& other) const { return compare(other) >= 0; }
|
||||
|
||||
[[nodiscard]] bool is_null() const { return m_data.is_empty(); }
|
||||
[[nodiscard]] bool has(String const& name) const { return index_of(name).has_value(); }
|
||||
[[nodiscard]] bool has(DeprecatedString const& name) const { return index_of(name).has_value(); }
|
||||
|
||||
Value const& operator[](size_t ix) const { return m_data[ix]; }
|
||||
Value& operator[](size_t ix) { return m_data[ix]; }
|
||||
Value const& operator[](String const& name) const;
|
||||
Value& operator[](String const& name);
|
||||
Value const& operator[](DeprecatedString const& name) const;
|
||||
Value& operator[](DeprecatedString const& name);
|
||||
void append(Value const&);
|
||||
Tuple& operator+=(Value const&);
|
||||
void extend(Tuple const&);
|
||||
|
|
|
@ -13,9 +13,9 @@
|
|||
namespace SQL {
|
||||
|
||||
struct TupleElementDescriptor {
|
||||
String schema { "" };
|
||||
String table { "" };
|
||||
String name { "" };
|
||||
DeprecatedString schema { "" };
|
||||
DeprecatedString table { "" };
|
||||
DeprecatedString name { "" };
|
||||
SQLType type { SQLType::Text };
|
||||
Order order { Order::Ascending };
|
||||
|
||||
|
@ -29,7 +29,7 @@ struct TupleElementDescriptor {
|
|||
}
|
||||
void deserialize(Serializer& serializer)
|
||||
{
|
||||
name = serializer.deserialize<String>();
|
||||
name = serializer.deserialize<DeprecatedString>();
|
||||
type = (SQLType)serializer.deserialize<u8>();
|
||||
order = (Order)serializer.deserialize<u8>();
|
||||
}
|
||||
|
@ -39,9 +39,9 @@ struct TupleElementDescriptor {
|
|||
return (sizeof(u32) + name.length()) + 2 * sizeof(u8);
|
||||
}
|
||||
|
||||
String to_string() const
|
||||
DeprecatedString to_string() const
|
||||
{
|
||||
return String::formatted(" name: {} type: {} order: {}", name, SQLType_name(type), Order_name(order));
|
||||
return DeprecatedString::formatted(" name: {} type: {} order: {}", name, SQLType_name(type), Order_name(order));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -91,13 +91,13 @@ public:
|
|||
return len;
|
||||
}
|
||||
|
||||
String to_string() const
|
||||
DeprecatedString to_string() const
|
||||
{
|
||||
Vector<String> elements;
|
||||
Vector<DeprecatedString> elements;
|
||||
for (auto& element : *this) {
|
||||
elements.append(element.to_string());
|
||||
}
|
||||
return String::formatted("[\n{}\n]", String::join('\n', elements));
|
||||
return DeprecatedString::formatted("[\n{}\n]", DeprecatedString::join('\n', elements));
|
||||
}
|
||||
|
||||
using Vector<TupleElementDescriptor>::operator==;
|
||||
|
|
|
@ -6,18 +6,18 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/HashMap.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/StringView.h>
|
||||
|
||||
namespace SQL {
|
||||
|
||||
#define ENUMERATE_SQL_TYPES(S) \
|
||||
S("null", 1, Null, int, sizeof(int)) \
|
||||
S("text", 2, Text, String, 65 + sizeof(u32)) \
|
||||
S("int", 4, Integer, int, sizeof(int)) \
|
||||
S("float", 8, Float, double, sizeof(double)) \
|
||||
S("bool", 16, Boolean, bool, sizeof(bool)) \
|
||||
#define ENUMERATE_SQL_TYPES(S) \
|
||||
S("null", 1, Null, int, sizeof(int)) \
|
||||
S("text", 2, Text, DeprecatedString, 65 + sizeof(u32)) \
|
||||
S("int", 4, Integer, int, sizeof(int)) \
|
||||
S("float", 8, Float, double, sizeof(double)) \
|
||||
S("bool", 16, Boolean, bool, sizeof(bool)) \
|
||||
S("tuple", 32, Tuple, int, sizeof(int))
|
||||
|
||||
enum class SQLType {
|
||||
|
|
|
@ -20,7 +20,7 @@ Value::Value(SQLType type)
|
|||
{
|
||||
}
|
||||
|
||||
Value::Value(String value)
|
||||
Value::Value(DeprecatedString value)
|
||||
: m_type(SQLType::Text)
|
||||
, m_value(move(value))
|
||||
{
|
||||
|
@ -105,17 +105,17 @@ bool Value::is_null() const
|
|||
return !m_value.has_value();
|
||||
}
|
||||
|
||||
String Value::to_string() const
|
||||
DeprecatedString Value::to_string() const
|
||||
{
|
||||
if (is_null())
|
||||
return "(null)"sv;
|
||||
|
||||
return m_value->visit(
|
||||
[](String const& value) -> String { return value; },
|
||||
[](int value) -> String { return String::number(value); },
|
||||
[](double value) -> String { return String::number(value); },
|
||||
[](bool value) -> String { return value ? "true"sv : "false"sv; },
|
||||
[](TupleValue const& value) -> String {
|
||||
[](DeprecatedString const& value) -> DeprecatedString { return value; },
|
||||
[](int value) -> DeprecatedString { return DeprecatedString::number(value); },
|
||||
[](double value) -> DeprecatedString { return DeprecatedString::number(value); },
|
||||
[](bool value) -> DeprecatedString { return value ? "true"sv : "false"sv; },
|
||||
[](TupleValue const& value) -> DeprecatedString {
|
||||
StringBuilder builder;
|
||||
|
||||
builder.append('(');
|
||||
|
@ -132,7 +132,7 @@ Optional<int> Value::to_int() const
|
|||
return {};
|
||||
|
||||
return m_value->visit(
|
||||
[](String const& value) -> Optional<int> { return value.to_int(); },
|
||||
[](DeprecatedString const& value) -> Optional<int> { return value.to_int(); },
|
||||
[](int value) -> Optional<int> { return value; },
|
||||
[](double value) -> Optional<int> {
|
||||
if (value > static_cast<double>(NumericLimits<int>::max()))
|
||||
|
@ -159,7 +159,7 @@ Optional<double> Value::to_double() const
|
|||
return {};
|
||||
|
||||
return m_value->visit(
|
||||
[](String const& value) -> Optional<double> {
|
||||
[](DeprecatedString const& value) -> Optional<double> {
|
||||
char* end = nullptr;
|
||||
double result = strtod(value.characters(), &end);
|
||||
|
||||
|
@ -179,7 +179,7 @@ Optional<bool> Value::to_bool() const
|
|||
return {};
|
||||
|
||||
return m_value->visit(
|
||||
[](String const& value) -> Optional<bool> {
|
||||
[](DeprecatedString const& value) -> Optional<bool> {
|
||||
if (value.equals_ignoring_case("true"sv) || value.equals_ignoring_case("t"sv))
|
||||
return true;
|
||||
if (value.equals_ignoring_case("false"sv) || value.equals_ignoring_case("f"sv))
|
||||
|
@ -218,7 +218,7 @@ Value& Value::operator=(Value value)
|
|||
return *this;
|
||||
}
|
||||
|
||||
Value& Value::operator=(String value)
|
||||
Value& Value::operator=(DeprecatedString value)
|
||||
{
|
||||
m_type = SQLType::Text;
|
||||
m_value = move(value);
|
||||
|
@ -300,7 +300,7 @@ size_t Value::length() const
|
|||
|
||||
// FIXME: This seems to be more of an encoded byte size rather than a length.
|
||||
return m_value->visit(
|
||||
[](String const& value) -> size_t { return sizeof(u32) + value.length(); },
|
||||
[](DeprecatedString const& value) -> size_t { return sizeof(u32) + value.length(); },
|
||||
[](int value) -> size_t { return sizeof(value); },
|
||||
[](double value) -> size_t { return sizeof(value); },
|
||||
[](bool value) -> size_t { return sizeof(value); },
|
||||
|
@ -320,7 +320,7 @@ u32 Value::hash() const
|
|||
return 0;
|
||||
|
||||
return m_value->visit(
|
||||
[](String const& value) -> u32 { return value.hash(); },
|
||||
[](DeprecatedString const& value) -> u32 { return value.hash(); },
|
||||
[](int value) -> u32 { return int_hash(value); },
|
||||
[](double) -> u32 { VERIFY_NOT_REACHED(); },
|
||||
[](bool value) -> u32 { return int_hash(value); },
|
||||
|
@ -346,7 +346,7 @@ int Value::compare(Value const& other) const
|
|||
return 1;
|
||||
|
||||
return m_value->visit(
|
||||
[&](String const& value) -> int { return value.view().compare(other.to_string()); },
|
||||
[&](DeprecatedString const& value) -> int { return value.view().compare(other.to_string()); },
|
||||
[&](int value) -> int {
|
||||
auto casted = other.to_int();
|
||||
if (!casted.has_value())
|
||||
|
@ -608,7 +608,7 @@ void Value::deserialize(Serializer& serializer)
|
|||
VERIFY_NOT_REACHED();
|
||||
break;
|
||||
case SQLType::Text:
|
||||
m_value = serializer.deserialize<String>();
|
||||
m_value = serializer.deserialize<DeprecatedString>();
|
||||
break;
|
||||
case SQLType::Integer:
|
||||
m_value = serializer.deserialize<int>(0);
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/Format.h>
|
||||
#include <AK/Optional.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/StringView.h>
|
||||
#include <AK/Variant.h>
|
||||
#include <AK/Vector.h>
|
||||
|
@ -27,7 +27,7 @@ namespace SQL {
|
|||
class Value {
|
||||
public:
|
||||
explicit Value(SQLType sql_type = SQLType::Null);
|
||||
explicit Value(String);
|
||||
explicit Value(DeprecatedString);
|
||||
explicit Value(int);
|
||||
explicit Value(u32);
|
||||
explicit Value(double);
|
||||
|
@ -49,7 +49,7 @@ public:
|
|||
[[nodiscard]] StringView type_name() const;
|
||||
[[nodiscard]] bool is_null() const;
|
||||
|
||||
[[nodiscard]] String to_string() const;
|
||||
[[nodiscard]] DeprecatedString to_string() const;
|
||||
[[nodiscard]] Optional<int> to_int() const;
|
||||
[[nodiscard]] Optional<u32> to_u32() const;
|
||||
[[nodiscard]] Optional<double> to_double() const;
|
||||
|
@ -57,7 +57,7 @@ public:
|
|||
[[nodiscard]] Optional<Vector<Value>> to_vector() const;
|
||||
|
||||
Value& operator=(Value);
|
||||
Value& operator=(String);
|
||||
Value& operator=(DeprecatedString);
|
||||
Value& operator=(int);
|
||||
Value& operator=(u32);
|
||||
Value& operator=(double);
|
||||
|
@ -110,7 +110,7 @@ private:
|
|||
Vector<Value> values;
|
||||
};
|
||||
|
||||
using ValueType = Variant<String, int, double, bool, TupleValue>;
|
||||
using ValueType = Variant<DeprecatedString, int, double, bool, TupleValue>;
|
||||
|
||||
static ResultOr<NonnullRefPtr<TupleDescriptor>> infer_tuple_descriptor(Vector<Value> const& values);
|
||||
Value(NonnullRefPtr<TupleDescriptor> descriptor, Vector<Value> values);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue