From c0f7139cf4e96bef784e4e3c8817d973183f80c7 Mon Sep 17 00:00:00 2001 From: mchrza Date: Tue, 10 Jun 2025 13:41:10 +0200 Subject: [PATCH] After updating to Postgres 17 it was not possible to write empty files. (State 38000 during s3.PutObject). The provided workaround solves the issue. --- aws_s3--0.0.1.sql | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/aws_s3--0.0.1.sql b/aws_s3--0.0.1.sql index d3dde33..47e7307 100644 --- a/aws_s3--0.0.1.sql +++ b/aws_s3--0.0.1.sql @@ -256,7 +256,11 @@ AS $$ num_lines += buffer.count(b'\n') size += len(buffer) fd.seek(0) - s3.upload_fileobj(fd, bucket, file_path) + if size == 0: + io = cache_import('io') + s3.upload_fileobj(io.BytesIO(b' '), bucket, file_path) + else: + s3.upload_fileobj(fd, bucket, file_path) yield (num_lines, 1, size) $$; @@ -265,6 +269,7 @@ CREATE OR REPLACE FUNCTION aws_s3.query_export_to_s3( s3_info aws_commons._s3_uri_1, options text default null, credentials aws_commons._aws_credentials_1 default null, + options text default null, endpoint_url text default null, OUT rows_uploaded bigint, OUT files_uploaded bigint,