bulkcopy accepts four-part table names that SQL Server always rejects
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 70/100
調査の方向性
パーツ数の上限は、一括コピー識別子パーサーにある定数 MAX_PARTS で、現在は4パーツまで許可されています。変更はここから始めます。上限を3に下げ、4パーツのターゲットがサーバー呼び出しの前に、ペイロードが5パーツの場合に示すのと同じ使用法エラーで失敗するようにします。再現ケースの4パーツが、メタデータ参照に到達せずに使用法エラーを発生させ、3パーツと5パーツのケースが記載どおりに動作し続ければ完了です。
索引モデルが issue の本文から書いたものです。
説明
Describe the bug
The 1.16.0 bulk copy identifier parser allows up to four name parts (MAX_PARTS is 4), so cursor.bulkcopy() accepts server.database.schema.table. SQL Server doesn't allow a server prefix on a bulk insert target, so every four-part name fails with error 117 after metadata lookup starts. A five-part name fails earlier, in the driver, with a clear usage error.
Exception message:
RuntimeError: Sql Error: 117: Class 15: State 1: The object name 'dlevy-sql25.test1.dbo.fp116' contains more than the maximum number of prefixes. The maximum is 2. on dlevy-sql25 in at line 1
For comparison, a five-part name:
RuntimeError: Failed to retrieve destination metadata: Usage Error: Too many identifier parts: 5 (maximum is 4)
To reproduce
import os
import mssql_python
conn = mssql_python.connect(os.environ["SQL_CONNECTION_STRING"], timeout=30)
cur = conn.cursor()
cur.execute("CREATE TABLE dbo.fp116 (i int)")
conn.commit()
server = cur.execute("SELECT @@SERVERNAME").fetchval()
try:
cur.bulkcopy(f"[{server}].test1.dbo.fp116", [(1,)])
except Exception as e:
print(type(e).__name__, e)
try:
cur.bulkcopy("a.b.c.d.e", [(1,)])
except Exception as e:
print(type(e).__name__, e)
cur.execute("DROP TABLE dbo.fp116")
conn.commit()
Expected behavior
The parser should allow at most three parts for a bulk copy target and reject a four-part name with the same kind of usage error it gives for five parts, before it contacts the server. The current limit of four suggests linked-server targets work, but they can't.
Further technical details
Python version: 3.14.0
mssql-python: 1.16.0 (pip), default msodbcsql18 provider
SQL Server version: SQL Server 2025 (RTM-CU9) 17.0.5005.3, Enterprise Edition, EngineEdition 3
Operating system: Windows 11
Additional context
Found while documenting the 1.16.0 bulk copy identifier changes in MicrosoftDocs/sql-docs-pr#38337. The docs now list one-part through three-part names and say that SQL Server rejects the four-part form.
- 主要言語
- Python
- スター
- 478
- フォーク
- 62
- 平均マージ
- 3日 1時間
- マージ済み PR(30日)
- 27
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
microsoft/mssql-python のほかの issue
-
macOS: encrypted connections fail after Homebrew moved the `openssl` alias to `openssl@4`対応中かも @bewithgaurav が 14 日前に担当しました。 オープンarea: packaging-platform bug triage needed
難易度 4/5 3〜5日 初心者へのやさしさ 55/100
microsoft/mssql-python#826 · コメント 2 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
bulkcopy PyCore login is closed by SQL Server 2019 while ODBC and Go clients succeed (1.14.0)再び着手できるかも @bewithgaurav が 34 日前に担当しましたが、オープン中のプルリクエストはありません。 オープンarea: bulk-copy bug triage done
microsoft/mssql-python#750 · コメント 4 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
Announcement: mssql-python is coming to Django through mssql-django 2.0再び着手できるかも @bewithgaurav が 41 日前に担当しましたが、オープン中のプルリクエストはありません。 オープンannouncement
microsoft/mssql-python#748 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
Connection pool can briefly exceed max_size when pooling is disabled under load対応中かも @bewithgaurav が 23 日前に担当しました。 オープンarea: connectivity-auth bug triage done under development
難易度 4/5 3〜5日 初心者へのやさしさ 62/100
microsoft/mssql-python#746 · コメント 1 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
Decimal in money range still string-binds on the executemany path対応中かも @bewithgaurav が 23 日前に担当しました。 オープンarea: data-types bug triage done under development
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
microsoft/mssql-python#745 · コメント 1 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
microsoft/mssql-python の issue をすべて見る
似ている issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
Deltares/imod-python#1940 ·
メンテナーはふだん 1 日以内に返信
-
effort: low prio: low ready
難易度 1/5 1時間未満 初心者へのやさしさ 82/100
digitalfabrik/integreat-cms#4621 ·
メンテナーはふだん 5 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
ioos/compliance-checker#1375 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信