Return-Path: owner-postman Received: from localhost.Berkeley.EDU (localhost.Berkeley.EDU [127.0.0.1]) by nobozo.CS.Berkeley.EDU (8.6.9/8.6.3) with SMTP id XAA19999 for postgres-redist; Sun, 11 Dec 1994 23:53:00 -0800 Resent-From: POSTGRES mailing list Resent-Message-Id: <199412120753.XAA19999@nobozo.CS.Berkeley.EDU> Sender: owner-postman@postgres.Berkeley.EDU X-Return-Path: owner-postman Received: from faerie.CS.Berkeley.EDU (faerie.CS.Berkeley.EDU [128.32.37.53]) by nobozo.CS.Berkeley.EDU (8.6.9/8.6.3) with ESMTP id XAA19989 for ; Sun, 11 Dec 1994 23:52:59 -0800 Received: from localhost.Berkeley.EDU (localhost.Berkeley.EDU [127.0.0.1]) by faerie.CS.Berkeley.EDU (8.6.9/8.1B) with SMTP id XAA17123; Sun, 11 Dec 1994 23:52:33 -0800 Message-Id: <199412120752.XAA17123@faerie.CS.Berkeley.EDU> X-Authentication-Warning: faerie.CS.Berkeley.EDU: Host localhost.Berkeley.EDU didn't use HELO protocol From: aoki@cs.berkeley.edu (Paul M. Aoki) To: SRIRAMK@charlie.usd.edu Cc: postgres@postgres.Berkeley.EDU Subject: Re: Re-sending - could someone please help ? Reply-To: aoki@cs.berkeley.edu (Paul M. Aoki) In-reply-to: Your message of Mon, 12 Dec 1994 1:13:07 -0600 (CST) <941212011307.14e1@charlie.usd.edu> Date: Sun, 11 Dec 94 23:52:27 -0800 X-Sender: aoki@postgres.Berkeley.EDU Resent-To: postgres-redist@postgres.Berkeley.EDU X-Mts: smtp Resent-Date: Sun, 11 Dec 94 23:53:00 -0800 Resent-XMts: smtp 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/