plpython-windows-encodings.patch
text/x-diff
Filename: plpython-windows-encodings.patch
Type: text/x-diff
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/pl/plpython/plpy_util.c | 0 | 0 |
diff --git a/src/pl/plpython/plpy_util.c b/src/pl/plpython/plpy_util.c
new file mode 100644
index 9a4901e..5fafbd1
*** a/src/pl/plpython/plpy_util.c
--- b/src/pl/plpython/plpy_util.c
*************** PLyUnicode_Bytes(PyObject *unicode)
*** 66,80 ****
/*
* Python understands almost all PostgreSQL encoding names, but it doesn't
! * know SQL_ASCII.
*/
! if (GetDatabaseEncoding() == PG_SQL_ASCII)
! serverenc = "ascii";
! else
! serverenc = GetDatabaseEncodingName();
rv = PyUnicode_AsEncodedString(unicode, serverenc, "strict");
! if (rv == NULL)
! PLy_elog(ERROR, "could not convert Python Unicode object to PostgreSQL server encoding");
return rv;
}
--- 66,125 ----
/*
* Python understands almost all PostgreSQL encoding names, but it doesn't
! * know SQL_ASCII and calls the Windows encodings differently.
*/
! switch (GetDatabaseEncoding())
! {
! case PG_SQL_ASCII:
! serverenc = "ascii";
! break;
! case PG_WIN1250:
! serverenc = "cp1250";
! break;
! case PG_WIN1251:
! serverenc = "cp1251";
! break;
! case PG_WIN1252:
! serverenc = "cp1252";
! break;
! case PG_WIN1253:
! serverenc = "cp1253";
! break;
! case PG_WIN1254:
! serverenc = "cp1254";
! break;
! case PG_WIN1255:
! serverenc = "cp1255";
! break;
! case PG_WIN1256:
! serverenc = "cp1256";
! break;
! case PG_WIN1257:
! serverenc = "cp1257";
! break;
! case PG_WIN1258:
! serverenc = "cp1258";
! break;
! case PG_WIN866:
! serverenc = "cp866";
! break;
! case PG_WIN874:
! serverenc = "cp874";
! break;
! default:
! serverenc = GetDatabaseEncodingName();
! break;
! }
!
rv = PyUnicode_AsEncodedString(unicode, serverenc, "strict");
! if (rv == NULL) {
! /*
! * Use a plan elog instead of PLy_elog here to avoid getting in
! * recursion trouble when the traceback formatting functions try doing
! * unicode to bytes conversion.
! */
! elog(ERROR, "could not convert Python Unicode object to PostgreSQL server encoding");
! }
return rv;
}