Commit the MDEV-17023 fix with the correct number

This commit is contained in:
Marko Mäkelä 2018-08-27 12:22:27 +03:00
commit 5fb251642e
9 changed files with 102 additions and 18 deletions

View File

@ -0,0 +1,33 @@
CREATE OR REPLACE TABLE t1 (
f1 DECIMAL(43,0) NOT NULL,
f2 TIME(4) NULL,
f3 BINARY(101) NULL,
f4 TIMESTAMP(4) NULL,
f5 DATETIME(1) NULL,
f6 SET('a','b','c') NOT NULL DEFAULT 'a',
f7 VARBINARY(2332) NOT NULL DEFAULT '',
f8 DATE NULL,
f9 BLOB NULL,
f10 MEDIUMINT(45) NOT NULL DEFAULT 0,
f11 YEAR NULL,
f12 BIT(58) NULL,
v2 TIME(1) AS (f2) VIRTUAL,
v3 BINARY(115) AS (f3) VIRTUAL,
v4 TIMESTAMP(3) AS (f4) VIRTUAL,
v7 VARBINARY(658) AS (f7) PERSISTENT,
v8 DATE AS (f8) PERSISTENT,
v9 TINYTEXT AS (f9) PERSISTENT,
v11 YEAR AS (f11) VIRTUAL
) ENGINE=Aria;
INSERT IGNORE INTO t1 (f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12) VALUES
(0.8,'16:01:46',NULL,'2006-03-01 12:44:34','2029-10-10 21:27:53','a','foo','1989-12-24','bar',9,1975,b'1');
Warnings:
Note 1265 Data truncated for column 'f1' at row 1
DROP TABLE t1;
CREATE OR REPLACE TABLE t1 (a INT(45));
INSERT IGNORE INTO t1 VALUES (1),(2);
CREATE OR REPLACE TABLE t2 ENGINE=Aria AS SELECT SUM(a) AS f1, IFNULL( 'qux', ExtractValue( 'foo', 'bar' ) ) AS f2 FROM t1;
select * from t2;
f1 f2
3 qux
DROP TABLE t1, t2;

View File

@ -0,0 +1,42 @@
--source include/have_maria.inc
# MDEV-17021
# Server crash or assertion `length <= column->length' failure in
# write_block_record
#
CREATE OR REPLACE TABLE t1 (
f1 DECIMAL(43,0) NOT NULL,
f2 TIME(4) NULL,
f3 BINARY(101) NULL,
f4 TIMESTAMP(4) NULL,
f5 DATETIME(1) NULL,
f6 SET('a','b','c') NOT NULL DEFAULT 'a',
f7 VARBINARY(2332) NOT NULL DEFAULT '',
f8 DATE NULL,
f9 BLOB NULL,
f10 MEDIUMINT(45) NOT NULL DEFAULT 0,
f11 YEAR NULL,
f12 BIT(58) NULL,
v2 TIME(1) AS (f2) VIRTUAL,
v3 BINARY(115) AS (f3) VIRTUAL,
v4 TIMESTAMP(3) AS (f4) VIRTUAL,
v7 VARBINARY(658) AS (f7) PERSISTENT,
v8 DATE AS (f8) PERSISTENT,
v9 TINYTEXT AS (f9) PERSISTENT,
v11 YEAR AS (f11) VIRTUAL
) ENGINE=Aria;
INSERT IGNORE INTO t1 (f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12) VALUES
(0.8,'16:01:46',NULL,'2006-03-01 12:44:34','2029-10-10 21:27:53','a','foo','1989-12-24','bar',9,1975,b'1');
DROP TABLE t1;
#
# MDEV-17067 Server crash in write_block_record
#
CREATE OR REPLACE TABLE t1 (a INT(45));
INSERT IGNORE INTO t1 VALUES (1),(2);
CREATE OR REPLACE TABLE t2 ENGINE=Aria AS SELECT SUM(a) AS f1, IFNULL( 'qux', ExtractValue( 'foo', 'bar' ) ) AS f2 FROM t1;
select * from t2;
DROP TABLE t1, t2;

View File

@ -210,7 +210,7 @@ cannot_find_file()
echo
echo "If you compiled from source, you need to either run 'make install' to"
echo "copy the software into the correct location ready for operation."
echo "If you don't want to do a full install, you can use the --srcddir"
echo "If you don't want to do a full install, you can use the --srcdir"
echo "option to only install the mysql database and privilege tables"
echo
echo "If you compiled from source, you need to either run 'make install' to"

View File

@ -9065,13 +9065,18 @@ void Create_field::create_length_to_internal_length(void)
}
break;
case MYSQL_TYPE_NEWDECIMAL:
key_length= pack_length=
my_decimal_get_binary_size(my_decimal_length_to_precision(length,
decimals,
flags &
UNSIGNED_FLAG),
decimals);
{
/*
This code must be identical to code in
Field_new_decimal::Field_new_decimal as otherwise the record layout
gets out of sync.
*/
uint precision= my_decimal_length_to_precision(length, decimals,
flags & UNSIGNED_FLAG);
set_if_smaller(precision, DECIMAL_MAX_PRECISION);
key_length= pack_length= my_decimal_get_binary_size(precision, decimals);
break;
}
default:
key_length= pack_length= calc_pack_length(sql_type, length);
break;

