summaryrefslogtreecommitdiff
path: root/sql/item.cc
diff options
context:
space:
mode:
authorunknown <bar@bar.mysql.r18.ru>2003-06-24 17:12:07 +0500
committerunknown <bar@bar.mysql.r18.ru>2003-06-24 17:12:07 +0500
commit3eaf8865ecdb8db3e5bc7c1b59716dfcff79dc92 (patch)
tree77e24de3dd69ace8f45ad249879fa0b92f6e44d7 /sql/item.cc
parent40654c71f4275c5ec324142a7a640f8ae08e7f54 (diff)
downloadmariadb-git-3eaf8865ecdb8db3e5bc7c1b59716dfcff79dc92.tar.gz
String comparison functions now use the same DTCollation with
CONCAT() and other string functions. This allows to reuse a lot if code and to simplify further development.
Diffstat (limited to 'sql/item.cc')
-rw-r--r--sql/item.cc67
1 files changed, 42 insertions, 25 deletions
diff --git a/sql/item.cc b/sql/item.cc
index 4c7b30b0410..950f27c5d69 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -183,44 +183,61 @@ CHARSET_INFO * Item::default_charset() const
return current_thd->variables.collation_connection;
}
-bool Item::set_charset(CHARSET_INFO *cs1, Derivation co1,
- CHARSET_INFO *cs2, Derivation co2)
+bool DTCollation::aggregate(DTCollation &dt)
{
- if (cs1 == &my_charset_bin || cs2 == &my_charset_bin)
+ if (collation == &my_charset_bin || dt.collation == &my_charset_bin)
{
- set_charset(&my_charset_bin, DERIVATION_NONE);
+ collation= &my_charset_bin;
+ derivation= derivation > dt.derivation ? derivation : dt.derivation;
return 0;
}
-
- if (!my_charset_same(cs1,cs2))
- return 1;
-
- if (co1 < co2)
+
+ if (!my_charset_same(collation, dt.collation))
{
- set_charset(cs1, co1);
+ /*
+ We do allow to use binary strings (like BLOBS)
+ together with character strings.
+ Binaries have more precedance
+ */
+ if ((derivation <= dt.derivation) && (collation == &my_charset_bin))
+ {
+ // Do nothing
+ }
+ else if ((dt.derivation <= derivation) && (dt.collation==&my_charset_bin))
+ {
+ set(dt);
+ }
+ else
+ {
+ set(0, DERIVATION_NONE);
+ return 1;
+ }
}
- else if (co2 < co1)
+ else if (derivation < dt.derivation)
{
- set_charset(cs2, co2);
+ // Do nothing
}
- else // co2 == co1
+ else if (dt.derivation < derivation)
{
- if (cs1 != cs2)
+ set(dt);
+ }
+ else
+ {
+ if (collation == dt.collation)
{
- if (co1 == DERIVATION_EXPLICIT)
- {
- return 1;
- }
- else
+ // Do nothing
+ }
+ else
+ {
+ if (derivation == DERIVATION_EXPLICIT)
{
- CHARSET_INFO *bin= get_charset_by_csname(cs1->csname, MY_CS_BINSORT,MYF(0));
- if (!bin)
- return 1;
- set_charset(bin, DERIVATION_NONE);
+ set(0, DERIVATION_NONE);
+ return 1;
}
+ CHARSET_INFO *bin= get_charset_by_csname(collation->csname,
+ MY_CS_BINSORT,MYF(0));
+ set(bin, DERIVATION_NONE);
}
- else
- set_charset(cs2, co2);
}
return 0;
}