> > > I agree that it would be better to *not* allow implicit coercions.
> > > that, any preferences on function names? Are text_to_bytea() and
> > > bytea_to_text() too ugly?
> > They're pretty ugly, but more importantly they're only suitable if we
> > have exactly one conversion function each way. If we have two, what
> > will we call the second one?
> Why not just stick these things into encode() and name them
> "my-cool-encoding" or whatever. There is no truly natural conversion
> between text and bytea, so encode/decode seem like the proper place.
(I'm sending directly to Peter, Tom, and Bruce because you were all involved
in this thread, and the list seems to be down)
Here's a patch for bytea string functions. As discussed:
text encode(bytea, 'escape')
bytea decode(text, 'escape')
to allow conversion bytea-text/text-bytea conversion. Also implemented
(SQL99 defines Binary Strings with all of these operators):
byteacat and "||" operator
trim (only did trim(bytea, bytea) since there is no default trim character
for bunary per SQL99)
length (just aliased octet_length, which is correct for bytea, I think)
like and "~~" operator
not like and "!~~" operator
I think that's it.
Passes all regression tests. Based on the discussion, I did not create
functions to allow casting text-to-bytea or bytea-to-text -- it sounded like
we just want people to use encode/decode. I'm still planning to write
PQescapeBytea, but that will come later as a seperate patch. One operator
defined by SQL99, but not implemented here (or for text datatype, that I
could see) is the "overlay" function (modifies string argument by replacing
a substring given start and length with a replacement string). It sounds
useful -- any interest?
Review and comments much appreciated!
In response to
pgsql-hackers by date
|Next:||From: Bruce Momjian||Date: 2001-09-05 21:24:43|
|Subject: Re: RAISE <level> <expr> <params>: state of play and request|
|Previous:||From: Ludovic Pnet||Date: 2001-09-05 17:31:10|
|Subject: Trans-transactions cursors|
pgsql-patches by date
|Next:||From: Dave Cramer||Date: 2001-09-06 00:40:42|
|Subject: Re: Read transactions don't work on 7.0.x db's 3rd attempt|
|Previous:||From: Joseph Shraibman||Date: 2001-09-05 19:41:19|
|Subject: Re: Patch for jdbc2 ResultSet.java|