![](https://secure.gravatar.com/avatar/39b623a1559cf9c69ac3d9d4fb44e7fe.jpg?s=120&d=mm&r=g)
Hi, Michael! On May 10, Michael Widenius wrote:
diff --git a/sql/item.cc b/sql/item.cc index 1a86b8b3114..0f160fa257b 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -55,7 +55,8 @@ const char *item_empty_name=""; const char *item_used_name= "\0";
static int save_field_in_field(Field *, bool *, Field *, bool); - +const Item_bool_static Item_false("FALSE", 0); +const Item_bool_static Item_true("TRUE", 1);
The main question - we have tons of modifiable Item members. How do you know none of them will modified in your Item_bool_static objects?
Because these are global const. We will get an assert if anyone tries.
No. It doesn't go into a read-only segment.
Here's the patch that really makes it to go there:
--- a/sql/item.h
+++ b/sql/item.h
@@ -4395,7 +4395,22 @@ class Item_bool_static :public Item_bool
{ DBUG_ASSERT(0); }
};
-extern const Item_bool_static Item_false, Item_true;
+class Item_bool_static_true: public Item_bool_static
+{
+ public:
+ Item_bool_static_true():
+ Item_bool_static("TRUE", 1) {}
+};
+
+class Item_bool_static_false: public Item_bool_static
+{
+ public:
+ Item_bool_static_false():
+ Item_bool_static("FALSE", 0) {}
+};
+
+extern const Item_bool_static_true Item_true;
+extern const Item_bool_static_false Item_false;
class Item_uint :public Item_int
{
diff --git a/sql/item.cc b/sql/item.cc
index 67fcb7d4e0c..1f0031dcfb9 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -55,8 +55,9 @@ const char *item_empty_name="";
const char *item_used_name= "\0";
static int save_field_in_field(Field *, bool *, Field *, bool);
-const Item_bool_static Item_false("FALSE", 0);
-const Item_bool_static Item_true("TRUE", 1);
+
+const Item_bool_static_false Item_false;
+const Item_bool_static_true Item_true __attribute__ ((section (".rodata")));
/**
Compare two Items for List<Item>::add_unique()
=============================================================
With this patch the server immediately crashes on startup, on
3052 class Type_numeric_attributes
3053 {
...
3069 Type_numeric_attributes()
3070 => :max_length(0), decimals(0), unsigned_flag(false)
3071 { }
with the stack trace:
#0 0x0000555555fa7210 in Type_numeric_attributes::Type_numeric_attributes (
this=0x555556db0468