Обсуждение: bad typenames sent to postgresql server

Поиск
Список
Период
Сортировка

bad typenames sent to postgresql server

От
"Scot Loach"
Дата:
I've recently updated my CVS, and I'm now getting parsing errors from the backend when I use a PREPARE statement with
varcharin the types clause. 
This seems to be because of the following changes made to pgtypes.c in version 1.63.

I looked at the postgresql parser, and sure enough, the varchar(), char() etc are not accepted.
Does anyone know what the intention of this change was?  (the comment says "Map (var)char type to SQL type more
properly")
Is this in fact a bug or am I missing something?


@@ -489,11 +502,11 @@ pgtype_to_name(StatementClass *stmt, Int
         case PG_TYPE_INT8:
             return "int8";
         case PG_TYPE_NUMERIC:
-            return "numeric";
+            return "numeric()";
         case PG_TYPE_VARCHAR:
-            return "varchar";
+            return "varchar()";
         case PG_TYPE_BPCHAR:
-            return "char";
+            return "char()";
         case PG_TYPE_TEXT:
             return "text";
         case PG_TYPE_NAME:
@@ -515,10 +528,12 @@ pgtype_to_name(StatementClass *stmt, Int
         case PG_TYPE_ABSTIME:
             return "abstime";
         case PG_TYPE_DATETIME:
-            if (PG_VERSION_GE(conn, 7.0))
-                return "timestamp with time zone";
-            else
+            if (PG_VERSION_GT(conn, 7.1))
+                return "timestamptz";
+            else if (PG_VERSION_LT(conn, 7.0))
                 return "datetime";
+            else
+                return "timestamp";
         case PG_TYPE_TIMESTAMP_NO_TMZONE:
             return "timestamp without time zone";
         case PG_TYPE_TIMESTAMP:


Re: bad typenames sent to postgresql server

От
"Dave Page"
Дата:

> -----Original Message-----
> From: pgsql-odbc-owner@postgresql.org
> [mailto:pgsql-odbc-owner@postgresql.org] On Behalf Of Scot Loach
> Sent: 04 October 2004 22:11
> To: pgsql-odbc@postgresql.org
> Subject: [ODBC] bad typenames sent to postgresql server
>
> I've recently updated my CVS, and I'm now getting parsing
> errors from the backend when I use a PREPARE statement with
> varchar in the types clause.
> This seems to be because of the following changes made to
> pgtypes.c in version 1.63.
>
> I looked at the postgresql parser, and sure enough, the
> varchar(), char() etc are not accepted.
> Does anyone know what the intention of this change was?  (the
> comment says "Map (var)char type to SQL type more properly")
> Is this in fact a bug or am I missing something?

Bug I /think/. The brackets were added to numeric, varchar and char, all
of which might have them when defining tables etc, however, when used as
casts or in type clauses I'm not surprised there are problems.

I'm not sure why they were added though (although I don't doubt Hiroshi
had a good reason). Can anyone remember? If not, istm, that the best
solution is to remove them again from there, and add them again in less
generic places if the original problem is found again.

Regards, Dave.