PQfmod and varchars

From: Shachar Shemesh <psql(at)shemesh(dot)biz>
To: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: PQfmod and varchars
Date: 2005-04-22 08:47:48
Message-ID: 4268BA34.9070303@shemesh.biz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi list,

I'm trying to find out, from a client, how many characters will fit in a
varchar field
(http://pgfoundry.org/tracker/index.php?func=detail&aid=1000286&group_id=1000085&atid=394)
Problem is that when I do "PQfmod" on a varchar field defined as
"varchar(20)", PQfmod returns "24".

Now, it's fairly easy for me to subtract 4 from each result I get from
PQfmod, but I have a suspicion that this "4" is actually "pointer's
length", which means that I need to detect a 64 bit server and subtract
8 instead.

1. Is this suspicion correct?
2. If so, how do I detect how much to subtract.
3. If not, what is the meaning of "4"?

Thanks,
Shachar

--
Shachar Shemesh
Lingnu Open Source Consulting ltd.
Have you backed up today's work? http://www.lingnu.com/backup.html

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Volkan YAZICI 2005-04-22 08:55:02 Fwd: [HACKERS] slides on the optimizer
Previous Message Neil Conway 2005-04-22 08:33:49 slides on the optimizer