List:Commits« Previous MessageNext Message »
From:Marc Alff Date:November 15 2010 8:21am
Subject:bzr commit into mysql-trunk-wl2111 branch (marc.alff:3205) WL#2111
View as plain text  
#At file:///Users/malff/BZR_TREE/mysql-trunk-wl2111/ based on revid:marc.alff@stripped

 3205 Marc Alff	2010-11-15
      WL#2111 Stored Procedures: Implement GET DIAGNOSTICS
      
      Preserving previous work from mysql-next-mr-wl2111

    modified:
      .bzr-mysql/default.conf
      sql/item_create.cc
      sql/lex.h
      sql/mysqld.cc
      sql/sql_class.h
      sql/sql_cmd.h
      sql/sql_lex.cc
      sql/sql_lex.h
      sql/sql_signal.cc
      sql/sql_signal.h
      sql/sql_yacc.yy
=== modified file '.bzr-mysql/default.conf'
--- a/.bzr-mysql/default.conf	2010-11-13 15:58:25 +0000
+++ b/.bzr-mysql/default.conf	2010-11-15 08:20:48 +0000
@@ -1,4 +1,4 @@
 [MYSQL]
 post_commit_to = "commits@stripped"
 post_push_to = "commits@stripped"
-tree_name = "mysql-trunk"
+tree_name = "mysql-trunk-wl2111"

=== modified file 'sql/item_create.cc'
--- a/sql/item_create.cc	2010-10-28 09:54:31 +0000
+++ b/sql/item_create.cc	2010-11-15 08:20:48 +0000
@@ -1912,19 +1912,6 @@ protected:
 };
 
 
-class Create_func_row_count : public Create_func_arg0
-{
-public:
-  virtual Item *create(THD *thd);
-
-  static Create_func_row_count s_singleton;
-
-protected:
-  Create_func_row_count() {}
-  virtual ~Create_func_row_count() {}
-};
-
-
 class Create_func_rpad : public Create_func_arg3
 {
 public:
@@ -4592,18 +4579,6 @@ Create_func_round::create_native(THD *th
 }
 
 
-Create_func_row_count Create_func_row_count::s_singleton;
-
-Item*
-Create_func_row_count::create(THD *thd)
-{
-  DBUG_ENTER("Create_func_row_count::create");
-  thd->lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION);
-  thd->lex->safe_to_cache_query= 0;
-  DBUG_RETURN(new (thd->mem_root) Item_func_row_count());
-}
-
-
 Create_func_rpad Create_func_rpad::s_singleton;
 
 Item*
@@ -5264,7 +5239,6 @@ static Native_func_registry func_array[]
   { { C_STRING_WITH_LEN("RELEASE_LOCK") }, BUILDER(Create_func_release_lock)},
   { { C_STRING_WITH_LEN("REVERSE") }, BUILDER(Create_func_reverse)},
   { { C_STRING_WITH_LEN("ROUND") }, BUILDER(Create_func_round)},
-  { { C_STRING_WITH_LEN("ROW_COUNT") }, BUILDER(Create_func_row_count)},
   { { C_STRING_WITH_LEN("RPAD") }, BUILDER(Create_func_rpad)},
   { { C_STRING_WITH_LEN("RTRIM") }, BUILDER(Create_func_rtrim)},
   { { C_STRING_WITH_LEN("SEC_TO_TIME") }, BUILDER(Create_func_sec_to_time)},

