Skip to content

Commit d5e606c

Browse files
MDEV-26611: ERROR_INDEX isn't intuitively clear
Fixup for MDEV-10075 Analysis: ERROR_INDEX implemented in MDEV-10075 was not intuitively clear. Fix: changed parser to use ROW_NUMBER instead of ERROR_INDEX. Removed ERROR_INDEX and ERROR_INDEX_SYM from related files. Changed m_error_index to m_row_number.
1 parent e9d8002 commit d5e606c

File tree

9 files changed

+283
-284
lines changed

9 files changed

+283
-284
lines changed

mysql-test/main/get_diagnostics.result

Lines changed: 134 additions & 134 deletions
Large diffs are not rendered by default.

mysql-test/main/get_diagnostics.test

Lines changed: 134 additions & 134 deletions
Large diffs are not rendered by default.

mysql-test/suite/perfschema/r/start_server_low_digest_sql_length.result

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ SELECT 1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1
88
####################################
99
SELECT event_name, digest, digest_text, sql_text FROM events_statements_history_long;
1010
event_name digest digest_text sql_text
11-
statement/sql/select dfe1e2b52a48f7294a6385d229770021 SELECT ? + ? + SELECT ...
12-
statement/sql/truncate 6aa520d69a5b4c9035650e7deeae48fd TRUNCATE TABLE truncat...
11+
statement/sql/select ca9181d6d668396d467dd974f58a9402 SELECT ? + ? + SELECT ...
12+
statement/sql/truncate 460cb5329baea0e4242059cfda01d1d7 TRUNCATE TABLE truncat...

sql/lex.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,6 @@ SYMBOL symbols[] = {
222222
{ "ENUM", SYM(ENUM)},
223223
{ "ERROR", SYM(ERROR_SYM)},
224224
{ "ERRORS", SYM(ERRORS)},
225-
{ "ERROR_INDEX", SYM(ERROR_INDEX_SYM)},
226225
{ "ESCAPE", SYM(ESCAPE_SYM)},
227226
{ "ESCAPED", SYM(ESCAPED)},
228227
{ "EVENT", SYM(EVENT_SYM)},
@@ -569,6 +568,8 @@ SYMBOL symbols[] = {
569568
{ "ROWTYPE", SYM(ROWTYPE_MARIADB_SYM)},
570569
{ "ROW_COUNT", SYM(ROW_COUNT_SYM)},
571570
{ "ROW_FORMAT", SYM(ROW_FORMAT_SYM)},
571+
/** sql_function and condition_property_name for GET DIAGNOSTICS */
572+
{ "ROW_NUMBER", SYM(ROW_NUMBER_SYM)},
572573
{ "RTREE", SYM(RTREE_SYM)},
573574
{ "SAVEPOINT", SYM(SAVEPOINT_SYM)},
574575
{ "SCHEDULE", SYM(SCHEDULE_SYM)},
@@ -783,7 +784,6 @@ SYMBOL sql_functions[] = {
783784
{ "PERCENTILE_CONT", SYM(PERCENTILE_CONT_SYM)},
784785
{ "PERCENTILE_DISC", SYM(PERCENTILE_DISC_SYM)},
785786
{ "RANK", SYM(RANK_SYM)},
786-
{ "ROW_NUMBER", SYM(ROW_NUMBER_SYM)},
787787
{ "SESSION_USER", SYM(USER_SYM)},
788788
{ "STD", SYM(STD_SYM)},
789789
{ "STDDEV", SYM(STD_SYM)},

sql/sql_error.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,8 @@ class Sql_condition_items
306306
/** SQL CURSOR_NAME condition item. */
307307
String m_cursor_name;
308308

309-
ulong m_error_index;
309+
/** SQL ROW_NUMBER condition item. */
310+
ulong m_row_number;
310311

311312
Sql_condition_items()
312313
:m_class_origin((const char*) NULL, 0, & my_charset_utf8mb3_bin),
@@ -319,7 +320,7 @@ class Sql_condition_items
319320
m_table_name((const char*) NULL, 0, & my_charset_utf8mb3_bin),
320321
m_column_name((const char*) NULL, 0, & my_charset_utf8mb3_bin),
321322
m_cursor_name((const char*) NULL, 0, & my_charset_utf8mb3_bin),
322-
m_error_index(0)
323+
m_row_number(0)
323324
{ }
324325

325326
void clear()
@@ -334,7 +335,7 @@ class Sql_condition_items
334335
m_table_name.length(0);
335336
m_column_name.length(0);
336337
m_cursor_name.length(0);
337-
m_error_index= 0;
338+
m_row_number= 0;
338339
}
339340
};
340341

@@ -446,7 +447,7 @@ class Sql_condition : public Sql_alloc,
446447
DBUG_ASSERT(value.get_sql_errno() != 0);
447448
DBUG_ASSERT(msg != NULL);
448449
set_builtin_message_text(msg);
449-
m_error_index= current_row_for_warning;
450+
m_row_number= current_row_for_warning;
450451
}
451452

