summaryrefslogtreecommitdiff
path: root/sql/sql_class.h
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mariadb.org>2017-03-31 14:26:43 +0400
committerAlexander Barkov <bar@mariadb.org>2017-03-31 14:26:43 +0400
commite191833d758e89d282aea2d84126c9ca10036571 (patch)
treef72e6169c5d1e2088b948ec301e9ed00065704ec /sql/sql_class.h
parent0d8dc74d3039753877c174a53b59c5f3d220113b (diff)
downloadmariadb-git-e191833d758e89d282aea2d84126c9ca10036571.tar.gz
MDEV-12415 Remove sp_name::m_qname
Diffstat (limited to 'sql/sql_class.h')
-rw-r--r--sql/sql_class.h62
1 files changed, 62 insertions, 0 deletions
diff --git a/sql/sql_class.h b/sql/sql_class.h
index 5b18f99022f..0572b3791a4 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -5757,6 +5757,68 @@ class Sql_mode_save
sql_mode_t old_mode; // SQL mode saved at construction time.
};
+
+/**
+ This class resembles the SQL Standard schema qualified object name:
+ <schema qualified name> ::= [ <schema name> <period> ] <qualified identifier>
+*/
+class Database_qualified_name
+{
+public:
+ LEX_STRING m_db;
+ LEX_STRING m_name;
+ Database_qualified_name(const LEX_STRING db, const LEX_STRING name)
+ :m_db(db), m_name(name)
+ { }
+ Database_qualified_name(char *db, size_t db_length,
+ char *name, size_t name_length)
+ {
+ m_db.str= db;
+ m_db.length= db_length;
+ m_name.str= name;
+ m_name.length= name_length;
+ }
+
+ // Export db and name as a qualified name string: 'db.name'
+ size_t make_qname(char *dst, size_t dstlen) const
+ {
+ return my_snprintf(dst, dstlen, "%.*s.%.*s",
+ (int) m_db.length, m_db.str,
+ (int) m_name.length, m_name.str);
+ }
+ // Export db and name as a qualified name string, allocate on mem_root.
+ bool make_qname(THD *thd, LEX_STRING *dst) const
+ {
+ const uint dot= !!m_db.length;
+ /* format: [database + dot] + name + '\0' */
+ dst->length= m_db.length + dot + m_name.length;
+ if (!(dst->str= (char*) thd->alloc(dst->length + 1)))
+ return true;
+ sprintf(dst->str, "%.*s%.*s%.*s",
+ (int) m_db.length, (m_db.length ? m_db.str : ""),
+ dot, ".",
+ (int) m_name.length, m_name.str);
+ DBUG_ASSERT(ok_for_lower_case_names(m_db.str));
+ return false;
+ }
+};
+
+
+class ErrConvDQName: public ErrConv
+{
+ const Database_qualified_name *m_name;
+public:
+ ErrConvDQName(const Database_qualified_name *name)
+ :m_name(name)
+ { }
+ const char *ptr() const
+ {
+ m_name->make_qname(err_buffer, sizeof(err_buffer));
+ return err_buffer;
+ }
+};
+
+
#endif /* MYSQL_SERVER */
#endif /* SQL_CLASS_INCLUDED */