agora inbox for postgres@postgres.berkeley.edu
help / color / mirror / Atom feedFrom: Paul M. Aoki <aoki@cs.berkeley.edu>
To: SRIRAMK@charlie.usd.edu
Cc: postgres@postgres.Berkeley.EDU
Subject: Re: Re-sending - could someone please help ?
Date: Sun, 11 Dec 94 23:52:27 -0800
Message-ID: <199412120752.XAA17123@faerie.CS.Berkeley.EDU> (raw)
In-Reply-To: <941212011307.14e1@charlie.usd.edu>
SRIRAMK@charlie.usd.edu writes:
> /* Display of a string attribute as below doesn't work */
> /* Nothing gets displayed */
> printf("Print : %s\n", GetAttributeByName(t,"fldrname",&isnull));
postgres has no "string" type.
when using user-defined functions (executed within the server) you
have to know what the internal representation of the type is in order
to print it out. that should be pretty obvious.
if you have defined your own "string" type, then i don't know what's
going on here.
if you are using "text", then you should understand that "text" is
defined as a 4-byte length field followed by the string (which is
*NOT* NUL-delimited, so it is not a C string). on a sun or other
big-endian computer, the first byte of the length field is very likely
to be 0, which is what would end a C string. so printf("%s") thinks
it's an empty string.
if you are using "char16", then the internal representation is simply
a 16-byte string that is, again, *NOT* NUL-delimited.
hence, "%s" is a bad idea for both "char16" and "text". for "char16",
"%.16s" works. for "text", you can do something like
struct varlena *v;
v = GetAttributeByName(blah blah);
printf("%.*s\n", v->vl_len, v->vl_dat);
--
Paul M. Aoki | University of California at Berkeley
aoki@CS.Berkeley.EDU | Dept. of EECS, Computer Science Division (#1776)
| Berkeley, CA 94720-1776
==============================================================================
To add/remove yourself to/from the POSTGRES mailing list: send mail with
the subject line ADD or DEL to "postgres-request@postgres.Berkeley.EDU".
If this fails, send mail to "post_questions@postgres.Berkeley.EDU" and
a human will deal with it. DO NOT post to the "postgres" mailing list.
==============================================================================
URL: http://s2k-ftp.CS.Berkeley.EDU:8000/postgres/
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: postgres@postgres.berkeley.edu
Cc: aoki@cs.berkeley.edu, SRIRAMK@charlie.usd.edu
Subject: Re: Re-sending - could someone please help ?
In-Reply-To: <199412120752.XAA17123@faerie.CS.Berkeley.EDU>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox