diff --git a/CHANGELOG.md b/CHANGELOG.md index 4356a573..d495d0f2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - PostgreSQL: Support COPY FROM stdin in SQL query (bug #942) - MySQL: Display number of found rows in group queries (regression from 5.1.1) - non-MySQL: Parse '--' without trailing space as comment in SQL command (bug SF-842) +- MS SQL: Limit one INSERT in export to 1000 rows (bug #983) - CSS: Add logo - Editor: Move mass sending e-mails to a plugin - Plugins: Allow formatting translations using Adminer\lang_format() diff --git a/adminer/include/adminer.inc.php b/adminer/include/adminer.inc.php index 5a0479fe..0b62ec42 100644 --- a/adminer/include/adminer.inc.php +++ b/adminer/include/adminer.inc.php @@ -816,6 +816,7 @@ class Adminer { $generated = array(); $suffix = ""; $fetch_function = ($table != '' ? 'fetch_assoc' : 'fetch_row'); + $count = 0; while ($row = $result->$fetch_function()) { if (!$keys) { $values = array(); @@ -855,13 +856,17 @@ class Adminer { $s = ($max_packet ? "\n" : " ") . "(" . implode(",\t", $row) . ")"; if (!$buffer) { $buffer = $insert . $s; - } elseif (strlen($buffer) + 4 + strlen($s) + strlen($suffix) < $max_packet) { // 4 - length specification + } elseif (JUSH == 'mssql' + ? $count % 1000 != 0 // https://learn.microsoft.com/en-us/sql/t-sql/queries/table-value-constructor-transact-sql#limitations-and-restrictions + : strlen($buffer) + 4 + strlen($s) + strlen($suffix) < $max_packet // 4 - length specification + ) { $buffer .= ",$s"; } else { echo $buffer . $suffix; $buffer = $insert . $s; } } + $count++; } if ($buffer) { echo $buffer . $suffix;