SPI_SCRO...SOR_FETCH(3)

✨ SPI_scroll_cursor_fetch β€” it's giving "fetch me some rows, bestie" πŸ’…

okay so real talk, this is a page straight out of the PostgreSQL 18.6 Documentation manual, and it's all about SPI_scroll_cursor_fetch β€” the C-level glow-up of the SQL FETCH command. grab a lil snack, we're getting into it πŸ“


πŸŽ€ NAME πŸŽ€

SPI_scroll_cursor_fetch β€” fetch some rows from a cursor


🌸 SYNOPSIS 🌸

void SPI_scroll_cursor_fetch(Portal portal, FetchDirection direction,
                             long count)

πŸ¦‹ DESCRIPTION πŸ¦‹

so SPI_scroll_cursor_fetch does exactly what it says on the tin: it fetches some rows from a cursor. no cap. it is equivalent to the SQL command FETCH β€” like, spiritually the same thing, just living down here in C land. πŸ‘‘


πŸ’– ARGUMENTS πŸ’–

  • Portal portal β€” the portal that's holding the cursor. it's literally the container for the whole vibe.
  • FetchDirection direction β€” you gotta pick one, and your options are: FETCH_FORWARD, FETCH_BACKWARD, FETCH_ABSOLUTE or FETCH_RELATIVE. choose wisely bestie.
  • long count β€” the number. but like, the number means different things depending on the direction you picked:
    • for FETCH_FORWARD or FETCH_BACKWARD it's the number of rows to fetch;
    • for FETCH_ABSOLUTE it's the absolute row number to fetch;
    • for FETCH_RELATIVE it's the relative row number to fetch.

πŸ”₯ RETURN VALUE πŸ”₯

if it works, SPI_processed and SPI_tuptable get set exactly like they do in SPI_execute. same energy, same deal. ✨


πŸ‘‘ NOTES πŸ‘‘

  • for the full tea on how direction and count are actually interpreted, go read the SQL FETCH(7) command. that's where the details live. πŸ“–
🚨 okay important one: direction values that aren't FETCH_FORWARD may fail if the cursor's plan wasn't created with the CURSOR_OPT_SCROLL option. so like… if you're scrolling backward and it's not working, that's probably why. not a vibe, but that's the rule. 😭

that's the whole page bestie, no skips, every flag and caveat intact 🫢 go forth and fetch responsibly.

PostgreSQL 18.6 Β· dated 2026 Β· SPI_SCRO...SOR_FETCH(3) β€” mwah, periodt πŸ’…πŸŒˆ