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 1vVkPx-0070sc-2B for pgsql-general@arkaria.postgresql.org; Wed, 17 Dec 2025 05:49:46 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vVkPv-00AKkN-2P for pgsql-general@arkaria.postgresql.org; Wed, 17 Dec 2025 05:49:44 +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 1vVkPv-00AKkF-1L for pgsql-general@lists.postgresql.org; Wed, 17 Dec 2025 05:49:44 +0000 Received: from mail-yw1-x112d.google.com ([2607:f8b0:4864:20::112d]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vVkPu-0015w3-2K for pgsql-general@lists.postgresql.org; Wed, 17 Dec 2025 05:49:43 +0000 Received: by mail-yw1-x112d.google.com with SMTP id 00721157ae682-78e6dc6d6d7so51416787b3.3 for ; Tue, 16 Dec 2025 21:49:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1765950581; x=1766555381; darn=lists.postgresql.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=nWYM4EdDoX3MzPRPpSNSwxRy7+23fHToM1LMtArnnL0=; b=FTWO+cc4SMKA+MlZ5PJImwl7EHFzxuh936H+FuILA5fHbk3SEnXciIRP4TBjB/dgmT QagQ75I+IQHaFr0Wj39g7mLKFrEplLKxaSjhrFq5P+HCbyucNju+uQOwiuxlgmHbM9PQ dC1DUOVlgMSjZE44Ly14O5RtPBa6sIsW6yRTNpU1Y55J03uBnZTBPJRxgguivAJA5doy ub09Cm4OtL+3PkZVGSs7MjscEQlXBq9mAvDu5cXmbNyriqoivc6tkuV2CDSv91a4c/iR FT0hB+18+s3c+MeakV7FKAm2G9sOb3Cec/d/dsbixuwYlR5xxDB1HU+0k4BbNdFnF3uY ARAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765950581; x=1766555381; h=to:subject:message-id:date:from:mime-version:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=nWYM4EdDoX3MzPRPpSNSwxRy7+23fHToM1LMtArnnL0=; b=pt8n47AsKqiG/0lhfn62J3HcsnHZOi7lWW8ylA7iLVOZ0FXgqDXEbDM2hr+C1FdBLI tssKfuAZHVGlzYpugkKPiTxLTozFaTbssRWJUoOa6vfbtJa/it6i1+XVxeVGCuGy3Vjz VKj7xpyo5BGprqXzcEkQsH+ayEF+ihhza5ehLg92LtfuA8KBc2peowN6cqtOx1tnM7Hv iYiL6gUE5gFxD4mg2D7gILmbJwBdMFegefx6l8Cyi8NT5+GXHXL4ghu6sSGQkH0eaN2i S1y2NFV2KoFHols8EJr/uHkW8rY8hMZ52khz77qrs7hZsyQxTw2svNf5sWZNF7uMMLs5 12IQ== X-Gm-Message-State: AOJu0YzcQUZEfq77NQfTEXvwaXJVjfVvfS81O3rqOFmveK+Q3uPrIANQ dX4lrW3DHEgl1+vtAYeZCPo0kSoFEtqnlQBJeiPdiFVW1EM2R7utBjsdMqUvjfpXbcfAsgxRYNO 73FYWDSScINJfSMOxZjmAgRoF8OENY/bPEa1dMuw= X-Gm-Gg: AY/fxX7uxfbbMkkIPkfhP2Ay5O5EjHtNY9I9MoAtkZPgeA2LK4NFHByZJTR1GMdHtXq b92E9MSviBrJ8A7ug2Mhxt1tBojY/ddeDnqDZdaH6Xi+Tg49d7YWRsqzz04ZdcC9ZaAfKlZRjwy OyjUTlCdUuFPpFSiTSzd0lEurHmM7Kk6OZdfsH8gRkQGZTMDFQGUkIshO9yljWH2A7KCRD9cwud ChmeObIiOLpkWXKG0FzuNfE2odkQq9yHTcPdqzI38hcNdGFjBx0aOG/S3bBAkNmM8gFFUEQi/x2 CmP5ci18jMB2YHgxjOZ4UdgSRSY= X-Google-Smtp-Source: AGHT+IELks94q1QWRo0XjyJeJmLzbgJH4hS29M9KHlqODiPlS9Em0Jejq7GhwUVmBrR6HpBw23lUBKk9vjSnzqfWMuU= X-Received: by 2002:a05:690c:7481:b0:786:7a54:4632 with SMTP id 00721157ae682-78e6694b730mr143674017b3.13.1765950581499; Tue, 16 Dec 2025 21:49:41 -0800 (PST) MIME-Version: 1.0 From: Igor Korot Date: Tue, 16 Dec 2025 21:49:37 -0800 X-Gm-Features: AQt7F2rlSnb0VHgzLb7os9uTTix7cryoNPAXqsnqH1bgiJ1y7JVC9bRZTNX27WE Message-ID: Subject: libpq simple SELECT To: "pgsql-generallists.postgresql.org" Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, ALL, On the page https://www.postgresql.org/docs/current/libpq-example.html in the first program there is a following comment: [code] /* * Our test case here involves using a cursor, for which we must be inside * a transaction block. We could do the whole thing with a single * PQexec() of "select * from pg_database", but that's too trivial to make * a good example. */ [/code] I just tried the following code: [code] std::wstring query1 = 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 = c.relname AND c.relowner = usesysid AND (t.table_type = 'BASE TABLE' OR t.table_type = 'VIEW' OR t.table_type = 'LOCAL TEMPORARY') ORDER BY table_name;"; res = PQexec( m_db, m_pimpl->m_myconv.to_bytes( query1.c_str() ).c_str() ); for( int i = 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? Thank you.