Thread: invalid input syntax for type tid: "(,)"

invalid input syntax for type tid: "(,)"

From
Jose' Cruanyes
Date:
at a point the postgresql ODBC driver issues a command like this (not
questioning here how useful or correct it could be)

select * from table1 where ctid = '(,)';

this command works (?) returning zero rows without error, even from
psql,
when the db is hosted in the following systems:

- debian i386 using the stable postgresql7.2.1-2 package
- debian ppc using the stable postgresql7.2.1-2 package
- debian i386 using the testing postgresql7.4.2-2 package
- MacOSX 10.2 using the 7.3.4 compiled from source


but when hosted in a MacOSX 10.3 (Panther) using postgres 7.4.x, or
7.3.x
compiled from source we get:

(in 7.4)        ERROR:  invalid input syntax for type tid: "(,)"
or
(in 7.3)        ERROR: tidin: invalid value

I've tried on three different machines and a miriad of different
configure parameters and always get the same error...

probably is an incompatible version of some external lib?, which one?
who is responsible of the parsing of the command?





Pax et Bonum

# dott. Jose' Cruanyes Aguilar  -  C.E. Soft srl
#  Pzza. Firenze,4 MILANO  -  XX Settembre 10, CREMONA
#   02,33603122                0372,460602


Re: invalid input syntax for type tid: "(,)"

From
Tom Lane
Date:
"Jose' Cruanyes" <cruanyes@cegroup.it> writes:
> select * from table1 where ctid = '(,)';
> [ works on some machines and not others ]

I would argue that the ODBC driver is broken and needs to be fixed,
as does the TID input parser which should never allow this ...

However, the reason for the platform dependency is probably that
strtoul() is setting errno on some machines and not others.

            regards, tom lane

Re: invalid input syntax for type tid: "(,)"

From
Jose' Cruanyes
Date:
On Apr 4, 2004, at 7:04 AM, Tom Lane wrote:

> "Jose' Cruanyes" <cruanyes@cegroup.it> writes:
>> select * from table1 where ctid = '(,)';
>> [ works on some machines and not others ]
>
> I would argue that the ODBC driver is broken and needs to be fixed,
> as does the TID input parser which should never allow this ...
>
> However, the reason for the platform dependency is probably that
> strtoul() is setting errno on some machines and not othe

since strtoul() should return 0 on an empty string, I think it will be
safe to change the instances of '(,)' to '(0,0)' in the driver source
code, even if it's not too clear to me what it does...

I've found three, two on "convert.c" and one on "results.c"

now if some one can put the changes upstream...

thanks.

Pax et Bonum

# dott. Jose' Cruanyes Aguilar  -  C.E. Soft srl
#  Pzza. Firenze,4 MILANO  -  XX Settembre 10, CREMONA
#   02,33603122                0372,460602


Re: invalid input syntax for type tid: '(,)'

From
"Dave Page"
Date:
It's rumoured that Jose Cruanyes once said:
>
> I've found three, two on "convert.c" and one on "results.c"
>
> now if some one can put the changes upstream...
>

Can you post a patch?

Regards, Dave



Re: invalid input syntax for type tid: '(,)'

From
Jose' Cruanyes
Date:
On Apr 5, 2004, at 11:32 AM, Dave Page wrote:

> It's rumoured that Jose Cruanyes once said:
>>
>> I've found three, two on "convert.c" and one on "results.c"
>>
>> now if some one can put the changes upstream...
>>
>
> Can you post a patch?
>
--------------<cut>--------------8<----------------8<-------------
-8<------------------
diff -Naur psqlodbc-old/convert.c psqlodbc-new/convert.c
--- psqlodbc-old/convert.c      Mon Oct 20 02:37:42 2003
+++ psqlodbc-new/convert.c      Sun Apr  4 19:39:39 2004
@@ -2059,7 +2059,7 @@
                                  * 1st query is for field information
                                  * 2nd query is keyset gathering
                                  */
-                               CVT_APPEND_STR(qb, " where ctid =
'(,)';select ctid, oid from ");
+                               CVT_APPEND_STR(qb, " where ctid =
'(0,0)';select ctid, oid from ");
                                 CVT_APPEND_DATA(qb, qp->statement +
qp->from_pos + 5, npos - qp->from_pos - 5);
                         }
                 }
@@ -2102,7 +2102,7 @@
                 qb->load_stmt_len = qb->npos;
                 if (0 != (qb->flags & FLGB_KEYSET_DRIVEN))
                 {
-                       CVT_APPEND_STR(qb, "where ctid = '(,)';select
CTID, OID from ");
+                       CVT_APPEND_STR(qb, "where ctid = '(0,0)';select
CTID, OID from ");
                         CVT_APPEND_DATA(qb, qp->statement +
qp->from_pos + 5, qp->where_pos - qp->from_pos - 5);
                 }
         }
diff -Naur psqlodbc-old/results.c psqlodbc-new/results.c
--- psqlodbc-old/results.c      Mon Oct 20 02:37:42 2003
+++ psqlodbc-new/results.c      Sun Apr  4 20:33:47 2004
@@ -1827,7 +1827,7 @@
         {
                 len += 50;
                 selstr = malloc(len);
-               sprintf(selstr, "%s where ctid = currtid(0, '(,)') and
oid = %u", stmt->load_statement, oid);
+               sprintf(selstr, "%s where ctid = currtid(0, '(0,0)')
and oid = %u", stmt->load_statement, oid);
         }
         else
         {
--------------<cut>--------------8<----------------8<-------------
-8<------------------





Pax et Bonum

# dott. Jose' Cruanyes Aguilar  -  C.E. Soft srl
#  Pzza. Firenze,4 MILANO  -  XX Settembre 10, CREMONA
#   02,33603122                0372,460602


Re: invalid input syntax for type tid: "(,)"

From
Bruce Momjian
Date:
Jose' Cruanyes wrote:
>
> On Apr 4, 2004, at 7:04 AM, Tom Lane wrote:
>
> > "Jose' Cruanyes" <cruanyes@cegroup.it> writes:
> >> select * from table1 where ctid = '(,)';
> >> [ works on some machines and not others ]
> >
> > I would argue that the ODBC driver is broken and needs to be fixed,
> > as does the TID input parser which should never allow this ...
> >
> > However, the reason for the platform dependency is probably that
> > strtoul() is setting errno on some machines and not othe
>
> since strtoul() should return 0 on an empty string, I think it will be
> safe to change the instances of '(,)' to '(0,0)' in the driver source
> code, even if it's not too clear to me what it does...
>
> I've found three, two on "convert.c" and one on "results.c"
>
> now if some one can put the changes upstream...

Has this been fixed in ODBC CVS?

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