diff options
author | unknown <konstantin@mysql.com> | 2006-06-27 00:52:56 +0400 |
---|---|---|
committer | unknown <konstantin@mysql.com> | 2006-06-27 00:52:56 +0400 |
commit | cf119987f1e966dcf63e542124cf84f3514d4b69 (patch) | |
tree | 01243a7bebf93caf027de3eb8cf04f4d328e2f47 /sql/sql_class.h | |
parent | c3cb46908c30895e0aafa0f7602370240a3c5a98 (diff) | |
parent | d6bcbfbe92db6aa3cb955ed0fb1f1a8e6f8bbb60 (diff) | |
download | mariadb-git-cf119987f1e966dcf63e542124cf84f3514d4b69.tar.gz |
Merge bk-internal.mysql.com:/home/bk/mysql-5.0-runtime
into mysql.com:/opt/local/work/mysql-5.0-17199
mysql-test/r/create.result:
Auto merged
mysql-test/t/create.test:
Auto merged
sql/item_strfunc.cc:
Auto merged
sql/log_event.cc:
Auto merged
sql/slave.cc:
Auto merged
sql/sp_head.cc:
Auto merged
sql/sql_class.h:
Auto merged
sql/sql_db.cc:
Auto merged
sql/sql_insert.cc:
Auto merged
sql/sql_lex.h:
Auto merged
sql/sql_parse.cc:
Auto merged
sql/sql_table.cc:
Auto merged
sql/sql_yacc.yy:
Auto merged
mysql-test/r/sp.result:
SCCS merged
mysql-test/t/sp.test:
SCCS merged
Diffstat (limited to 'sql/sql_class.h')
-rw-r--r-- | sql/sql_class.h | 43 |
1 files changed, 42 insertions, 1 deletions
diff --git a/sql/sql_class.h b/sql/sql_class.h index 2cfc9142453..47150912c52 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -1571,6 +1571,47 @@ public: void restore_sub_statement_state(Sub_statement_state *backup); void set_n_backup_active_arena(Query_arena *set, Query_arena *backup); void restore_active_arena(Query_arena *set, Query_arena *backup); + + /* + Initialize the current database from a NULL-terminated string with length + */ + void set_db(const char *new_db, uint new_db_len) + { + if (new_db) + { + /* Do not reallocate memory if current chunk is big enough. */ + if (db && db_length >= new_db_len) + memcpy(db, new_db, new_db_len+1); + else + { + safeFree(db); + db= my_strdup_with_length(new_db, new_db_len, MYF(MY_WME)); + } + db_length= db ? new_db_len: 0; + } + } + void reset_db(char *new_db, uint new_db_len) + { + db= new_db; + db_length= new_db_len; + } + /* + Copy the current database to the argument. Use the current arena to + allocate memory for a deep copy: current database may be freed after + a statement is parsed but before it's executed. + */ + bool copy_db_to(char **p_db, uint *p_db_length) + { + if (db == NULL) + { + my_message(ER_NO_DB_ERROR, ER(ER_NO_DB_ERROR), MYF(0)); + return TRUE; + } + *p_db= strmake(db, db_length); + if (p_db_length) + *p_db_length= db_length; + return FALSE; + } }; @@ -1916,7 +1957,7 @@ typedef struct st_sort_buffer { class Table_ident :public Sql_alloc { - public: +public: LEX_STRING db; LEX_STRING table; SELECT_LEX_UNIT *sel; |