![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| ||||
| ||||
|
|
My company have bought a new Server which our Linux admin has set up with Red Hat Enterprise Linux 4 and PostgreSQL 8.1.8(UTF8). Our old server was the same OS but PostgreSQL 8.1.3(UTF8). I wrote a backup script for old DB Server running PG 8.1.3(UTF8) which preformed a pg_dumpall on the entire schema (to include logins, functions etc) and an individual backup (pg_dump) of all the seperate schemas within that database as a series of SQL statements [...] When we tried the restore from the current like server to the dev server both on 8.1.3(UTF8) the restore worked flawlessly, however when we ran the restore to populate our new server (current live 8.1.3(UTF8) to prospective new live db server 8.1.8(UTF8)) it started throwing back the errors listed at the bottom of this email [...] |
|
I suggested using the iconv command to clean the files of the bad data, and I did attempt this but [...] [...] |
|
I thought about dumping the DB in binary but wasn't sure if the problem would persist in the format as it did in .sql format, I am looking for any help or pointers in the right direction. [...] |
|
psql:/mnt/tmp/app/application_data.sql:17: ERROR: duplicate key violates unique constraint "a_table_key" CONTEXT: COPY a_table, line 1: "2006-06-01 00:54:49.470988+01" |
#3
| |||||||
| |||||||
|
|
There are incorrect bytes in your database. I thought that might be the case, when I reilised that we where |
|
I am not sure why the restore works in 8.1.3, but perhaps it has to do with the following remark in the release nots of 8.1.4: # Change the server to reject invalidly-encoded multibyte characters in all cases (Tatsuo, Tom) While PostgreSQL has been moving in this direction for some time, the checks are now applied uniformly to all encodings and all textual input, and are now always errors not merely warnings. This change defends against SQL-injection attacks of the type described in CVE-2006-2313. |
|
I think that iconv is the wrong tool anyway, because it converts (correct) data from one encoding to another and will fail if it encounters incorrect data. It wouldn't operate on the file anyway which is just as well if its |

|
I think that, rather than attempting to somehow get the dumps into the new database, you should try to fix the bad data. Well we need import the data from flat files written in cobol (a |

|
Do you get many such error messages or only a handful? In the latter case, maybe the easiest solution is to identify the rows at fault and manually change the data in the database before dumping it. there about 2 dozen rows which isn't many but I can't identify what |
|
Do you know which characters should be there in place of the invalid bytes 0xFF, 0xA1, and 0xAC? I haven't been able to identify what these characters should be in |
|
But this error is mysterious. Are the keys identical? Why does 8.1.3 not fail on this? I assume its because the security patch for CVE-2006-2313 and the |

#4
| |||
| |||
|
|
There are incorrect bytes in your database. [...] though it seems to be something to do with the backslash being delimiting quotes as it then means you can trail the quote with instructions to allow SQL Injection to occur [...] |
|
Do you get many such error messages or only a handful? there about 2 dozen rows which isn't many but I can't identify what character unicode is trying to add in as it returns <?> the question mark in a black triangle and depending what interface I am using (pgadmin/phppgadmin) I can see the black triangle with question mark or nothing at all. Do you know which characters should be there in place of the invalid bytes 0xFF, 0xA1, and 0xAC? I haven't been able to identify what these characters should be in the businuss system but I am beinging to think it might just be junk [...] |
|
But this error is mysterious. Are the keys identical? Why does 8.1.3 not fail on this? I assume its because the security patch for CVE-2006-2313 and the proceeding similar error was patch in 8.1.4 and we were running unpatched 8.1.3. |
![]() |
| Thread Tools | |
| Display Modes | |
| |