1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 06:37:35 +00:00

Everywhere: Rename {Deprecated => Byte}String

This commit un-deprecates DeprecatedString, and repurposes it as a byte
string.
As the null state has already been removed, there are no other
particularly hairy blockers in repurposing this type as a byte string
(what it _really_ is).

This commit is auto-generated:
  $ xs=$(ack -l \bDeprecatedString\b\|deprecated_string AK Userland \
    Meta Ports Ladybird Tests Kernel)
  $ perl -pie 's/\bDeprecatedString\b/ByteString/g;
    s/deprecated_string/byte_string/g' $xs
  $ clang-format --style=file -i \
    $(git diff --name-only | grep \.cpp\|\.h)
  $ gn format $(git ls-files '*.gn' '*.gni')
This commit is contained in:
Ali Mohammad Pur 2023-12-16 17:49:34 +03:30 committed by Ali Mohammad Pur
parent 38d62563b3
commit 5e1499d104
1615 changed files with 10257 additions and 10257 deletions

View file

@ -8,7 +8,7 @@
#pragma once
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/NonnullRefPtr.h>
#include <AK/RefCounted.h>
#include <AK/RefPtr.h>
@ -54,53 +54,53 @@ private:
class TypeName : public ASTNode {
public:
TypeName(DeprecatedString name, Vector<NonnullRefPtr<SignedNumber>> signed_numbers)
TypeName(ByteString name, Vector<NonnullRefPtr<SignedNumber>> signed_numbers)
: m_name(move(name))
, m_signed_numbers(move(signed_numbers))
{
VERIFY(m_signed_numbers.size() <= 2);
}
DeprecatedString const& name() const { return m_name; }
ByteString const& name() const { return m_name; }
Vector<NonnullRefPtr<SignedNumber>> const& signed_numbers() const { return m_signed_numbers; }
private:
DeprecatedString m_name;
ByteString m_name;
Vector<NonnullRefPtr<SignedNumber>> m_signed_numbers;
};
class ColumnDefinition : public ASTNode {
public:
ColumnDefinition(DeprecatedString name, NonnullRefPtr<TypeName> type_name)
ColumnDefinition(ByteString name, NonnullRefPtr<TypeName> type_name)
: m_name(move(name))
, m_type_name(move(type_name))
{
}
DeprecatedString const& name() const { return m_name; }
ByteString const& name() const { return m_name; }
NonnullRefPtr<TypeName> const& type_name() const { return m_type_name; }
private:
DeprecatedString m_name;
ByteString m_name;
NonnullRefPtr<TypeName> m_type_name;
};
class CommonTableExpression : public ASTNode {
public:
CommonTableExpression(DeprecatedString table_name, Vector<DeprecatedString> column_names, NonnullRefPtr<Select> select_statement)
CommonTableExpression(ByteString table_name, Vector<ByteString> column_names, NonnullRefPtr<Select> select_statement)
: m_table_name(move(table_name))
, m_column_names(move(column_names))
, m_select_statement(move(select_statement))
{
}
DeprecatedString const& table_name() const { return m_table_name; }
Vector<DeprecatedString> const& column_names() const { return m_column_names; }
ByteString const& table_name() const { return m_table_name; }
Vector<ByteString> const& column_names() const { return m_column_names; }
NonnullRefPtr<Select> const& select_statement() const { return m_select_statement; }
private:
DeprecatedString m_table_name;
Vector<DeprecatedString> m_column_names;
ByteString m_table_name;
Vector<ByteString> m_column_names;
NonnullRefPtr<Select> m_select_statement;
};
@ -123,28 +123,28 @@ private:
class QualifiedTableName : public ASTNode {
public:
QualifiedTableName(DeprecatedString schema_name, DeprecatedString table_name, DeprecatedString alias)
QualifiedTableName(ByteString schema_name, ByteString table_name, ByteString alias)
: m_schema_name(move(schema_name))
, m_table_name(move(table_name))
, m_alias(move(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; }
ByteString const& schema_name() const { return m_schema_name; }
ByteString const& table_name() const { return m_table_name; }
ByteString const& alias() const { return m_alias; }
private:
DeprecatedString m_schema_name;
DeprecatedString m_table_name;
DeprecatedString m_alias;
ByteString m_schema_name;
ByteString m_table_name;
ByteString m_alias;
};
class ReturningClause : public ASTNode {
public:
struct ColumnClause {
NonnullRefPtr<Expression> expression;
DeprecatedString column_alias;
ByteString column_alias;
};
ReturningClause() = default;
@ -171,13 +171,13 @@ class ResultColumn : public ASTNode {
public:
ResultColumn() = default;
explicit ResultColumn(DeprecatedString table_name)
explicit ResultColumn(ByteString table_name)
: m_type(ResultType::Table)
, m_table_name(move(table_name))
{
}
ResultColumn(NonnullRefPtr<Expression> expression, DeprecatedString column_alias)
ResultColumn(NonnullRefPtr<Expression> expression, ByteString column_alias)
: m_type(ResultType::Expression)
, m_expression(move(expression))
, m_column_alias(move(column_alias))
@ -187,19 +187,19 @@ public:
ResultType type() const { return m_type; }
bool select_from_table() const { return m_table_name.has_value(); }
Optional<DeprecatedString> const& table_name() const { return m_table_name; }
Optional<ByteString> 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; }
DeprecatedString const& column_alias() const { return m_column_alias; }
ByteString const& column_alias() const { return m_column_alias; }
private:
ResultType m_type { ResultType::All };
Optional<DeprecatedString> m_table_name {};
Optional<ByteString> m_table_name {};
RefPtr<Expression> m_expression {};
DeprecatedString m_column_alias {};
ByteString m_column_alias {};
};
class GroupByClause : public ASTNode {
@ -223,7 +223,7 @@ class TableOrSubquery : public ASTNode {
public:
TableOrSubquery() = default;
TableOrSubquery(DeprecatedString schema_name, DeprecatedString table_name, DeprecatedString table_alias)
TableOrSubquery(ByteString schema_name, ByteString table_name, ByteString table_alias)
: m_is_table(true)
, m_schema_name(move(schema_name))
, m_table_name(move(table_name))
@ -238,18 +238,18 @@ public:
}
bool is_table() const { return m_is_table; }
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; }
ByteString const& schema_name() const { return m_schema_name; }
ByteString const& table_name() const { return m_table_name; }
ByteString const& table_alias() const { return m_table_alias; }
bool is_subquery() const { return m_is_subquery; }
Vector<NonnullRefPtr<TableOrSubquery>> const& subqueries() const { return m_subqueries; }
private:
bool m_is_table { false };
DeprecatedString m_schema_name {};
DeprecatedString m_table_name {};
DeprecatedString m_table_alias {};
ByteString m_schema_name {};
ByteString m_table_name {};
ByteString m_table_alias {};
bool m_is_subquery { false };
Vector<NonnullRefPtr<TableOrSubquery>> m_subqueries {};
@ -257,7 +257,7 @@ private:
class OrderingTerm : public ASTNode {
public:
OrderingTerm(NonnullRefPtr<Expression> expression, DeprecatedString collation_name, Order order, Nulls nulls)
OrderingTerm(NonnullRefPtr<Expression> expression, ByteString collation_name, Order order, Nulls nulls)
: m_expression(move(expression))
, m_collation_name(move(collation_name))
, m_order(order)
@ -266,13 +266,13 @@ public:
}
NonnullRefPtr<Expression> const& expression() const { return m_expression; }
DeprecatedString const& collation_name() const { return m_collation_name; }
ByteString 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;
DeprecatedString m_collation_name;
ByteString m_collation_name;
Order m_order;
Nulls m_nulls;
};
@ -331,29 +331,29 @@ private:
class StringLiteral : public Expression {
public:
explicit StringLiteral(DeprecatedString value)
explicit StringLiteral(ByteString value)
: m_value(move(value))
{
}
DeprecatedString const& value() const { return m_value; }
ByteString const& value() const { return m_value; }
virtual ResultOr<Value> evaluate(ExecutionContext&) const override;
private:
DeprecatedString m_value;
ByteString m_value;
};
class BlobLiteral : public Expression {
public:
explicit BlobLiteral(DeprecatedString value)
explicit BlobLiteral(ByteString value)
: m_value(move(value))
{
}
DeprecatedString const& value() const { return m_value; }
ByteString const& value() const { return m_value; }
private:
DeprecatedString m_value;
ByteString m_value;
};
class BooleanLiteral : public Expression {
@ -455,22 +455,22 @@ private:
class ColumnNameExpression : public Expression {
public:
ColumnNameExpression(DeprecatedString schema_name, DeprecatedString table_name, DeprecatedString column_name)
ColumnNameExpression(ByteString schema_name, ByteString table_name, ByteString column_name)
: m_schema_name(move(schema_name))
, m_table_name(move(table_name))
, m_column_name(move(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; }
ByteString const& schema_name() const { return m_schema_name; }
ByteString const& table_name() const { return m_table_name; }
ByteString const& column_name() const { return m_column_name; }
virtual ResultOr<Value> evaluate(ExecutionContext&) const override;
private:
DeprecatedString m_schema_name;
DeprecatedString m_table_name;
DeprecatedString m_column_name;
ByteString m_schema_name;
ByteString m_table_name;
ByteString m_column_name;
};
#define __enum_UnaryOperator(S) \
@ -641,16 +641,16 @@ private:
class CollateExpression : public NestedExpression {
public:
CollateExpression(NonnullRefPtr<Expression> expression, DeprecatedString collation_name)
CollateExpression(NonnullRefPtr<Expression> expression, ByteString collation_name)
: NestedExpression(move(expression))
, m_collation_name(move(collation_name))
{
}
DeprecatedString const& collation_name() const { return m_collation_name; }
ByteString const& collation_name() const { return m_collation_name; }
private:
DeprecatedString m_collation_name;
ByteString m_collation_name;
};
enum class MatchOperator {
@ -738,19 +738,19 @@ private:
class InTableExpression : public InvertibleNestedExpression {
public:
InTableExpression(NonnullRefPtr<Expression> expression, DeprecatedString schema_name, DeprecatedString table_name, bool invert_expression)
InTableExpression(NonnullRefPtr<Expression> expression, ByteString schema_name, ByteString table_name, bool invert_expression)
: InvertibleNestedExpression(move(expression), invert_expression)
, m_schema_name(move(schema_name))
, m_table_name(move(table_name))
{
}
DeprecatedString const& schema_name() const { return m_schema_name; }
DeprecatedString const& table_name() const { return m_table_name; }
ByteString const& schema_name() const { return m_schema_name; }
ByteString const& table_name() const { return m_table_name; }
private:
DeprecatedString m_schema_name;
DeprecatedString m_table_name;
ByteString m_schema_name;
ByteString m_table_name;
};
//==================================================================================================
@ -772,25 +772,25 @@ class ErrorStatement final : public Statement {
class CreateSchema : public Statement {
public:
CreateSchema(DeprecatedString schema_name, bool is_error_if_schema_exists)
CreateSchema(ByteString 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)
{
}
DeprecatedString const& schema_name() const { return m_schema_name; }
ByteString 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:
DeprecatedString m_schema_name;
ByteString m_schema_name;
bool m_is_error_if_schema_exists;
};
class CreateTable : public Statement {
public:
CreateTable(DeprecatedString schema_name, DeprecatedString table_name, RefPtr<Select> select_statement, bool is_temporary, bool is_error_if_table_exists)
CreateTable(ByteString schema_name, ByteString 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))
@ -799,7 +799,7 @@ public:
{
}
CreateTable(DeprecatedString schema_name, DeprecatedString table_name, Vector<NonnullRefPtr<ColumnDefinition>> columns, bool is_temporary, bool is_error_if_table_exists)
CreateTable(ByteString schema_name, ByteString table_name, Vector<NonnullRefPtr<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))
@ -808,8 +808,8 @@ public:
{
}
DeprecatedString const& schema_name() const { return m_schema_name; }
DeprecatedString const& table_name() const { return m_table_name; }
ByteString const& schema_name() const { return m_schema_name; }
ByteString 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; }
@ -823,8 +823,8 @@ public:
ResultOr<ResultSet> execute(ExecutionContext&) const override;
private:
DeprecatedString m_schema_name;
DeprecatedString m_table_name;
ByteString m_schema_name;
ByteString m_table_name;
RefPtr<Select> m_select_statement;
Vector<NonnullRefPtr<ColumnDefinition>> m_columns;
bool m_is_temporary;
@ -833,55 +833,55 @@ private:
class AlterTable : public Statement {
public:
DeprecatedString const& schema_name() const { return m_schema_name; }
DeprecatedString const& table_name() const { return m_table_name; }
ByteString const& schema_name() const { return m_schema_name; }
ByteString const& table_name() const { return m_table_name; }
protected:
AlterTable(DeprecatedString schema_name, DeprecatedString table_name)
AlterTable(ByteString schema_name, ByteString table_name)
: m_schema_name(move(schema_name))
, m_table_name(move(table_name))
{
}
private:
DeprecatedString m_schema_name;
DeprecatedString m_table_name;
ByteString m_schema_name;
ByteString m_table_name;
};
class RenameTable : public AlterTable {
public:
RenameTable(DeprecatedString schema_name, DeprecatedString table_name, DeprecatedString new_table_name)
RenameTable(ByteString schema_name, ByteString table_name, ByteString new_table_name)
: AlterTable(move(schema_name), move(table_name))
, m_new_table_name(move(new_table_name))
{
}
DeprecatedString const& new_table_name() const { return m_new_table_name; }
ByteString const& new_table_name() const { return m_new_table_name; }
private:
DeprecatedString m_new_table_name;
ByteString m_new_table_name;
};
class RenameColumn : public AlterTable {
public:
RenameColumn(DeprecatedString schema_name, DeprecatedString table_name, DeprecatedString column_name, DeprecatedString new_column_name)
RenameColumn(ByteString schema_name, ByteString table_name, ByteString column_name, ByteString new_column_name)
: AlterTable(move(schema_name), move(table_name))
, m_column_name(move(column_name))
, m_new_column_name(move(new_column_name))
{
}
DeprecatedString const& column_name() const { return m_column_name; }
DeprecatedString const& new_column_name() const { return m_new_column_name; }
ByteString const& column_name() const { return m_column_name; }
ByteString const& new_column_name() const { return m_new_column_name; }
private:
DeprecatedString m_column_name;
DeprecatedString m_new_column_name;
ByteString m_column_name;
ByteString m_new_column_name;
};
class AddColumn : public AlterTable {
public:
AddColumn(DeprecatedString schema_name, DeprecatedString table_name, NonnullRefPtr<ColumnDefinition> column)
AddColumn(ByteString schema_name, ByteString table_name, NonnullRefPtr<ColumnDefinition> column)
: AlterTable(move(schema_name), move(table_name))
, m_column(move(column))
{
@ -895,34 +895,34 @@ private:
class DropColumn : public AlterTable {
public:
DropColumn(DeprecatedString schema_name, DeprecatedString table_name, DeprecatedString column_name)
DropColumn(ByteString schema_name, ByteString table_name, ByteString column_name)
: AlterTable(move(schema_name), move(table_name))
, m_column_name(move(column_name))
{
}
DeprecatedString const& column_name() const { return m_column_name; }
ByteString const& column_name() const { return m_column_name; }
private:
DeprecatedString m_column_name;
ByteString m_column_name;
};
class DropTable : public Statement {
public:
DropTable(DeprecatedString schema_name, DeprecatedString table_name, bool is_error_if_table_does_not_exist)
DropTable(ByteString schema_name, ByteString 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)
{
}
DeprecatedString const& schema_name() const { return m_schema_name; }
DeprecatedString const& table_name() const { return m_table_name; }
ByteString const& schema_name() const { return m_schema_name; }
ByteString 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:
DeprecatedString m_schema_name;
DeprecatedString m_table_name;
ByteString m_schema_name;
ByteString m_table_name;
bool m_is_error_if_table_does_not_exist;
};
@ -936,7 +936,7 @@ enum class ConflictResolution {
class Insert : public Statement {
public:
Insert(RefPtr<CommonTableExpressionList> common_table_expression_list, ConflictResolution conflict_resolution, DeprecatedString schema_name, DeprecatedString table_name, DeprecatedString alias, Vector<DeprecatedString> column_names, Vector<NonnullRefPtr<ChainedExpression>> chained_expressions)
Insert(RefPtr<CommonTableExpressionList> common_table_expression_list, ConflictResolution conflict_resolution, ByteString schema_name, ByteString table_name, ByteString alias, Vector<ByteString> column_names, Vector<NonnullRefPtr<ChainedExpression>> chained_expressions)
: m_common_table_expression_list(move(common_table_expression_list))
, m_conflict_resolution(conflict_resolution)
, m_schema_name(move(schema_name))
@ -947,7 +947,7 @@ public:
{
}
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)
Insert(RefPtr<CommonTableExpressionList> common_table_expression_list, ConflictResolution conflict_resolution, ByteString schema_name, ByteString table_name, ByteString alias, Vector<ByteString> 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))
@ -958,7 +958,7 @@ public:
{
}
Insert(RefPtr<CommonTableExpressionList> common_table_expression_list, ConflictResolution conflict_resolution, DeprecatedString schema_name, DeprecatedString table_name, DeprecatedString alias, Vector<DeprecatedString> column_names)
Insert(RefPtr<CommonTableExpressionList> common_table_expression_list, ConflictResolution conflict_resolution, ByteString schema_name, ByteString table_name, ByteString alias, Vector<ByteString> column_names)
: m_common_table_expression_list(move(common_table_expression_list))
, m_conflict_resolution(conflict_resolution)
, m_schema_name(move(schema_name))
@ -970,10 +970,10 @@ public:
RefPtr<CommonTableExpressionList> const& common_table_expression_list() const { return m_common_table_expression_list; }
ConflictResolution conflict_resolution() const { return m_conflict_resolution; }
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; }
ByteString const& schema_name() const { return m_schema_name; }
ByteString const& table_name() const { return m_table_name; }
ByteString const& alias() const { return m_alias; }
Vector<ByteString> const& column_names() const { return m_column_names; }
bool default_values() const { return !has_expressions() && !has_selection(); }
@ -988,10 +988,10 @@ public:
private:
RefPtr<CommonTableExpressionList> m_common_table_expression_list;
ConflictResolution m_conflict_resolution;
DeprecatedString m_schema_name;
DeprecatedString m_table_name;
DeprecatedString m_alias;
Vector<DeprecatedString> m_column_names;
ByteString m_schema_name;
ByteString m_table_name;
ByteString m_alias;
Vector<ByteString> m_column_names;
Vector<NonnullRefPtr<ChainedExpression>> m_chained_expressions;
RefPtr<Select> m_select_statement;
};
@ -999,7 +999,7 @@ private:
class Update : public Statement {
public:
struct UpdateColumns {
Vector<DeprecatedString> column_names;
Vector<ByteString> column_names;
NonnullRefPtr<Expression> expression;
};

View file

@ -68,9 +68,9 @@ ResultOr<Value> BinaryOperatorExpression::evaluate(ExecutionContext& context) co
return Result { SQLCommand::Unknown, SQLErrorCode::BooleanOperatorTypeMismatch, BinaryOperator_name(type()) };
AK::StringBuilder builder;
builder.append(lhs_value.to_deprecated_string());
builder.append(rhs_value.to_deprecated_string());
return Value(builder.to_deprecated_string());
builder.append(lhs_value.to_byte_string());
builder.append(rhs_value.to_byte_string());
return Value(builder.to_byte_string());
}
case BinaryOperator::Multiplication:
return lhs_value.multiply(rhs_value);
@ -181,7 +181,7 @@ ResultOr<Value> MatchExpression::evaluate(ExecutionContext& context) const
char escape_char = '\0';
if (escape()) {
auto escape_str = TRY(escape()->evaluate(context)).to_deprecated_string();
auto escape_str = TRY(escape()->evaluate(context)).to_byte_string();
if (escape_str.length() != 1)
return Result { SQLCommand::Unknown, SQLErrorCode::SyntaxError, "ESCAPE should be a single character" };
escape_char = escape_str[0];
@ -192,7 +192,7 @@ ResultOr<Value> MatchExpression::evaluate(ExecutionContext& context) const
bool escaped = false;
AK::StringBuilder builder;
builder.append('^');
for (auto c : rhs_value.to_deprecated_string()) {
for (auto c : rhs_value.to_byte_string()) {
if (escape() && c == escape_char && !escaped) {
escaped = true;
} else if (s_posix_basic_metacharacters.contains(c)) {
@ -211,25 +211,25 @@ ResultOr<Value> MatchExpression::evaluate(ExecutionContext& context) const
builder.append('$');
// FIXME: We should probably cache this regex.
auto regex = Regex<PosixBasic>(builder.to_deprecated_string());
auto result = regex.match(lhs_value.to_deprecated_string(), PosixFlags::Insensitive | PosixFlags::Unicode);
auto regex = Regex<PosixBasic>(builder.to_byte_string());
auto result = regex.match(lhs_value.to_byte_string(), PosixFlags::Insensitive | PosixFlags::Unicode);
return Value(invert_expression() ? !result.success : result.success);
}
case MatchOperator::Regexp: {
Value lhs_value = TRY(lhs()->evaluate(context));
Value rhs_value = TRY(rhs()->evaluate(context));
auto regex = Regex<PosixExtended>(rhs_value.to_deprecated_string());
auto regex = Regex<PosixExtended>(rhs_value.to_byte_string());
auto err = regex.parser_result.error;
if (err != regex::Error::NoError) {
StringBuilder builder;
builder.append("Regular expression: "sv);
builder.append(get_error_string(err));
return Result { SQLCommand::Unknown, SQLErrorCode::SyntaxError, builder.to_deprecated_string() };
return Result { SQLCommand::Unknown, SQLErrorCode::SyntaxError, builder.to_byte_string() };
}
auto result = regex.match(lhs_value.to_deprecated_string(), PosixFlags::Insensitive | PosixFlags::Unicode);
auto result = regex.match(lhs_value.to_byte_string(), PosixFlags::Insensitive | PosixFlags::Unicode);
return Value(invert_expression() ? !result.success : result.success);
}
case MatchOperator::Glob:

View file

@ -37,7 +37,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, DeprecatedString::empty() };
return Result { SQLCommand::Insert, SQLErrorCode::InvalidNumberOfValues, ByteString::empty() };
for (auto ix = 0u; ix < values.size(); ix++) {
auto& tuple_descriptor = *row.descriptor();

View file

@ -11,9 +11,9 @@
namespace SQL::AST {
HashMap<DeprecatedString, TokenType> Lexer::s_keywords;
HashMap<ByteString, TokenType> Lexer::s_keywords;
HashMap<char, TokenType> Lexer::s_one_char_tokens;
HashMap<DeprecatedString, TokenType> Lexer::s_two_char_tokens;
HashMap<ByteString, TokenType> Lexer::s_two_char_tokens;
Lexer::Lexer(StringView source)
: m_source(source)
@ -109,7 +109,7 @@ Token Lexer::next()
}
}
Token token(token_type, current_token.to_deprecated_string(),
Token token(token_type, current_token.to_byte_string(),
{ value_start_line_number, value_start_column_number },
{ m_line_number, m_line_column });

View file

@ -8,7 +8,7 @@
#pragma once
#include "Token.h"
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/HashMap.h>
#include <AK/StringView.h>
@ -46,9 +46,9 @@ private:
bool is_line_break() const;
bool is_eof() const;
static HashMap<DeprecatedString, TokenType> s_keywords;
static HashMap<ByteString, TokenType> s_keywords;
static HashMap<char, TokenType> s_one_char_tokens;
static HashMap<DeprecatedString, TokenType> s_two_char_tokens;
static HashMap<ByteString, TokenType> s_two_char_tokens;
StringView m_source;
size_t m_line_number { 1 };

View file

@ -91,7 +91,7 @@ NonnullRefPtr<CreateSchema> Parser::parse_create_schema_statement()
is_error_if_exists = false;
}
DeprecatedString schema_name = consume(TokenType::Identifier).value();
ByteString 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;
}
DeprecatedString schema_name;
DeprecatedString table_name;
ByteString schema_name;
ByteString 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);
DeprecatedString schema_name;
DeprecatedString table_name;
ByteString schema_name;
ByteString 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;
}
DeprecatedString schema_name;
DeprecatedString table_name;
ByteString schema_name;
ByteString 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);
DeprecatedString schema_name;
DeprecatedString table_name;
ByteString schema_name;
ByteString table_name;
parse_schema_and_table_name(schema_name, table_name);
DeprecatedString alias;
ByteString alias;
if (consume_if(TokenType::As))
alias = consume(TokenType::Identifier).value();
Vector<DeprecatedString> column_names;
Vector<ByteString> 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<DeprecatedString> column_names;
Vector<ByteString> 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(DeprecatedString::formatted("Exceeded maximum expression tree depth of {}", Limits::maximum_expression_tree_depth));
syntax_error(ByteString::formatted("Exceeded maximum expression tree depth of {}", Limits::maximum_expression_tree_depth));
return create_ast_node<ErrorExpression>();
}
@ -558,7 +558,7 @@ RefPtr<Expression> Parser::parse_bind_parameter_expression()
if (consume_if(TokenType::Placeholder)) {
auto parameter = m_parser_state.m_bound_parameters;
if (++m_parser_state.m_bound_parameters > Limits::maximum_bound_parameters)
syntax_error(DeprecatedString::formatted("Exceeded maximum number of bound parameters {}", Limits::maximum_bound_parameters));
syntax_error(ByteString::formatted("Exceeded maximum number of bound parameters {}", Limits::maximum_bound_parameters));
return create_ast_node<Placeholder>(parameter);
}
@ -566,23 +566,23 @@ RefPtr<Expression> Parser::parse_bind_parameter_expression()
return {};
}
RefPtr<Expression> Parser::parse_column_name_expression(Optional<DeprecatedString> with_parsed_identifier, bool with_parsed_period)
RefPtr<Expression> Parser::parse_column_name_expression(Optional<ByteString> with_parsed_identifier, bool with_parsed_period)
{
if (!with_parsed_identifier.has_value() && !match(TokenType::Identifier))
return {};
DeprecatedString first_identifier;
ByteString first_identifier;
if (!with_parsed_identifier.has_value())
first_identifier = consume(TokenType::Identifier).value();
else
first_identifier = with_parsed_identifier.release_value();
DeprecatedString schema_name;
DeprecatedString table_name;
DeprecatedString column_name;
ByteString schema_name;
ByteString table_name;
ByteString column_name;
if (with_parsed_period || consume_if(TokenType::Period)) {
DeprecatedString second_identifier = consume(TokenType::Identifier).value();
ByteString second_identifier = consume(TokenType::Identifier).value();
if (consume_if(TokenType::Period)) {
schema_name = move(first_identifier);
@ -762,7 +762,7 @@ RefPtr<Expression> Parser::parse_collate_expression(NonnullRefPtr<Expression> ex
return {};
consume();
DeprecatedString collation_name = consume(TokenType::Identifier).value();
ByteString collation_name = consume(TokenType::Identifier).value();
return create_ast_node<CollateExpression>(move(expression), move(collation_name));
}
@ -879,8 +879,8 @@ RefPtr<Expression> Parser::parse_in_expression(NonnullRefPtr<Expression> express
return create_ast_node<InChainedExpression>(move(expression), move(chain), invert_expression);
}
DeprecatedString schema_name;
DeprecatedString table_name;
ByteString schema_name;
ByteString table_name;
parse_schema_and_table_name(schema_name, table_name);
if (match(TokenType::ParenOpen)) {
@ -948,7 +948,7 @@ NonnullRefPtr<CommonTableExpression> Parser::parse_common_table_expression()
// https://sqlite.org/syntax/common-table-expression.html
auto table_name = consume(TokenType::Identifier).value();
Vector<DeprecatedString> column_names;
Vector<ByteString> column_names;
if (match(TokenType::ParenOpen))
parse_comma_separated_list(true, [&]() { column_names.append(consume(TokenType::Identifier).value()); });
@ -963,11 +963,11 @@ NonnullRefPtr<CommonTableExpression> Parser::parse_common_table_expression()
NonnullRefPtr<QualifiedTableName> Parser::parse_qualified_table_name()
{
// https://sqlite.org/syntax/qualified-table-name.html
DeprecatedString schema_name;
DeprecatedString table_name;
ByteString schema_name;
ByteString table_name;
parse_schema_and_table_name(schema_name, table_name);
DeprecatedString alias;
ByteString alias;
if (consume_if(TokenType::As))
alias = consume(TokenType::Identifier).value();
@ -991,7 +991,7 @@ NonnullRefPtr<ReturningClause> Parser::parse_returning_clause()
parse_comma_separated_list(false, [&]() {
auto expression = parse_expression();
DeprecatedString column_alias;
ByteString column_alias;
if (consume_if(TokenType::As) || match(TokenType::Identifier))
column_alias = consume(TokenType::Identifier).value();
@ -1010,7 +1010,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.
Optional<DeprecatedString> table_name;
Optional<ByteString> table_name;
bool parsed_period = false;
if (match(TokenType::Identifier)) {
@ -1024,7 +1024,7 @@ NonnullRefPtr<ResultColumn> Parser::parse_result_column()
? parse_expression()
: static_cast<NonnullRefPtr<Expression>>(*parse_column_name_expression(move(table_name), parsed_period));
DeprecatedString column_alias;
ByteString column_alias;
if (consume_if(TokenType::As) || match(TokenType::Identifier))
column_alias = consume(TokenType::Identifier).value();
@ -1034,17 +1034,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(DeprecatedString::formatted("Exceeded maximum subquery depth of {}", Limits::maximum_subquery_depth));
syntax_error(ByteString::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)) {
DeprecatedString schema_name;
DeprecatedString table_name;
ByteString schema_name;
ByteString table_name;
parse_schema_and_table_name(schema_name, table_name);
DeprecatedString table_alias;
ByteString table_alias;
if (consume_if(TokenType::As) || match(TokenType::Identifier))
table_alias = consume(TokenType::Identifier).value();
@ -1064,7 +1064,7 @@ NonnullRefPtr<OrderingTerm> Parser::parse_ordering_term()
// https://sqlite.org/syntax/ordering-term.html
auto expression = parse_expression();
DeprecatedString collation_name;
ByteString collation_name;
if (is<CollateExpression>(*expression)) {
auto const& collate = static_cast<CollateExpression const&>(*expression);
collation_name = collate.collation_name();
@ -1089,9 +1089,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(DeprecatedString& schema_name, DeprecatedString& table_name)
void Parser::parse_schema_and_table_name(ByteString& schema_name, ByteString& table_name)
{
DeprecatedString schema_or_table_name = consume(TokenType::Identifier).value();
ByteString schema_or_table_name = consume(TokenType::Identifier).value();
if (consume_if(TokenType::Period)) {
schema_name = move(schema_or_table_name);
@ -1153,10 +1153,10 @@ bool Parser::match(TokenType type) const
void Parser::expected(StringView what)
{
syntax_error(DeprecatedString::formatted("Unexpected token {}, expected {}", m_parser_state.m_token.name(), what));
syntax_error(ByteString::formatted("Unexpected token {}, expected {}", m_parser_state.m_token.name(), what));
}
void Parser::syntax_error(DeprecatedString message)
void Parser::syntax_error(ByteString message)
{
m_parser_state.m_errors.append({ move(message), position() });
}

View file

@ -7,7 +7,7 @@
#pragma once
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/StringView.h>
#include <LibSQL/AST/AST.h>
#include <LibSQL/AST/Lexer.h>
@ -24,12 +24,12 @@ constexpr size_t maximum_bound_parameters = 1000;
class Parser {
struct Error {
DeprecatedString message;
ByteString message;
SourcePosition position;
DeprecatedString to_deprecated_string() const
ByteString to_byte_string() const
{
return DeprecatedString::formatted("{} (line: {}, column: {})", message, position.line, position.column);
return ByteString::formatted("{} (line: {}, column: {})", message, position.line, position.column);
}
};
@ -74,7 +74,7 @@ private:
bool match_secondary_expression() const;
RefPtr<Expression> parse_literal_value_expression();
RefPtr<Expression> parse_bind_parameter_expression();
RefPtr<Expression> parse_column_name_expression(Optional<DeprecatedString> with_parsed_identifier = {}, bool with_parsed_period = false);
RefPtr<Expression> parse_column_name_expression(Optional<ByteString> 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(bool surrounded_by_parentheses = true);
@ -97,7 +97,7 @@ private:
NonnullRefPtr<ResultColumn> parse_result_column();
NonnullRefPtr<TableOrSubquery> parse_table_or_subquery();
NonnullRefPtr<OrderingTerm> parse_ordering_term();
void parse_schema_and_table_name(DeprecatedString& schema_name, DeprecatedString& table_name);
void parse_schema_and_table_name(ByteString& schema_name, ByteString& table_name);
ConflictResolution parse_conflict_resolution();
template<typename ParseCallback>
@ -125,7 +125,7 @@ private:
bool match(TokenType type) const;
void expected(StringView what);
void syntax_error(DeprecatedString message);
void syntax_error(ByteString message);
SourcePosition position() const;

View file

@ -12,10 +12,10 @@
namespace SQL::AST {
static DeprecatedString result_column_name(ResultColumn const& column, size_t column_index)
static ByteString result_column_name(ResultColumn const& column, size_t column_index)
{
auto fallback_column_name = [column_index]() {
return DeprecatedString::formatted("Column{}", column_index);
return ByteString::formatted("Column{}", column_index);
};
if (auto const& alias = column.column_alias(); !alias.is_empty())
@ -40,7 +40,7 @@ static DeprecatedString result_column_name(ResultColumn const& column, size_t co
ResultOr<ResultSet> Select::execute(ExecutionContext& context) const
{
Vector<NonnullRefPtr<ResultColumn const>> columns;
Vector<DeprecatedString> column_names;
Vector<ByteString> column_names;
auto const& result_column_list = this->result_column_list();
VERIFY(!result_column_list.is_empty());

View file

@ -6,7 +6,7 @@
#include "Token.h"
#include <AK/Assertions.h>
#include <AK/DeprecatedString.h>
#include <AK/ByteString.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);
DeprecatedString value(m_value);
ByteString value(m_value);
if (value[0] == '0' && value.length() >= 2) {
if (value[1] == 'x' || value[1] == 'X')

View file

@ -8,7 +8,7 @@
#pragma once
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/HashMap.h>
#include <AK/StringView.h>
@ -224,7 +224,7 @@ struct SourcePosition {
class Token {
public:
Token(TokenType type, DeprecatedString value, SourcePosition start_position, SourcePosition end_position)
Token(TokenType type, ByteString value, SourcePosition start_position, SourcePosition end_position)
: m_type(type)
, m_value(move(value))
, m_start_position(start_position)
@ -239,7 +239,7 @@ public:
TokenType type() const { return m_type; }
TokenCategory category() const { return category(m_type); }
DeprecatedString const& value() const { return m_value; }
ByteString const& value() const { return m_value; }
double double_value() const;
SourcePosition const& start_position() const { return m_start_position; }
@ -247,7 +247,7 @@ public:
private:
TokenType m_type;
DeprecatedString m_value;
ByteString m_value;
SourcePosition m_start_position;
SourcePosition m_end_position;
};

View file

@ -6,7 +6,7 @@
#pragma once
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/Function.h>
#include <AK/NonnullRefPtr.h>
#include <AK/Optional.h>
@ -75,7 +75,7 @@ public:
private:
TreeNode(BTree&, TreeNode*, DownPointer&, u32 = 0);
void dump_if(int, DeprecatedString&& = "");
void dump_if(int, ByteString&& = "");
bool insert_in_leaf(Key const&);
void just_insert(Key const&, TreeNode* = nullptr);
void split();

View file

@ -5,7 +5,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <LibSQL/BTree.h>
#include <LibSQL/Database.h>
#include <LibSQL/Heap.h>
@ -15,7 +15,7 @@
namespace SQL {
ErrorOr<NonnullRefPtr<Database>> Database::create(DeprecatedString name)
ErrorOr<NonnullRefPtr<Database>> Database::create(ByteString name)
{
auto heap = TRY(Heap::create(move(name)));
return adopt_nonnull_ref_or_enomem(new (nothrow) Database(move(heap)));
@ -96,14 +96,14 @@ ResultOr<void> Database::add_schema(SchemaDef const& schema)
return {};
}
Key Database::get_schema_key(DeprecatedString const& schema_name)
Key Database::get_schema_key(ByteString const& schema_name)
{
auto key = SchemaDef::make_key();
key["schema_name"] = schema_name;
return key;
}
ResultOr<NonnullRefPtr<SchemaDef>> Database::get_schema(DeprecatedString const& schema)
ResultOr<NonnullRefPtr<SchemaDef>> Database::get_schema(ByteString const& schema)
{
VERIFY(is_open());
@ -139,14 +139,14 @@ ResultOr<void> Database::add_table(TableDef& table)
return {};
}
Key Database::get_table_key(DeprecatedString const& schema_name, DeprecatedString const& table_name)
Key Database::get_table_key(ByteString const& schema_name, ByteString 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(DeprecatedString const& schema, DeprecatedString const& name)
ResultOr<NonnullRefPtr<TableDef>> Database::get_table(ByteString const& schema, ByteString const& name)
{
VERIFY(is_open());
@ -160,7 +160,7 @@ ResultOr<NonnullRefPtr<TableDef>> Database::get_table(DeprecatedString const& sc
auto table_iterator = m_tables->find(key);
if (table_iterator.is_end() || (*table_iterator != key))
return Result { SQLCommand::Unknown, SQLErrorCode::TableDoesNotExist, DeprecatedString::formatted("{}.{}", schema_name, name) };
return Result { SQLCommand::Unknown, SQLErrorCode::TableDoesNotExist, ByteString::formatted("{}.{}", schema_name, name) };
auto schema_def = TRY(get_schema(schema));
auto table_def = TRY(TableDef::create(schema_def, name));

View file

@ -7,7 +7,7 @@
#pragma once
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/NonnullRefPtr.h>
#include <AK/RefPtr.h>
#include <LibSQL/Forward.h>
@ -25,7 +25,7 @@ namespace SQL {
*/
class Database : public RefCounted<Database> {
public:
static ErrorOr<NonnullRefPtr<Database>> create(DeprecatedString);
static ErrorOr<NonnullRefPtr<Database>> create(ByteString);
~Database();
ResultOr<void> open();
@ -34,12 +34,12 @@ public:
ErrorOr<size_t> file_size_in_bytes() const { return m_heap->file_size_in_bytes(); }
ResultOr<void> add_schema(SchemaDef const&);
static Key get_schema_key(DeprecatedString const&);
ResultOr<NonnullRefPtr<SchemaDef>> get_schema(DeprecatedString const&);
static Key get_schema_key(ByteString const&);
ResultOr<NonnullRefPtr<SchemaDef>> get_schema(ByteString const&);
ResultOr<void> add_table(TableDef& table);
static Key get_table_key(DeprecatedString const&, DeprecatedString const&);
ResultOr<NonnullRefPtr<TableDef>> get_table(DeprecatedString const&, DeprecatedString const&);
static Key get_table_key(ByteString const&, ByteString const&);
ResultOr<NonnullRefPtr<TableDef>> get_table(ByteString const&, ByteString const&);
ErrorOr<Vector<Row>> select_all(TableDef&);
ErrorOr<Vector<Row>> match(TableDef&, Key const&);

View file

@ -5,7 +5,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/Format.h>
#include <AK/QuickSort.h>
#include <LibCore/System.h>
@ -14,12 +14,12 @@
namespace SQL {
ErrorOr<NonnullRefPtr<Heap>> Heap::create(DeprecatedString file_name)
ErrorOr<NonnullRefPtr<Heap>> Heap::create(ByteString file_name)
{
return adopt_nonnull_ref_or_enomem(new (nothrow) Heap(move(file_name)));
}
Heap::Heap(DeprecatedString file_name)
Heap::Heap(ByteString file_name)
: m_name(move(file_name))
{
}

View file

@ -8,8 +8,8 @@
#pragma once
#include <AK/Array.h>
#include <AK/ByteString.h>
#include <AK/Debug.h>
#include <AK/DeprecatedString.h>
#include <AK/HashMap.h>
#include <AK/RefCounted.h>
#include <AK/Vector.h>
@ -68,10 +68,10 @@ class Heap : public RefCounted<Heap> {
public:
static constexpr u32 VERSION = 4;
static ErrorOr<NonnullRefPtr<Heap>> create(DeprecatedString);
static ErrorOr<NonnullRefPtr<Heap>> create(ByteString);
virtual ~Heap();
DeprecatedString const& name() const { return m_name; }
ByteString const& name() const { return m_name; }
ErrorOr<void> open();
ErrorOr<size_t> file_size_in_bytes() const;
@ -122,7 +122,7 @@ public:
ErrorOr<void> flush();
private:
explicit Heap(DeprecatedString);
explicit Heap(ByteString);
ErrorOr<ByteBuffer> read_raw_block(Block::Index);
ErrorOr<void> write_raw_block(Block::Index, ReadonlyBytes);
@ -136,7 +136,7 @@ private:
ErrorOr<void> initialize_zero_block();
ErrorOr<void> update_zero_block();
DeprecatedString m_name;
ByteString m_name;
OwnPtr<Core::InputBufferedFile> m_file;
Block::Index m_highest_block_written { 0 };

View file

@ -15,17 +15,17 @@ u32 Relation::hash() const
return key().hash();
}
ErrorOr<NonnullRefPtr<SchemaDef>> SchemaDef::create(DeprecatedString name)
ErrorOr<NonnullRefPtr<SchemaDef>> SchemaDef::create(ByteString name)
{
return adopt_nonnull_ref_or_enomem(new (nothrow) SchemaDef(move(name)));
}
ErrorOr<NonnullRefPtr<SchemaDef>> SchemaDef::create(Key const& key)
{
return create(key["schema_name"].to_deprecated_string());
return create(key["schema_name"].to_byte_string());
}
SchemaDef::SchemaDef(DeprecatedString name)
SchemaDef::SchemaDef(ByteString name)
: Relation(move(name))
{
}
@ -52,12 +52,12 @@ NonnullRefPtr<IndexDef> SchemaDef::index_def()
return s_index_def;
}
ErrorOr<NonnullRefPtr<ColumnDef>> ColumnDef::create(Relation* parent, size_t column_number, DeprecatedString name, SQLType sql_type)
ErrorOr<NonnullRefPtr<ColumnDef>> ColumnDef::create(Relation* parent, size_t column_number, ByteString name, SQLType sql_type)
{
return adopt_nonnull_ref_or_enomem(new (nothrow) ColumnDef(parent, column_number, move(name), sql_type));
}
ColumnDef::ColumnDef(Relation* parent, size_t column_number, DeprecatedString name, SQLType sql_type)
ColumnDef::ColumnDef(Relation* parent, size_t column_number, ByteString name, SQLType sql_type)
: Relation(move(name), parent)
, m_index(column_number)
, m_type(sql_type)
@ -100,35 +100,35 @@ NonnullRefPtr<IndexDef> ColumnDef::index_def()
return s_index_def;
}
ErrorOr<NonnullRefPtr<KeyPartDef>> KeyPartDef::create(IndexDef* index, DeprecatedString name, SQLType sql_type, Order sort_order)
ErrorOr<NonnullRefPtr<KeyPartDef>> KeyPartDef::create(IndexDef* index, ByteString name, SQLType sql_type, Order sort_order)
{
return adopt_nonnull_ref_or_enomem(new (nothrow) KeyPartDef(index, move(name), sql_type, sort_order));
}
KeyPartDef::KeyPartDef(IndexDef* index, DeprecatedString name, SQLType sql_type, Order sort_order)
KeyPartDef::KeyPartDef(IndexDef* index, ByteString name, SQLType sql_type, Order sort_order)
: ColumnDef(index, index->size(), move(name), sql_type)
, m_sort_order(sort_order)
{
}
ErrorOr<NonnullRefPtr<IndexDef>> IndexDef::create(TableDef* table, DeprecatedString name, bool unique, u32 pointer)
ErrorOr<NonnullRefPtr<IndexDef>> IndexDef::create(TableDef* table, ByteString name, bool unique, u32 pointer)
{
return adopt_nonnull_ref_or_enomem(new (nothrow) IndexDef(table, move(name), unique, pointer));
}
ErrorOr<NonnullRefPtr<IndexDef>> IndexDef::create(DeprecatedString name, bool unique, u32 pointer)
ErrorOr<NonnullRefPtr<IndexDef>> IndexDef::create(ByteString name, bool unique, u32 pointer)
{
return create(nullptr, move(name), unique, pointer);
}
IndexDef::IndexDef(TableDef* table, DeprecatedString name, bool unique, u32 pointer)
IndexDef::IndexDef(TableDef* table, ByteString name, bool unique, u32 pointer)
: Relation(move(name), pointer, table)
, m_key_definition()
, m_unique(unique)
{
}
void IndexDef::append_column(DeprecatedString name, SQLType sql_type, Order sort_order)
void IndexDef::append_column(ByteString name, SQLType sql_type, Order sort_order)
{
auto part = KeyPartDef::create(this, move(name), sql_type, sort_order).release_value_but_fixme_should_propagate_errors();
m_key_definition.append(part);
@ -170,12 +170,12 @@ NonnullRefPtr<IndexDef> IndexDef::index_def()
return s_index_def;
}
ErrorOr<NonnullRefPtr<TableDef>> TableDef::create(SchemaDef* schema, DeprecatedString name)
ErrorOr<NonnullRefPtr<TableDef>> TableDef::create(SchemaDef* schema, ByteString name)
{
return adopt_nonnull_ref_or_enomem(new (nothrow) TableDef(schema, move(name)));
}
TableDef::TableDef(SchemaDef* schema, DeprecatedString name)
TableDef::TableDef(SchemaDef* schema, ByteString name)
: Relation(move(name), schema)
, m_columns()
, m_indexes()
@ -200,7 +200,7 @@ Key TableDef::key() const
return key;
}
void TableDef::append_column(DeprecatedString name, SQLType sql_type)
void TableDef::append_column(ByteString name, SQLType sql_type)
{
auto column = ColumnDef::create(this, num_columns(), move(name), sql_type).release_value_but_fixme_should_propagate_errors();
m_columns.append(column);
@ -211,7 +211,7 @@ void TableDef::append_column(Key const& column)
auto column_type = column["column_type"].to_int<UnderlyingType<SQLType>>();
VERIFY(column_type.has_value());
append_column(column["column_name"].to_deprecated_string(), static_cast<SQLType>(*column_type));
append_column(column["column_name"].to_byte_string(), static_cast<SQLType>(*column_type));
}
Key TableDef::make_key(SchemaDef const& schema_def)

View file

@ -6,7 +6,7 @@
#pragma once
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/NonnullRefPtr.h>
#include <AK/RefCounted.h>
#include <AK/Result.h>
@ -28,7 +28,7 @@ class Relation : public RefCounted<Relation> {
public:
virtual ~Relation() = default;
DeprecatedString const& name() const { return m_name; }
ByteString const& name() const { return m_name; }
Relation const* parent() const { return m_parent; }
u32 hash() const;
@ -37,27 +37,27 @@ public:
virtual Key key() const = 0;
protected:
Relation(DeprecatedString name, Block::Index block_index, Relation* parent = nullptr)
Relation(ByteString name, Block::Index block_index, Relation* parent = nullptr)
: m_name(move(name))
, m_block_index(block_index)
, m_parent(parent)
{
}
explicit Relation(DeprecatedString name, Relation* parent = nullptr)
explicit Relation(ByteString name, Relation* parent = nullptr)
: Relation(move(name), 0, parent)
{
}
private:
DeprecatedString m_name;
ByteString m_name;
Block::Index m_block_index { 0 };
Relation const* m_parent { nullptr };
};
class SchemaDef : public Relation {
public:
static ErrorOr<NonnullRefPtr<SchemaDef>> create(DeprecatedString name);
static ErrorOr<NonnullRefPtr<SchemaDef>> create(ByteString name);
static ErrorOr<NonnullRefPtr<SchemaDef>> create(Key const&);
Key key() const override;
@ -65,12 +65,12 @@ public:
static Key make_key();
private:
explicit SchemaDef(DeprecatedString);
explicit SchemaDef(ByteString);
};
class ColumnDef : public Relation {
public:
static ErrorOr<NonnullRefPtr<ColumnDef>> create(Relation*, size_t, DeprecatedString, SQLType);
static ErrorOr<NonnullRefPtr<ColumnDef>> create(Relation*, size_t, ByteString, SQLType);
Key key() const override;
SQLType type() const { return m_type; }
@ -84,7 +84,7 @@ public:
static Key make_key(TableDef const&);
protected:
ColumnDef(Relation*, size_t, DeprecatedString, SQLType);
ColumnDef(Relation*, size_t, ByteString, SQLType);
private:
size_t m_index;
@ -95,32 +95,32 @@ private:
class KeyPartDef : public ColumnDef {
public:
static ErrorOr<NonnullRefPtr<KeyPartDef>> create(IndexDef*, DeprecatedString, SQLType, Order = Order::Ascending);
static ErrorOr<NonnullRefPtr<KeyPartDef>> create(IndexDef*, ByteString, SQLType, Order = Order::Ascending);
Order sort_order() const { return m_sort_order; }
private:
KeyPartDef(IndexDef*, DeprecatedString, SQLType, Order);
KeyPartDef(IndexDef*, ByteString, SQLType, Order);
Order m_sort_order { Order::Ascending };
};
class IndexDef : public Relation {
public:
static ErrorOr<NonnullRefPtr<IndexDef>> create(TableDef*, DeprecatedString, bool unique = true, u32 pointer = 0);
static ErrorOr<NonnullRefPtr<IndexDef>> create(DeprecatedString, bool unique = true, u32 pointer = 0);
static ErrorOr<NonnullRefPtr<IndexDef>> create(TableDef*, ByteString, bool unique = true, u32 pointer = 0);
static ErrorOr<NonnullRefPtr<IndexDef>> create(ByteString, bool unique = true, u32 pointer = 0);
Vector<NonnullRefPtr<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(DeprecatedString, SQLType, Order = Order::Ascending);
void append_column(ByteString, 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*, DeprecatedString, bool unique, u32 pointer);
IndexDef(TableDef*, ByteString, bool unique, u32 pointer);
Vector<NonnullRefPtr<KeyPartDef>> m_key_definition;
bool m_unique { false };
@ -130,10 +130,10 @@ private:
class TableDef : public Relation {
public:
static ErrorOr<NonnullRefPtr<TableDef>> create(SchemaDef*, DeprecatedString);
static ErrorOr<NonnullRefPtr<TableDef>> create(SchemaDef*, ByteString);
Key key() const override;
void append_column(DeprecatedString, SQLType);
void append_column(ByteString, SQLType);
void append_column(Key const&);
size_t num_columns() { return m_columns.size(); }
size_t num_indexes() { return m_indexes.size(); }
@ -146,7 +146,7 @@ public:
static Key make_key(Key const& schema_key);
private:
explicit TableDef(SchemaDef*, DeprecatedString);
explicit TableDef(SchemaDef*, ByteString);
Vector<NonnullRefPtr<ColumnDef>> m_columns;
Vector<NonnullRefPtr<IndexDef>> m_indexes;

View file

@ -9,7 +9,7 @@
namespace SQL {
DeprecatedString Result::error_string() const
ByteString Result::error_string() const
{
VERIFY(is_error());
@ -41,7 +41,7 @@ DeprecatedString Result::error_string() const
builder.append(error_description);
}
return builder.to_deprecated_string();
return builder.to_byte_string();
}
}

View file

@ -7,7 +7,7 @@
#pragma once
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/Error.h>
#include <AK/Noncopyable.h>
#include <LibSQL/Type.h>
@ -90,7 +90,7 @@ public:
{
}
ALWAYS_INLINE Result(SQLCommand command, SQLErrorCode error, DeprecatedString error_message)
ALWAYS_INLINE Result(SQLCommand command, SQLErrorCode error, ByteString error_message)
: m_command(command)
, m_error(error)
, m_error_message(move(error_message))
@ -105,7 +105,7 @@ public:
SQLCommand command() const { return m_command; }
SQLErrorCode error() const { return m_error; }
DeprecatedString error_string() const;
ByteString error_string() const;
// These are for compatibility with the TRY() macro in AK.
[[nodiscard]] bool is_error() const { return m_error != SQLErrorCode::NoError; }
@ -123,7 +123,7 @@ private:
SQLCommand m_command { SQLCommand::Unknown };
SQLErrorCode m_error { SQLErrorCode::NoError };
Optional<DeprecatedString> m_error_message {};
Optional<ByteString> m_error_message {};
};
template<typename ValueType>

View file

@ -25,14 +25,14 @@ public:
{
}
ALWAYS_INLINE ResultSet(SQLCommand command, Vector<DeprecatedString> column_names)
ALWAYS_INLINE ResultSet(SQLCommand command, Vector<ByteString> column_names)
: m_command(command)
, m_column_names(move(column_names))
{
}
SQLCommand command() const { return m_command; }
Vector<DeprecatedString> const& column_names() const { return m_column_names; }
Vector<ByteString> const& column_names() const { return m_column_names; }
void insert_row(Tuple const& row, Tuple const& sort_key);
void limit(size_t offset, size_t limit);
@ -41,7 +41,7 @@ private:
size_t binary_search(Tuple const& sort_key, size_t low, size_t high);
SQLCommand m_command { SQLCommand::Unknown };
Vector<DeprecatedString> m_column_names;
Vector<ByteString> m_column_names;
};
}

View file

@ -5,7 +5,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/String.h>
#include <LibSQL/SQLClient.h>
@ -23,7 +23,7 @@ namespace SQL {
#if !defined(AK_OS_SERENITY)
// This is heavily based on how SystemServer's Service creates its socket.
static ErrorOr<int> create_database_socket(DeprecatedString const& socket_path)
static ErrorOr<int> create_database_socket(ByteString const& socket_path)
{
if (FileSystem::exists(socket_path))
TRY(Core::System::unlink(socket_path));
@ -51,7 +51,7 @@ static ErrorOr<int> create_database_socket(DeprecatedString const& socket_path)
return socket_fd;
}
static ErrorOr<void> launch_server(DeprecatedString const& socket_path, DeprecatedString const& pid_path, Vector<String> candidate_server_paths)
static ErrorOr<void> launch_server(ByteString const& socket_path, ByteString const& pid_path, Vector<String> candidate_server_paths)
{
auto server_fd_or_error = create_database_socket(socket_path);
if (server_fd_or_error.is_error()) {
@ -73,14 +73,14 @@ static ErrorOr<void> launch_server(DeprecatedString const& socket_path, Deprecat
if (server_pid != 0) {
auto server_pid_file = TRY(Core::File::open(pid_path, Core::File::OpenMode::Write));
TRY(server_pid_file->write_until_depleted(DeprecatedString::number(server_pid).bytes()));
TRY(server_pid_file->write_until_depleted(ByteString::number(server_pid).bytes()));
TRY(Core::System::kill(getpid(), SIGTERM));
}
server_fd = TRY(Core::System::dup(server_fd));
auto takeover_string = DeprecatedString::formatted("SQLServer:{}", server_fd);
auto takeover_string = ByteString::formatted("SQLServer:{}", server_fd);
TRY(Core::System::setenv("SOCKET_TAKEOVER"sv, takeover_string, true));
ErrorOr<void> result;
@ -110,7 +110,7 @@ static ErrorOr<void> launch_server(DeprecatedString const& socket_path, Deprecat
return {};
}
static ErrorOr<bool> should_launch_server(DeprecatedString const& pid_path)
static ErrorOr<bool> should_launch_server(ByteString const& pid_path)
{
if (!FileSystem::exists(pid_path))
return true;
@ -149,8 +149,8 @@ static ErrorOr<bool> should_launch_server(DeprecatedString const& pid_path)
ErrorOr<NonnullRefPtr<SQLClient>> SQLClient::launch_server_and_create_client(Vector<String> candidate_server_paths)
{
auto runtime_directory = TRY(Core::StandardPaths::runtime_directory());
auto socket_path = DeprecatedString::formatted("{}/SQLServer.socket", runtime_directory);
auto pid_path = DeprecatedString::formatted("{}/SQLServer.pid", runtime_directory);
auto socket_path = ByteString::formatted("{}/SQLServer.socket", runtime_directory);
auto pid_path = ByteString::formatted("{}/SQLServer.pid", runtime_directory);
if (TRY(should_launch_server(pid_path)))
TRY(launch_server(socket_path, pid_path, move(candidate_server_paths)));
@ -163,7 +163,7 @@ ErrorOr<NonnullRefPtr<SQLClient>> SQLClient::launch_server_and_create_client(Vec
#endif
void SQLClient::execution_success(u64 statement_id, u64 execution_id, Vector<DeprecatedString> const& column_names, bool has_results, size_t created, size_t updated, size_t deleted)
void SQLClient::execution_success(u64 statement_id, u64 execution_id, Vector<ByteString> const& column_names, bool has_results, size_t created, size_t updated, size_t deleted)
{
if (!on_execution_success) {
outln("{} row(s) created, {} updated, {} deleted", created, updated, deleted);
@ -173,7 +173,7 @@ void SQLClient::execution_success(u64 statement_id, u64 execution_id, Vector<Dep
ExecutionSuccess success {
.statement_id = statement_id,
.execution_id = execution_id,
.column_names = move(const_cast<Vector<DeprecatedString>&>(column_names)),
.column_names = move(const_cast<Vector<ByteString>&>(column_names)),
.has_results = has_results,
.rows_created = created,
.rows_updated = updated,
@ -183,7 +183,7 @@ void SQLClient::execution_success(u64 statement_id, u64 execution_id, Vector<Dep
on_execution_success(move(success));
}
void SQLClient::execution_error(u64 statement_id, u64 execution_id, SQLErrorCode const& code, DeprecatedString const& message)
void SQLClient::execution_error(u64 statement_id, u64 execution_id, SQLErrorCode const& code, ByteString const& message)
{
if (!on_execution_error) {
warnln("Execution error for statement_id {}: {} ({})", statement_id, message, to_underlying(code));
@ -194,7 +194,7 @@ void SQLClient::execution_error(u64 statement_id, u64 execution_id, SQLErrorCode
.statement_id = statement_id,
.execution_id = execution_id,
.error_code = code,
.error_message = move(const_cast<DeprecatedString&>(message)),
.error_message = move(const_cast<ByteString&>(message)),
};
on_execution_error(move(error));

View file

@ -19,7 +19,7 @@ struct ExecutionSuccess {
u64 statement_id { 0 };
u64 execution_id { 0 };
Vector<DeprecatedString> column_names;
Vector<ByteString> column_names;
bool has_results { false };
size_t rows_created { 0 };
size_t rows_updated { 0 };
@ -31,7 +31,7 @@ struct ExecutionError {
u64 execution_id { 0 };
SQLErrorCode error_code;
DeprecatedString error_message;
ByteString error_message;
};
struct ExecutionResult {
@ -71,8 +71,8 @@ private:
{
}
virtual void execution_success(u64 statement_id, u64 execution_id, Vector<DeprecatedString> const& column_names, bool has_results, size_t created, size_t updated, size_t deleted) override;
virtual void execution_error(u64 statement_id, u64 execution_id, SQLErrorCode const& code, DeprecatedString const& message) override;
virtual void execution_success(u64 statement_id, u64 execution_id, Vector<ByteString> const& column_names, bool has_results, size_t created, size_t updated, size_t deleted) override;
virtual void execution_error(u64 statement_id, u64 execution_id, SQLErrorCode const& code, ByteString const& message) override;
virtual void next_result(u64 statement_id, u64 execution_id, Vector<SQL::Value> const&) override;
virtual void results_exhausted(u64 statement_id, u64 execution_id, size_t total_rows) override;
};

View file

@ -8,18 +8,18 @@
namespace SQL {
void Serializer::serialize(DeprecatedString const& text)
void Serializer::serialize(ByteString const& text)
{
serialize<u32>(text.length());
if (!text.is_empty())
write((u8 const*)text.characters(), text.length());
}
void Serializer::deserialize_to(DeprecatedString& text)
void Serializer::deserialize_to(ByteString& text)
{
auto length = deserialize<u32>();
if (length > 0) {
text = DeprecatedString(reinterpret_cast<char const*>(read(length)), length);
text = ByteString(reinterpret_cast<char const*>(read(length)), length);
} else {
text = "";
}

View file

@ -7,8 +7,8 @@
#pragma once
#include <AK/ByteBuffer.h>
#include <AK/ByteString.h>
#include <AK/Debug.h>
#include <AK/DeprecatedString.h>
#include <AK/Format.h>
#include <LibSQL/Forward.h>
#include <LibSQL/Heap.h>
@ -64,7 +64,7 @@ public:
t.deserialize(*this);
}
void deserialize_to(DeprecatedString& text);
void deserialize_to(ByteString& text);
template<typename T, typename... Args>
NonnullOwnPtr<T> make_and_deserialize(Args&&... args)
@ -99,7 +99,7 @@ public:
t.serialize(*this);
}
void serialize(DeprecatedString const&);
void serialize(ByteString const&);
template<typename T>
bool serialize_and_write(T const& t)
@ -145,17 +145,17 @@ private:
return buffer_ptr;
}
static void dump(u8 const* ptr, size_t sz, DeprecatedString const& prefix)
static void dump(u8 const* ptr, size_t sz, ByteString const& prefix)
{
StringBuilder builder;
builder.appendff("{0} {1:04x} | ", prefix, sz);
Vector<DeprecatedString> bytes;
Vector<ByteString> bytes;
for (auto ix = 0u; ix < sz; ++ix)
bytes.append(DeprecatedString::formatted("{0:02x}", *(ptr + ix)));
bytes.append(ByteString::formatted("{0:02x}", *(ptr + ix)));
StringBuilder bytes_builder;
bytes_builder.join(' ', bytes);
builder.append(bytes_builder.to_deprecated_string());
dbgln(builder.to_deprecated_string());
builder.append(bytes_builder.to_byte_string());
dbgln(builder.to_byte_string());
}
ByteBuffer m_buffer {};

View file

@ -151,7 +151,7 @@ size_t TreeNode::length() const
bool TreeNode::insert(Key const& key)
{
dbgln_if(SQL_DEBUG, "[#{}] INSERT({})", block_index(), key.to_deprecated_string());
dbgln_if(SQL_DEBUG, "[#{}] INSERT({})", block_index(), key.to_byte_string());
if (!is_leaf())
return node_for(key)->insert_in_leaf(key);
return insert_in_leaf(key);
@ -159,14 +159,14 @@ bool TreeNode::insert(Key const& key)
bool TreeNode::update_key_pointer(Key const& key)
{
dbgln_if(SQL_DEBUG, "[#{}] UPDATE({}, {})", block_index(), key.to_deprecated_string(), key.block_index());
dbgln_if(SQL_DEBUG, "[#{}] UPDATE({}, {})", block_index(), key.to_byte_string(), key.block_index());
if (!is_leaf())
return node_for(key)->update_key_pointer(key);
for (auto ix = 0u; ix < size(); ix++) {
if (key == m_entries[ix]) {
dbgln_if(SQL_DEBUG, "[#{}] {} == {}",
block_index(), key.to_deprecated_string(), m_entries[ix].to_deprecated_string());
block_index(), key.to_byte_string(), m_entries[ix].to_byte_string());
if (m_entries[ix].block_index() != key.block_index()) {
m_entries[ix].set_block_index(key.block_index());
dump_if(SQL_DEBUG, "To WAL");
@ -184,13 +184,13 @@ bool TreeNode::insert_in_leaf(Key const& key)
if (!m_tree.duplicates_allowed()) {
for (auto& entry : m_entries) {
if (key == entry) {
dbgln_if(SQL_DEBUG, "[#{}] duplicate key {}", block_index(), key.to_deprecated_string());
dbgln_if(SQL_DEBUG, "[#{}] duplicate key {}", block_index(), key.to_byte_string());
return false;
}
}
}
dbgln_if(SQL_DEBUG, "[#{}] insert_in_leaf({})", block_index(), key.to_deprecated_string());
dbgln_if(SQL_DEBUG, "[#{}] insert_in_leaf({})", block_index(), key.to_byte_string());
just_insert(key, nullptr);
return true;
}
@ -207,56 +207,56 @@ TreeNode* TreeNode::down_node(size_t ix)
TreeNode* TreeNode::node_for(Key const& key)
{
dump_if(SQL_DEBUG, DeprecatedString::formatted("node_for(Key {})", key.to_deprecated_string()));
dump_if(SQL_DEBUG, ByteString::formatted("node_for(Key {})", key.to_byte_string()));
if (is_leaf())
return this;
for (size_t ix = 0; ix < size(); ix++) {
if (key < m_entries[ix]) {
dbgln_if(SQL_DEBUG, "[{}] {} < {} v{}",
block_index(), (DeprecatedString)key, (DeprecatedString)m_entries[ix], m_down[ix].block_index());
block_index(), (ByteString)key, (ByteString)m_entries[ix], m_down[ix].block_index());
return down_node(ix)->node_for(key);
}
}
dbgln_if(SQL_DEBUG, "[#{}] {} >= {} v{}",
block_index(), key.to_deprecated_string(), (DeprecatedString)m_entries[size() - 1], m_down[size()].block_index());
block_index(), key.to_byte_string(), (ByteString)m_entries[size() - 1], m_down[size()].block_index());
return down_node(size())->node_for(key);
}
Optional<u32> TreeNode::get(Key& key)
{
dump_if(SQL_DEBUG, DeprecatedString::formatted("get({})", key.to_deprecated_string()));
dump_if(SQL_DEBUG, ByteString::formatted("get({})", key.to_byte_string()));
for (auto ix = 0u; ix < size(); ix++) {
if (key < m_entries[ix]) {
if (is_leaf()) {
dbgln_if(SQL_DEBUG, "[#{}] {} < {} -> 0",
block_index(), key.to_deprecated_string(), (DeprecatedString)m_entries[ix]);
block_index(), key.to_byte_string(), (ByteString)m_entries[ix]);
return {};
} else {
dbgln_if(SQL_DEBUG, "[{}] {} < {} ({} -> {})",
block_index(), key.to_deprecated_string(), (DeprecatedString)m_entries[ix],
block_index(), key.to_byte_string(), (ByteString)m_entries[ix],
ix, m_down[ix].block_index());
return down_node(ix)->get(key);
}
}
if (key == m_entries[ix]) {
dbgln_if(SQL_DEBUG, "[#{}] {} == {} -> {}",
block_index(), key.to_deprecated_string(), (DeprecatedString)m_entries[ix],
block_index(), key.to_byte_string(), (ByteString)m_entries[ix],
m_entries[ix].block_index());
key.set_block_index(m_entries[ix].block_index());
return m_entries[ix].block_index();
}
}
if (m_entries.is_empty()) {
dbgln_if(SQL_DEBUG, "[#{}] {} Empty node??", block_index(), key.to_deprecated_string());
dbgln_if(SQL_DEBUG, "[#{}] {} Empty node??", block_index(), key.to_byte_string());
VERIFY_NOT_REACHED();
}
if (is_leaf()) {
dbgln_if(SQL_DEBUG, "[#{}] {} > {} -> 0",
block_index(), key.to_deprecated_string(), (DeprecatedString)m_entries[size() - 1]);
block_index(), key.to_byte_string(), (ByteString)m_entries[size() - 1]);
return {};
}
dbgln_if(SQL_DEBUG, "[#{}] {} > {} ({} -> {})",
block_index(), key.to_deprecated_string(), (DeprecatedString)m_entries[size() - 1],
block_index(), key.to_byte_string(), (ByteString)m_entries[size() - 1],
size(), m_down[size()].block_index());
return down_node(size())->get(key);
}
@ -264,7 +264,7 @@ Optional<u32> TreeNode::get(Key& key)
void TreeNode::just_insert(Key const& key, TreeNode* right)
{
dbgln_if(SQL_DEBUG, "[#{}] just_insert({}, right = {})",
block_index(), (DeprecatedString)key, (right) ? right->block_index() : 0);
block_index(), (ByteString)key, (right) ? right->block_index() : 0);
dump_if(SQL_DEBUG, "Before");
for (auto ix = 0u; ix < size(); ix++) {
if (key < m_entries[ix]) {
@ -331,7 +331,7 @@ void TreeNode::split()
m_up->just_insert(median, new_node);
}
void TreeNode::dump_if(int flag, DeprecatedString&& msg)
void TreeNode::dump_if(int flag, ByteString&& msg)
{
if (!flag)
return;
@ -349,7 +349,7 @@ void TreeNode::dump_if(int flag, DeprecatedString&& msg)
builder.appendff("[v{}] ", m_down[ix].block_index());
else
VERIFY(m_down[ix].block_index() == 0);
builder.appendff("'{}' ", (DeprecatedString)m_entries[ix]);
builder.appendff("'{}' ", (ByteString)m_entries[ix]);
}
if (!is_leaf())
builder.appendff("[v{}]", m_down[size()].block_index());
@ -359,7 +359,7 @@ void TreeNode::dump_if(int flag, DeprecatedString&& msg)
if (is_leaf())
builder.append(", leaf"sv);
builder.append(')');
dbgln(builder.to_deprecated_string());
dbgln(builder.to_byte_string());
}
void TreeNode::list_node(int indent)
@ -374,7 +374,7 @@ void TreeNode::list_node(int indent)
if (!is_leaf())
down_node(ix)->list_node(indent + 2);
do_indent();
warnln("{}", m_entries[ix].to_deprecated_string());
warnln("{}", m_entries[ix].to_byte_string());
}
if (!is_leaf())
down_node(size())->list_node(indent + 2);

View file

@ -4,7 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/StringBuilder.h>
#include <LibSQL/Serializer.h>
#include <LibSQL/Tuple.h>
@ -84,14 +84,14 @@ Optional<size_t> Tuple::index_of(StringView name) const
return {};
}
Value const& Tuple::operator[](DeprecatedString const& name) const
Value const& Tuple::operator[](ByteString const& name) const
{
auto index = index_of(name);
VERIFY(index.has_value());
return (*this)[index.value()];
}
Value& Tuple::operator[](DeprecatedString const& name)
Value& Tuple::operator[](ByteString const& name)
{
auto index = index_of(name);
VERIFY(index.has_value());
@ -132,17 +132,17 @@ size_t Tuple::length() const
return len;
}
DeprecatedString Tuple::to_deprecated_string() const
ByteString Tuple::to_byte_string() const
{
StringBuilder builder;
for (auto& part : m_data) {
if (!builder.is_empty())
builder.append('|');
builder.append(part.to_deprecated_string());
builder.append(part.to_byte_string());
}
if (block_index() != 0)
builder.appendff(":{}", block_index());
return builder.to_deprecated_string();
return builder.to_byte_string();
}
void Tuple::copy_from(Tuple const& other)

View file

@ -34,8 +34,8 @@ public:
Tuple& operator=(Tuple const&);
[[nodiscard]] DeprecatedString to_deprecated_string() const;
explicit operator DeprecatedString() const { return to_deprecated_string(); }
[[nodiscard]] ByteString to_byte_string() const;
explicit operator ByteString() const { return to_byte_string(); }
bool operator<(Tuple const& other) const { return compare(other) < 0; }
bool operator<=(Tuple const& other) const { return compare(other) <= 0; }
@ -45,12 +45,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(DeprecatedString const& name) const { return index_of(name).has_value(); }
[[nodiscard]] bool has(ByteString 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[](DeprecatedString const& name) const;
Value& operator[](DeprecatedString const& name);
Value const& operator[](ByteString const& name) const;
Value& operator[](ByteString const& name);
void append(Value const&);
Tuple& operator+=(Value const&);
void extend(Tuple const&);

View file

@ -13,9 +13,9 @@
namespace SQL {
struct TupleElementDescriptor {
DeprecatedString schema { "" };
DeprecatedString table { "" };
DeprecatedString name { "" };
ByteString schema { "" };
ByteString table { "" };
ByteString name { "" };
SQLType type { SQLType::Text };
Order order { Order::Ascending };
@ -29,7 +29,7 @@ struct TupleElementDescriptor {
}
void deserialize(Serializer& serializer)
{
name = serializer.deserialize<DeprecatedString>();
name = serializer.deserialize<ByteString>();
type = (SQLType)serializer.deserialize<u8>();
order = (Order)serializer.deserialize<u8>();
}
@ -39,9 +39,9 @@ struct TupleElementDescriptor {
return sizeof(u32) + name.length() + 2 * sizeof(u8);
}
DeprecatedString to_deprecated_string() const
ByteString to_byte_string() const
{
return DeprecatedString::formatted(" name: {} type: {} order: {}", name, SQLType_name(type), Order_name(order));
return ByteString::formatted(" name: {} type: {} order: {}", name, SQLType_name(type), Order_name(order));
}
};
@ -90,12 +90,12 @@ public:
return len;
}
DeprecatedString to_deprecated_string() const
ByteString to_byte_string() const
{
Vector<DeprecatedString> elements;
Vector<ByteString> elements;
for (auto& element : *this)
elements.append(element.to_deprecated_string());
return DeprecatedString::formatted("[\n{}\n]", DeprecatedString::join('\n', elements));
elements.append(element.to_byte_string());
return ByteString::formatted("[\n{}\n]", ByteString::join('\n', elements));
}
using Vector<TupleElementDescriptor>::operator==;

View file

@ -97,7 +97,7 @@ Value::Value(SQLType type)
{
}
Value::Value(DeprecatedString value)
Value::Value(ByteString value)
: m_type(SQLType::Text)
, m_value(move(value))
{
@ -214,24 +214,24 @@ bool Value::is_int() const
return m_value.has_value() && (m_value->has<i64>() || m_value->has<u64>());
}
DeprecatedString Value::to_deprecated_string() const
ByteString Value::to_byte_string() const
{
if (is_null())
return "(null)"sv;
return m_value->visit(
[](DeprecatedString const& value) -> DeprecatedString { return value; },
[](Integer auto 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 {
[](ByteString const& value) -> ByteString { return value; },
[](Integer auto value) -> ByteString { return ByteString::number(value); },
[](double value) -> ByteString { return ByteString::number(value); },
[](bool value) -> ByteString { return value ? "true"sv : "false"sv; },
[](TupleValue const& value) -> ByteString {
StringBuilder builder;
builder.append('(');
builder.join(',', value.values);
builder.append(')');
return builder.to_deprecated_string();
return builder.to_byte_string();
});
}
@ -241,7 +241,7 @@ Optional<double> Value::to_double() const
return {};
return m_value->visit(
[](DeprecatedString const& value) -> Optional<double> { return value.to_double(); },
[](ByteString const& value) -> Optional<double> { return value.to_double(); },
[](Integer auto value) -> Optional<double> { return static_cast<double>(value); },
[](double value) -> Optional<double> { return value; },
[](bool value) -> Optional<double> { return static_cast<double>(value); },
@ -254,7 +254,7 @@ Optional<bool> Value::to_bool() const
return {};
return m_value->visit(
[](DeprecatedString const& value) -> Optional<bool> {
[](ByteString const& value) -> Optional<bool> {
if (value.equals_ignoring_ascii_case("true"sv) || value.equals_ignoring_ascii_case("t"sv))
return true;
if (value.equals_ignoring_ascii_case("false"sv) || value.equals_ignoring_ascii_case("f"sv))
@ -293,7 +293,7 @@ Value& Value::operator=(Value value)
return *this;
}
Value& Value::operator=(DeprecatedString value)
Value& Value::operator=(ByteString value)
{
m_type = SQLType::Text;
m_value = move(value);
@ -361,7 +361,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(
[](DeprecatedString const& value) -> size_t { return sizeof(u32) + value.length(); },
[](ByteString const& value) -> size_t { return sizeof(u32) + value.length(); },
[](Integer auto value) -> size_t {
return downsize_integer(value, [](auto integer, auto) {
return sizeof(integer);
@ -385,7 +385,7 @@ u32 Value::hash() const
return 0;
return m_value->visit(
[](DeprecatedString const& value) -> u32 { return value.hash(); },
[](ByteString const& value) -> u32 { return value.hash(); },
[](Integer auto value) -> u32 {
return downsize_integer(value, [](auto integer, auto) {
if constexpr (sizeof(decltype(integer)) == 8)
@ -418,7 +418,7 @@ int Value::compare(Value const& other) const
return 1;
return m_value->visit(
[&](DeprecatedString const& value) -> int { return value.view().compare(other.to_deprecated_string()); },
[&](ByteString const& value) -> int { return value.view().compare(other.to_byte_string()); },
[&](Integer auto value) -> int {
auto casted = other.to_int<IntegerType<decltype(value)>>();
if (!casted.has_value())
@ -479,7 +479,7 @@ bool Value::operator==(Value const& value) const
bool Value::operator==(StringView value) const
{
return to_deprecated_string() == value;
return to_byte_string() == value;
}
bool Value::operator==(double value) const
@ -749,7 +749,7 @@ void Value::deserialize(Serializer& serializer)
case SQLType::Null:
VERIFY_NOT_REACHED();
case SQLType::Text:
m_value = serializer.deserialize<DeprecatedString>();
m_value = serializer.deserialize<ByteString>();
break;
case SQLType::Integer:
switch (type_data) {
@ -834,7 +834,7 @@ ErrorOr<void> IPC::encode(Encoder& encoder, SQL::Value const& value)
case SQL::SQLType::Null:
return {};
case SQL::SQLType::Text:
return encoder.encode(value.to_deprecated_string());
return encoder.encode(value.to_byte_string());
case SQL::SQLType::Integer:
return SQL::downsize_integer(value, [&](auto integer, auto) {
return encoder.encode(integer);
@ -865,7 +865,7 @@ ErrorOr<SQL::Value> IPC::decode(Decoder& decoder)
case SQL::SQLType::Null:
return SQL::Value {};
case SQL::SQLType::Text:
return SQL::Value { TRY(decoder.decode<DeprecatedString>()) };
return SQL::Value { TRY(decoder.decode<ByteString>()) };
case SQL::SQLType::Integer:
switch (type_data) {
case SQL::TypeData::Int8:

View file

@ -7,8 +7,8 @@
#pragma once
#include <AK/ByteString.h>
#include <AK/Checked.h>
#include <AK/DeprecatedString.h>
#include <AK/Format.h>
#include <AK/Optional.h>
#include <AK/StringView.h>
@ -39,7 +39,7 @@ class Value {
public:
explicit Value(SQLType sql_type = SQLType::Null);
explicit Value(DeprecatedString);
explicit Value(ByteString);
explicit Value(double);
Value(Value const&);
Value(Value&&);
@ -74,7 +74,7 @@ public:
return *m_value;
}
[[nodiscard]] DeprecatedString to_deprecated_string() const;
[[nodiscard]] ByteString to_byte_string() const;
[[nodiscard]] Optional<double> to_double() const;
[[nodiscard]] Optional<bool> to_bool() const;
[[nodiscard]] Optional<Vector<Value>> to_vector() const;
@ -86,7 +86,7 @@ public:
return {};
return m_value->visit(
[](DeprecatedString const& value) -> Optional<T> {
[](ByteString const& value) -> Optional<T> {
if constexpr (IsSigned<T>)
return value.to_int<T>();
else
@ -107,7 +107,7 @@ public:
}
Value& operator=(Value);
Value& operator=(DeprecatedString);
Value& operator=(ByteString);
Value& operator=(double);
Value& operator=(Integer auto value)
@ -171,7 +171,7 @@ private:
Vector<Value> values;
};
using ValueType = Variant<DeprecatedString, i64, u64, double, bool, TupleValue>;
using ValueType = Variant<ByteString, i64, u64, double, bool, TupleValue>;
static ResultOr<NonnullRefPtr<TupleDescriptor>> infer_tuple_descriptor(Vector<Value> const& values);
Value(NonnullRefPtr<TupleDescriptor> descriptor, Vector<Value> values);
@ -186,7 +186,7 @@ template<>
struct AK::Formatter<SQL::Value> : Formatter<StringView> {
ErrorOr<void> format(FormatBuilder& builder, SQL::Value const& value)
{
return Formatter<StringView>::format(builder, value.to_deprecated_string());
return Formatter<StringView>::format(builder, value.to_byte_string());
}
};