]> git.joonet.de Git - adminer.git/commitdiff
MS SQL: Limit one INSERT in export to 1000 rows (fix #983)
authorJakub Vrana <jakub@vrana.cz>
Fri, 4 Apr 2025 17:13:03 +0000 (19:13 +0200)
committerJakub Vrana <jakub@vrana.cz>
Fri, 4 Apr 2025 17:13:03 +0000 (19:13 +0200)
CHANGELOG.md
adminer/include/adminer.inc.php

index 4356a573db66e2a373276277d1a48d73b8f875d6..d495d0f27a7c5693d69641ad95aeb8557811c44a 100644 (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()
index 5a0479fe230e63f1c50396c231f3c68f6235e433..0b62ec42487c8fff80f985b6c3993f8b9fe72062 100644 (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;