List:Commits« Previous MessageNext Message »
From:Roy Lyseng Date:August 28 2009 8:12am
Subject:Re: bzr commit into mysql-5.4 branch (roy.lyseng:2800) WL#5070
View as plain text  

Tor Didriksen wrote:
> On Thu, 27 Aug 2009 09:37:12 +0200, Roy Lyseng <Roy.Lyseng@stripped> wrote:
> 
>> #At file:///home/rl136806/mysql/repo/mysql-reeng/ based on 
>> revid:jon.hauglid@stripped
>>
>>  2800 Roy Lyseng    2009-08-27
>>       WL#5070 - Prepare Sql_cmd class for addition of new statement 
>> classes.
>>      - Renamed class Sql_statement to Sql_cmd.
>>       - Added a new file sql/sql_cmd.h and moved the definition of 
>> class Sql_cmd,
>>         including the enum_sql_command, to this file.
>>       - Removed the m_lex member from the base class.
>>       - Added a virtual method sql_command_code() that will return the
> 
> NITPICK: C++ doesn't have methods, it has (virtual) member functions.
> 
>> legacy
>>         SQLCOM_ code from the SQL command object.
>>       sql/sql_class.h
>>         Updated friend classes.
>>       sql/sql_cmd.h
>>         Contains definition of class Sql_cmd and enum_sql_command.
>>       sql/sql_error.h
>>         Updated friend classes.
>>       sql/sql_lex.h
>>         Removed definition of class Sql_statement and enum_sql_command.
>>       sql/sql_signal.cc
>>         Updated class names.
>>       sql/sql_signal.h
>>         Updated class names.
>>
>>     added:
>>       sql/sql_cmd.h
>>     modified:
>>       sql/Makefile.am
>>       sql/sql_class.h
>>       sql/sql_error.cc
>>       sql/sql_error.h
>>       sql/sql_lex.cc
>>       sql/sql_lex.h
>>       sql/sql_parse.cc
>>       sql/sql_signal.cc
>>       sql/sql_signal.h
>>       sql/sql_yacc.yy
>> === modified file 'sql/Makefile.am'
>> --- a/sql/Makefile.am    2009-07-31 20:21:25 +0000
>> +++ b/sql/Makefile.am    2009-08-27 07:33:27 +0000
>> @@ -103,7 +103,7 @@ noinst_HEADERS =    item.h item_func.h item
>>              probes.h sql_audit.h transaction.h \
>>              contributors.h sql_servers.h bml.h \
>>              si_objects.h si_logs.h sql_plist.h mdl.h records.h \
>> -            sql_signal.h \
>> +            sql_cmd.h sql_signal.h \
>>              rpl_handler.h replication.h sql_prepare.h debug_sync.h
>> mysqld_SOURCES =    sql_lex.cc sql_handler.cc sql_partition.cc \
>>
>> === modified file 'sql/sql_class.h'
>> --- a/sql/sql_class.h    2009-08-26 09:14:05 +0000
>> +++ b/sql/sql_class.h    2009-08-27 07:33:27 +0000
>> @@ -2560,9 +2560,9 @@ private:
>>      To raise a SQL condition, the code should use the public
>>      raise_error() or raise_warning() methods provided by class THD.
>>    */
>> -  friend class Signal_common;
>> -  friend class Signal_statement;
>> -  friend class Resignal_statement;
>> +  friend class Sql_cmd_common_signal;
>> +  friend class Sql_cmd_signal;
>> +  friend class Sql_cmd_resignal;
>>    friend void push_warning(THD*, MYSQL_ERROR::enum_warning_level, 
>> uint, const char*);
>>    friend void my_message_sql(uint, const char *, myf);
>>
>> === added file 'sql/sql_cmd.h'
>> --- a/sql/sql_cmd.h    1970-01-01 00:00:00 +0000
>> +++ b/sql/sql_cmd.h    2009-08-27 07:33:27 +0000
>> @@ -0,0 +1,169 @@
>> +/* Copyright 2009 Sun Microsystems, Inc.
>> +
>> +   This program is free software; you can redistribute it and/or modify
>> +   it under the terms of the GNU General Public License as published by
>> +   the Free Software Foundation; version 2 of the License.
>> +
>> +   This program is distributed in the hope that it will be useful,
>> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
>> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>> +   GNU General Public License for more details.
>> +
>> +   You should have received a copy of the GNU General Public License
>> +   along with this program; if not, write to the Free Software
>> +   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  
>> 02111-1307  USA */
>> +
>> +/**
>> +  @file Representation of an SQL command.
>> +*/
>> +
>> +#ifndef SQL_CMD_H
>> +#define SQL_CMD_H
> 
> I think this should be SQL_CMD_H_INCLUDED

