0

I have a multi-lingual Django/Postgres-based app that fails on the following input (sanitized):

STATEMENT:  INSERT INTO "main_model" ("a_id", "b", "c", "d", "text", "f", "g", "h")
  VALUES (1, 2, 'c', 'd', '...nahlá<U+009A>ení ... nahla<U+009A>ování...', 'f', 'g', 'h')
  RETURNING "main_model"."id"
ERROR:  current transaction is aborted, commands ignored until end of transaction block

The text strings are in unicode, and it appears postgres is chocking on it. This is one example, but this is happening on several other languages as well.

Is there a better way to understand what the exact error on this statement is?

Is there any sanitation I need to do on the unicode strings before throwing them on the DB?

Yuval Adam
  • 161,610
  • 92
  • 305
  • 395
  • It's not **that** statement, it's some statement before that which threw an error and therefor you get the "current transaction is aborted". –  Jun 12 '12 at 14:02
  • 2
    Upvoted to balance out the downvote.. theres no reason to downvote this question – Phillip Schmidt Jun 12 '12 at 14:07
  • @a_horse_with_no_name - ok, it would be awesome if you could explain how to see the failing statement. Because the logs show nothing right now. – Yuval Adam Jun 12 '12 at 14:12
  • @YuvalAdam: no idea. Shouldn't your application log that? Where is that statement coming from? If it's a script you might want to check that out. –  Jun 12 '12 at 14:14
  • This is a printout of the postgres log itself. I find it odd that it logs a subsequent error, but not the original. – Yuval Adam Jun 12 '12 at 14:30

1 Answers1

0

I stumbled onto https://stackoverflow.com/a/10437521/24545

The lesson learned from this issue is to ensure there are no errors that are caught and not handled.

In my case I had a try/except block that was hiding a real error, and the next time it came up was a transaction error in postgres.

Community
  • 1
  • 1
Yuval Adam
  • 161,610
  • 92
  • 305
  • 395
  • OK, you're talking about a try/except block in Python code talking to PostgreSQL. I was confused for a minute there an thought you were talking about PL/PgSQL. – Craig Ringer Jun 12 '12 at 23:35