Skip site navigation (1) Skip section navigation (2)

How to use CreateFunctionStmt's RETURN TABLE?

From: _石头 <tanjia76(at)qq(dot)com>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: How to use CreateFunctionStmt's RETURN TABLE?
Date: 2011-07-26 07:21:05
Message-ID: tencent_3282B8DD514F05D42CCC579B@qq.com (view raw or flat)
Thread:
Lists: pgsql-hackers
Hello Guys,


       Lately, I saw this syntax in ./src/backend/parser/Gray.y as following!
   
      CreateFunctionStmt:
			CREATE opt_or_replace FUNCTION func_name func_args_with_defaults
			RETURNS func_return createfunc_opt_list opt_definition
				{
					CreateFunctionStmt *n = makeNode(CreateFunctionStmt);
					n->replace = $2;
					n->funcname = $4;
					n->parameters = $5;
					n->returnType = $7;
					n->options = $8;
					n->withClause = $9;
					$$ = (Node *)n;
				}
			| CREATE opt_or_replace FUNCTION func_name func_args_with_defaults
			  RETURNS TABLE '(' table_func_column_list ')' createfunc_opt_list opt_definition
				{
					CreateFunctionStmt *n = makeNode(CreateFunctionStmt);
					n->replace = $2;
					n->funcname = $4;
					n->parameters = mergeTableFuncParameters($5, $9);
					n->returnType = TableFuncTypeName($9);
					n->returnType->location = @7;
					n->options = $11;
					n->withClause = $12;
					$$ = (Node *)n;
				}
			| CREATE opt_or_replace FUNCTION func_name func_args_with_defaults
			  createfunc_opt_list opt_definition
				{
					CreateFunctionStmt *n = makeNode(CreateFunctionStmt);
					n->replace = $2;
					n->funcname = $4;
					n->parameters = $5;
					n->returnType = NULL;
					n->options = $6;
					n->withClause = $7;
					$$ = (Node *)n;
				}
		;


          I do not know how to use the second syntax:RETURNS TABLE '(' table_func_column_list ')' createfunc_opt_list opt_definition.


          May someone help me to write a simple example of this syntax!  Thank you very much. Looking forward for your help!

Responses

pgsql-hackers by date

Next:From: _石头Date: 2011-07-26 07:22:50
Subject: How to use CreateFunctionStmt's RETURN TABLE?
Previous:From: Alvaro HerreraDate: 2011-07-26 04:19:08
Subject: Re: Check constraints on partition parents only?

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group