Re: escape string type for upcoming 8.1

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Jeff Davis <jdavis-pgsql(at)empires(dot)org>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: escape string type for upcoming 8.1
Date: 2005-08-10 03:21:01
Message-ID: 200508100321.j7A3L1o29154@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


E'' is more a marker than a type. I realize making E a type might work,
but it seems unusual.

What we could do is backpatch E'' to 8.0.X as a no-op like it will be in
8.1.

---------------------------------------------------------------------------

Jeff Davis wrote:
> >From what I've read, it looks like 8.1 will introduce the E'' escape
> string, and eventually postgresql will change the normal '' strings to
> be more SQL-compliant.
>
> If I wanted to start being forwards-compatible right now, and I have
> existing databases in 7.4 and 8.0, my idea was to create a type E. Any
> string using that type would work in 7.4/8.0 as normal, and then when I
> upgrade to 8.1 I will drop the type and the applications will still work.
>
> To do that is relatively simple, I'd just use the textin/out functions
> that already exist to create the type (which in 7.4/8.0 will give the
> desired behavior of escaping). Like so:
>
> CREATE FUNCTION ein(CSTRING) RETURNS E AS 'textin' LANGUAGE internal;
>
> CREATE FUNCTION eout(E) RETURNS CSTRING AS 'textout' LANGUAGE internal;
>
> CREATE TYPE E (input=ein,output=eout);
>
> CREATE CAST (E AS TEXT) WITHOUT FUNCTION AS IMPLICIT;
>
> CREATE CAST (TEXT AS E) WITHOUT FUNCTION AS IMPLICIT;
>
> Then, when I upgrade a system to 8.1, I can just remove the type, and
> all the applications will still work. Eventually when the '' strings are
> changed, I can start using those again, but in a SQL-compliant way.
>
> Does this migration path make sense? Will creating the type possibly
> cause casting problems of some kind? I read something about possibly
> "backpatching" the E'' string to 8.0. If someone did that, what would be
> the difference between applying a backpatch and what I did above?
>
> One thing that has me concerned about the idea is that there are some
> string constants, like B'' and X'' that aren't really types. Does that
> mean that E'' won't be a type? Why are B'' and X'' not types, and are
> there any other notations like that that are not types?
>
> Regards,
> Jeff Davis
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: don't forget to increase your free space map settings
>

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Roman Neuhauser 2005-08-10 05:50:07 Re: Error Loading postgresql
Previous Message Adrian Klaver 2005-08-10 02:58:13 Re: plpythonu and return void