PostgreSQL/LightDB copy ERROR: invalid byte sequence for encoding "UTF8": 0x00
https://jdbc.postgresql.org/documentation/publicapi/org/postgresql/copy/CopyManager.html
https://jdbc.postgresql.org/documentation/publicapi/org/postgresql/copy/CopyManager.html
執行COPY命令報如下錯誤
lightdb@postgres=# copy test from '/home/lightdb/copy.txt'; ERROR: invalid byte sequence for encoding "UTF8": 0xd1 0x05 CONTEXT: COPY test, line 6: "#1 0x000000000051d5fc in XLogWritePages (from=from@entry=0x7f4e3d53c000 "\006\321\005", npages=npag..."
原因
程式中存在\0 需要轉義
[lightdb@node1 ~]$ more copy.txt 2393633 lightdb 20 0 194.0g 137468 135980 S 6.0 0.0 1:40.54 lightdb: walwriter [lightdb@hs-10-20-30-217 ~]$ pstack 2393633#0 0x00007f7eb7bb20a4 in pwrite64 () from /lib64/libpthread.so.0#1 0x000000000051d5fc in XLogWritePages (from=from@entry=0x7f4e3d53c000 "\006\321\005", npages=npages@entry=8, startoffset=startoffset@entry=376242176) at xlog.c:2761
測試
lightdb@postgres=# copy test from '/home/lightdb/test.txt'; ERROR: invalid byte sequence for encoding "UTF8": 0x00 CONTEXT: COPY test, line 2: "\0" lightdb@postgres=# exit [lightdb@node1 ~]$ cat test.txt \0 [lightdb@node1 ~]$ vim test.txt [lightdb@node1 ~]$ ltsql ltsql (13.3-22.1) Type "help" for help. lightdb@postgres=# truncate table test; TRUNCATE TABLE lightdb@postgres=# copy test from '/home/lightdb/test.txt'; COPY 2 lightdb@postgres=# select * from test; name ------ \0 (2 rows) lightdb@postgres=# exit [lightdb@node1 ~]$ cat test.txt \\0
java程式中的處理
if(fileName.endsWith(".txt")){ String str = readSingle(fileName).toString().replaceAll("\t"," "); LemDbLog lemDbLog = new LemDbLog(); lemDbLog.setDbLogTime(new Date()); lemDbLog.setDbLogMessage(str.replaceAll("\\\\","\\\\\\\\"));// if (mode_lightdb.equals(mode)) { String tsv = JiebaUtils.getSegmentStr(str); List<String> list = Arrays.asList(tsv.split(" ")); if(list.size() > participlesNum){
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29990276/viewspace-2907131/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Invalid byte 3 of 3-byte UTF-8 sequence 解決方案
- PostgreSQL/LightDB- Tried to send an out-of-range integer as a 2-byte valueSQL
- pipenv install error UnicodeDecodeError: 'utf8' codec can't decode byte 0xb4 in positionErrorUnicode
- PostgreSQL:COPYSQL
- PostgreSQL 序列(Sequence)SQL
- PostgreSQL sequence (一)SQL
- LightDB/PostgreSQL 客戶端部署SQL客戶端
- LightDB/PostgreSQL等待事件 Lock transactionidSQL事件
- err Invalid input of type: 'dict'. Convert to a byte, string or number first
- PostgreSQL DBA(103) - pgAdmin(Don't do this:Encoding)SQLEncoding
- LightDB/PostgreSQL 設定LightDB訪問白名單pg_hba.confSQL
- Struts - NotUtf8Exception: Not valid UTF8! byte Bf in state 0Exception
- PostgreSQL copy相關選項SQL
- UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc8 in position 0: invalid continuation byteUnicodeError
- PostgreSQL/Lightdb 更改列屬性語法SQL
- LightDB/PostgreSQL 相容Oracle儲存過程SQLOracle儲存過程
- 使用GoldenGate 遷移Oracle到PostgreSQL/LightDBGoOracleSQL
- ERROR:Failed to load resource: net::ERR_INCOMPLETE_CHUNKED_ENCODINGErrorAIEncoding
- PostgreSQL DBA(82) - PG 12 Improving COPYSQL
- PostgreSQL/LightDB 分割槽表之分割槽裁剪SQL
- Oracle/MySQL透過odbc訪問PostgreSQL for LightDBOracleMySql
- 安裝benchmarksql報java:143: error: unmappable character for encoding ASCIISQLJavaErrorAPPEncodingASCII
- PostgreSQL/LightDB分割槽表之常見問題SQL
- PostgreSQL/LightDB 不走並行是為什麼?SQL並行
- xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools)ErrorDeveloper
- error creating overlay mount to invalid argument unbuntu系統Error
- error: invalid type argument of unary ‘*‘ (have ‘int‘) *__first = __tmp;Error
- LightDB/PostgreSQL 生成可重複執行的指令碼SQL指令碼
- PostgreSQL error 錯誤碼SQLError
- PostgreSQL DBA(179)-invalid memory alloc request size XXXSQL
- DataPump Export (EXPDP) Fails With Error LPX-216 Invalid CharacterExportAIError
- Copy of a Copy of a Copy
- Dynamics CRM Error- Creating Entity with an invalid parent. Entity: EmailErrorAI
- 技術前刊:PostgreSQL12 COPY和bulkloading提升SQL
- 小程式 · 報錯:Error: errCode: -501007 ,errMsg: Invalid Key Name (__keyPath)Error
- sequence to sequence模型模型
- Syntax Error: ValidationError: Invalid options object. Stylus Loader has been initialized using anErrorObjectZed
- ## HTTP系列之Accept-Encoding和Content-EncodingHTTPEncoding