Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[APIS-784] raised System.AccessViolationException #14

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 19 additions & 19 deletions Code/Src/CUBRIDCciInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,10 @@ internal struct T_CCI_COL_INFO
public char is_non_null;
public short scale;
public int precision;
public IntPtr col_name;
public IntPtr real_attr;
public IntPtr class_name;
public IntPtr default_value;
public String col_name;
public String real_attr;
public String class_name;
public String default_value;
public char is_auto_increment;
public char is_unique_key;
public char is_primary_key;
Expand Down Expand Up @@ -266,8 +266,7 @@ public static ColumnMetaData[] cci_get_result_info(CUBRIDConnection conn, int re
{
int stmt_type = 0;
int col_num = 0;
int n;
byte[] name = new byte[MAX_TBALE_COLUMN_NAME_LENGTH];
byte[] name;

IntPtr pt = cci_get_result_info_internal(req_handle, ref stmt_type, ref col_num);
ColumnMetaData[] item = new ColumnMetaData[col_num];
Expand All @@ -277,9 +276,11 @@ public static ColumnMetaData[] cci_get_result_info(CUBRIDConnection conn, int re
ColumnMetaData data = new ColumnMetaData();
try
{

T_CCI_COL_INFO tmp =
(T_CCI_COL_INFO)Marshal.PtrToStructure((IntPtr)((UInt32)pt +
i * Marshal.SizeOf(typeof(T_CCI_COL_INFO))), typeof(T_CCI_COL_INFO));

data.Type = (CUBRIDDataType)tmp.ext_type;

data.IsAutoIncrement = int_to_bool(tmp.is_auto_increment - 0);
Expand All @@ -294,24 +295,23 @@ public static ColumnMetaData[] cci_get_result_info(CUBRIDConnection conn, int re
data.Scale = tmp.scale;
data.Type = (CUBRIDDataType)tmp.ext_type;

Marshal.Copy(tmp.col_name, name, 0, MAX_TBALE_COLUMN_NAME_LENGTH);
for (n = 0; n < MAX_TBALE_COLUMN_NAME_LENGTH; n++) if (name[n] == 0) break;
if (conn.GetEncoding().Equals(Encoding.UTF8))
data.Name = Encoding.UTF8.GetString(name, 0, n);
else
data.Name = Encoding.Unicode.GetString(name, 0, n);

Marshal.Copy(tmp.class_name, name, 0, MAX_TBALE_COLUMN_NAME_LENGTH);
for (n = 0; n < MAX_TBALE_COLUMN_NAME_LENGTH; n++) if (name[n] == 0) break;
if (conn.GetEncoding().Equals(Encoding.UTF8))
{
data.RealName = Encoding.UTF8.GetString(name, 0, n);
data.Table = Encoding.UTF8.GetString(name, 0, n);
name = Encoding.UTF8.GetBytes(tmp.col_name);
data.Name = Encoding.UTF8.GetString(name);

name = Encoding.UTF8.GetBytes(tmp.class_name);
data.RealName = Encoding.UTF8.GetString(name);
data.Table = Encoding.UTF8.GetString(name);
}
else
{
data.RealName = Encoding.Unicode.GetString(name, 0, n);
data.Table = Encoding.Unicode.GetString(name, 0, n);
name = Encoding.Unicode.GetBytes(tmp.col_name);
data.Name = Encoding.Unicode.GetString(name);

name = Encoding.Unicode.GetBytes(tmp.class_name);
data.RealName = Encoding.Unicode.GetString(name);
data.Table = Encoding.Unicode.GetString(name);
}
}
catch
Expand Down