You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Exercises `Text::as_str` directly (not via serde): sum of UTF-8 byte lengths of the non-null elements. Verifies the varlena header is excluded from the data.
Copy file name to clipboardExpand all lines: pgrx/src/datum/borrow.rs
+5-3Lines changed: 5 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -146,10 +146,12 @@ unsafe impl Element for ffi::CStr {
146
146
pubstructText([u8]);
147
147
148
148
implText{
149
-
/// The string contents (UTF-8), excluding the varlena header.
149
+
/// The string contents, excluding the varlena header.
150
+
///
151
+
/// Uses pgrx's encoding-aware conversion: when the database encoding isn't guaranteed UTF-8 (e.g. `SQL_ASCII`), the bytes are validated and this panics on non-UTF-8 data — same behavior as reading a `text` datum as `&str`.
150
152
pubfnas_str(&self) -> &str{
151
-
// SAFETY: tail is a valid varlena; Postgres text is UTF-8 in pgrx's server encodings
0 commit comments