Ascii null in varchars
| От | Thomas Mack |
|---|---|
| Тема | Ascii null in varchars |
| Дата | |
| Msg-id | 199907030836.KAA26086@infbsdb7.idb.cs.tu-bs.de обсуждение исходный текст |
| Список | pgsql-sql |
We try to migrate some projects from commercial Ingres to postgres. One problem we found: varchars can hold any byte from \000 to \377. In Ingres we could specify all these characters as a hex-string, e.g. X'4163006341', meaning a string "Ac\000cA". Construction of varchars in postgres do obviously not know of any comparable method, this means, saying: select char_length(varchar 'ab\000defghi'); will result in 2 and not in 9 as expected. I can somehow understand, why it works this way, so I came to the thought of saying instead: select char_length(translate(varchar 'abcdefghi','c','\000')); which returns '9' as expected. But this is really not nice... The documentation does not tell anything about constructions of varchars (or char / text) beyond this '||', the mentioned functions do also not give any hint - does it mean, there is no such facility (in 6.4.2)? We would like to hear some comments, Thank you anyway, Thomas Mack TU Braunschweig, Abt. Informationssysteme
В списке pgsql-sql по дате отправления: