简体   繁体   中英

Is it possible to change the name of a parameter in a PostgresQL function?

I have a Postgres function defined as follows:

CREATE OR REPLACE FUNCTION my_test_function(query_since timestamp) RETURNS TABLE () ...

Can I update the name of the parameter, query_since , to query_from without dropping the function?

Thedocumentation for CREATE OR REPLACE FUNCTION makes it clear that I can not change the argument types using this SQL command. While it does not specifically mention argument names, I suspect the same restriction applies.

Checking the manual: it does, in fact, mention the same restriction for argument names in the Description section :

To replace the current definition of an existing function, use CREATE OR REPLACE FUNCTION . It is not possible to change the name or argument types of a function this way (if you tried, you would actually be creating a new, distinct function).

Bold emphasis mine.

(But, like you commented, seems to refer to the function name rather than argument names.)

Either way, since you can refer to parameter (argument) names inside the function body in PL/pgSQL or SQL functions, simply renaming is not an option.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM