1
0
mirror of https://github.com/vrana/adminer.git synced 2025-08-11 17:14:07 +02:00

MS SQL: Limit one INSERT in export to 1000 rows (fix #983)

This commit is contained in:
Jakub Vrana
2025-04-04 19:13:03 +02:00
parent 806efe5e2d
commit ebd2e4f5b4
2 changed files with 7 additions and 1 deletions

View File

@@ -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()

View File

@@ -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;