# Set Returning Functions and PostgreSQL 10

DevFeed: [Set Returning Functions and PostgreSQL 10](<https://devfeed.tech/articles/set-returning-functions-and-postgresql-10-34567.md>)

Original publisher: [Read original article](<https://tapoueh.org/blog/2017/10/set-returning-functions-and-postgresql-10/>)

Author: Dimitri Fontaine PostgreSQL Major Contributor; Author

Published: 2017-10-13T11:25:21Z

Content type: article

Language: en

Sources: [Dimitri Fontaine](<https://devfeed.tech/sources/dimitri-fontaine.md>)

Topics: [PostgreSQL](<https://devfeed.tech/topics/postgresql.md>), [function](<https://devfeed.tech/topics/function.md>), [SQL](<https://devfeed.tech/topics/sql.md>), [JSON](<https://devfeed.tech/topics/json.md>), [Query (disambiguation)](<https://devfeed.tech/topics/query.md>)

Tags: [functions](<https://devfeed.tech/tags/functions.md>), [json](<https://devfeed.tech/tags/json.md>), [jsonb](<https://devfeed.tech/tags/jsonb.md>), [lateral](<https://devfeed.tech/tags/lateral.md>), [postgresql](<https://devfeed.tech/tags/postgresql.md>), [sql](<https://devfeed.tech/tags/sql.md>)

## AI overview

This article explains how PostgreSQL 10 changed the evaluation and permitted contexts of set-returning functions. It reviews clearer semantics for functions in SELECT lists, including handling of multiple functions with different row counts, and explains restrictions in CASE and COALESCE expressions.

## Source excerpt

PostgreSQL 10 is now available for everyone to use, and hinted by David Fetter I had to review my previous article on Json and SQL to adapt to Set Returning Functions changes. A Set Returning Function is a PostgreSQL Stored Procedure that can be used as a relation: from a single call it returns an entire result set, much like a subquery or a table. It used to be possible to use SRF in the SELECT clause, with dubious (but useful at times) semantics, and also in scalar contexts. The semantics have been fixed and are now much clearer, and the uses in scalar contexts are forbidden -- they were a hack and never made sense anyway.