Я получаю сообщение об ошибке при запуске набора операторов SQL через соединение ODBC, которые изменяют тип данных для столбца.
Ошибка:
[HY000] Установлено неверное значение [typeName = SQL_PUBLIC_X_0aae5780_0c94_4706_b144_f2ca2336a96e, fieldName = VALUE, fieldType = String, assignValueType = int]
Это предполагаемое поведение или ожидаемая ошибка? Изменится ли это поведение в будущих выпусках для поддержки изменения типа данных столбца?
Я использую свежий экземпляр Ignite (v2.7) по умолчанию, подключенный из .Net Core (v2.2) через OdbcConnection (System.Data.Odbc v4.5.0).
Трассировка стека:
System.Data.Odbc.OdbcException (0x80131937): ERROR [HY000] Wrong value has been set [typeName=SQL_PUBLIC_X_0aae5780_0c94_4706_b144_f2ca2336a96e, fieldName=VALUE, fieldType=String, assignedValueType=int]
at System.Data.Odbc.OdbcCommand.ExecuteReaderObject(CommandBehavior behavior, String method, Boolean needReader, Object[] methodArguments, SQL_API odbcApiMethod)
at System.Data.Odbc.OdbcCommand.ExecuteReaderObject(CommandBehavior behavior, String method, Boolean needReader)
at System.Data.Odbc.OdbcCommand.ExecuteNonQuery()
at IgniteReproducer.Program.ChangeColumnType() in C:\...\IgniteMultistatementReproducer\IgniteMultistatementReproducer\Program.cs:line 51
Репродуктор:
using System;
using System.Data.Odbc;
namespace IgniteReproducer {
internal class Program {
private static void Main(string[] args) {
ChangeColumnType();
}
private static void ChangeColumnType() {
try {
using (var conn = new OdbcConnection($"DRIVER={{Apache Ignite}};ADDRESS=localhost:10800;")) {
conn.Open();
var cmd = new OdbcCommand {
Connection = conn
};
cmd.CommandText = "DROP TABLE IF EXISTS X;";
var numRecordsAffected = cmd.ExecuteNonQuery();
Console.WriteLine($"Num Records Affected: {numRecordsAffected}");
cmd.CommandText = "CREATE TABLE X (Id INT, Value VARCHAR(36), PRIMARY KEY (Id));";
numRecordsAffected = cmd.ExecuteNonQuery();
Console.WriteLine($"Num Records Affected: {numRecordsAffected}");
cmd.CommandText = "INSERT INTO X (Id, Value) VALUES (1, 'a');";
numRecordsAffected = cmd.ExecuteNonQuery();
Console.WriteLine($"Num Records Affected: {numRecordsAffected}");
cmd.CommandText = "INSERT INTO X (Id, Value) VALUES (2, 'b');";
numRecordsAffected = cmd.ExecuteNonQuery();
Console.WriteLine($"Num Records Affected: {numRecordsAffected}");
cmd.CommandText = "ALTER TABLE X ADD COLUMN Temp INT;";
numRecordsAffected = cmd.ExecuteNonQuery();
Console.WriteLine($"Num Records Affected: {numRecordsAffected}");
cmd.CommandText = "UPDATE X SET Temp = 1;";
numRecordsAffected = cmd.ExecuteNonQuery();
Console.WriteLine($"Num Records Affected: {numRecordsAffected}");
cmd.CommandText = "ALTER TABLE X DROP COLUMN Value;";
numRecordsAffected = cmd.ExecuteNonQuery();
Console.WriteLine($"Num Records Affected: {numRecordsAffected}");
cmd.CommandText = "ALTER TABLE X ADD COLUMN Value INT;";
numRecordsAffected = cmd.ExecuteNonQuery();
Console.WriteLine($"Num Records Affected: {numRecordsAffected}");
cmd.CommandText = "UPDATE X SET Value = Temp;";
numRecordsAffected = cmd.ExecuteNonQuery();
Console.WriteLine($"Num Records Affected: {numRecordsAffected}");
cmd.CommandText = "ALTER TABLE X DROP COLUMN Temp;";
numRecordsAffected = cmd.ExecuteNonQuery();
Console.WriteLine($"Num Records Affected: {numRecordsAffected}");
}
}
catch (Exception ex) {
Console.WriteLine(ex);
}
}
}
}