View File

@ -3328,6 +3328,10 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
}
}
/* Virtual fields are always NULL */
if (sql_field->vcol_info)
sql_field->flags&= ~NOT_NULL_FLAG;
if (sql_field->sql_type == MYSQL_TYPE_SET ||
sql_field->sql_type == MYSQL_TYPE_ENUM)
{

View File

@ -153,7 +153,7 @@ bool JAVAConn::Check(jint rc)
if (exc != nullptr && tid != nullptr) {
jstring s = (jstring)env->CallObjectMethod(exc, tid);
const char *utf = env->GetStringUTFChars(s, (jboolean)false);
const char *utf = env->GetStringUTFChars(s, NULL);
env->DeleteLocalRef(s);
Msg = PlugDup(m_G, utf);
} else
@ -162,7 +162,7 @@ bool JAVAConn::Check(jint rc)
env->ExceptionClear();
} else if (rc < 0) {
s = (jstring)env->CallObjectMethod(job, errid);
Msg = (char*)env->GetStringUTFChars(s, (jboolean)false);
Msg = (char*)env->GetStringUTFChars(s, NULL);
} else
Msg = NULL;
@ -456,7 +456,7 @@ bool JAVAConn::Open(PGLOBAL g)
//=============== load and initialize Java VM and JNI interface =============
rc = CreateJavaVM(&jvm, (void**)&env, &vm_args); // YES !!
delete options; // we then no longer need the initialisation options.
delete[] options; // we then no longer need the initialisation options.
switch (rc) {
case JNI_OK:

View File

@ -828,11 +828,11 @@ bool JDBConn::Connect(PJPARM sop)
jstring s = (jstring)env->CallObjectMethod(job, qcid);
if (s != nullptr) {
char *qch = (char*)env->GetStringUTFChars(s, (jboolean)false);
char *qch = (char*)env->GetStringUTFChars(s, NULL);
m_IDQuoteChar[0] = *qch;
} else {
s = (jstring)env->CallObjectMethod(job, errid);
Msg = (char*)env->GetStringUTFChars(s, (jboolean)false);
Msg = (char*)env->GetStringUTFChars(s, NULL);
} // endif s
} // endif qcid
@ -1010,7 +1010,7 @@ void JDBConn::SetColumnValue(int rank, PSZ name, PVAL val)
cn = nullptr;
if (cn) {
field = env->GetStringUTFChars(cn, (jboolean)false);
field = env->GetStringUTFChars(cn, NULL);
val->SetValue_psz((PSZ)field);
} else
val->Reset();
@ -1084,7 +1084,7 @@ void JDBConn::SetColumnValue(int rank, PSZ name, PVAL val)
cn = nullptr;
if (cn) {
const char *field = env->GetStringUTFChars(cn, (jboolean)false);
const char *field = env->GetStringUTFChars(cn, NULL);
val->SetValue_psz((PSZ)field);
} else
val->Reset();
@ -1462,7 +1462,7 @@ bool JDBConn::SetParam(JDBCCOL *colp)
return NULL;
} // endif label
name = env->GetStringUTFChars(label, (jboolean)false);
name = env->GetStringUTFChars(label, NULL);
crp = qrp->Colresp; // Column_Name
crp->Kdata->SetValue((char*)name, i);
n = env->GetIntArrayElements(val, 0);

View File

@ -522,7 +522,7 @@ PSZ JMgoConn::GetDocument(void)
jdc = (jstring)env->CallObjectMethod(job, getdocid);
if (jdc)
doc = (PSZ)env->GetStringUTFChars(jdc, (jboolean)false);
doc = (PSZ)env->GetStringUTFChars(jdc, NULL);
} // endif getdocid
@ -807,7 +807,7 @@ PSZ JMgoConn::GetColumnValue(PSZ path)
fn = (jstring)env->CallObjectMethod(job, objfldid, jn);
if (fn)
fld = (PSZ)env->GetStringUTFChars(fn, (jboolean)false);
fld = (PSZ)env->GetStringUTFChars(fn, NULL);
} // endif objfldid

View File

@ -101,7 +101,7 @@ bool JMGDISC::ColDesc(PGLOBAL g, jobject obj, char *pcn, char *pfmt,
continue;
jkey = (jstring)Jcp->env->CallObjectMethod(Jcp->job, bvnameid);
key = Jcp->env->GetStringUTFChars(jkey, (jboolean)false);
key = Jcp->env->GetStringUTFChars(jkey, NULL);
if (pcn) {
strncpy(colname, pcn, 64);