PG_LO_WRITE(n)

πŸ“¦ version 3.1.1, in alpine 3.22, alpine 3.23, alpine 3.24, nixpkgs unstable

✨ pg_lo_write β€” bestie, we're writing to a large object πŸ’…

okay so real quick vibe check: this is the PostgreSQL Tcl Interface Documentation page for pg_lo_write, and honestly? she's a little icon. short, sweet, does exactly what she says on the tin. no cap. πŸŽ€


🌸 NAME 🌸

pg_lo_write β€” write to a large object βœοΈπŸ’–


πŸ¦‹ SYNOPSIS πŸ¦‹

pg_lo_write conn descriptor buf len

literally that's it. four little args and you're off. slay. ✨


πŸ’œ DESCRIPTION πŸ’œ

okay so here's the tea β˜• β€” pg_lo_write writes at most len bytes from a variable called buf to a large object. that's the whole job. she's not doing anything extra, she's not overachieving, she's just writing your bytes where they need to go. main character energy but make it efficient. 🫢


πŸ“ ARGUMENTS πŸ“

  • conn β€” the handle of a connection to the database in which the large object lives. like, which database are we even talking about, bestie? this is that. πŸ—‚οΈ
  • descriptor β€” a descriptor for the large object, and it comes from pg_lo_open. you can't just make one up, iykyk. πŸ”‘
  • buf β€” the string to write to the large object. and listen, not a variable name β€” the value itself. like, the actual string, not the name of the thing holding the string. this is the one people get wrong and i'm not gonna let it be you πŸ’€
  • len β€” the maximum number of bytes to write. and here's the lil twist πŸŒ€: the number actually written is the smaller of this value and the length of the string. so if you're over here requesting more bytes than your string has… she's gonna write what she's got and move on. periodt. πŸ‘‘

πŸ”₯ RETURN VALUE πŸ”₯

the number of bytes actually written gets returned, which β€” ordinarily β€” is gonna be the same as the number you asked for. 🌈

but in the event of an error? the return value is negative. so like… if you see a negative number, something went wrong, and you should probably pay attention to it instead of pretending you didn't see it. πŸ™ˆ negative = not the vibe. πŸ’€


⚠️ gentle reminder bestie: len is a maximum, not a promise. the return value is the truth. always check the return value. always. 🫢

🧚 see also & credits 🧚

ngl this page is short and iconic and that's her brand. 🌸

this absolute gem is dated 17 September 2020, and it comes to you courtesy of the PostgreSQL Tcl Interface Documentation β€” so go give your Tcl/Postgres setup a little kiss on the forehead for me, mkay? πŸ’–βœ¨πŸŽ€

go write those large objects. slay. πŸ’…πŸ‘‘

πŸ“¦ where this page comes from