Thread: Query doesn't work anymore on 7.2

Query doesn't work anymore on 7.2

From
ricardorsj@uol.com.br
Date:
Hello there. I've just upgraded to pgsql 7.2 on netbsd and one of my  programs stopped working because of a parser
error:

carteirinhas=# \d registros
               Table "registros"
  Column   |          Type          | Modifiers
-----------+------------------------+-----------
 matricula | integer                |
 resp      | character varying(50)  |
 tipo      | character(1)           |
 nome      | character varying(50)  |
 data      | date                   |
 hora      | time without time zone |
 baixa     | boolean                |

carteirinhas=# insert into registros values (1234,'Teste','A','Teste',date('now'),time('now'),false);
ERROR:  parser: parse error at or near "'"


Although it's clear that this program was done in 10 minutes, it was working on 7.1.3. Has something changed or it
seemsto be a bug in 7.2's parser? 

[]'s
Ricardo.

Re: Query doesn't work anymore on 7.2

From
Thomas Lockhart
Date:
> Hello there. I've just upgraded to pgsql 7.2 on netbsd and one of my  programs stopped working because of a parser
error:
> carteirinhas=# insert into registros values (1234,'Teste','A','Teste',date('now'),time('now'),false);
> ERROR:  parser: parse error at or near "'"
> Although it's clear that this program was done in 10 minutes, it was working on 7.1.3. Has something changed or it
seemsto be a bug in 7.2's parser? 

You also upgraded in 10 minutes ;)

The release notes explicitly mention syntax changes to support SQL9x
date/time precision features. In particular, "time(p)" is now not
recognized as a function call but rather as a specifier for the type
"time" with a precision of "p". You can rewrite your query using
standard SQL9x syntax (which was also available in versions prior to
7.2):

  insert into registros
  values (1234,'Teste','A','Teste',date 'now',time 'now',false);

In general, you know and I know that PostgreSQL uses functions of the
form "type(src)" to do type conversions, but it is usually better to use
standard SQL to actually write your queries. The two forms of literal
coersion for a string to a type which SQL9x defines are:

  type 'string'
  cast('string' as type)

where SQL9x defines the first form as applying to date/time literals
only while PostgreSQL extends this to all data types.

hth

                        - Thomas

Re: Query doesn't work anymore on 7.2

From
ricardorsj@uol.com.br
Date:
Well, thanks! I've got to RTFM next time. Anyway, before reading your message, I had just submitted a bug report :~

[]s
Ricardo.

PS: You're right, I indeed upgraded in 10 minutes :-)



> ---------- In�cio da mensagem original -----------
>      De: Thomas Lockhart <thomas@fourpalms.org>
>    Para: ricardorsj@uol.com.br
>      Cc: pgsql-general@postgresql.org
>    Data: 26/Feb/2002-05:36
> Assunto: Re: [GENERAL] Query doesn't work anymore on 7.2
>
>>> Hello there. I've just upgraded to pgsql 7.2 on netbsd and one of my  programs stopped working because of a parser
error:
>> carteirinhas=# insert into registros values (1234,'Teste','A','Teste',date('now'),time('now'),false);
>> ERROR:  parser: parse error at or near "'"
>> Although it's clear that this program was done in 10 minutes, it was working on 7.1.3. Has something changed or it
seemsto be a bug in 7.2's parser? 
>
>You also upgraded in 10 minutes ;)
>
>The release notes explicitly mention syntax changes to support SQL9x
>date/time precision features. In particular, "time(p)" is now not
>recognized as a function call but rather as a specifier for the type
>"time" with a precision of "p". You can rewrite your query using
>standard SQL9x syntax (which was also available in versions prior to
>7.2):
>
>  insert into registros
>  values (1234,'Teste','A','Teste',date 'now',time 'now',false);
>
>In general, you know and I know that PostgreSQL uses functions of the
>form "type(src)" to do type conversions, but it is usually better to use
>standard SQL to actually write your queries. The two forms of literal
>coersion for a string to a type which SQL9x defines are:
>
>  type 'string'
>  cast('string' as type)
>
>where SQL9x defines the first form as applying to date/time literals
>only while PostgreSQL extends this to all data types.
>
>hth
>
>                        - Thomas
>
>---------------------------(end of broadcast)---------------------------
>TIP 5: Have you checked our extensive FAQ?
>
>http://www.postgresql.org/users-lounge/docs/faq.html
>

---
UOL: o melhor da Internet.