452453
/** Destructor. */

sql/sql_get_diagnostics.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,8 +338,8 @@ Condition_information_item::get_value(THD *thd, const Sql_condition *cond)
338338
str.set_ascii(cond->get_sqlstate(), strlen(cond->get_sqlstate()));
339339
value= make_utf8_string_item(thd, &str);
340340
break;
341-
case ERROR_INDEX:
342-
value= new (thd->mem_root) Item_uint(thd, cond->m_error_index);
341+
case ROW_NUMBER:
342+
value= new (thd->mem_root) Item_uint(thd, cond->m_row_number);
343343
}
344344

345345
DBUG_RETURN(value);

sql/sql_get_diagnostics.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ class Condition_information_item : public Diagnostics_information_item
255255
MESSAGE_TEXT,
256256
MYSQL_ERRNO,
257257
RETURNED_SQLSTATE,
258-
ERROR_INDEX
258+
ROW_NUMBER
259259
};
260260

261261
/**

sql/sql_yacc.yy

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -974,7 +974,6 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize);
974974
%token <kwd> MUTEX_SYM
975975
%token <kwd> MYSQL_SYM
976976
%token <kwd> MYSQL_ERRNO_SYM
977-
%token <kwd> ERROR_INDEX_SYM
978977
%token <kwd> NAMES_SYM /* SQL-2003-N */
979978
%token <kwd> NAME_SYM /* SQL-2003-N */
980979
%token <kwd> NATIONAL_SYM /* SQL-2003-R */
@@ -3631,8 +3630,8 @@ condition_information_item_name:
36313630
{ $$= Condition_information_item::MYSQL_ERRNO; }
36323631
| RETURNED_SQLSTATE_SYM
36333632
{ $$= Condition_information_item::RETURNED_SQLSTATE; }
3634-
| ERROR_INDEX_SYM
3635-
{ $$= Condition_information_item::ERROR_INDEX; }
3633+
| ROW_NUMBER_SYM
3634+
{ $$= Condition_information_item::ROW_NUMBER; }
36363635
;
36373636

36383637
sp_decl_ident:
@@ -15664,7 +15663,6 @@ keyword_sp_var_and_label:
1566415663
| INVOKER_SYM
1566515664
| IMPORT
1566615665
| INDEXES
15667-
| ERROR_INDEX_SYM
1566815666
| INITIAL_SIZE_SYM
1566915667
| IO_SYM
1567015668
| IPC_SYM

tests/mysql_client_test.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21580,7 +21580,7 @@ void test_mdev_10075()
2158021580

2158121581
mysql_stmt_close(stmt);
2158221582

21583-
rc= mysql_query(mysql, "GET DIAGNOSTICS CONDITION 1 @var1 = ERROR_INDEX");
21583+
rc= mysql_query(mysql, "GET DIAGNOSTICS CONDITION 1 @var1 = ROW_NUMBER");
2158421584
myquery(rc);
2158521585

2158621586
rc= mysql_query(mysql, "SELECT @var1");

0 commit comments

Comments
 (0)