Skip to content

Commit 1bcf0bc

Browse files
authored
Merge pull request #277 from schveiguy/fix276
Fix issue where 251+ columns are not allowed in query result.
2 parents fa4d3fb + da8ac7d commit 1bcf0bc

File tree

5 files changed

+42
-15
lines changed

5 files changed

+42
-15
lines changed

.github/workflows/dub.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,10 @@ jobs:
2626
compiler:
2727
- dmd-latest
2828
- ldc-latest
29+
- dmd-2.101.2
2930
- dmd-2.098.1
30-
- dmd-2.097.2
31-
- dmd-2.096.1
31+
- ldc-1.31.0 # eq to dmd v2.101.2
3232
- ldc-1.28.1 # eq to dmd v2.098.1
33-
- ldc-1.27.1 # eq to dmd v2.097.2
3433
steps:
3534
- uses: actions/checkout@v3
3635

@@ -58,6 +57,7 @@ jobs:
5857
matrix:
5958
os: [ ubuntu-latest, windows-latest ] # don't bother with macos-latest
6059
compiler:
60+
- dmd-2.097.2
6161
- dmd-2.095.1
6262
- dmd-2.094.2
6363
- dmd-2.093.1

.github/workflows/integration-testing.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,10 @@ jobs:
8686
compiler:
8787
- dmd-latest
8888
- ldc-latest
89+
- dmd-2.101.2
8990
- dmd-2.098.1
9091
- dmd-2.097.2
92+
- ldc-1.31.0 # eq to dmd v2.101.2
9193
- ldc-1.28.1 # eq to dmd v2.098.1
9294
- ldc-1.27.0 # eq to dmd v2.097.2
9395

@@ -157,8 +159,10 @@ jobs:
157159
compiler:
158160
- dmd-latest
159161
- ldc-latest
162+
- dmd-2.101.2
160163
- dmd-2.098.1
161164
- dmd-2.097.2
165+
- ldc-1.31.0 # eq to dmd v2.101.2
162166
- ldc-1.28.1 # eq to dmd v2.098.1
163167
- ldc-1.27.0 # eq to dmd v2.097.2
164168

integration-tests/source/mysql/test/integration.d

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,11 @@ debug(MYSQLN_TESTS)
491491
https://mariadb.com/kb/en/library/information-schema-columns-table/
492492
+/
493493

