Escaping parameters ($1, $2,...) when creating SQL functions
Open
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 8.7k
- Forks
- 374
- Avg merge
- 11d 16h
- Merged PRs (30d)
- 1
Description
Hi all,
I am looking for the right way to escape $1, $2,..., when used inside a CREATE FUNCTION statement.
As a minimal example, let's say we have this query in a file:
CREATE OR REPLACE FUNCTION "sample_function"(integer) RETURNS boolean
AS
$$
SELECT CASE WHEN $1 > 15 THEN true ELSE false END AS x FROM (VALUES (1)) AS y
$$
LANGUAGE SQL
STABLE
RETURNS NULL ON NULL INPUT
How should I escape $$ and $1 in this example?
Thank you a lot in advance for your help!
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No file, test, or entry point is named. Start by tracing how the client handles the supplied CREATE FUNCTION statement and its dollar-quoted body, then identify the relevant parameter-handling tests; done means the escaping behavior for $$ and $1 is defined and covered for this example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, postgresql
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100