diff --git a/src/backend/commands/copy.c b/src/backend/commands/copy.c
index a9c1980..a415bbe 100644
*** a/src/backend/commands/copy.c
--- b/src/backend/commands/copy.c
*************** BeginCopyFrom(Relation rel,
*** 2199,2204 ****
--- 2199,2216 ----
  			ereport(ERROR,
  					(errcode(ERRCODE_WRONG_OBJECT_TYPE),
  					 errmsg("\"%s\" is a directory", cstate->filename)));
+ 
+ 		/* ignore UTF-8 Unicode byte-order mark */
+ 		if (cstate->file_encoding == PG_UTF8)
+ 		{
+ 			char	bom[3];
+ 			int		len;
+ 
+ 			len = fread(bom, 1, 3, cstate->copy_file);
+ 			/* rewind the file pointer if not a BOM. */
+ 			if (len != 3 || memcmp(bom, "\xef\xbb\xbf", 3) != 0)
+ 				fseek(cstate->copy_file, 0, SEEK_SET);
+ 		}
  	}
  
  	if (!cstate->binary)
