Skip to content

Python extension truncates output  #33

@maXXis253

Description

@maXXis253

Python extension seems to truncate output string to 65535 characters. This is reproducible with SQL Server 2019 and Python 3.7.x and 3.9.x
The code snippet below reproduces the issue, assuming external language myPython is created.

CREATE OR ALTER PROCEDURE dbo.P_TestPython
AS
BEGIN
DECLARE @RequestStr VARCHAR(max)=replicate('A',10000),
@ResponseStr VARCHAR(max),
@i INT=1

WHILE @i<=4 BEGIN
	SELECT @RequestStr=@RequestStr+@RequestStr
	SET @i+=1
END
-- Prints 128000
select len(@RequestStr)

EXEC sp_execute_external_script
	@language=N'myPython',
	@script=N'

print(len(RequestStr))
ResponseStr = RequestStr
',
@params=N'@RequestStr VARCHAR(MAX),@ResponseStr VARCHAR(MAX) OUTPUT',
@RequestStr=@RequestStr,
@ResponseStr=@ResponseStr OUTPUT

-- Prints 65535
select len(@ResponseStr)

END
go
EXEC dbo.P_TestPython
go
-- Output 128000,65535

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions