Skip to content

Commit 96f2294

Browse files
committed
Fix MDEV-12973: Blank columns querying SQL Server
Added support of NCHAR, NVARCHAR an ROWID JDBC types. modified: storage/connect/jdbconn.cpp
1 parent b781d29 commit 96f2294

File tree

1 file changed

+40
-21
lines changed

1 file changed

+40
-21
lines changed

storage/connect/jdbconn.cpp

Lines changed: 40 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -120,42 +120,47 @@ int TranslateJDBCType(int stp, char *tn, int prec, int& len, char& v)
120120
int type;
121121

122122
switch (stp) {
123-
case -1: // LONGVARCHAR
123+
case -1: // LONGVARCHAR
124+
case -16: // LONGNVARCHAR (unicode)
124125
if (GetTypeConv() != TPC_YES)
125126
return TYPE_ERROR;
126127
else
127128
len = MY_MIN(abs(len), GetConvSize());
128-
case 12: // VARCHAR
129+
case 12: // VARCHAR
130+
case -9: // NVARCHAR (unicode)
129131
v = 'V';
130-
case 1: // CHAR
132+
case 1: // CHAR
133+
case -15: // NCHAR (unicode)
134+
case -8: // ROWID
131135
type = TYPE_STRING;
132136
break;
133-
case 2: // NUMERIC
134-
case 3: // DECIMAL
135-
case -3: // VARBINARY
137+
case 2: // NUMERIC
138+
case 3: // DECIMAL
139+
case -3: // VARBINARY
136140
type = TYPE_DECIM;
137141
break;
138-
case 4: // INTEGER
142+
case 4: // INTEGER
139143
type = TYPE_INT;
140144
break;
141-
case 5: // SMALLINT
145+
case 5: // SMALLINT
142146
type = TYPE_SHORT;
143147
break;
144-
case -6: // TINYINT
145-
case -7: // BIT
148+
case -6: // TINYINT
149+
case -7: // BIT
150+
case 16: // BOOLEAN
146151
type = TYPE_TINY;
147152
break;
148-
case 6: // FLOAT
149-
case 7: // REAL
150-
case 8: // DOUBLE
153+
case 6: // FLOAT
154+
case 7: // REAL
155+
case 8: // DOUBLE
151156
type = TYPE_DOUBLE;
152157
break;
153-
case 93: // TIMESTAMP, DATETIME
158+
case 93: // TIMESTAMP, DATETIME
154159
type = TYPE_DATE;
155160
len = 19 + ((prec) ? (prec+1) : 0);
156161
v = (tn && toupper(tn[0]) == 'T') ? 'S' : 'E';
157162
break;
158-
case 91: // DATE, YEAR
163+
case 91: // DATE, YEAR
159164
type = TYPE_DATE;
160165

161166
if (!tn || toupper(tn[0]) != 'Y') {
@@ -167,17 +172,27 @@ int TranslateJDBCType(int stp, char *tn, int prec, int& len, char& v)
167172
} // endif len
168173

169174
break;
170-
case 92: // TIME
175+
case 92: // TIME
171176
type = TYPE_DATE;
172177
len = 8 + ((prec) ? (prec+1) : 0);
173178
v = 'T';
174179
break;
175-
case -5: // BIGINT
180+
case -5: // BIGINT
176181
type = TYPE_BIGINT;
177182
break;
178-
case 0: // NULL
179-
case -2: // BINARY
180-
case -4: // LONGVARBINARY
183+
case 0: // NULL
184+
case -2: // BINARY
185+
case -4: // LONGVARBINARY
186+
case 70: // DATALINK
187+
case 2000: // JAVA_OBJECT
188+
case 2001: // DISTINCT
189+
case 2002: // STRUCT
190+
case 2003: // ARRAY
191+
case 2004: // BLOB
192+
case 2005: // CLOB
193+
case 2006: // REF
194+
case 2009: // SQLXML
195+
case 2011: // NCLOB
181196
default:
182197
type = TYPE_ERROR;
183198
len = 0;
@@ -1225,9 +1240,12 @@ void JDBConn::SetColumnValue(int rank, PSZ name, PVAL val)
12251240

12261241
switch (ctyp) {
12271242
case 12: // VARCHAR
1243+
case -9: // NVARCHAR
12281244
case -1: // LONGVARCHAR
12291245
case 1: // CHAR
1230-
case 3: // DECIMAL
1246+
case -15: // NCHAR
1247+
case 3: // DECIMAL
1248+
case -8: // ROWID
12311249
if (jb && ctyp != 3)
12321250
cn = (jstring)jb;
12331251
else if (!gmID(g, chrfldid, "StringField", "(ILjava/lang/String;)Ljava/lang/String;"))
@@ -1245,6 +1263,7 @@ void JDBConn::SetColumnValue(int rank, PSZ name, PVAL val)
12451263
case 4: // INTEGER
12461264
case 5: // SMALLINT
12471265
case -6: // TINYINT
1266+
case 16: // BOOLEAN
12481267
case -7: // BIT
12491268
if (!gmID(g, intfldid, "IntField", "(ILjava/lang/String;)I"))
12501269
val->SetValue((int)env->CallIntMethod(job, intfldid, rank, jn));

0 commit comments

Comments
 (0)