foreign_table_like_02.diff

text/plain

Filename: foreign_table_like_02.diff
Type: text/plain
Part: 0
Message: Re: CREATE FOREGIN TABLE LACUNA

Patch

Same data as JSON: GET /api/v1/attachments/:id/patch the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes. API reference →
Format: context
File+
src/backend/parser/gram.y 1 0
src/backend/parser/parse_utilcmd.c 21 0
*** a/src/backend/parser/gram.y
--- b/src/backend/parser/gram.y
***************
*** 3950,3955 **** ForeignTableElementList:
--- 3950,3956 ----
  
  ForeignTableElement:
  			columnDef					{ $$ = $1; }
+             | TableLikeClause			{ $$ = $1; }
  		;
  
  /*****************************************************************************
*** a/src/backend/parser/parse_utilcmd.c
--- b/src/backend/parser/parse_utilcmd.c
***************
*** 652,657 **** transformTableLikeClause(CreateStmtContext *cxt, TableLikeClause *table_like_cla
--- 652,678 ----
  						table_like_clause->relation->relname)));
  
  	cancel_parser_errposition_callback(&pcbstate);
+ 	
+ 	/*
+ 	 * For foreign tables, disallow some options.
+ 	 */
+ 	if (strcmp(cxt->stmtType, "CREATE FOREIGN TABLE")==0)
+ 	{
+ 		if (table_like_clause->options & CREATE_TABLE_LIKE_CONSTRAINTS)
+ 		{
+ 			ereport(ERROR,
+ 					(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ 					 errmsg("\"%s\" is a foreign table. Only local tables can take LIKE CONSTRAINTS",
+ 							table_like_clause->relation->relname)));
+ 		}
+ 		else if (table_like_clause->options & CREATE_TABLE_LIKE_INDEXES)
+ 		{
+ 			ereport(ERROR,
+ 					(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ 					 errmsg("\"%s\" is a foreign table. Only local tables can take LIKE INDEXES",
+ 							table_like_clause->relation->relname)));
+ 		}
+ 	}
  
  	/*
  	 * Check for privileges