rowexpr.patch

text/plain

Filename: rowexpr.patch
Type: text/plain
Part: 0
Message: INSERT and parentheses

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/analyze.c 20 0
*** a/src/backend/parser/analyze.c
--- b/src/backend/parser/analyze.c
***************
*** 730,742 **** transformInsertRow(ParseState *pstate, List *exprlist,
  												  list_length(icolumns))))));
  	if (stmtcols != NIL &&
  		list_length(exprlist) < list_length(icolumns))
! 		ereport(ERROR,
  				(errcode(ERRCODE_SYNTAX_ERROR),
  				 errmsg("INSERT has more target columns than expressions"),
  				 parser_errposition(pstate,
  									exprLocation(list_nth(icolumns,
  												  list_length(exprlist))))));
  
  	/*
  	 * Prepare columns for assignment to target table.
  	 */
--- 730,761 ----
  												  list_length(icolumns))))));
  	if (stmtcols != NIL &&
  		list_length(exprlist) < list_length(icolumns))
! 	{
! 		/*
! 		 * If the expression only has a single column of type record, it's
! 		 * possible that that wasn't intended.
! 		 */
! 		if (list_length(exprlist) == 1 &&
! 			(IsA(linitial(exprlist), Var) &&
! 			((Var *) linitial(exprlist))->vartype == RECORDOID) ||
! 			IsA(linitial(exprlist), RowExpr))
! 			ereport(ERROR,
! 				(errcode(ERRCODE_SYNTAX_ERROR),
! 				 errmsg("INSERT has more target columns than expressions"),
! 				 errhint("Did you accidentally use extra parentheses?"),
! 				 parser_errposition(pstate,
! 									exprLocation(list_nth(icolumns,
! 												  list_length(exprlist))))));
! 		else
! 			ereport(ERROR,
  				(errcode(ERRCODE_SYNTAX_ERROR),
  				 errmsg("INSERT has more target columns than expressions"),
  				 parser_errposition(pstate,
  									exprLocation(list_nth(icolumns,
  												  list_length(exprlist))))));
  
+ 	}
+ 
  	/*
  	 * Prepare columns for assignment to target table.
  	 */