Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vVvXc-009mw7-1F for pgsql-general@arkaria.postgresql.org; Wed, 17 Dec 2025 17:42:25 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vVvXb-00FN5K-11 for pgsql-general@arkaria.postgresql.org; Wed, 17 Dec 2025 17:42:24 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vVvXa-00FN5A-2e for pgsql-general@lists.postgresql.org; Wed, 17 Dec 2025 17:42:23 +0000 Received: from mail-yx1-xb12d.google.com ([2607:f8b0:4864:20::b12d]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vVvXZ-001Bn5-2f for pgsql-general@lists.postgresql.org; Wed, 17 Dec 2025 17:42:22 +0000 Received: by mail-yx1-xb12d.google.com with SMTP id 956f58d0204a3-6446d7a8eadso5506721d50.0 for ; Wed, 17 Dec 2025 09:42:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1765993341; x=1766598141; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=zF+Y56BRdClTGC1EgJ3vAEgHWMCpwaaJSV4cnBb3ozo=; b=S+Pym/epFhDKI4S5q7Y1gTdws5M4Wziqu8HU76QCtp3c4WLsRlADxT946qza8wk0re lYjVnDCS/5+WgTOB3D8WcuLuvfT5SIqfs2TOAgPYcCShW8YNFPOM/YNxFQ7B8b5OzLy7 DE6XuWU0zlTMdwFmWDjB6xa1gynvW52Q0ggkfCIbHIw/jt9KlQSb0ayKviXE6t3fWV+6 xlyvXlUHsF6/ka+OLeLlDEpWsdhiokOT4IZKxPf7SBFMXXlNAQSqPY1TXcR0BDyqbElR Ad5tjB//ajl6UfzHn5V5KPBaunKGDr+oR3jaAnSQv8Ti9vRmFsVL382YnZ6UNH2qvAsO so4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765993341; x=1766598141; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=zF+Y56BRdClTGC1EgJ3vAEgHWMCpwaaJSV4cnBb3ozo=; b=p7aibwOqnCyyulRsDdMzuNOz6nVnRNrHgvcr5XT/XA8rIjVK9HWIeH8LT8M4A3hNLu HZB/GcbPbDmgCQIU9x0PA6vO6w1936hJDZit/mb9icIe1+IG1MujKx2hmi1dHHSGoIPD M1tu6qevPMrfpp0ySQclUOazNf9QcC6vey0EA8FfMojyRqN1hZ5aNBt3zz7HmcLWuBvI ux/wrbGel9xhhP+zK39kY4nQ0P5BanLJS0WeCOTNvXWGxWgWeJLdQuBQNoeL0U0ochve zNN4j5ovgx4fUfriicrh5BOW4uFP9V1JdpYeAlW/Xi0M5LbUn3JiEKeH9NaFyc1cBs2e DR0w== X-Gm-Message-State: AOJu0YwvJzBzrKLPlmv1DGUi1//lG94w9sdsvNDTE/31/X2IVdze8DIO 5UPJu7MHXTHSuU+fG6ug9ieicuKH061+MOwmIG8gWQ/uUGIOjC7lDB8HHPcnePeLuPT2kaMMGVD 1UuRiwapCQka2+cibtQm/in/0SoPI4gqcJMra X-Gm-Gg: AY/fxX5YtsYNcFUkj/kcUodVU2SJhqGtNQsErs2Czw6w5BI65tLQH9XQYtY/rPr5wqA QqUIMHax1W9SlMgDTnnSq6PtVxfeqjw54UalpKCwkE4JNkOADV4/siyXMjFIhktnWL/7LR3EoC7 QRUBFdn6DhaG1UfTEtJaxnh5ZhD4HY0w7fvpdWmrxkgtmgsKl50ikaEVrj+z4CeYjvy+LHbhYdb zx65Mg4PC/JGiav5KiAdwLQ4KT9B5EkpL+LrmRYi8Mu/STATp9quWU8r3xRFkeeBolusRdOvFt5 J0RHPg8rygafPVTNwTwnsqL0Zw== X-Google-Smtp-Source: AGHT+IFW0jgvGNIAVCemJH+Ku+Fe0yPAxOy49y3g0G4URP2ordBAzrCGz+OhPMadg55SShP94Up2mMa+BheG8emI/tY= X-Received: by 2002:a05:690e:1888:b0:646:60c5:8c46 with SMTP id 956f58d0204a3-64660c5918dmr1333195d50.51.1765993340749; Wed, 17 Dec 2025 09:42:20 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Igor Korot Date: Wed, 17 Dec 2025 09:42:09 -0800 X-Gm-Features: AQt7F2pR3sjxSEECu0o42B-OFTr5Eyr6TL5UeEoh7jRxClHLjDKEejfmwwT0FZc Message-ID: Subject: Re: libpq simple SELECT To: Laurenz Albe Cc: "pgsql-generallists.postgresql.org" Content-Type: multipart/alternative; boundary="000000000000c04cdd0646295d34" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000c04cdd0646295d34 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Lauren=E2=80=99s,, On Tue, Dec 16, 2025 at 11:34=E2=80=AFPM Laurenz Albe wrote: > On Tue, 2025-12-16 at 21:49 -0800, Igor Korot wrote: > > I just tried the following code: > > > > [code] > > std::wstring query1 =3D L"SELECT t.table_catalog AS catalog, > > t.table_schema AS schema, t.table_name AS table, u.usename AS owner, > > c.oid AS table_id FROM information_schema.tables t, > > pg_catalog.pg_class c, pg_catalog.pg_user u WHERE t.table_name =3D > > c.relname AND c.relowner =3D usesysid AND (t.table_type =3D 'BASE TABLE= ' > > OR t.table_type =3D 'VIEW' OR t.table_type =3D 'LOCAL TEMPORARY') ORDER= BY > > table_name;"; > > res =3D PQexec( m_db, m_pimpl->m_myconv.to_bytes( query1.c_str(= ) > > ).c_str() ); > > for( int i =3D 0; i < PQntuples( res ); i++ ) > > { > > some code handling the results > > } > > [/code] > > > > The loop is executed exactly 1 time. > > > > My question is - according to the comment above I don't have to use > cursor, > > but it looks like it's unavoidable? > > I see no cursor in your example... That is my question. The code shows cursor but the comment indicate that the cursor is not required. So do I have to use it? And if not - how to get the results? Thank you. > > Yours, > Laurenz Albe > --000000000000c04cdd0646295d34 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Lauren=E2=80=99s,,

On Tue, Dec = 16, 2025 at 11:34=E2=80=AFPM Laurenz Albe <laurenz.albe@cybertec.at> wrote:
On Tue, 2025-12-16 at 21:49 -0800, Igor Korot wrote: > I just tried the following code:
>
> [code]
>=C2=A0 =C2=A0 =C2=A0std::wstring query1 =3D L"SELECT t.table_catal= og AS catalog,
> t.table_schema AS schema, t.table_name AS table, u.usename AS owner, > c.oid AS table_id FROM information_schema.tables t,
> pg_catalog.pg_class c, pg_catalog.pg_user u WHERE t.table_name =3D
> c.relname AND c.relowner =3D usesysid AND (t.table_type =3D 'BASE = TABLE'
> OR t.table_type =3D 'VIEW' OR t.table_type =3D 'LOCAL TEMP= ORARY') ORDER BY
> table_name;";
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0res =3D PQexec( m_db, m_pimpl->m_m= yconv.to_bytes( query1.c_str()
> ).c_str() );
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 for( int i =3D 0; i < PQntuples( = res ); i++ )
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 {
> some code handling the results
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 }
> [/code]
>
> The loop is executed exactly 1 time.
>
> My question is - according to the comment above I don't have to us= e cursor,
> but it looks like it's unavoidable?

I see no cursor in your example...

=
That is my question.

The code shows cursor but the comment indicate that the curs= or is not required.

So d= o I have to use it? And if not - how to get the results?

Thank you.



Yours,
Laurenz Albe
--000000000000c04cdd0646295d34--