Received: from sss.pgh.pa.us (sss.pgh.pa.us [209.114.132.154]) by mail.postgresql.org (8.11.1/8.11.1) with ESMTP id f0S3mnq19537 for ; Sat, 27 Jan 2001 22:48:49 -0500 (EST) (envelope-from tgl@sss.pgh.pa.us) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.11.1/8.11.1) with ESMTP id f0S3mY929145; Sat, 27 Jan 2001 22:48:35 -0500 (EST) To: "Joe Conway" cc: pgsql-interfaces@postgresql.org Subject: Re: libpq/c function question In-reply-to: <01aa01c088d4$cae4f220$0705a8c0@jecw2k1> References: <01aa01c088d4$cae4f220$0705a8c0@jecw2k1> Comments: In-reply-to "Joe Conway" message dated "Sat, 27 Jan 2001 18:48:28 -0800" Date: Sat, 27 Jan 2001 22:48:34 -0500 Message-ID: <29142.980653714@sss.pgh.pa.us> From: Tom Lane X-Archive-Number: 200101/313 X-Sequence-Number: 939 "Joe Conway" writes: > optstr = PG_GETARG_TEXT_P(0); > jpgsql = PG_GETARG_TEXT_P(1); > conn = PQconnectdb(VARDATA(optstr)); I think you've missed the fact that a TEXT value's VARDATA is not null-terminated. There are numerous examples of transforming a TEXT into a C string in the backend, see for example text_cmp/varstr_cmp in src/backend/utils/adt/varlena.c. regards, tom lane