Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion contrib/babelfishpg_tsql/src/string.c
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,7 @@ float_str(PG_FUNCTION_ARGS)
}
}

return return_varchar_pointer(buf, size);
return return_varchar_pointer(buf, strlen(buf));
}

/*
Expand Down
26 changes: 26 additions & 0 deletions test/JDBC/expected/str.out
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,32 @@ GO
-- =============================================
-- CLEANUP
-- =============================================
-- =============================================
-- STRING CONCATENATION WITH STR() (GitHub Issue #4297)
-- =============================================
-- STR() result should not truncate strings appended after it
SELECT 'distance:' + STR(123, 4, 0) + ' mi';
GO
~~START~~
varchar
distance: 123 mi
~~END~~

SELECT 'val=' + STR(42, 2, 0) + ',done';
GO
~~START~~
varchar
val=42,done
~~END~~

SELECT STR(1, 1, 0) + ' suffix';
GO
~~START~~
varchar
1 suffix
~~END~~


-- Drop Views
DROP VIEW str_v1;
DROP VIEW str_v2;
Expand Down
13 changes: 13 additions & 0 deletions test/JDBC/input/functions/string_functions/str.sql
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,19 @@ GO
-- CLEANUP
-- =============================================

-- =============================================
-- STRING CONCATENATION WITH STR() (GitHub Issue #4297)
-- =============================================
-- STR() result should not truncate strings appended after it
SELECT 'distance:' + STR(123, 4, 0) + ' mi';
GO

SELECT 'val=' + STR(42, 2, 0) + ',done';
GO

SELECT STR(1, 1, 0) + ' suffix';
GO

-- Drop Views
DROP VIEW str_v1;
DROP VIEW str_v2;
Expand Down
Loading