Commit 916caac2 authored by Alexander Barkov's avatar Alexander Barkov

MDEV-33019 The database part is not case sensitive in SP names

Part#1 A non-functional change

Changing the signature of Identifier_chain2::make_qname() from

  bool make_qname(MEM_ROOT *mem_root, LEX_CSTRING *dst) const;

to

  LEX_CSTRING make_qname(MEM_ROOT *mem_root) const;

Now the result is returned as LEX_CSTRING from the function rather than
is passed as a parameter.
The return value {NULL,0} means "EOM".
parent 371bf4ab
...@@ -7088,20 +7088,21 @@ class Identifier_chain2 ...@@ -7088,20 +7088,21 @@ class Identifier_chain2
} }
// Export as a qualified name string, allocate on mem_root. // Export as a qualified name string, allocate on mem_root.
bool make_qname(MEM_ROOT *mem_root, LEX_CSTRING *dst) const LEX_CSTRING make_qname(MEM_ROOT *mem_root) const
{ {
const uint dot= !!m_name[0].length; LEX_STRING dst;
char *tmp;
/* format: [pkg + dot] + name + '\0' */ /* format: [pkg + dot] + name + '\0' */
dst->length= m_name[0].length + dot + m_name[1].length; size_t dst_size= m_name[0].length + 1 /*dot*/ + m_name[1].length + 1/*\0*/;
if (unlikely(!(dst->str= tmp= (char*) alloc_root(mem_root, if (unlikely(!(dst.str= (char*) alloc_root(mem_root, dst_size))))
dst->length + 1)))) return {NULL, 0};
return true; if (!m_name[0].length)
snprintf(tmp, dst->length + 1, "%.*s%.*s%.*s", {
(int) m_name[0].length, (m_name[0].length ? m_name[0].str : ""), dst.length= my_snprintf(dst.str, dst_size, "%.*s",
dot, ".", (int) m_name[1].length, m_name[1].str);
(int) m_name[1].length, m_name[1].str); return {dst.str, dst.length};
return false; }
dst.length= make_qname(dst.str, dst_size);
return {dst.str, dst.length};
} }
}; };
...@@ -7154,10 +7155,10 @@ class Database_qualified_name ...@@ -7154,10 +7155,10 @@ class Database_qualified_name
return Identifier_chain2(m_db, m_name).make_qname(dst, dstlen); return Identifier_chain2(m_db, m_name).make_qname(dst, dstlen);
} }
// Export db and name as a qualified name string, allocate on mem_root. // Export db and name as a qualified name string, allocate on mem_root.
bool make_qname(MEM_ROOT *mem_root, LEX_CSTRING *dst) const LEX_CSTRING make_qname(MEM_ROOT *mem_root) const
{ {
DBUG_SLOW_ASSERT(ok_for_lower_case_names(m_db.str)); DBUG_SLOW_ASSERT(ok_for_lower_case_names(m_db.str));
return Identifier_chain2(m_db, m_name).make_qname(mem_root, dst); return Identifier_chain2(m_db, m_name).make_qname(mem_root);
} }
bool make_package_routine_name(MEM_ROOT *mem_root, bool make_package_routine_name(MEM_ROOT *mem_root,
......
...@@ -6754,7 +6754,8 @@ sp_head *LEX::make_sp_head(THD *thd, const sp_name *name, ...@@ -6754,7 +6754,8 @@ sp_head *LEX::make_sp_head(THD *thd, const sp_name *name,
name->m_name); name->m_name);
else else
sp->init_sp_name(name); sp->init_sp_name(name);
sp->make_qname(sp->get_main_mem_root(), &sp->m_qname); if (!(sp->m_qname= sp->make_qname(sp->get_main_mem_root())).str)
return NULL;
} }
sphead= sp; sphead= sp;
} }
...@@ -8632,7 +8633,7 @@ bool LEX::call_statement_start(THD *thd, const LEX_CSTRING &db, ...@@ -8632,7 +8633,7 @@ bool LEX::call_statement_start(THD *thd, const LEX_CSTRING &db,
// Concat `pkg` and `name` to `pkg.name` // Concat `pkg` and `name` to `pkg.name`
LEX_CSTRING pkg_dot_proc; LEX_CSTRING pkg_dot_proc;
if (q_pkg_proc.make_qname(thd->mem_root, &pkg_dot_proc) || if (!(pkg_dot_proc= q_pkg_proc.make_qname(thd->mem_root)).str ||
check_ident_length(&pkg_dot_proc) || check_ident_length(&pkg_dot_proc) ||
!(spname= new (thd->mem_root) sp_name(&db, &pkg_dot_proc, true))) !(spname= new (thd->mem_root) sp_name(&db, &pkg_dot_proc, true)))
return true; return true;
...@@ -8698,7 +8699,8 @@ sp_package *LEX::create_package_start(THD *thd, ...@@ -8698,7 +8699,8 @@ sp_package *LEX::create_package_start(THD *thd,
return NULL; return NULL;
pkg->reset_thd_mem_root(thd); pkg->reset_thd_mem_root(thd);
pkg->init(this); pkg->init(this);
pkg->make_qname(pkg->get_main_mem_root(), &pkg->m_qname); if (!(pkg->m_qname= pkg->make_qname(pkg->get_main_mem_root())).str)
return NULL;
sphead= pkg; sphead= pkg;
return pkg; return pkg;
} }
...@@ -9043,7 +9045,7 @@ Item *LEX::make_item_func_call_generic(THD *thd, ...@@ -9043,7 +9045,7 @@ Item *LEX::make_item_func_call_generic(THD *thd,
// Concat `pkg` and `name` to `pkg.name` // Concat `pkg` and `name` to `pkg.name`
LEX_CSTRING pkg_dot_func; LEX_CSTRING pkg_dot_func;
if (q_pkg_func.make_qname(thd->mem_root, &pkg_dot_func) || if (!(pkg_dot_func= q_pkg_func.make_qname(thd->mem_root)).str ||
check_ident_length(&pkg_dot_func) || check_ident_length(&pkg_dot_func) ||
!(qname= new (thd->mem_root) sp_name(&db, &pkg_dot_func, true))) !(qname= new (thd->mem_root) sp_name(&db, &pkg_dot_func, true)))
return NULL; return NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment