copy_from_bom.patch
application/octet-stream
Filename: copy_from_bom.patch
Type: application/octet-stream
Part: 0
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: unified
| File | + | − |
|---|---|---|
| src/backend/commands/copy.c | 0 | 0 |
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)