From: | Patryk Kordylewski <pk(at)fooby(dot)de> |
---|---|
To: | pgsql-de-allgemein(at)postgresql(dot)org |
Subject: | Re: PG meckert *nicht* bei quotes um Zahlen !? |
Date: | 2012-08-07 07:20:23 |
Message-ID: | 5020C1B7.7090508@fooby.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-de-allgemein |
Am 07.08.2012 07:47, schrieb Thomas Markus:
> Moins,
>
> Am 06.08.2012 19:24, schrieb Patryk Kordylewski:
>>
>> Verstehe ich jetzt nicht, dein pg_typeof() Beispiel unterstützt doch
>> meine Aussage? :-)
> na nicht ganz. Lässt sich auch verdeutlichen durch die 2 Bsp:
>
> select 1 + '1'
> macht dann int4 + unknown = int4
>
> bzw
> select 1 + '1'::text
> und entsprechend int4 + text
>
> Quotes definieren nicht den Datentyp, aber der ist entscheidend.
> Variante 2 hat glaub ich bis zur 8.3 funktioniert, dann wurde die autom.
> Konvertierung text->xxx abgeschafft in der 8.4
>
> Gruss
> Thomas
Hi,
der + Operator gibt hier doch schon den Kontext und damit die möglichen
Datentyp vor.
Aber nochmal, ein INSERT INTO (id) VALUES ('1'); hat auch vor der
Entfernung von expliziten Text-Casts in 8.3 funtkioniert.
8.0:
# CREATE TABLE foo (id INTEGER);
CREATE TABLE
# INSERT INTO foo (id) VALUES ('1');
INSERT 128673153 1
# INSERT INTO foo (id) VALUES ('1'::text);
ERROR: column "id" is of type integer but expression is of type text
HINT: You will need to rewrite or cast the expression.
8.2:
# CREATE TABLE foo (id INTEGER);
CREATE TABLE
# INSERT INTO foo (id) VALUES ('1');
INSERT 0 1
# INSERT INTO foo (id) VALUES ('1'::text);
ERROR: column "id" is of type integer but expression is of type text
LINE 1: INSERT INTO foo (id) VALUES ('1'::text);
^
HINT: You will need to rewrite or cast the expression.
8.4:
# CREATE TABLE foo (id INTEGER);
CREATE TABLE
# INSERT INTO foo (id) VALUES ('1');
INSERT 0 1
# INSERT INTO foo (id) VALUES ('1'::text);
ERROR: column "id" is of type integer but expression is of type text
LINE 1: INSERT INTO foo (id) VALUES ('1'::text);
^
HINT: You will need to rewrite or cast the expression.
9.1:
# CREATE TABLE foo (id INTEGER);
CREATE TABLE
# INSERT INTO foo (id) VALUES ('1');
INSERT 0 1
# INSERT INTO foo (id) VALUES ('1'::text);
ERROR: column "id" is of type integer but expression is of type text
LINE 1: INSERT INTO foo (id) VALUES ('1'::text);
^
HINT: You will need to rewrite or cast the expression.
Über was diskutiert man hier eigentlich noch? :-)
Gruß
PS: Und hier noch deine 2. Variante auf einer PG 8.0 Büchse - das hat
auch noch nie funktioniert:
# select 1 + '1'::text;
ERROR: operator does not exist: integer + text
HINT: No operator matches the given name and argument type(s). You may
need to add explicit type casts.
From | Date | Subject | |
---|---|---|---|
Next Message | Nicolas Barbier | 2012-08-07 07:48:44 | Re: PG meckert *nicht* bei quotes um Zahlen !? |
Previous Message | Thomas Markus | 2012-08-07 05:47:28 | Re: PG meckert *nicht* bei quotes um Zahlen !? |