=== modified file 'sql/lex.h'
--- a/sql/lex.h	2010-10-21 12:18:25 +0000
+++ b/sql/lex.h	2010-11-15 08:20:48 +0000
@@ -119,6 +119,8 @@ static SYMBOL symbols[] = {
   { "COLUMN",		SYM(COLUMN_SYM)},
   { "COLUMN_NAME",      SYM(COLUMN_NAME_SYM)},
   { "COLUMNS",		SYM(COLUMNS)},
+  { "COMMAND_FUNCTION", SYM(COMMAND_FUNCTION_SYM)},
+  { "COMMAND_FUNCTION_CODE", SYM(COMMAND_FUNCTION_CODE_SYM)},
   { "COMMENT",		SYM(COMMENT_SYM)},
   { "COMMIT",		SYM(COMMIT_SYM)},
   { "COMMITTED",	SYM(COMMITTED_SYM)},
@@ -127,7 +129,10 @@ static SYMBOL symbols[] = {
   { "COMPRESSED",	SYM(COMPRESSED_SYM)},
   { "CONCURRENT",	SYM(CONCURRENT)},
   { "CONDITION",        SYM(CONDITION_SYM)},
+  { "CONDITION_NUMBER", SYM(CONDITION_NUMBER_SYM)},
+  { "CONDITION_IDENTIFIER", SYM(CONDITION_IDENTIFIER_SYM)},
   { "CONNECTION",       SYM(CONNECTION_SYM)},
+  { "CONNECTION_NAME",  SYM(CONNECTION_NAME_SYM)},
   { "CONSISTENT",	SYM(CONSISTENT_SYM)},
   { "CONSTRAINT",	SYM(CONSTRAINT)},
   { "CONSTRAINT_CATALOG", SYM(CONSTRAINT_CATALOG_SYM)},
@@ -142,6 +147,7 @@ static SYMBOL symbols[] = {
   { "CREATE",		SYM(CREATE)},
   { "CROSS",		SYM(CROSS)},
   { "CUBE",		SYM(CUBE_SYM)},
+  { "CURRENT",          SYM(CURRENT_SYM)},
   { "CURRENT_DATE",	SYM(CURDATE)},
   { "CURRENT_TIME",	SYM(CURTIME)},
   { "CURRENT_TIMESTAMP", SYM(NOW_SYM)},
@@ -172,6 +178,7 @@ static SYMBOL symbols[] = {
   { "DESCRIBE",		SYM(DESCRIBE)},
   { "DES_KEY_FILE",	SYM(DES_KEY_FILE)},
   { "DETERMINISTIC",    SYM(DETERMINISTIC_SYM)},
+  { "DIAGNOSTICS",      SYM(DIAGNOSTICS_SYM)},
   { "DIRECTORY",	SYM(DIRECTORY_SYM)},
   { "DISABLE",		SYM(DISABLE_SYM)},
   { "DISCARD",		SYM(DISCARD)},
@@ -186,6 +193,8 @@ static SYMBOL symbols[] = {
   { "DUMPFILE",		SYM(DUMPFILE)},
   { "DUPLICATE",	SYM(DUPLICATE_SYM)},
   { "DYNAMIC",		SYM(DYNAMIC_SYM)},
+  { "DYNAMIC_FUNCTION", SYM(DYNAMIC_FUNCTION_SYM)},
+  { "DYNAMIC_FUNCTION_CODE", SYM(DYNAMIC_FUNCTION_CODE_SYM)},
   { "EACH",             SYM(EACH_SYM)},
   { "ELSE",             SYM(ELSE)},
   { "ELSEIF",           SYM(ELSEIF_SYM)},
@@ -203,6 +212,7 @@ static SYMBOL symbols[] = {
   { "EVENT",		SYM(EVENT_SYM)},
   { "EVENTS",		SYM(EVENTS_SYM)},
   { "EVERY",		SYM(EVERY_SYM)},
+  { "EXCEPTION",        SYM(EXCEPTION_SYM)},
   { "EXECUTE",		SYM(EXECUTE_SYM)},
   { "EXISTS",		SYM(EXISTS)},
   { "EXIT",             SYM(EXIT_SYM)},
@@ -234,6 +244,7 @@ static SYMBOL symbols[] = {
   { "GENERAL",          SYM(GENERAL)},
   { "GEOMETRY",		SYM(GEOMETRY_SYM)},
   { "GEOMETRYCOLLECTION",SYM(GEOMETRYCOLLECTION)},
+  { "GET",              SYM(GET_SYM)},
   { "GET_FORMAT",       SYM(GET_FORMAT)},
   { "GLOBAL",		SYM(GLOBAL_SYM)},
   { "GRANT",		SYM(GRANT)},
@@ -348,6 +359,8 @@ static SYMBOL symbols[] = {
   { "MEDIUMTEXT",	SYM(MEDIUMTEXT)},
   { "MEMORY",		SYM(MEMORY_SYM)},
   { "MERGE",		SYM(MERGE_SYM)},
+  { "MESSAGE_LENGTH",   SYM(MESSAGE_LENGTH_SYM)},
+  { "MESSAGE_OCTET_LENGTH", SYM(MESSAGE_OCTET_LENGTH_SYM)},
   { "MESSAGE_TEXT",     SYM(MESSAGE_TEXT_SYM)},
   { "MICROSECOND",	SYM(MICROSECOND_SYM)},
   { "MIDDLEINT",	SYM(MEDIUMINT)},	/* For powerbuilder */
@@ -361,6 +374,7 @@ static SYMBOL symbols[] = {
   { "MODIFIES",		SYM(MODIFIES_SYM)},
   { "MODIFY",		SYM(MODIFY_SYM)},
   { "MONTH",		SYM(MONTH_SYM)},
+  { "MORE",             SYM(MORE_SYM)},
   { "MULTILINESTRING",	SYM(MULTILINESTRING)},
   { "MULTIPOINT",	SYM(MULTIPOINT)},
   { "MULTIPOLYGON",	SYM(MULTIPOLYGON)},
@@ -382,6 +396,7 @@ static SYMBOL symbols[] = {
   { "NOT",		SYM(NOT_SYM)},
   { "NO_WRITE_TO_BINLOG",  SYM(NO_WRITE_TO_BINLOG)},
   { "NULL",		SYM(NULL_SYM)},
+  { "NUMBER",          SYM(NUMBER_SYM)},
   { "NUMERIC",		SYM(NUMERIC_SYM)},
   { "NVARCHAR",		SYM(NVARCHAR_SYM)},
   { "OFFSET",		SYM(OFFSET_SYM)},
@@ -401,6 +416,9 @@ static SYMBOL symbols[] = {
   { "OUTFILE",		SYM(OUTFILE)},
   { "OWNER",		SYM(OWNER_SYM)},
   { "PACK_KEYS",	SYM(PACK_KEYS_SYM)},
+  { "PARAMETER_MODE",   SYM(PARAMETER_MODE_SYM)},
+  { "PARAMETER_NAME",   SYM(PARAMETER_NAME_SYM)},
+  { "PARAMETER_ORDINAL_POSITION", SYM(PARAMETER_ORDINAL_POSITION_SYM)},
   { "PARSER",           SYM(PARSER_SYM)},
   { "PAGE",	        SYM(PAGE_SYM)},
   { "PARTIAL",		SYM(PARTIAL)},
@@ -465,6 +483,7 @@ static SYMBOL symbols[] = {
   { "RESTRICT",		SYM(RESTRICT)},
   { "RESUME",           SYM(RESUME_SYM)},
   { "RETURN",           SYM(RETURN_SYM)},
+  { "RETURNED_SQLSTATE", SYM(RETURNED_SQLSTATE_SYM)},
   { "RETURNS",		SYM(RETURNS_SYM)},
   { "REVERSE",		SYM(REVERSE_SYM)},
   { "REVOKE",		SYM(REVOKE)},
@@ -473,8 +492,12 @@ static SYMBOL symbols[] = {
   { "ROLLBACK",		SYM(ROLLBACK_SYM)},
   { "ROLLUP",		SYM(ROLLUP_SYM)},
   { "ROUTINE",		SYM(ROUTINE_SYM)},
+  { "ROUTINE_CATALOG",  SYM(ROUTINE_CATALOG_SYM)},
+  { "ROUTINE_NAME",     SYM(ROUTINE_NAME_SYM)},
+  { "ROUTINE_SCHEMA",   SYM(ROUTINE_SCHEMA_SYM)},
   { "ROW",		SYM(ROW_SYM)},
   { "ROWS",		SYM(ROWS_SYM)},
+  { "ROW_COUNT",        SYM(ROW_COUNT_SYM)},
   { "ROW_FORMAT",	SYM(ROW_FORMAT_SYM)},
   { "RTREE",		SYM(RTREE_SYM)},
   { "SAVEPOINT",	SYM(SAVEPOINT_SYM)},
@@ -492,6 +515,7 @@ static SYMBOL symbols[] = {
   { "SERIALIZABLE",	SYM(SERIALIZABLE_SYM)},
   { "SESSION",		SYM(SESSION_SYM)},
   { "SERVER",           SYM(SERVER_SYM)},
+  { "SERVER_NAME",      SYM(SERVER_NAME_SYM)},
   { "SET",		SYM(SET)},
   { "SHARE",		SYM(SHARE_SYM)},
   { "SHOW",		SYM(SHOW)},
@@ -510,6 +534,7 @@ static SYMBOL symbols[] = {
   { "SOURCE",   SYM(SOURCE_SYM)},
   { "SPATIAL",		SYM(SPATIAL_SYM)},
   { "SPECIFIC",         SYM(SPECIFIC_SYM)},
+  { "SPECIFIC_NAME",    SYM(SPECIFIC_NAME_SYM)},
   { "SQL",              SYM(SQL_SYM)},
   { "SQLEXCEPTION",     SYM(SQLEXCEPTION_SYM)},
   { "SQLSTATE",         SYM(SQLSTATE_SYM)},
@@ -530,6 +555,7 @@ static SYMBOL symbols[] = {
   { "SQL_TSI_QUARTER",  SYM(QUARTER_SYM)},
   { "SQL_TSI_YEAR",     SYM(YEAR_SYM)},
   { "SSL",		SYM(SSL_SYM)},
+  { "STACKED",          SYM(STACKED_SYM)},
   { "START",		SYM(START_SYM)},
   { "STARTING",		SYM(STARTING)},
   { "STARTS",		SYM(STARTS_SYM)},
@@ -567,7 +593,13 @@ static SYMBOL symbols[] = {
   { "TO",		SYM(TO_SYM)},
   { "TRAILING",		SYM(TRAILING)},
   { "TRANSACTION",	SYM(TRANSACTION_SYM)},
+  { "TRANSACTION_ACTIVE", SYM(TRANSACTION_ACTIVE_SYM)},
+  { "TRANSACTIONS_COMMITTED", SYM(TRANSACTIONS_COMMITTED_SYM)},
+  { "TRANSACTIONS_ROLLED_BACK", SYM(TRANSACTIONS_ROLLED_BACK_SYM)},
   { "TRIGGER",          SYM(TRIGGER_SYM)},
+  { "TRIGGER_CATALOG",  SYM(TRIGGER_CATALOG_SYM)},
+  { "TRIGGER_NAME",     SYM(TRIGGER_NAME_SYM)},
+  { "TRIGGER_SCHEMA",   SYM(TRIGGER_SCHEMA_SYM)},
   { "TRIGGERS",         SYM(TRIGGERS_SYM)},
   { "TRUE",		SYM(TRUE_SYM)},
   { "TRUNCATE",		SYM(TRUNCATE_SYM)},

=== modified file 'sql/mysqld.cc'
--- a/sql/mysqld.cc	2010-11-09 20:10:44 +0000
+++ b/sql/mysqld.cc	2010-11-15 08:20:48 +0000
@@ -2960,6 +2960,7 @@ SHOW_VAR com_status_vars[]= {
   {"empty_query",          (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_EMPTY_QUERY]), SHOW_LONG_STATUS},
   {"execute_sql",          (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_EXECUTE]), SHOW_LONG_STATUS},
   {"flush",                (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_FLUSH]), SHOW_LONG_STATUS},
+  {"get_diagnostics",      (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_GET_DIAGNOSTICS]), SHOW_LONG_STATUS},
   {"grant",                (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_GRANT]), SHOW_LONG_STATUS},
   {"ha_close",             (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_HA_CLOSE]), SHOW_LONG_STATUS},
   {"ha_open",              (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_HA_OPEN]), SHOW_LONG_STATUS},

=== modified file 'sql/sql_class.h'
--- a/sql/sql_class.h	2010-11-05 08:13:09 +0000
+++ b/sql/sql_class.h	2010-11-15 08:20:48 +0000
@@ -344,9 +344,51 @@ typedef enum enum_diag_condition_item_na
   DIAG_CURSOR_NAME= 9,
   DIAG_MESSAGE_TEXT= 10,
   DIAG_MYSQL_ERRNO= 11,
-  LAST_DIAG_SET_PROPERTY= DIAG_MYSQL_ERRNO
+  LAST_DIAG_SET_PROPERTY= DIAG_MYSQL_ERRNO,
+
+  /*
+    Conditions that can be set only by the server implementation.
+  */
+
+  DIAG_CONDITION_IDENTIFIER= 12,
+  DIAG_CONDITION_NUMBER= 13,
+  DIAG_CONNECTION_NAME= 14,
+  DIAG_MESSAGE_LENGTH= 15,
+  DIAG_MESSAGE_OCTET_LENGTH= 16,
+  DIAG_PARAMETER_MODE= 17,
+  DIAG_PARAMETER_NAME= 18,
+  DIAG_PARAMETER_ORDINAL_POSITION= 19,
+  DIAG_RETURNED_SQLSTATE= 20,
+  DIAG_ROUTINE_CATALOG= 21,
+  DIAG_ROUTINE_NAME= 22,
+  DIAG_ROUTINE_SCHEMA= 23,
+  DIAG_SERVER_NAME= 24,
+  DIAG_SPECIFIC_NAME= 25,
+  DIAG_TRIGGER_CATALOG= 26,
+  DIAG_TRIGGER_NAME= 27,
+  DIAG_TRIGGER_SCHEMA= 28,
 } Diag_condition_item_name;
 
+typedef enum enum_diag_statement_item_name
+{
+  DIAG_NUMBER= 0,
+  DIAG_MORE= 1,
+  DIAG_COMMAND_FUNCTION= 2,
+  DIAG_COMMAND_FUNCTION_CODE= 3,
+  DIAG_DYNAMIC_FUNCTION= 4,
+  DIAG_DYNAMIC_FUNCTION_CODE= 5,
+  DIAG_ROW_COUNT= 6,
+  DIAG_TRANSACTIONS_COMMITTED= 7,
+  DIAG_TRANSACTIONS_ROLLED_BACK= 8,
+  DIAG_TRANSACTION_ACTIVE= 9
+} Diag_statement_item_name;
+
+enum diagnostic_area_type
+{
+  CURRENT_AREA,
+  STACKED_AREA
+};
+
 /**
   Name of each diagnostic condition item.
   This array is indexed by Diag_condition_item_name.

=== modified file 'sql/sql_cmd.h'
--- a/sql/sql_cmd.h	2010-04-16 09:07:23 +0000
+++ b/sql/sql_cmd.h	2010-11-15 08:20:48 +0000
@@ -87,8 +87,8 @@ enum enum_sql_command {
   SQLCOM_ALTER_DB_UPGRADE,
   SQLCOM_SHOW_PROFILE, SQLCOM_SHOW_PROFILES,
   SQLCOM_SIGNAL, SQLCOM_RESIGNAL,
-  SQLCOM_SHOW_RELAYLOG_EVENTS, 
-
+  SQLCOM_SHOW_RELAYLOG_EVENTS,
+  SQLCOM_GET_DIAGNOSTICS,
   /*
     When a command is added here, be sure it's also added in mysqld.cc
     in "struct show_var_st status_vars[]= {" ...

=== modified file 'sql/sql_lex.cc'
--- a/sql/sql_lex.cc	2010-11-10 11:26:45 +0000
+++ b/sql/sql_lex.cc	2010-11-15 08:20:48 +0000
@@ -903,6 +903,8 @@ int MYSQLlex(void *arg, void *yythd)
     break;
   }
 
+fprintf(stderr, "lex token %d\n", token);
+
   return token;
 }
 

=== modified file 'sql/sql_lex.h'
--- a/sql/sql_lex.h	2010-11-10 11:26:45 +0000
+++ b/sql/sql_lex.h	2010-11-15 08:20:48 +0000
@@ -2434,7 +2434,7 @@ class Set_signal_information
 {
 public:
   /** Empty default constructor, use clear() */
- Set_signal_information() {} 
+  Set_signal_information() {} 
 
   /** Copy constructor. */
   Set_signal_information(const Set_signal_information& set);
@@ -2454,6 +2454,37 @@ public:
   Item *m_item[LAST_DIAG_SET_PROPERTY+1];
 };
 
+class Diag_condition_property : public Sql_alloc
+{
+public:
+  Diag_condition_property(Item *target, Diag_condition_item_name item_name)
+    : m_target(target),
+      m_item_name(item_name)
+  {}
+
+  ~Diag_condition_property()
+  {}
+
+private:
+  Item *m_target;
+  Diag_condition_item_name m_item_name;
+};
+
+class Diag_statement_property : public Sql_alloc
+{
+public:
+  Diag_statement_property(Item *target, Diag_statement_item_name item_name)
+    : m_target(target),
+      m_item_name(item_name)
+  {}
+
+  ~Diag_statement_property()
+  {}
+
+private:
+  Item *m_target;
+  Diag_statement_item_name m_item_name;
+};
 
 /**
   The internal state of the syntax parser.

=== modified file 'sql/sql_signal.cc'
--- a/sql/sql_signal.cc	2010-08-04 10:34:01 +0000
+++ b/sql/sql_signal.cc	2010-11-15 08:20:48 +0000
@@ -504,3 +504,10 @@ bool Sql_cmd_resignal::execute(THD *thd)
 
   DBUG_RETURN(result);
 }
+
+bool Sql_cmd_get_diag::execute(THD *thd)
+{
+  my_error(ER_NOT_SUPPORTED_YET, MYF(0), "GET DIAGNOSTICS");
+  return true;
+}
+

=== modified file 'sql/sql_signal.h'
--- a/sql/sql_signal.h	2010-07-13 17:29:44 +0000
+++ b/sql/sql_signal.h	2010-11-15 08:20:48 +0000
@@ -142,5 +142,47 @@ public:
   virtual bool execute(THD *thd);
 };
 
+/**
+  Sql_cmd_get_diag represents a GET DIAGNOSTICS statement.
+*/
+class Sql_cmd_get_diag : public Sql_cmd
+{
+public:
+  Sql_cmd_get_diag(diagnostic_area_type area_type,
+                   List<Diag_statement_property> *statement_property_list)
+    : Sql_cmd(),
+      m_area_type(area_type),
+      m_cond_expr(NULL),
+      m_condition_property_list(NULL),
+      m_statement_property_list(statement_property_list)
+  {}
+
+  Sql_cmd_get_diag(diagnostic_area_type area_type,
+                   Item *condition_expr,
+                   List<Diag_condition_property> *condition_property_list)
+    : Sql_cmd(),
+      m_area_type(area_type),
+      m_cond_expr(condition_expr),
+      m_condition_property_list(condition_property_list),
+      m_statement_property_list(NULL)
+  {}
+
+  virtual ~Sql_cmd_get_diag()
+  {}
+
+  virtual enum_sql_command sql_command_code() const
+  {
+    return SQLCOM_GET_DIAGNOSTICS;
+  }
+
+  virtual bool execute(THD *thd);
+
+private:
+  diagnostic_area_type m_area_type;
+  Item *m_cond_expr;
+  List<Diag_condition_property> *m_condition_property_list;
+  List<Diag_statement_property> *m_statement_property_list;
+};
+
 #endif
 

=== modified file 'sql/sql_yacc.yy'
--- a/sql/sql_yacc.yy	2010-11-05 12:03:40 +0000
+++ b/sql/sql_yacc.yy	2010-11-15 08:20:48 +0000
@@ -772,6 +772,12 @@ static bool add_create_index (LEX *lex, 
   enum Foreign_key::fk_option m_fk_option;
   enum enum_yes_no_unknown m_yes_no_unk;
   Diag_condition_item_name diag_condition_item_name;
+  Diag_statement_item_name diag_statement_item_name;
+  class Diag_condition_property *diag_condition;
+  class Diag_statement_property *diag_statement;
+  List<Diag_condition_property> *condition_information_list;
+  List<Diag_statement_property> *statement_information_list;
+  enum diagnostic_area_type diag_area;
 }
 
 %{
@@ -872,6 +878,8 @@ bool my_yyoverflow(short **a, YYSTYPE **
 %token  COLUMNS
 %token  COLUMN_SYM                    /* SQL-2003-R */
 %token  COLUMN_NAME_SYM               /* SQL-2003-N */
+%token  COMMAND_FUNCTION_SYM          /* SQL-2003-N */
+%token  COMMAND_FUNCTION_CODE_SYM     /* SQL-2003-N */
 %token  COMMENT_SYM
 %token  COMMITTED_SYM                 /* SQL-2003-N */
 %token  COMMIT_SYM                    /* SQL-2003-R */
@@ -879,7 +887,10 @@ bool my_yyoverflow(short **a, YYSTYPE **
 %token  COMPLETION_SYM
 %token  COMPRESSED_SYM
 %token  CONCURRENT
+%token  CONDITION_NUMBER_SYM          /* SQL-2003-N */
+%token  CONDITION_IDENTIFIER_SYM      /* SQL-2003-N */
 %token  CONDITION_SYM                 /* SQL-2003-R, SQL-2008-R */
+%token  CONNECTION_NAME_SYM           /* SQL-2003-N */
 %token  CONNECTION_SYM
 %token  CONSISTENT_SYM
 %token  CONSTRAINT                    /* SQL-2003-R */
@@ -897,6 +908,7 @@ bool my_yyoverflow(short **a, YYSTYPE **
 %token  CROSS                         /* SQL-2003-R */
 %token  CUBE_SYM                      /* SQL-2003-R */
 %token  CURDATE                       /* MYSQL-FUNC */
+%token  CURRENT_SYM                   /* SQL-2003-N */
 %token  CURRENT_USER                  /* SQL-2003-R */
 %token  CURSOR_SYM                    /* SQL-2003-R */
 %token  CURSOR_NAME_SYM               /* SQL-2003-N */
@@ -927,6 +939,7 @@ bool my_yyoverflow(short **a, YYSTYPE **
 %token  DESCRIBE                      /* SQL-2003-R */
 %token  DES_KEY_FILE
 %token  DETERMINISTIC_SYM             /* SQL-2003-R */
+%token  DIAGNOSTICS_SYM               /* SQL-2003-N */
 %token  DIRECTORY_SYM
 %token  DISABLE_SYM
 %token  DISCARD
@@ -939,6 +952,8 @@ bool my_yyoverflow(short **a, YYSTYPE **
 %token  DUAL_SYM
 %token  DUMPFILE
 %token  DUPLICATE_SYM
+%token  DYNAMIC_FUNCTION_SYM          /* SQL-2003-N */
+%token  DYNAMIC_FUNCTION_CODE_SYM     /* SQL-2003-N */
 %token  DYNAMIC_SYM                   /* SQL-2003-R */
 %token  EACH_SYM                      /* SQL-2003-R */
 %token  ELSE                          /* SQL-2003-R */
@@ -960,6 +975,7 @@ bool my_yyoverflow(short **a, YYSTYPE **
 %token  EVENTS_SYM
 %token  EVENT_SYM
 %token  EVERY_SYM                     /* SQL-2003-N */
+%token  EXCEPTION_SYM                 /* SQL-2003-N */
 %token  EXCHANGE_SYM
 %token  EXECUTE_SYM                   /* SQL-2003-R */
 %token  EXISTS                        /* SQL-2003-R */
@@ -991,6 +1007,7 @@ bool my_yyoverflow(short **a, YYSTYPE **
 %token  GEOMETRYCOLLECTION
 %token  GEOMETRY_SYM
 %token  GET_FORMAT                    /* MYSQL-FUNC */
+%token  GET_SYM                       /* SQL-2003-R */
 %token  GLOBAL_SYM                    /* SQL-2003-R */
 %token  GRANT                         /* SQL-2003-R */
 %token  GRANTS
@@ -1106,6 +1123,8 @@ bool my_yyoverflow(short **a, YYSTYPE **
 %token  MEDIUM_SYM
 %token  MEMORY_SYM
 %token  MERGE_SYM                     /* SQL-2003-R */
+%token  MESSAGE_LENGTH_SYM            /* SQL-2003-N */
+%token  MESSAGE_OCTET_LENGTH_SYM      /* SQL-2003-N */
 %token  MESSAGE_TEXT_SYM              /* SQL-2003-N */
 %token  MICROSECOND_SYM               /* MYSQL-FUNC */
 %token  MIGRATE_SYM
@@ -1119,6 +1138,7 @@ bool my_yyoverflow(short **a, YYSTYPE **
 %token  MODIFY_SYM
 %token  MOD_SYM                       /* SQL-2003-N */
 %token  MONTH_SYM                     /* SQL-2003-R */
+%token  MORE_SYM                      /* SQL-2003-N */
 %token  MULTILINESTRING
 %token  MULTIPOINT
 %token  MULTIPOLYGON
@@ -1145,6 +1165,7 @@ bool my_yyoverflow(short **a, YYSTYPE **
 %token  NO_WRITE_TO_BINLOG
 %token  NULL_SYM                      /* SQL-2003-R */
 %token  NUM
+%token  NUMBER_SYM                    /* SQL-2003-N */
 %token  NUMERIC_SYM                   /* SQL-2003-R */
 %token  NVARCHAR_SYM
 %token  OFFSET_SYM
@@ -1168,6 +1189,9 @@ bool my_yyoverflow(short **a, YYSTYPE **
 %token  PACK_KEYS_SYM
 %token  PAGE_SYM
 %token  PARAM_MARKER
+%token  PARAMETER_MODE_SYM            /* SQL-2003-N */
+%token  PARAMETER_NAME_SYM            /* SQL-2003-N */
+%token  PARAMETER_ORDINAL_POSITION_SYM /* SQL-2003-N */
 %token  PARSER_SYM
 %token  PARTIAL                       /* SQL-2003-N */
 %token  PARTITIONING_SYM
@@ -1232,6 +1256,7 @@ bool my_yyoverflow(short **a, YYSTYPE **
 %token  RESTORE_SYM
 %token  RESTRICT
 %token  RESUME_SYM
+%token  RETURNED_SQLSTATE_SYM         /* SQL-2003-N */
 %token  RETURNS_SYM                   /* SQL-2003-R */
 %token  RETURN_SYM                    /* SQL-2003-R */
 %token  REVERSE_SYM
@@ -1240,7 +1265,11 @@ bool my_yyoverflow(short **a, YYSTYPE **
 %token  ROLLBACK_SYM                  /* SQL-2003-R */
 %token  ROLLUP_SYM                    /* SQL-2003-R */
 %token  ROUTINE_SYM                   /* SQL-2003-N */
+%token  ROUTINE_CATALOG_SYM           /* SQL-2003-N */
+%token  ROUTINE_NAME_SYM              /* SQL-2003-N */
+%token  ROUTINE_SCHEMA_SYM            /* SQL-2003-N */
 %token  ROWS_SYM                      /* SQL-2003-R */
+%token  ROW_COUNT_SYM                 /* SQL-2003-N */
 %token  ROW_FORMAT_SYM
 %token  ROW_SYM                       /* SQL-2003-R */
 %token  RTREE_SYM
@@ -1257,6 +1286,7 @@ bool my_yyoverflow(short **a, YYSTYPE **
 %token  SERIAL_SYM
 %token  SESSION_SYM                   /* SQL-2003-N */
 %token  SERVER_SYM
+%token  SERVER_NAME_SYM               /* SQL-2003-N */
 %token  SERVER_OPTIONS
 %token  SET                           /* SQL-2003-R */
 %token  SET_VAR
@@ -1278,6 +1308,7 @@ bool my_yyoverflow(short **a, YYSTYPE **
 %token  SOURCE_SYM
 %token  SPATIAL_SYM
 %token  SPECIFIC_SYM                  /* SQL-2003-R */
+%token  SPECIFIC_NAME_SYM             /* SQL-2003-N */
 %token  SQLEXCEPTION_SYM              /* SQL-2003-R */
 %token  SQLSTATE_SYM                  /* SQL-2003-R */
 %token  SQLWARNING_SYM                /* SQL-2003-R */
@@ -1290,6 +1321,7 @@ bool my_yyoverflow(short **a, YYSTYPE **
 %token  SQL_SYM                       /* SQL-2003-R */
 %token  SQL_THREAD
 %token  SSL_SYM
+%token  STACKED_SYM                   /* SQL-2003-N */
 %token  STARTING
 %token  STARTS_SYM
 %token  START_SYM                     /* SQL-2003-R */
@@ -1335,8 +1367,14 @@ bool my_yyoverflow(short **a, YYSTYPE **
 %token  TO_SYM                        /* SQL-2003-R */
 %token  TRAILING                      /* SQL-2003-R */
 %token  TRANSACTION_SYM
+%token  TRANSACTION_ACTIVE_SYM        /* SQL-2003-N */
+%token  TRANSACTIONS_COMMITTED_SYM    /* SQL-2003-N */
+%token  TRANSACTIONS_ROLLED_BACK_SYM  /* SQL-2003-N */
 %token  TRIGGERS_SYM
 %token  TRIGGER_SYM                   /* SQL-2003-R */
+%token  TRIGGER_CATALOG_SYM           /* SQL-2003-N */
+%token  TRIGGER_NAME_SYM              /* SQL-2003-N */
+%token  TRIGGER_SCHEMA_SYM            /* SQL-2003-N */
 %token  TRIM                          /* SQL-2003-N */
 %token  TRUE_SYM                      /* SQL-2003-R */
 %token  TRUNCATE_SYM
@@ -1630,8 +1668,16 @@ END_OF_INPUT
 %type <num> index_hint_clause
 %type <filetype> data_or_xml
 
-%type <NONE> signal_stmt resignal_stmt
+%type <NONE> signal_stmt resignal_stmt get_diagnostics_stmt
 %type <diag_condition_item_name> signal_condition_information_item_name
+%type <diag_condition_item_name> condition_information_item_name
+%type <diag_statement_item_name> statement_information_item_name
+%type <diag_condition> condition_information_item
+%type <diag_statement> statement_information_item
+%type <diag_area> opt_which_area
+%type <item> simple_target_specification
+%type <condition_information_list> condition_information_list
+%type <statement_information_list> statement_information
 
 %type <NONE>
         '-' '+' '*' '/' '%' '(' ')'
@@ -1733,6 +1779,7 @@ statement:
         | drop
         | execute
         | flush
+        | get_diagnostics_stmt
         | grant
         | handler
         | help
@@ -3092,6 +3139,46 @@ signal_condition_information_item_name:
           { $$= DIAG_MYSQL_ERRNO; }
         ;
 
+/* conditions that can be read in get diagnostics */
+condition_information_item_name:
+          signal_condition_information_item_name
+          { $$= $1; }
+        | CONDITION_IDENTIFIER_SYM
+          { $$= DIAG_CONDITION_IDENTIFIER; }
+        | CONDITION_NUMBER_SYM
+          { $$= DIAG_CONDITION_NUMBER; }
+        | CONNECTION_NAME_SYM
+          { $$= DIAG_CONNECTION_NAME; }
+        | MESSAGE_LENGTH_SYM
+          { $$= DIAG_MESSAGE_LENGTH; }
+        | MESSAGE_OCTET_LENGTH_SYM
+          { $$= DIAG_MESSAGE_OCTET_LENGTH; }
+        | PARAMETER_MODE_SYM
+          { $$= DIAG_PARAMETER_MODE; }
+        | PARAMETER_NAME_SYM
+          { $$= DIAG_PARAMETER_NAME; }
+        | PARAMETER_ORDINAL_POSITION_SYM
+          { $$= DIAG_PARAMETER_ORDINAL_POSITION; }
+        | RETURNED_SQLSTATE_SYM
+          { $$= DIAG_RETURNED_SQLSTATE; }
+        | ROUTINE_CATALOG_SYM
+          { $$= DIAG_ROUTINE_CATALOG; }
+        | ROUTINE_NAME_SYM
+          { $$= DIAG_ROUTINE_NAME; }
+        | ROUTINE_SCHEMA_SYM
+          { $$= DIAG_ROUTINE_SCHEMA; }
+        | SERVER_NAME_SYM
+          { $$= DIAG_SERVER_NAME; }
+        | SPECIFIC_NAME_SYM
+          { $$= DIAG_SPECIFIC_NAME; }
+        | TRIGGER_CATALOG_SYM
+          { $$= DIAG_TRIGGER_CATALOG; }
+        | TRIGGER_NAME_SYM
+          { $$= DIAG_TRIGGER_NAME; }
+        | TRIGGER_SCHEMA_SYM
+          { $$= DIAG_TRIGGER_SCHEMA; }
+        ;
+
 resignal_stmt:
           RESIGNAL_SYM opt_signal_value opt_set_signal_information
           {
@@ -3108,6 +3195,151 @@ resignal_stmt:
           }
         ;
 
+get_diagnostics_stmt:
+          GET_SYM /* $1 */
+          opt_which_area /* $2 */
+          DIAGNOSTICS_SYM /* $3 */
+          statement_information /* $4 */
+          {
+            THD *thd= YYTHD;
+            LEX *lex= thd->lex;
+            lex->sql_command= SQLCOM_GET_DIAGNOSTICS;
+            lex->m_sql_cmd= new (thd->mem_root) Sql_cmd_get_diag($2, $4);
+            if (lex->m_sql_cmd == NULL)
+              MYSQL_YYABORT;
+          }
+        | GET_SYM /* $1 */
+          opt_which_area /* $2 */
+          DIAGNOSTICS_SYM /* $3 */
+          exception_or_condition /* $4 */
+          expr /* $5 */
+          condition_information_list /* $6 */
+          {
+            THD *thd= YYTHD;
+            LEX *lex= thd->lex;
+            lex->sql_command= SQLCOM_GET_DIAGNOSTICS;
+            lex->m_sql_cmd= new (thd->mem_root) Sql_cmd_get_diag($2, $5, $6);
+            if (lex->m_sql_cmd == NULL)
+              MYSQL_YYABORT;
+          }
+        ;
+
+opt_which_area:
+          /* empty */
+          { $$= CURRENT_AREA; }
+        | CURRENT_SYM
+          { $$= CURRENT_AREA; }
+        | STACKED_SYM
+          { $$= STACKED_AREA; }
+        ;
+
+statement_information:
+          statement_information_item
+          {
+            $$= new (YYTHD->mem_root) List<Diag_statement_property>;
+            $$->push_back($1);
+          }
+        | statement_information ',' statement_information_item
+          {
+            $1->push_back($3);
+            $$= $1;
+          }
+        ;
+
+statement_information_item:
+          simple_target_specification EQ statement_information_item_name
+          {
+            $$= new (YYTHD->mem_root) Diag_statement_property($1, $3);
+            if ($$ == NULL)
+              MYSQL_YYABORT;
+          }
+        ;
+
+statement_information_item_name:
+          NUMBER_SYM
+          { $$= DIAG_NUMBER; }
+        | MORE_SYM
+          { $$= DIAG_MORE; }
+        | COMMAND_FUNCTION_SYM
+          { $$= DIAG_COMMAND_FUNCTION; }
+        | COMMAND_FUNCTION_CODE_SYM
+          { $$= DIAG_COMMAND_FUNCTION_CODE; }
+        | DYNAMIC_FUNCTION_SYM
+          { $$= DIAG_DYNAMIC_FUNCTION; }
+        | DYNAMIC_FUNCTION_CODE_SYM
+          { $$= DIAG_DYNAMIC_FUNCTION_CODE; }
+        | ROW_COUNT_SYM
+          { $$= DIAG_ROW_COUNT; }
+        | TRANSACTIONS_COMMITTED_SYM
+          { $$= DIAG_TRANSACTIONS_COMMITTED; }
+        | TRANSACTIONS_ROLLED_BACK_SYM
+          { $$= DIAG_TRANSACTIONS_ROLLED_BACK; }
+        | TRANSACTION_ACTIVE_SYM
+          { $$= DIAG_TRANSACTION_ACTIVE; }
+        ;
+
+simple_target_specification:
+          ident
+          {
+            THD *thd= YYTHD;
+            LEX *lex= thd->lex;
+            Lex_input_stream *lip= YYLIP;
+            sp_pcontext *spc= thd->lex->spcont;
+            sp_variable_t *spv;
+            Item_splocal *splocal;
+            uint pos_in_q;
+            uint len_in_q;
+
+            DBUG_ASSERT(spc);
+            spv = spc->find_variable(&$1);
+            if (spv == NULL)
+            {
+              my_error(ER_SP_UNDECLARED_VAR, MYF(0), $1.str);
+              MYSQL_YYABORT;
+            }
+
+            pos_in_q= lip->get_tok_start_prev() - lex->sphead->m_tmp_query;
+            len_in_q= lip->get_tok_end() - lip->get_tok_start_prev();
+            splocal= new (thd->mem_root) Item_splocal($1,
+                                                      spv->offset, spv->type,
+                                                      pos_in_q, len_in_q);
+#ifndef DBUG_OFF
+            if (splocal)
+              splocal->m_sp= lex->sphead;
+#endif
+            $$ = splocal;
+          }
+        | '@' ident_or_text
+          {
+            $$= new (YYTHD->mem_root) Item_user_var_as_out_param($2);
+          }
+        ;
+
+exception_or_condition:
+          EXCEPTION_SYM
+        | CONDITION_SYM
+        ;
+
+condition_information_list:
+          condition_information_item
+          {
+            $$= new (YYTHD->mem_root) List<Diag_condition_property>;
+            $$->push_back($1);
+          }
+        | condition_information_list ',' condition_information_item
+          {
+            $1->push_back($3);
+            $$= $1;
+          }
+        ;
+
+condition_information_item:
+          simple_target_specification EQ condition_information_item_name
+          {
+            $$= new (YYTHD->mem_root) Diag_condition_property($1, $3);
+          }
+        ;
+
 sp_decl_idents:
           ident
           {
@@ -8612,6 +8844,14 @@ function_call_conflict:
             if ($$ == NULL)
               MYSQL_YYABORT;
           }
+        | ROW_COUNT_SYM '(' ')'
+          {
+            Lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION);
+            Lex->safe_to_cache_query= 0;
+            $$= new (YYTHD->mem_root) Item_func_row_count();
+            if ($$ == NULL)
+              MYSQL_YYABORT;
+          }
         | TRUNCATE_SYM '(' expr ',' expr ')'
           {
             $$= new (YYTHD->mem_root) Item_func_round($3,$5,1);
@@ -12595,12 +12835,17 @@ keyword_sp:
         | COLLATION_SYM            {}
         | COLUMN_NAME_SYM          {}
         | COLUMNS                  {}
+        | COMMAND_FUNCTION_SYM     {}
+        | COMMAND_FUNCTION_CODE_SYM {}
         | COMMITTED_SYM            {}
         | COMPACT_SYM              {}
         | COMPLETION_SYM           {}
         | COMPRESSED_SYM           {}
         | CONCURRENT               {}
+        | CONDITION_IDENTIFIER_SYM {}
+        | CONDITION_NUMBER_SYM     {}
         | CONNECTION_SYM           {}
+        | CONNECTION_NAME_SYM      {}
         | CONSISTENT_SYM           {}
         | CONSTRAINT_CATALOG_SYM   {}
         | CONSTRAINT_SCHEMA_SYM    {}
@@ -12609,6 +12854,7 @@ keyword_sp:
         | CONTRIBUTORS_SYM         {}
         | CPU_SYM                  {}
         | CUBE_SYM                 {}
+        | CURRENT_SYM              {}
         | CURSOR_NAME_SYM          {}
         | DATA_SYM                 {}
         | DATAFILE_SYM             {}
@@ -12618,6 +12864,7 @@ keyword_sp:
         | DEFINER_SYM              {}
         | DELAY_KEY_WRITE_SYM      {}
         | DES_KEY_FILE             {}
+        | DIAGNOSTICS_SYM          {}
         | DIRECTORY_SYM            {}
         | DISABLE_SYM              {}
         | DISCARD                  {}
@@ -12625,6 +12872,8 @@ keyword_sp:
         | DUMPFILE                 {}
         | DUPLICATE_SYM            {}
         | DYNAMIC_SYM              {}
+        | DYNAMIC_FUNCTION_SYM     {}
+        | DYNAMIC_FUNCTION_CODE_SYM {}
         | ENDS_SYM                 {}
         | ENUM                     {}
         | ENGINE_SYM               {}
@@ -12635,6 +12884,7 @@ keyword_sp:
         | EVENT_SYM                {}
         | EVENTS_SYM               {}
         | EVERY_SYM                {}
+        | EXCEPTION_SYM            {}
         | EXCHANGE_SYM             {}
         | EXPANSION_SYM            {}
         | EXTENDED_SYM             {}
@@ -12705,6 +12955,8 @@ keyword_sp:
         | MEDIUM_SYM               {}
         | MEMORY_SYM               {}
         | MERGE_SYM                {}
+        | MESSAGE_LENGTH_SYM       {}
+        | MESSAGE_OCTET_LENGTH_SYM {}
         | MESSAGE_TEXT_SYM         {}
         | MICROSECOND_SYM          {}
         | MIGRATE_SYM              {}
@@ -12713,6 +12965,7 @@ keyword_sp:
         | MODIFY_SYM               {}
         | MODE_SYM                 {}
         | MONTH_SYM                {}
+        | MORE_SYM                 {}
         | MULTILINESTRING          {}
         | MULTIPOINT               {}
         | MULTIPOLYGON             {}
@@ -12728,12 +12981,16 @@ keyword_sp:
         | NO_WAIT_SYM              {}
         | NODEGROUP_SYM            {}
         | NONE_SYM                 {}
+        | NUMBER_SYM               {}
         | NVARCHAR_SYM             {}
         | OFFSET_SYM               {}
         | OLD_PASSWORD             {}
         | ONE_SYM                  {}
         | PACK_KEYS_SYM            {}
         | PAGE_SYM                 {}
+        | PARAMETER_MODE_SYM       {}
+        | PARAMETER_NAME_SYM       {}
+        | PARAMETER_ORDINAL_POSITION_SYM {}
         | PARTIAL                  {}
         | PARTITIONING_SYM         {}
         | PARTITIONS_SYM           {}
@@ -12771,11 +13028,16 @@ keyword_sp:
         | REPLICATION              {}
         | RESOURCES                {}
         | RESUME_SYM               {}
+        | RETURNED_SQLSTATE_SYM    {}
         | RETURNS_SYM              {}
         | REVERSE_SYM              {}
         | ROLLUP_SYM               {}
         | ROUTINE_SYM              {}
+        | ROUTINE_CATALOG_SYM      {}
+        | ROUTINE_NAME_SYM         {}
+        | ROUTINE_SCHEMA_SYM       {}
         | ROWS_SYM                 {}
+        | ROW_COUNT_SYM            {}
         | ROW_FORMAT_SYM           {}
         | ROW_SYM                  {}
         | RTREE_SYM                {}
@@ -12784,6 +13046,7 @@ keyword_sp:
         | SECOND_SYM               {}
         | SERIAL_SYM               {}
         | SERIALIZABLE_SYM         {}
+        | SERVER_NAME_SYM          {}
         | SESSION_SYM              {}
         | SIMPLE_SYM               {}
         | SHARE_SYM                {}
@@ -12792,10 +13055,12 @@ keyword_sp:
         | SNAPSHOT_SYM             {}
         | SOUNDS_SYM               {}
         | SOURCE_SYM               {}
+        | SPECIFIC_NAME_SYM        {}
         | SQL_CACHE_SYM            {}
         | SQL_BUFFER_RESULT        {}
         | SQL_NO_CACHE_SYM         {}
         | SQL_THREAD               {}
+        | STACKED_SYM              {}
         | STARTS_SYM               {}
         | STATUS_SYM               {}
         | STORAGE_SYM              {}
@@ -12818,6 +13083,12 @@ keyword_sp:
         | TEXT_SYM                 {}
         | THAN_SYM                 {}
         | TRANSACTION_SYM          {}
+        | TRANSACTION_ACTIVE_SYM   {}
+        | TRANSACTIONS_COMMITTED_SYM {}
+        | TRANSACTIONS_ROLLED_BACK_SYM {}
+        | TRIGGER_CATALOG_SYM      {}
+        | TRIGGER_NAME_SYM         {}
+        | TRIGGER_SCHEMA_SYM       {}
         | TRIGGERS_SYM             {}
         | TIMESTAMP                {}
         | TIMESTAMP_ADD            {}


Attachment: [text/bzr-bundle] bzr/marc.alff@oracle.com-20101115082048-qezlh0djb1u757ki.bundle
Thread
bzr commit into mysql-trunk-wl2111 branch (marc.alff:3205) WL#2111Marc Alff15 Nov