Re: Problems with PQfmod() returning -1 on varchar field (libpq-8.0.0 )?

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: Jerry Day <jerry_day(at)esri(dot)com>
Cc: "'pgsql-interfaces(at)postgresql(dot)org'" <pgsql-interfaces(at)postgresql(dot)org>
Subject: Re: Problems with PQfmod() returning -1 on varchar field (libpq-8.0.0 )?
Date: 2005-04-03 01:56:13
Message-ID: 20050403015613.GA29651@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

On Fri, Apr 01, 2005 at 04:21:03PM -0800, Jerry Day wrote:
>
> I've recently encountered a situation where PQfmod() fails to return the
> defined length of a varchar field referenced in a query, as expected -
> returning no information (-1), instead. Has anyone else encountered this
> issue? If so, why does this occur? Can you recommended a method to more
> reliably obtain the length of varchar fields, as defined in the relations
> referenced by a query?

Are you sure the column has a length specifier? What does "\d tablename"
show, or what's the result of the following query?

SELECT attname, attnum, atttypid::regtype, atttypmod
FROM pg_attribute
WHERE attrelid = 'tablename'::regclass
AND attnum >= 1
AND attisdropped IS FALSE
ORDER by attnum;

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/

In response to

Browse pgsql-interfaces by date

  From Date Subject
Next Message Robert Treat 2005-04-03 12:34:50 Re: Fw: suscribe
Previous Message Bruce Momjian 2005-04-03 01:26:34 Re: Problems with PQfmod() returning -1 on varchar field