494+
// note on integer type widths -- these are not shown in the column type name with mysql 8.
495+
// From docs:
496+
// As of MySQL 8.0.17, the display width attribute is deprecated for integer data types;
497+
// you should expect support for it to be removed in a future version of MySQL.
498+
494499
ColumnInfo[] ca = md.columns("basetest");
495500
assert( ca[0].schema == schemaName && ca[0].table == "basetest" && ca[0].name == "boolcol" && ca[0].index == 0 &&
496501
ca[0].nullable && ca[0].type == "bit" && ca[0].charsMax == -1 && ca[0].octetsMax == -1 &&
@@ -499,36 +504,36 @@ debug(MYSQLN_TESTS)
499504
assert( ca[1].schema == schemaName && ca[1].table == "basetest" && ca[1].name == "bytecol" && ca[1].index == 1 &&
500505
ca[1].nullable && ca[1].type == "tinyint" && ca[1].charsMax == -1 && ca[1].octetsMax == -1 &&
501506
ca[1].numericPrecision == 3 && ca[1].numericScale == 0 && ca[1].charSet == "<NULL>" && ca[1].collation == "<NULL>" &&
502-
ca[1].colType == "tinyint(4)");
507+
(ca[1].colType == "tinyint(4)" || ca[1].colType == "tinyint"));
503508
assert( ca[2].schema == schemaName && ca[2].table == "basetest" && ca[2].name == "ubytecol" && ca[2].index == 2 &&
504509
ca[2].nullable && ca[2].type == "tinyint" && ca[2].charsMax == -1 && ca[2].octetsMax == -1 &&
505510
ca[2].numericPrecision == 3 && ca[2].numericScale == 0 && ca[2].charSet == "<NULL>" && ca[2].collation == "<NULL>" &&
506-
ca[2].colType == "tinyint(3) unsigned");
511+
(ca[2].colType == "tinyint(3) unsigned" || ca[2].colType == "tinyint unsigned"));
507512
assert( ca[3].schema == schemaName && ca[3].table == "basetest" && ca[3].name == "shortcol" && ca[3].index == 3 &&
508513
ca[3].nullable && ca[3].type == "smallint" && ca[3].charsMax == -1 && ca[3].octetsMax == -1 &&
509514
ca[3].numericPrecision == 5 && ca[3].numericScale == 0 && ca[3].charSet == "<NULL>" && ca[3].collation == "<NULL>" &&
510-
ca[3].colType == "smallint(6)");
515+
(ca[3].colType == "smallint(6)" || ca[3].colType == "smallint"));
511516
assert( ca[4].schema == schemaName && ca[4].table == "basetest" && ca[4].name == "ushortcol" && ca[4].index == 4 &&
512517
ca[4].nullable && ca[4].type == "smallint" && ca[4].charsMax == -1 && ca[4].octetsMax == -1 &&
513518
ca[4].numericPrecision == 5 && ca[4].numericScale == 0 && ca[4].charSet == "<NULL>" && ca[4].collation == "<NULL>" &&
514-
ca[4].colType == "smallint(5) unsigned");
519+
(ca[4].colType == "smallint(5) unsigned" || ca[4].colType == "smallint unsigned"));
515520
assert( ca[5].schema == schemaName && ca[5].table == "basetest" && ca[5].name == "intcol" && ca[5].index == 5 &&
516521
ca[5].nullable && ca[5].type == "int" && ca[5].charsMax == -1 && ca[5].octetsMax == -1 &&
517522
ca[5].numericPrecision == 10 && ca[5].numericScale == 0 && ca[5].charSet == "<NULL>" && ca[5].collation == "<NULL>" &&
518-
ca[5].colType == "int(11)");
523+
(ca[5].colType == "int(11)" || ca[5].colType == "int"));
519524
assert( ca[6].schema == schemaName && ca[6].table == "basetest" && ca[6].name == "uintcol" && ca[6].index == 6 &&
520525
ca[6].nullable && ca[6].type == "int" && ca[6].charsMax == -1 && ca[6].octetsMax == -1 &&
521526
ca[6].numericPrecision == 10 && ca[6].numericScale == 0 && ca[6].charSet == "<NULL>" && ca[6].collation == "<NULL>" &&
522-
ca[6].colType == "int(10) unsigned");
527+
(ca[6].colType == "int(10) unsigned" ||ca[6].colType == "int unsigned"));
523528
assert( ca[7].schema == schemaName && ca[7].table == "basetest" && ca[7].name == "longcol" && ca[7].index == 7 &&
524529
ca[7].nullable && ca[7].type == "bigint" && ca[7].charsMax == -1 && ca[7].octetsMax == -1 &&
525530
ca[7].numericPrecision == 19 && ca[7].numericScale == 0 && ca[7].charSet == "<NULL>" && ca[7].collation == "<NULL>" &&
526-
ca[7].colType == "bigint(20)");
531+
(ca[7].colType == "bigint(20)" || ca[7].colType == "bigint"));
527532
assert( ca[8].schema == schemaName && ca[8].table == "basetest" && ca[8].name == "ulongcol" && ca[8].index == 8 &&
528533
ca[8].nullable && ca[8].type == "bigint" && ca[8].charsMax == -1 && ca[8].octetsMax == -1 &&
529534
//TODO: I'm getting numericPrecision==19, figure it out later
530535
/+ca[8].numericPrecision == 20 &&+/ ca[8].numericScale == 0 && ca[8].charSet == "<NULL>" && ca[8].collation == "<NULL>" &&
531-
ca[8].colType == "bigint(20) unsigned");
536+
(ca[8].colType == "bigint(20) unsigned" || ca[8].colType == "bigint unsigned"));
532537
assert( ca[9].schema == schemaName && ca[9].table == "basetest" && ca[9].name == "charscol" && ca[9].index == 9 &&
533538
ca[9].nullable && ca[9].type == "char" && ca[9].charsMax == 10 && ca[9].octetsMax == 10 &&
534539
ca[9].numericPrecision == -1 && ca[9].numericScale == -1 && ca[9].charSet == "latin1" && ca[9].collation == "latin1_swedish_ci" &&
@@ -564,7 +569,7 @@ debug(MYSQLN_TESTS)
564569
assert( ca[17].schema == schemaName && ca[17].table == "basetest" && ca[17].name == "nullcol" && ca[17].index == 17 &&
565570
ca[17].nullable && ca[17].type == "int" && ca[17].charsMax == -1 && ca[17].octetsMax == -1 &&
566571
ca[17].numericPrecision == 10 && ca[17].numericScale == 0 && ca[17].charSet == "<NULL>" && ca[17].collation == "<NULL>" &&
567-
ca[17].colType == "int(11)");
572+
(ca[17].colType == "int(11)" || ca[17].colType == "int"));
568573
assert( ca[18].schema == schemaName && ca[18].table == "basetest" && ca[18].name == "decimalcol" && ca[18].index == 18 &&
569574
ca[18].nullable && ca[18].type == "decimal" && ca[18].charsMax == -1 && ca[18].octetsMax == -1 &&
570575
ca[18].numericPrecision == 11 && ca[18].numericScale == 4 && ca[18].charSet == "<NULL>" && ca[18].collation == "<NULL>" &&
@@ -1024,7 +1029,8 @@ debug(MYSQLN_TESTS)
10241029
auto row = cn.queryRow(stmt).get;
10251030
assert(row.length == 4);
10261031
assert(row[0] == "utf8mb4");
1027-
assert(row[1] == "utf8mb4_general_ci");
1032+
// note, the second possibility is from mysql 8
1033+
assert(row[1] == "utf8mb4_general_ci" || row[1] == "utf8mb4_0900_ai_ci");
10281034
assert(row[2] == "UTF-8 Unicode");
10291035
assert(row[3] == 4);
10301036
}
@@ -1263,3 +1269,19 @@ unittest
12631269
auto exitCode = spawnProcess(["dub", "-q", "--", testConnectionStr]).wait;
12641270
assert(exitCode == 0);
12651271
}
1272+
1273+
// https://github.com/mysql-d/mysql-native/issues/276
1274+
@("large result field count")
1275+
debug(MYSQLN_TESTS)
1276+
unittest
1277+
{
1278+
mixin(scopedCn);
1279+
import mysql.safe.commands;
1280+
import std.format;
1281+
1282+
auto sql = format("SELECT 1 AS `%-(%s`, 1 AS `%)`",
1283+
iota(26*26).map!(i => [cast(char)(i / 26 + 'A'), cast(char)(i % 26 + 'A')]));
1284+
auto result = cn.queryRow(sql);
1285+
assert(!result.isNull);
1286+
assert(result.get.length == 26*26);
1287+
}

