While looking at Fujita Etsuro's patch to allow copy to/from a shell command, I noticed that the grammar currently allows these:

COPY foo FROM STDOUT
COPY foo TO STDIN

In other words, STDIN and STDOUT can be used completely interchangeably. However, the ecpg grammar is more strict about that:

ERROR: COPY TO STDIN is not possible

Any particular reason for ecpg to check that, while the backend doesn't care? I think we should just remove those checks from the ecpg grammar.

- Heikki
*** a/src/interfaces/ecpg/preproc/ecpg.addons
--- b/src/interfaces/ecpg/preproc/ecpg.addons
***************
*** 193,207 **** ECPG: where_or_current_clauseWHERECURRENT_POFcursor_name block
  		$$ = cat_str(2,mm_strdup("where current of"), cursor_marker);
  	}
  ECPG: CopyStmtCOPYopt_binaryqualified_nameopt_column_listopt_oidscopy_fromcopy_file_namecopy_delimiteropt_withcopy_options addon
! 			if (strcmp($6, "to") == 0 && strcmp($7, "stdin") == 0)
! 				mmerror(PARSE_ERROR, ET_ERROR, "COPY TO STDIN is not possible");
! 			else if (strcmp($6, "from") == 0 && strcmp($7, "stdout") == 0)
! 				mmerror(PARSE_ERROR, ET_ERROR, "COPY FROM STDOUT is not possible");
! 			else if (strcmp($6, "from") == 0 && strcmp($7, "stdin") == 0)
  				mmerror(PARSE_ERROR, ET_WARNING, "COPY FROM STDIN is not implemented");
- ECPG: CopyStmtCOPYselect_with_parensTOcopy_file_nameopt_withcopy_options addon
- 			if (strcmp($4, "stdin") == 0)
- 				mmerror(PARSE_ERROR, ET_ERROR, "COPY TO STDIN is not possible");
  ECPG: var_valueNumericOnly addon
  		if ($1[0] == '$')
  		{
--- 193,201 ----
  		$$ = cat_str(2,mm_strdup("where current of"), cursor_marker);
  	}
  ECPG: CopyStmtCOPYopt_binaryqualified_nameopt_column_listopt_oidscopy_fromcopy_file_namecopy_delimiteropt_withcopy_options addon
! 			if (strcmp($6, "from") == 0 &&
! 			   (strcmp($7, "stdin") == 0 || strcmp($7, "stdout") == 0))
  				mmerror(PARSE_ERROR, ET_WARNING, "COPY FROM STDIN is not implemented");
  ECPG: var_valueNumericOnly addon
  		if ($1[0] == '$')
  		{
-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to