Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 9572E632CC3 for ; Tue, 22 Jun 2010 04:57:33 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 05146-03 for ; Tue, 22 Jun 2010 07:57:25 +0000 (UTC) Received: from mx1.hub.org (mx1.hub.org [200.46.208.106]) by mail.postgresql.org (Postfix) with ESMTP id 6DCE6632E95 for ; Tue, 22 Jun 2010 04:57:25 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-px0-f174.google.com (mail-px0-f174.google.com [209.85.212.174]) by mx1.hub.org (Postfix) with ESMTP id 3B93A32681CE for ; Tue, 22 Jun 2010 07:57:24 +0000 (UTC) Received: by pxi12 with SMTP id 12so1836719pxi.19 for ; Tue, 22 Jun 2010 00:57:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:subject:content-type :content-transfer-encoding; bh=ncq9YZdthPknGyJUHThE6NGt4+npaq7Gdj8P4QmkLzc=; b=dv9vf9CFkHlfMW3nuiDKvHnzP3g3OICrRAMXdtZUB9vqqf1DtyuNz2jStm1NekTCbo lUpx6qA3eCjUMNtFq0SMS3JzM0GX+xzB2VKR/AvsDsC8BKSquHKrH9s4kW8sETM2TS4X HLGsot307DT9xlohsC89AKYWJE27l/CwxCy98= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject :content-type:content-transfer-encoding; b=WBK33Fc53daS477muF77Si8Y+zVqvmWvHkCmA9hogm0UWFpUpooZ1CCxxOt4G+0f+r FBNpCtHTVyOZlgmbvO7oAzE/XSoKE9fdQ70ilyOi2cQeNtKkdlPtQ3USE1ybXbbHchf6 ptlgN6WZYarnYMl6bB183mZvQihGA/9RtLeTY= Received: by 10.142.55.20 with SMTP id d20mr4618644wfa.331.1277193436355; Tue, 22 Jun 2010 00:57:16 -0700 (PDT) Received: from [10.0.2.101] ([121.2.69.237]) by mx.google.com with ESMTPS id s9sm7168142rvl.5.2010.06.22.00.57.12 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 22 Jun 2010 00:57:14 -0700 (PDT) Message-ID: <4C206CD8.7050801@gmail.com> Date: Tue, 22 Jun 2010 16:57:12 +0900 From: Satoshi Nagayasu User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; ja; rv:1.9.1.10) Gecko/20100512 Thunderbird/3.0.5 MIME-Version: 1.0 To: pgsql-interfaces@postgresql.org Subject: SQLDA question Content-Type: text/plain; charset=ISO-2022-JP Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-5 required=5 tests=BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001 X-Spam-Level: X-Archive-Number: 201006/12 X-Sequence-Number: 6913 Hi all, I'm trying SQLDA features, and I'm encountered strange thing which I can't solve. In my sample code, I retreived some records from the pg_database table, and dump all columns of the records. Almost works well, but the "datconnlimit" column shows a string "????" instead of the correct value. (See below for more details.) I think it should show "-1". (By the way, all values are represented as string form in sqlvar.sqldata, right?) Why does it happen? Any suggestions? Here are my sample code, the result of execution and the correct table. -------------------------------------------------------------- EXEC SQL include sqlda.h; sqlda_t *sqlda1; int main(void) { EXEC SQL CONNECT TO uptimedb AS con1 USER uptime; EXEC SQL DECLARE cur CURSOR FOR SELECT * FROM pg_database; EXEC SQL OPEN cur; EXEC SQL WHENEVER NOT FOUND DO BREAK; while (1) { /* Open a cursor and assign descriptor to the cursor */ EXEC SQL FETCH NEXT FROM cur INTO DESCRIPTOR sqlda1; while (1) { int i; char name_buf[1024]; char var_buf[1024]; for (i=0 ; isqld ; i++) { sqlvar_t v = sqlda1->sqlvar[i]; char *sqldata = v.sqldata; short sqllen = v.sqllen; strncpy(name_buf, v.sqlname.data, v.sqlname.length); name_buf[v.sqlname.length] = '\0'; strncpy(var_buf, sqldata, sqllen); var_buf[sqllen] = '\0'; printf("%s = %s, (type:%d)\n", name_buf, var_buf, v.sqltype); } printf("\n"); if ( sqlda1->desc_next==NULL ) break; } } EXEC SQL CLOSE cur; EXEC SQL COMMIT; EXEC SQL DISCONNECT ALL; return (0); } -------------------------------------------------------------- [snaga@devwa02 test]$ ./test_desc3 datname = template1, (type:1) datdba = 10, (type:1) encoding = , (type:5) datistemplate = t, (type:1) datallowconn = t, (type:1) datconnlimit = ????, (type:5) datlastsysoid = 11510, (type:1) datfrozenxid = 379, (type:1) dattablespace = 1663, (type:1) datconfig = , (type:1) datacl = {=c/uptime,uptime=CTc/uptime}, (type:1) datname = template0, (type:1) datdba = 10, (type:1) encoding = , (type:5) datistemplate = t, (type:1) datallowconn = f, (type:1) datconnlimit = ????, (type:5) datlastsysoid = 11510, (type:1) datfrozenxid = 379, (type:1) dattablespace = 1663, (type:1) datconfig = , (type:1) datacl = {=c/uptime,uptime=CTc/uptime}, (type:1) datname = postgres, (type:1) datdba = 10, (type:1) encoding = , (type:5) datistemplate = f, (type:1) datallowconn = t, (type:1) datconnlimit = ????, (type:5) datlastsysoid = 11510, (type:1) datfrozenxid = 379, (type:1) dattablespace = 1663, (type:1) datconfig = , (type:1) datacl = , (type:1) datname = uptimedb, (type:1) datdba = 10, (type:1) encoding = , (type:5) datistemplate = f, (type:1) datallowconn = t, (type:1) datconnlimit = ????, (type:5) datlastsysoid = 11510, (type:1) datfrozenxid = 379, (type:1) dattablespace = 1663, (type:1) datconfig = , (type:1) datacl = , (type:1) datname = testdb, (type:1) datdba = 10, (type:1) encoding = , (type:5) datistemplate = f, (type:1) datallowconn = t, (type:1) datconnlimit = ????, (type:5) datlastsysoid = 11510, (type:1) datfrozenxid = 379, (type:1) dattablespace = 1663, (type:1) datconfig = , (type:1) datacl = , (type:1) [snaga@devwa02 test]$ -------------------------------------------------------------- uptimedb=# SELECT * FROM pg_database ; datname | datdba | encoding | datistemplate | datallowconn | datconnlimit | datlastsysoid | datfrozenxid | dattablespace | datconfig | datacl -----------+--------+----------+---------------+--------------+--------------+---------------+--------------+---------------+-----------+------------------------------- template1 | 10 | 0 | t | t | -1 | 11510 | 379 | 1663 | | {=c/uptime,uptime=CTc/uptime} template0 | 10 | 0 | t | f | -1 | 11510 | 379 | 1663 | | {=c/uptime,uptime=CTc/uptime} postgres | 10 | 0 | f | t | -1 | 11510 | 379 | 1663 | | uptimedb | 10 | 6 | f | t | -1 | 11510 | 379 | 1663 | | testdb | 10 | 0 | f | t | -1 | 11510 | 379 | 1663 | | (5 rows) uptimedb=# -------------------------------------------------------------- -- NAGAYASU Satoshi