source/mysql/metadata.d

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,8 @@ public:
236236
" CHARACTER_SET_NAME, COLLATION_NAME, COLUMN_TYPE," ~
237237
" COLUMN_KEY, EXTRA, PRIVILEGES, COLUMN_COMMENT" ~
238238
" FROM information_schema.COLUMNS WHERE" ~
239-
" table_schema='" ~ _con.currentDB ~ "' AND table_name='" ~ table ~ "'";
239+
" table_schema='" ~ _con.currentDB ~ "' AND table_name='" ~ table ~ "'" ~
240+
" ORDER BY ORDINAL_POSITION";
240241
auto rs = _con.query(query).array;
241242
ColumnInfo[] ca;
242243
ca.length = rs.length;

source/mysql/protocol/comms.d

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,12 +489,12 @@ package(mysql) bool execQueryImpl(Connection conn, ExecQueryImplInfo info, out u
489489
else
490490
{
491491
// There was presumably a result set
492-
assert(packet.front >= 1 && packet.front <= 250); // Result set packet header should have this value
493492
conn._headersPending = conn._rowsPending = true;
494493
conn._binaryPending = info.isPrepared;
495494
auto lcb = packet.consumeIfComplete!LCB();
496495
assert(!lcb.isNull);
497496
assert(!lcb.isIncomplete);
497+
assert(lcb.value >= 1 && lcb.value <= ushort.max); // Result set packet header should have this value
498498
conn._fieldCount = cast(ushort)lcb.value;
499499
assert(conn._fieldCount == lcb.value);
500500
rv = true;

0 commit comments

Comments
 (0)