[MDEV-15539] Issuing a warning while inserting crashes the server Created: 2018-03-10  Updated: 2020-07-13

Status: Confirmed
Project: MariaDB Server
Component/s: Server, Storage Engine - Connect
Affects Version/s: 10.2.6, 10.2
Fix Version/s: 10.2

Type: Bug Priority: Major
Reporter: Olivier Bertrand Assignee: Rucha Deodhar
Resolution: Unresolved Votes: 0
Labels: connect-engine
Environment:

Windows 10



 Description   

This occured while testing a new fix:

CREATE TABLE `t1` (
  `id` int(10) NOT NULL,
  `name` varchar(32) DEFAULT NULL,
  `title` char(16) DEFAULT NULL,
  `salary` decimal(12,2) DEFAULT NULL
) ENGINE=CONNECT DEFAULT CHARSET=latin1 CONNECTION='jdbc:postgresql://localhost/test?user=postgres&password=tinono' `TABLE_TYPE`='JDBC' `TABNAME`='public.employee';

When executing:

INSERT INTO t1 VALUES(3126,'Smith', 'Clerk', 5230.00);

It raised an assert failure in Diagnostics_area::set_ok_status on line:

  DBUG_ASSERT(!is_set() || (m_status == DA_OK_BULK && is_bulk_op()));

It was apparently because a warning was issued by CONNECT.

To try to reproduce on the present version, edit tabdos.cpp. In TDBDOS::OpenDB and after:

  if (Mode == MODE_INSERT) {

add the lines:

        strcpy(g->Message, "Whatever");
	PushWarning(g, this, 1);

After recompiling, execute:

drop table t1;
create table t1 (n int, m varchar(16)) engine=connect;
select * from t1;
insert into t1 values(1,'One');

This does not affect MariaDB 10.1 but only MariaDB 10.2.



 Comments   
Comment by Elena Stepanova [ 2018-03-16 ]

diff --git a/storage/connect/tabdos.cpp b/storage/connect/tabdos.cpp
index 3b850cf..3db0028 100644
--- a/storage/connect/tabdos.cpp
+++ b/storage/connect/tabdos.cpp
@@ -2178,6 +2178,8 @@ bool TDBDOS::OpenDB(PGLOBAL g)
   To_Line = (char*)PlugSubAlloc(g, NULL, linelen);
 
   if (Mode == MODE_INSERT) {
+    strcpy(g->Message, "Whatever");
+    PushWarning(g, this, 1);
     // Spaces between fields must be filled with blanks
     memset(To_Line, ' ', Lrecl);
     To_Line[Lrecl] = '\0';

10.2 e119799a920 with the patch above

mysqld: /data/src/10.2-bug/sql/sql_error.cc:380: void Diagnostics_area::set_ok_status(ulonglong, ulonglong, const char*): Assertion `!is_set() || (m_status == DA_OK_BULK && is_bulk_op())' failed.
180316 20:32:52 [ERROR] mysqld got signal 6 ;
 
#7  0x00007f4969799ee2 in __assert_fail () from /lib/x86_64-linux-gnu/libc.so.6
#8  0x0000557677635343 in Diagnostics_area::set_ok_status (this=0x7f48f4005c90, affected_rows=1, last_insert_id=0, message=0x0) at /data/src/10.2-bug/sql/sql_error.cc:380
#9  0x00005576775e7a9b in my_ok (thd=0x7f48f4000b00, affected_rows=1, id=0, message=0x0) at /data/src/10.2-bug/sql/sql_class.h:4492
#10 0x000055767763d894 in mysql_insert (thd=0x7f48f4000b00, table_list=0x7f48f4011110, fields=..., values_list=..., update_fields=..., update_values=..., duplic=DUP_ERROR, ignore=false) at /data/src/10.2-bug/sql/sql_insert.cc:1217
#11 0x00005576776646b1 in mysql_execute_command (thd=0x7f48f4000b00) at /data/src/10.2-bug/sql/sql_parse.cc:4418
#12 0x000055767766f621 in mysql_parse (thd=0x7f48f4000b00, rawbuf=0x7f48f4011028 "insert into t1 values(1,'One')", length=30, parser_state=0x7f49682d1250, is_com_multi=false, is_next_command=false) at /data/src/10.2-bug/sql/sql_parse.cc:7902
#13 0x000055767765d541 in dispatch_command (command=COM_QUERY, thd=0x7f48f4000b00, packet=0x7f48f4019251 "insert into t1 values(1,'One')", packet_length=30, is_com_multi=false, is_next_command=false) at /data/src/10.2-bug/sql/sql_parse.cc:1806
#14 0x000055767765bea4 in do_command (thd=0x7f48f4000b00) at /data/src/10.2-bug/sql/sql_parse.cc:1360
#15 0x00005576777aa67a in do_handle_one_connection (connect=0x55767aa83ec0) at /data/src/10.2-bug/sql/sql_connect.cc:1335
#16 0x00005576777aa407 in handle_one_connection (arg=0x55767aa83ec0) at /data/src/10.2-bug/sql/sql_connect.cc:1241
#17 0x00007f496b470494 in start_thread (arg=0x7f49682d2700) at pthread_create.c:333
#18 0x00007f496985693f in clone () from /lib/x86_64-linux-gnu/libc.so.6

Generated at Thu Feb 08 08:22:05 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.