..or rather SQL_CMD_INCLUDED
> 
>> +
>> +/*
>> +  When a command is added here, be sure it's also added in mysqld.cc
>> +  in "struct show_var_st status_vars[]= {" ...
>> +
>> +  If the command returns a result set or is not allowed in stored
>> +  functions or triggers, please also make sure that
>> +  sp_get_flags_for_command (sp_head.cc) returns proper flags for the
>> +  added SQLCOM_.
>> +*/
>> +
>> +enum enum_sql_command {
>> +  SQLCOM_SELECT, SQLCOM_CREATE_TABLE, SQLCOM_CREATE_INDEX, 
>> SQLCOM_ALTER_TABLE,
>> +  SQLCOM_UPDATE, SQLCOM_INSERT, SQLCOM_INSERT_SELECT,
>> +  SQLCOM_DELETE, SQLCOM_TRUNCATE, SQLCOM_DROP_TABLE, SQLCOM_DROP_INDEX,
>> +
>> +  SQLCOM_SHOW_DATABASES, SQLCOM_SHOW_TABLES, SQLCOM_SHOW_FIELDS,
>> +  SQLCOM_SHOW_KEYS, SQLCOM_SHOW_VARIABLES, SQLCOM_SHOW_STATUS,
>> +  SQLCOM_SHOW_ENGINE_LOGS, SQLCOM_SHOW_ENGINE_STATUS, 
>> SQLCOM_SHOW_ENGINE_MUTEX,
>> +  SQLCOM_SHOW_PROCESSLIST, SQLCOM_SHOW_MASTER_STAT, 
>> SQLCOM_SHOW_SLAVE_STAT,
>> +  SQLCOM_SHOW_GRANTS, SQLCOM_SHOW_CREATE, SQLCOM_SHOW_CHARSETS,
>> +  SQLCOM_SHOW_COLLATIONS, SQLCOM_SHOW_CREATE_DB, 
>> SQLCOM_SHOW_TABLE_STATUS,
>> +  SQLCOM_SHOW_TRIGGERS,
>> +
>> +  SQLCOM_LOAD,SQLCOM_SET_OPTION,SQLCOM_LOCK_TABLES,SQLCOM_UNLOCK_TABLES,
>> +  SQLCOM_GRANT,
>> +  SQLCOM_CHANGE_DB, SQLCOM_CREATE_DB, SQLCOM_DROP_DB, SQLCOM_ALTER_DB,
>> +  SQLCOM_REPAIR, SQLCOM_REPLACE, SQLCOM_REPLACE_SELECT,
>> +  SQLCOM_CREATE_FUNCTION, SQLCOM_DROP_FUNCTION,
>> +  SQLCOM_REVOKE,SQLCOM_OPTIMIZE, SQLCOM_CHECK,
>> +  SQLCOM_ASSIGN_TO_KEYCACHE, SQLCOM_PRELOAD_KEYS,
>> +  SQLCOM_FLUSH, SQLCOM_KILL, SQLCOM_ANALYZE,
>> +  SQLCOM_ROLLBACK, SQLCOM_ROLLBACK_TO_SAVEPOINT,
>> +  SQLCOM_COMMIT, SQLCOM_SAVEPOINT, SQLCOM_RELEASE_SAVEPOINT,
>> +  SQLCOM_SLAVE_START, SQLCOM_SLAVE_STOP,
>> +  SQLCOM_BEGIN, SQLCOM_CHANGE_MASTER,
>> +  SQLCOM_RENAME_TABLE,
>> +  SQLCOM_RESET, SQLCOM_PURGE, SQLCOM_PURGE_BEFORE, SQLCOM_SHOW_BINLOGS,
>> +  SQLCOM_SHOW_OPEN_TABLES,
>> +  SQLCOM_HA_OPEN, SQLCOM_HA_CLOSE, SQLCOM_HA_READ,
>> +  SQLCOM_SHOW_SLAVE_HOSTS, SQLCOM_DELETE_MULTI, SQLCOM_UPDATE_MULTI,
>> +  SQLCOM_SHOW_BINLOG_EVENTS, SQLCOM_SHOW_NEW_MASTER, SQLCOM_DO,
>> +  SQLCOM_SHOW_WARNS, SQLCOM_EMPTY_QUERY, SQLCOM_SHOW_ERRORS,
>> +  SQLCOM_SHOW_STORAGE_ENGINES, SQLCOM_SHOW_PRIVILEGES,
>> +  SQLCOM_HELP, SQLCOM_CREATE_USER, SQLCOM_DROP_USER, SQLCOM_RENAME_USER,
>> +  SQLCOM_REVOKE_ALL, SQLCOM_CHECKSUM,
>> +  SQLCOM_CREATE_PROCEDURE, SQLCOM_CREATE_SPFUNCTION, SQLCOM_CALL,
>> +  SQLCOM_DROP_PROCEDURE, SQLCOM_ALTER_PROCEDURE,SQLCOM_ALTER_FUNCTION,
>> +  SQLCOM_SHOW_CREATE_PROC, SQLCOM_SHOW_CREATE_FUNC,
>> +  SQLCOM_SHOW_STATUS_PROC, SQLCOM_SHOW_STATUS_FUNC,
>> +  SQLCOM_PREPARE, SQLCOM_EXECUTE, SQLCOM_DEALLOCATE_PREPARE,
>> +  SQLCOM_CREATE_VIEW, SQLCOM_DROP_VIEW,
>> +  SQLCOM_CREATE_TRIGGER, SQLCOM_DROP_TRIGGER,
>> +  SQLCOM_XA_START, SQLCOM_XA_END, SQLCOM_XA_PREPARE,
>> +  SQLCOM_XA_COMMIT, SQLCOM_XA_ROLLBACK, SQLCOM_XA_RECOVER,
>> +  SQLCOM_SHOW_PROC_CODE, SQLCOM_SHOW_FUNC_CODE,
>> +  SQLCOM_ALTER_TABLESPACE,
>> +  SQLCOM_INSTALL_PLUGIN, SQLCOM_UNINSTALL_PLUGIN,
>> +  SQLCOM_SHOW_AUTHORS, SQLCOM_BINLOG_BASE64_EVENT,
>> +  SQLCOM_SHOW_PLUGINS,
>> +  SQLCOM_SHOW_CONTRIBUTORS,
>> +  SQLCOM_CREATE_SERVER, SQLCOM_DROP_SERVER, SQLCOM_ALTER_SERVER,
>> +  SQLCOM_CREATE_EVENT, SQLCOM_ALTER_EVENT, SQLCOM_DROP_EVENT,
>> +  SQLCOM_SHOW_CREATE_EVENT, SQLCOM_SHOW_EVENTS,
>> +  SQLCOM_SHOW_CREATE_TRIGGER,
>> +  SQLCOM_ALTER_DB_UPGRADE,
>> +  SQLCOM_BACKUP, SQLCOM_RESTORE, SQLCOM_PURGE_BACKUP_LOGS,
>> +  SQLCOM_SHOW_PROFILE, SQLCOM_SHOW_PROFILES,
>> +  SQLCOM_SIGNAL, SQLCOM_RESIGNAL,
>> +  SQLCOM_SHOW_RELAYLOG_EVENTS,
>> +
>> +  /*
>> +    When a command is added here, be sure it's also added in mysqld.cc
>> +    in "struct show_var_st status_vars[]= {" ...
>> +  */
>> +  /*
>> +    Conditional SQL command codes are not recommended, but if you 
>> need to
>> +    define them, make sure that they are defined immediately before 
>> SQLCOM_END.
>> +  */
>> +#ifdef BACKUP_TEST
>> +  SQLCOM_BACKUP_TEST,
>> +#endif
>> +  /* This should be the last !!! */
>> +  SQLCOM_END
>> +};
>> +
>> +/**
>> +  @class Sql_cmd - Representation of an SQL command.
>> +
>> +  This class is an interface between the parser and the runtime.
>> +  The parser builds the appropriate derived classes of Sql_cmd
>> +  to represent a SQL statement in the parsed tree.
>> +  The execute() method in the derived classes of Sql_cmd contain the 
>> runtime
>> +  implementation.
>> +  Note that this interface is used for SQL statements recently 
>> implemented,
>> +  the code for older statements tend to load the LEX structure with more
>> +  attributes instead.
>> +  Implement new statements by sub-classing Sql_cmd, as this improves
>> +  code modularity (see the 'big switch' in dispatch_command()), and 
>> decreases
>> +  the total size of the LEX structure (therefore saving memory in stored
>> +  programs).
>> +  The recommended name of a derived class of Sql_cmd is 
>> Sql_cmd_<derived>.
>> +
>> +  Notice that the Sql_cmd class should not be confused with the 
>> Statement class.
>> +  Statement is a class that is used to manage an SQL command or a set
>> +  of SQL commands. When the SQL statement text is analyzed, the 
>> parser will
>> +  create one or more Sql_cmd objects to represent the actual SQL 
>> commands.
>> +*/
>> +class Sql_cmd : public Sql_alloc
>> +{
>> +private:
>> +  Sql_cmd(const Sql_cmd &);         // No copy constructor wanted
>> +  void operator=(Sql_cmd &);        // No assignment operator wanted
>> +
>> +public:
>> +  /**
>> +    @brief Return the command code for this statement
>> +  */
> 
> Add blank line
> 
>> +  virtual enum_sql_command sql_command_code() const = 0;

Here, I think...
>> +  /**
>> +    Execute this SQL statement.
>> +    @param thd the current thread.
>> +    @retval false on success.
>> +    @retval true on error
>> +  */
>> +  virtual bool execute(THD *thd) = 0;
>> +
>> +protected:
>> +  /**
>> +    Constructor.
>> +  */
> 
> This function is obvious, no need for the comment. Similarly for 
> destructor below.

OK.
> 
>> +  Sql_cmd()
>> +  {}
>> +
>> +  /** Destructor. */
>> +  virtual ~Sql_cmd()
>> +  {
>> +    /*
>> +      Sql_cmd objects are allocated in thd->mem_root.
>> +      In MySQL, the C++ destructor is never called, the underlying 
>> MEM_ROOT is
>> +      simply destroyed instead.
>> +      Do not rely on the destructor for any cleanup.
>> +    */
>> +    DBUG_ASSERT(FALSE);
>> +  }
>> +};
>> +
>> +#endif /* Include guard */
> 
> I would prefer
> # endif  // SQL_CMD_H_INCLUDED

