![]() Why would you think so? bytea is coerced to either hex (default) or escape format when assigned to a text column. How to prevent different connections treating bytea in same query differently?įor example if there are non-ASCII bytes it cannot work smoothly.This question follows from my previous question: I was a little surprised by this behaviour because Postgres usually errs on the side of strictness, which I like. The sql is issued automatically, so I can add a preceding SQL statement before every statement, that's no problem. How do I make (implicit) casts from bytea to text throw an exception only within the current connection? I could do CREATE CAST followed by DROP CAST but this seems dirty to me as it still not contained within the connection. I do not want to change the system behaviour for other connections. I am aware of CREATE CAST, but as I understand, this is a system-wide action. Therefore, if a bytea to text conversion happens, I want Posgres to raise an exception. I think users may not realise the strange insert behaviour is due to their use of a binary string in the calling program. By default, Postgres will allow this, but this cannot always work smoothly - for example if there are non-ASCII bytes. ![]() The problem is that users might accidentally try to insert these values into a text column. I am working with some program code which automatically converts certain values (binary strings) in the program to a bytea format. In Postgres bytea values are automatically converted to text when inserted to text/ varchar columns, based on the bytea_output setting. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |