summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimothy Flynn <trflynn89@pm.me>2022-12-11 17:15:45 -0500
committerTim Flynn <trflynn89@pm.me>2022-12-14 09:21:30 -0500
commit264db4fc405c63c28510dfd538177ee0862f92f5 (patch)
treeaeadc8c7d5107658c650953902a55038eccb10a2
parentb5fd96b7ac0e6ded8119819077cfeb6c272bd391 (diff)
downloadserenity-264db4fc405c63c28510dfd538177ee0862f92f5.zip
LibSQL: Remove unnecessary values from the ENUMERATE_SQL_TYPES macro
Removing the bitmask-esque values from the enumeration necessitates a Heap version bump.
-rw-r--r--Userland/Libraries/LibSQL/Heap.h2
-rw-r--r--Userland/Libraries/LibSQL/Type.h37
-rw-r--r--Userland/Libraries/LibSQL/Value.cpp4
3 files changed, 16 insertions, 27 deletions
diff --git a/Userland/Libraries/LibSQL/Heap.h b/Userland/Libraries/LibSQL/Heap.h
index a703b9a7aa..7291586222 100644
--- a/Userland/Libraries/LibSQL/Heap.h
+++ b/Userland/Libraries/LibSQL/Heap.h
@@ -33,7 +33,7 @@ class Heap : public Core::Object {
C_OBJECT(Heap);
public:
- static constexpr inline u32 current_version = 1;
+ static constexpr inline u32 current_version = 2;
virtual ~Heap() override;
diff --git a/Userland/Libraries/LibSQL/Type.h b/Userland/Libraries/LibSQL/Type.h
index a05fc6a260..7cf649a2c9 100644
--- a/Userland/Libraries/LibSQL/Type.h
+++ b/Userland/Libraries/LibSQL/Type.h
@@ -12,17 +12,20 @@
namespace SQL {
-#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))
+// Adding to this list is fine, but changing the order of any value here will result in LibSQL
+// becoming unable to read existing .db files. If the order must absolutely be changed, be sure
+// to bump Heap::current_version.
+#define ENUMERATE_SQL_TYPES(S) \
+ S("null", Null) \
+ S("text", Text) \
+ S("int", Integer) \
+ S("float", Float) \
+ S("bool", Boolean) \
+ S("tuple", Tuple)
enum class SQLType {
#undef __ENUMERATE_SQL_TYPE
-#define __ENUMERATE_SQL_TYPE(name, cardinal, type, impl, size) type = cardinal,
+#define __ENUMERATE_SQL_TYPE(name, type) type,
ENUMERATE_SQL_TYPES(__ENUMERATE_SQL_TYPE)
#undef __ENUMERATE_SQL_TYPE
};
@@ -31,8 +34,8 @@ constexpr StringView SQLType_name(SQLType t)
{
switch (t) {
#undef __ENUMERATE_SQL_TYPE
-#define __ENUMERATE_SQL_TYPE(name, cardinal, type, impl, size) \
- case SQLType::type: \
+#define __ENUMERATE_SQL_TYPE(name, type) \
+ case SQLType::type: \
return name##sv;
ENUMERATE_SQL_TYPES(__ENUMERATE_SQL_TYPE)
#undef __ENUMERATE_SQL_TYPE
@@ -41,20 +44,6 @@ constexpr StringView SQLType_name(SQLType t)
}
}
-constexpr size_t size_of(SQLType t)
-{
- switch (t) {
-#undef __ENUMERATE_SQL_TYPE
-#define __ENUMERATE_SQL_TYPE(name, cardinal, type, impl, size) \
- case SQLType::type: \
- return size;
- ENUMERATE_SQL_TYPES(__ENUMERATE_SQL_TYPE)
-#undef __ENUMERATE_SQL_TYPE
- default:
- VERIFY_NOT_REACHED();
- }
-}
-
#define ENUMERATE_ORDERS(S) \
S(Ascending) \
S(Descending)
diff --git a/Userland/Libraries/LibSQL/Value.cpp b/Userland/Libraries/LibSQL/Value.cpp
index ab3ab0c2b3..5f36618993 100644
--- a/Userland/Libraries/LibSQL/Value.cpp
+++ b/Userland/Libraries/LibSQL/Value.cpp
@@ -92,8 +92,8 @@ StringView Value::type_name() const
{
switch (type()) {
#undef __ENUMERATE_SQL_TYPE
-#define __ENUMERATE_SQL_TYPE(name, cardinal, type, impl, size) \
- case SQLType::type: \
+#define __ENUMERATE_SQL_TYPE(name, type) \
+ case SQLType::type: \
return name##sv;
ENUMERATE_SQL_TYPES(__ENUMERATE_SQL_TYPE)
#undef __ENUMERATE_SQL_TYPE