OK - but without space within #endif
> 
>>
>> === modified file 'sql/sql_error.cc'
>> --- a/sql/sql_error.cc    2009-07-30 09:41:30 +0000
>> +++ b/sql/sql_error.cc    2009-08-27 07:33:27 +0000
>> @@ -153,7 +153,7 @@ This file contains the implementation of
>>    This is implemented by using 'String MYSQL_ERROR::m_message_text'.
>>   The UTF8 -> error_message_charset_info conversion is implemented in
>> -  Signal_common::eval_signal_informations() (for path #B and #C).
>> +  Sql_cmd_common_signal::eval_signal_informations() (for path #B and 
>> #C).
>>   Future work
>>    -----------
>>
>> === modified file 'sql/sql_error.h'
>> --- a/sql/sql_error.h    2009-07-30 09:41:30 +0000
>> +++ b/sql/sql_error.h    2009-08-27 07:33:27 +0000
>> @@ -213,9 +213,9 @@ private:
>>    */
>>    friend class THD;
>>    friend class Warning_info;
>> -  friend class Signal_common;
>> -  friend class Signal_statement;
>> -  friend class Resignal_statement;
>> +  friend class Sql_cmd_common_signal;
>> +  friend class Sql_cmd_signal;
>> +  friend class Sql_cmd_resignal;
>>    friend class sp_rcontext;
>>   /**
>> @@ -512,7 +512,7 @@ private:
>>    /** Read only status. */
>>    bool m_read_only;
>> -  friend class Resignal_statement;
>> +  friend class Sql_cmd_resignal;
>>  };
>> /////////////////////////////////////////////////////////////////////////// 
>>
>>
>> === modified file 'sql/sql_lex.cc'
>> --- a/sql/sql_lex.cc    2009-07-28 14:16:37 +0000
>> +++ b/sql/sql_lex.cc    2009-08-27 07:33:27 +0000
>> @@ -341,6 +341,7 @@ void lex_start(THD *thd)
>>    lex->select_lex.group_list.empty();
>>    lex->select_lex.order_list.empty();
>>    lex->sql_command= SQLCOM_END;
>> +  lex->m_sql_cmd= NULL;
>>    lex->duplicates= DUP_ERROR;
>>    lex->ignore= 0;
>>    lex->spname= NULL;
>>
>> === modified file 'sql/sql_lex.h'
>> --- a/sql/sql_lex.h    2009-08-26 09:14:05 +0000
>> +++ b/sql/sql_lex.h    2009-08-27 07:33:27 +0000
>> @@ -55,86 +55,7 @@ class Event_parse_data;
>>  #endif
>>  #endif
>> -/*
>> -  When a command is added here, be sure it's also added in mysqld.cc
>> -  in "struct show_var_st status_vars[]= {" ...
>> -
>> -  If the command returns a result set or is not allowed in stored
>> -  functions or triggers, please also make sure that
>> -  sp_get_flags_for_command (sp_head.cc) returns proper flags for the
>> -  added SQLCOM_.
>> -*/
>> -
>> -enum enum_sql_command {
>> -  SQLCOM_SELECT, SQLCOM_CREATE_TABLE, SQLCOM_CREATE_INDEX, 
>> SQLCOM_ALTER_TABLE,
>> -  SQLCOM_UPDATE, SQLCOM_INSERT, SQLCOM_INSERT_SELECT,
>> -  SQLCOM_DELETE, SQLCOM_TRUNCATE, SQLCOM_DROP_TABLE, SQLCOM_DROP_INDEX,
>> -
>> -  SQLCOM_SHOW_DATABASES, SQLCOM_SHOW_TABLES, SQLCOM_SHOW_FIELDS,
>> -  SQLCOM_SHOW_KEYS, SQLCOM_SHOW_VARIABLES, SQLCOM_SHOW_STATUS,
>> -  SQLCOM_SHOW_ENGINE_LOGS, SQLCOM_SHOW_ENGINE_STATUS, 
>> SQLCOM_SHOW_ENGINE_MUTEX,
>> -  SQLCOM_SHOW_PROCESSLIST, SQLCOM_SHOW_MASTER_STAT, 
>> SQLCOM_SHOW_SLAVE_STAT,
>> -  SQLCOM_SHOW_GRANTS, SQLCOM_SHOW_CREATE, SQLCOM_SHOW_CHARSETS,
>> -  SQLCOM_SHOW_COLLATIONS, SQLCOM_SHOW_CREATE_DB, 
>> SQLCOM_SHOW_TABLE_STATUS,
>> -  SQLCOM_SHOW_TRIGGERS,
>> -
>> -  SQLCOM_LOAD,SQLCOM_SET_OPTION,SQLCOM_LOCK_TABLES,SQLCOM_UNLOCK_TABLES,
>> -  SQLCOM_GRANT,
>> -  SQLCOM_CHANGE_DB, SQLCOM_CREATE_DB, SQLCOM_DROP_DB, SQLCOM_ALTER_DB,
>> -  SQLCOM_REPAIR, SQLCOM_REPLACE, SQLCOM_REPLACE_SELECT,
>> -  SQLCOM_CREATE_FUNCTION, SQLCOM_DROP_FUNCTION,
>> -  SQLCOM_REVOKE,SQLCOM_OPTIMIZE, SQLCOM_CHECK,
>> -  SQLCOM_ASSIGN_TO_KEYCACHE, SQLCOM_PRELOAD_KEYS,
>> -  SQLCOM_FLUSH, SQLCOM_KILL, SQLCOM_ANALYZE,
>> -  SQLCOM_ROLLBACK, SQLCOM_ROLLBACK_TO_SAVEPOINT,
>> -  SQLCOM_COMMIT, SQLCOM_SAVEPOINT, SQLCOM_RELEASE_SAVEPOINT,
>> -  SQLCOM_SLAVE_START, SQLCOM_SLAVE_STOP,
>> -  SQLCOM_BEGIN, SQLCOM_CHANGE_MASTER,
>> -  SQLCOM_RENAME_TABLE,
>> -  SQLCOM_RESET, SQLCOM_PURGE, SQLCOM_PURGE_BEFORE, SQLCOM_SHOW_BINLOGS,
>> -  SQLCOM_SHOW_OPEN_TABLES,
>> -  SQLCOM_HA_OPEN, SQLCOM_HA_CLOSE, SQLCOM_HA_READ,
>> -  SQLCOM_SHOW_SLAVE_HOSTS, SQLCOM_DELETE_MULTI, SQLCOM_UPDATE_MULTI,
>> -  SQLCOM_SHOW_BINLOG_EVENTS, SQLCOM_SHOW_NEW_MASTER, SQLCOM_DO,
>> -  SQLCOM_SHOW_WARNS, SQLCOM_EMPTY_QUERY, SQLCOM_SHOW_ERRORS,
>> -  SQLCOM_SHOW_STORAGE_ENGINES, SQLCOM_SHOW_PRIVILEGES,
>> -  SQLCOM_HELP, SQLCOM_CREATE_USER, SQLCOM_DROP_USER, SQLCOM_RENAME_USER,
>> -  SQLCOM_REVOKE_ALL, SQLCOM_CHECKSUM,
>> -  SQLCOM_CREATE_PROCEDURE, SQLCOM_CREATE_SPFUNCTION, SQLCOM_CALL,
>> -  SQLCOM_DROP_PROCEDURE, SQLCOM_ALTER_PROCEDURE,SQLCOM_ALTER_FUNCTION,
>> -  SQLCOM_SHOW_CREATE_PROC, SQLCOM_SHOW_CREATE_FUNC,
>> -  SQLCOM_SHOW_STATUS_PROC, SQLCOM_SHOW_STATUS_FUNC,
>> -  SQLCOM_PREPARE, SQLCOM_EXECUTE, SQLCOM_DEALLOCATE_PREPARE,
>> -  SQLCOM_CREATE_VIEW, SQLCOM_DROP_VIEW,
>> -  SQLCOM_CREATE_TRIGGER, SQLCOM_DROP_TRIGGER,
>> -  SQLCOM_XA_START, SQLCOM_XA_END, SQLCOM_XA_PREPARE,
>> -  SQLCOM_XA_COMMIT, SQLCOM_XA_ROLLBACK, SQLCOM_XA_RECOVER,
>> -  SQLCOM_SHOW_PROC_CODE, SQLCOM_SHOW_FUNC_CODE,
>> -  SQLCOM_ALTER_TABLESPACE,
>> -  SQLCOM_INSTALL_PLUGIN, SQLCOM_UNINSTALL_PLUGIN,
>> -  SQLCOM_SHOW_AUTHORS, SQLCOM_BINLOG_BASE64_EVENT,
>> -  SQLCOM_SHOW_PLUGINS,
>> -  SQLCOM_SHOW_CONTRIBUTORS,
>> -  SQLCOM_CREATE_SERVER, SQLCOM_DROP_SERVER, SQLCOM_ALTER_SERVER,
>> -  SQLCOM_CREATE_EVENT, SQLCOM_ALTER_EVENT, SQLCOM_DROP_EVENT,
>> -  SQLCOM_SHOW_CREATE_EVENT, SQLCOM_SHOW_EVENTS,
>> -  SQLCOM_SHOW_CREATE_TRIGGER,
>> -  SQLCOM_ALTER_DB_UPGRADE,
>> -  SQLCOM_BACKUP, SQLCOM_RESTORE, SQLCOM_PURGE_BACKUP_LOGS,
>> -#ifdef BACKUP_TEST
>> -  SQLCOM_BACKUP_TEST,
>> -#endif
>> -  SQLCOM_SHOW_PROFILE, SQLCOM_SHOW_PROFILES,
>> -  SQLCOM_SIGNAL, SQLCOM_RESIGNAL,
>> -  SQLCOM_SHOW_RELAYLOG_EVENTS,
>> -
>> -  /*
>> -    When a command is added here, be sure it's also added in mysqld.cc
>> -    in "struct show_var_st status_vars[]= {" ...
>> -  */
>> -  /* This should be the last !!! */
>> -  SQLCOM_END
>> -};
>> +#include "sql_cmd.h"
>> // describe/explain types
>>  #define DESCRIBE_NORMAL        1
>> @@ -1560,62 +1481,6 @@ public:
>>    CHARSET_INFO *m_underscore_cs;
>>  };
>> -/**
>> -  Abstract representation of a statement.
>> -  This class is an interface between the parser and the runtime.
>> -  The parser builds the appropriate sub classes of Sql_statement
>> -  to represent a SQL statement in the parsed tree.
>> -  The execute() method in the sub classes contain the runtime 
>> implementation.
>> -  Note that this interface is used for SQL statement recently 
>> implemented,
>> -  the code for older statements tend to load the LEX structure with more
>> -  attributes instead.
>> -  The recommended way to implement new statements is to sub-class
>> -  Sql_statement, as this improves code modularity (see the 'big 
>> switch' in
>> -  dispatch_command()), and decrease the total size of the LEX structure
>> -  (therefore saving memory in stored programs).
>> -*/
>> -class Sql_statement : public Sql_alloc
>> -{
>> -public:
>> -  /**
>> -    Execute this SQL statement.
>> -    @param thd the current thread.
>> -    @return 0 on success.
>> -  */
>> -  virtual bool execute(THD *thd) = 0;
>> -
>> -protected:
>> -  /**
>> -    Constructor.
>> -    @param lex the LEX structure that represents parts of this 
>> statement.
>> -  */
>> -  Sql_statement(struct LEX *lex)
>> -    : m_lex(lex)
>> -  {}
>> -
>> -  /** Destructor. */
> un-necessary comment.

virtually deleted...
> 
>> -  virtual ~Sql_statement()
>> -  {
>> -    /*
>> -      Sql_statement objects are allocated in thd->mem_root.
>> -      In MySQL, the C++ destructor is never called, the underlying 
>> MEM_ROOT is
>> -      simply destroyed instead.
>> -      Do not rely on the destructor for any cleanup.
>> -    */
>> -    DBUG_ASSERT(FALSE);
>> -  }
>> -
>> -protected:
>> -  /**
>> -    The legacy LEX structure for this statement.
>> -    The LEX structure contains the existing properties of the parsed 
>> tree.
>> -    TODO: with time, attributes from LEX should move to sub classes of
>> -    Sql_statement, so that the parser only builds Sql_statement objects
>> -    with the minimum set of attributes, instead of a LEX structure that
>> -    contains the collection of every possible attribute.
>> -  */
>> -  struct LEX *m_lex;
>> -};
>> /* The state of the lex parsing. This is saved in the THD struct */
>> @@ -1721,7 +1586,7 @@ struct LEX: public Query_tables_list
>>    nesting_map allow_sum_func;
>>    enum_sql_command sql_command;
>> -  Sql_statement *m_stmt;
>> +  Sql_cmd *m_sql_cmd;
>>   /*
>>      Usually `expr` rule of yacc is quite reused but some commands better
>>
>> === modified file 'sql/sql_parse.cc'
>> --- a/sql/sql_parse.cc    2009-08-25 07:22:47 +0000
>> +++ b/sql/sql_parse.cc    2009-08-27 07:33:27 +0000
>> @@ -4809,8 +4809,8 @@ create_sp_error:
>>    }
>>    case SQLCOM_SIGNAL:
>>    case SQLCOM_RESIGNAL:
>> -    DBUG_ASSERT(lex->m_stmt != NULL);
>> -    res= lex->m_stmt->execute(thd);
>> +    DBUG_ASSERT(lex->m_sql_cmd != NULL);
>> +    res= lex->m_sql_cmd->execute(thd);
>>      break;
>>    default:
>>  #ifndef EMBEDDED_LIBRARY
>>
>> === modified file 'sql/sql_signal.cc'
>> --- a/sql/sql_signal.cc    2009-07-30 09:41:30 +0000
>> +++ b/sql/sql_signal.cc    2009-08-27 07:33:27 +0000
>> @@ -91,7 +91,8 @@ void Set_signal_information::clear()
>>    memset(m_item, 0, sizeof(m_item));
>>  }
>> -void Signal_common::assign_defaults(MYSQL_ERROR *cond,
>> +void Sql_cmd_common_signal::assign_defaults(
>> +                                    MYSQL_ERROR *cond,
>>                                      bool set_level_code,
>>                                      MYSQL_ERROR::enum_warning_level 
>> level,
>>                                      int sqlcode)
>> @@ -105,7 +106,7 @@ void Signal_common::assign_defaults(MYSQ
>>      cond->set_builtin_message_text(ER(sqlcode));
>>  }
>> -void Signal_common::eval_defaults(THD *thd, MYSQL_ERROR *cond)
>> +void Sql_cmd_common_signal::eval_defaults(THD *thd, MYSQL_ERROR *cond)
>>  {
>>    DBUG_ASSERT(cond);
>> @@ -260,7 +261,7 @@ static int assign_condition_item(MEM_ROO
>>  }
>> -int Signal_common::eval_signal_informations(THD *thd, MYSQL_ERROR *cond)
>> +int Sql_cmd_common_signal::eval_signal_informations(THD *thd, 
>> MYSQL_ERROR *cond)
>>  {
>>    struct cond_item_map
>>    {
>> @@ -292,7 +293,7 @@ int Signal_common::eval_signal_informati
>>    String *member;
>>    const LEX_STRING *name;
>> -  DBUG_ENTER("Signal_common::eval_signal_informations");
>> +  DBUG_ENTER("Sql_cmd_common_signal::eval_signal_informations");
>>   for (i= FIRST_DIAG_SET_PROPERTY;
>>         i <= LAST_DIAG_SET_PROPERTY;
>> @@ -418,13 +419,13 @@ end:
>>    DBUG_RETURN(result);
>>  }
>> -bool Signal_common::raise_condition(THD *thd, MYSQL_ERROR *cond)
>> +bool Sql_cmd_common_signal::raise_condition(THD *thd, MYSQL_ERROR *cond)
>>  {
>>    bool result= TRUE;
>> -  DBUG_ENTER("Signal_common::raise_condition");
>> +  DBUG_ENTER("Sql_cmd_common_signal::raise_condition");
>> -  DBUG_ASSERT(m_lex->query_tables == NULL);
>> +  DBUG_ASSERT(thd->lex->query_tables == NULL);
>>   eval_defaults(thd, cond);
>>    if (eval_signal_informations(thd, cond))
>> @@ -451,12 +452,12 @@ bool Signal_common::raise_condition(THD
>>    DBUG_RETURN(result);
>>  }
>> -bool Signal_statement::execute(THD *thd)
>> +bool Sql_cmd_signal::execute(THD *thd)
>>  {
>>    bool result= TRUE;
>>    MYSQL_ERROR cond(thd->mem_root);
>> -  DBUG_ENTER("Signal_statement::execute");
>> +  DBUG_ENTER("Sql_cmd_signal::execute");
>>   thd->stmt_da->reset_diagnostics_area();
>>    thd->row_count_func= 0;
>> @@ -468,12 +469,12 @@ bool Signal_statement::execute(THD *thd)
>>  }
>> -bool Resignal_statement::execute(THD *thd)
>> +bool Sql_cmd_resignal::execute(THD *thd)
>>  {
>>    MYSQL_ERROR *signaled;
>>    int result= TRUE;
>> -  DBUG_ENTER("Resignal_statement::execute");
>> +  DBUG_ENTER("Sql_cmd_resignal::execute");
>>   thd->warning_info->m_warn_id= thd->query_id;
>> @@ -507,4 +508,3 @@ bool Resignal_statement::execute(THD *th
>>   DBUG_RETURN(result);
>>  }
>> -
>>
>> === modified file 'sql/sql_signal.h'
>> --- a/sql/sql_signal.h    2009-07-30 09:41:30 +0000
>> +++ b/sql/sql_signal.h    2009-08-27 07:33:27 +0000
>> @@ -17,27 +17,25 @@
>>  #define SQL_SIGNAL_H
>> /**
>> -  Signal_common represents the common properties of the SIGNAL and 
>> RESIGNAL
>> -  statements.
>> +  Sql_cmd_common_signal represents the common properties of the
>> +  SIGNAL and RESIGNAL statements.
>>  */
>> -class Signal_common : public Sql_statement
>> +class Sql_cmd_common_signal : public Sql_cmd
>>  {
>>  protected:
>>    /**
>>      Constructor.
>> -    @param lex the LEX structure for this statement.
>>      @param cond the condition signaled if any, or NULL.
>>      @param set collection of signal condition item assignments.
>>    */
>> -  Signal_common(LEX *lex,
>> -                const sp_cond_type_t *cond,
>> -                const Set_signal_information& set)
>> -    : Sql_statement(lex),
>> +  Sql_cmd_common_signal(const sp_cond_type_t *cond,
>> +                        const Set_signal_information& set)
>> +    : Sql_cmd(),
>>        m_cond(cond),
>>        m_set_signal_information(set)
>>    {}
>> -  virtual ~Signal_common()
>> +  virtual ~Sql_cmd_common_signal()
>>    {}
>>   /**
>> @@ -91,26 +89,27 @@ protected:
>>  };
>> /**
>> -  Signal_statement represents a SIGNAL statement.
>> +  Sql_cmd_signal represents a SIGNAL statement.
>>  */
>> -class Signal_statement : public Signal_common
>> +class Sql_cmd_signal : public Sql_cmd_common_signal
>>  {
>>  public:
>>    /**
>>      Constructor, used to represent a SIGNAL statement.
>> -    @param lex the LEX structure for this statement.
>>      @param cond the SQL condition to signal (required).
>>      @param set the collection of signal informations to signal.
>>    */
>> -  Signal_statement(LEX *lex,
>> -                const sp_cond_type_t *cond,
>> -                const Set_signal_information& set)
>> -    : Signal_common(lex, cond, set)
>> +  Sql_cmd_signal(const sp_cond_type_t *cond,
>> +                 const Set_signal_information& set)
>> +    : Sql_cmd_common_signal(cond, set)
>>    {}
>> -  virtual ~Signal_statement()
>> +  virtual ~Sql_cmd_signal()
>>    {}
>> -
> 
> Add blank line between functions.

OK.
> 
>> +  virtual enum_sql_command sql_command_code() const
>> +  {
>> +    return SQLCOM_SIGNAL;
>> +  }
>>    /**
>>      Execute a SIGNAL statement at runtime.
>>      @param thd the current thread.
> 
> This is the implementation of the right?
> So this function should only be documented once,
> with a reference to the interface here.

OK
> 
>> @@ -120,30 +119,32 @@ public:
>>  };
>> /**
>> -  Resignal_statement represents a RESIGNAL statement.
>> +  Sql_cmd_resignal represents a RESIGNAL statement.
>>  */
>> -class Resignal_statement : public Signal_common
>> +class Sql_cmd_resignal : public Sql_cmd_common_signal
>>  {
>>  public:
>>    /**
>>      Constructor, used to represent a RESIGNAL statement.
>> -    @param lex the LEX structure for this statement.
>>      @param cond the SQL condition to resignal (optional, may be NULL).
>>      @param set the collection of signal informations to resignal.
>>    */
>> -  Resignal_statement(LEX *lex,
>> -                     const sp_cond_type_t *cond,
>> -                     const Set_signal_information& set)
>> -    : Signal_common(lex, cond, set)
>> +  Sql_cmd_resignal(const sp_cond_type_t *cond,
>> +                   const Set_signal_information& set)
>> +    : Sql_cmd_common_signal(cond, set)
>>    {}
>> -  virtual ~Resignal_statement()
>> +  virtual ~Sql_cmd_resignal()
>>    {}
> 
> I *think* there should be a blank line here.

Agree.
> 
>> +  virtual enum_sql_command sql_command_code() const
>> +  {
>> +    return SQLCOM_RESIGNAL;
>> +  }
>>   /**
>>      Execute a RESIGNAL statement at runtime.
>>      @param thd the current thread.
>> -    @return 0 on success.
>> +    @retval false on success.
>>    */
>>    virtual bool execute(THD *thd);
>>  };
>>
>> === modified file 'sql/sql_yacc.yy'
>> --- a/sql/sql_yacc.yy    2009-08-24 09:56:29 +0000
>> +++ b/sql/sql_yacc.yy    2009-08-27 07:33:27 +0000
>> @@ -2773,9 +2773,9 @@ signal_stmt:
>>              Yacc_state *state= & thd->m_parser_state->m_yacc;
>>             lex->sql_command= SQLCOM_SIGNAL;
>> -            lex->m_stmt= new (thd->mem_root) Signal_statement(lex, $2,
>> +            lex->m_sql_cmd= new (thd->mem_root) Sql_cmd_signal($2,
>>                                                        
>> state->m_set_signal_info);
> 
> Please indent arguments properly, similarly below.

Using this model now for constructor calls that need to be broken up:

          lex->m_sql_cmd=
            new (thd->mem_root) Sql_cmd_signal($2, state->m_set_signal_info);
          if (lex->m_sql_cmd == NULL)
            MYSQL_YYABORT;

> 
>> -            if (lex->m_stmt == NULL)
>> +            if (lex->m_sql_cmd == NULL)
>>                MYSQL_YYABORT;
>>            }
>>          ;
>> @@ -2912,9 +2912,9 @@ resignal_stmt:
>>              Yacc_state *state= & thd->m_parser_state->m_yacc;
>>             lex->sql_command= SQLCOM_RESIGNAL;
>> -            lex->m_stmt= new (thd->mem_root) Resignal_statement(lex, $2,
>> +            lex->m_sql_cmd= new (thd->mem_root) Sql_cmd_resignal($2,
>>                                                        
>> state->m_set_signal_info);
>> -            if (lex->m_stmt == NULL)
>> +            if (lex->m_sql_cmd == NULL)
>>                MYSQL_YYABORT;
>>            }
>>          ;
>>
> 
> 
> 
Thanks,
Roy
Thread
bzr commit into mysql-5.4 branch (roy.lyseng:2800) WL#5070Roy Lyseng27 Aug
  • Re: bzr commit into mysql-5.4 branch (roy.lyseng:2800) WL#5070Tor Didriksen27 Aug
    • Re: bzr commit into mysql-5.4 branch (roy.lyseng:2800) WL#5070Tor Didriksen27 Aug
    • Re: bzr commit into mysql-5.4 branch (roy.lyseng:2800) WL#5070Roy Lyseng28 Aug
      • Re: bzr commit into mysql-5.4 branch (roy.lyseng:2800) WL#5070Konstantin Osipov14 Sep