Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Pgsql General > Re: more custom...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 3 of 4 Topic 15463 of 17602
Post > Topic >>

Re: more custom C function fun

by heron@[EMAIL PROTECTED] ("Dan \"Heron\" Myers") May 6, 2008 at 09:39 AM

Martijn van Oosterhout wrote:
> You do realise that VARDATA does not return a null terminated string?

I did not realize that...  but it led me in the right direction.

> Try using something like text_to_cstring or using elog(NOTICE) to
> display what's actually being compared.

I've outputted some things with elog (which is the other thing I needed 
to figure this out).

Using DatumToCString(mytextvariable), I get single-character-length 
strings that do not match the data actually in the fields.

Using VARDATA(mytextvariable) as the char*, I get things like this (name 
obscured) (using strlen to get the string's length):

string: "Hillary Clinton(6611)", length 21
string: "95555551234nton(6611)", length 21

Of course, then I realized that strlen isn't the right tool for the job; 
I need: int len = VARSIZE(mytextvariable) - VARHDRSZ;

Using that with the VARDATA as my char*, I get this:

string: "Hillary Clinton(6611)" - length: 21
string: "95555551234" - length: 11

Which is what I need.  Perhaps we could get some do***entation about how 
to use this stuff?  I was unable to find any on the Postgres site, if 
there is any.

Thanks for your help guys :)

- Dan

-- 
Sent via pgsql-general mailing list (pgsql-general@[EMAIL PROTECTED]
)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general
 




 4 Posts in Topic:
more custom C function fun
heron@[EMAIL PROTECTED]   2008-05-05 23:43:40 
Re: more custom C function fun
kleptog@[EMAIL PROTECTED]  2008-05-06 08:48:26 
Re: more custom C function fun
heron@[EMAIL PROTECTED]   2008-05-06 09:39:50 
Re: more custom C function fun
kleptog@[EMAIL PROTECTED]  2008-05-06 17:59:44 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Mon Dec 1 19:57:08 CST 2008.