Record last SELECT on a row?

2025-12-16 Thread Matthias Leisi
An application (which we can’t change) is accessing some Postgres table, and we would like to record when the rows in that table were last read (meaning: appeared in a SELECT result). The ultimate goal would be that we can „age out“ rows which have not been accessed in a certain period of time.

Re: libpq simple SELECT

2025-12-16 Thread Laurenz Albe
On Tue, 2025-12-16 at 21:49 -0800, Igor Korot wrote: > 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_cata

Re: PQexecPrepared() question

2025-12-16 Thread Laurenz Albe
On Tue, 2025-12-16 at 21:53 -0800, Igor Korot wrote: > Is there some default value for client_encoding? The default value for a client connection is whatever the parameter "client_encoding" was set to in the PostgreSQL server configuration. But that value can be overridden in several ways: - exp

Re: PQexecPrepared() question

2025-12-16 Thread Igor Korot
Thx, Tom.. Is there some default value for client_encoding? Thank you. On Tue, Dec 16, 2025 at 7:08 PM Tom Lane wrote: > > Igor Korot writes: > > If I want to have strings (aka char *) as parameters fr the query, > > should I send UTF-8 strings or something else? > > They should be in whatever

libpq simple SELECT

2025-12-16 Thread Igor Korot
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 *

Re: [GENERAL] Retrieving query results

2025-12-16 Thread Igor Korot
Hi, ALL, On Sun, Aug 27, 2017 at 11:05 PM Michael Paquier wrote: > > On Sun, Aug 27, 2017 at 12:12 AM, Tom Lane wrote: > > Michael Paquier writes: > >> On Fri, Aug 25, 2017 at 8:10 AM, Tom Lane wrote: > >>> I think the real problem occurs where we realloc the array bigger. > > > >> Looking at

Re: PQexecPrepared() question

2025-12-16 Thread Tom Lane
Igor Korot writes: > If I want to have strings (aka char *) as parameters fr the query, > should I send UTF-8 strings or something else? They should be in whatever is selected as the client_encoding on your connection. That goes for query strings too, and whatever other text a client might send.

PQexecPrepared() question

2025-12-16 Thread Igor Korot
Hi, ALL, If I want to have strings (aka char *) as parameters fr the query, should I send UTF-8 strings or something else? Thank you.

Re: Advent of Code Day 8

2025-12-16 Thread Bernice Southey
Greg Sabino Mullane wrote: > As I said, I'm trying to solve them in a single statement. Recursive CTEs, > CASE, and creative use of JSON can get you a long way. Here's my day 7, which > runs slow compared to other languages, but runs as a single SQL statement and > no plpgsql, and I think is a

Re: Advent of Code Day 8

2025-12-16 Thread Greg Sabino Mullane
On Tue, Dec 16, 2025 at 7:59 AM Bernice Southey wrote: > Greg Sabino Mullane wrote: > > What's so wrong with brute force? :) > Yeah, a few more days of AoC changed my mind. > Doing things in SQL and/or plpgsql definitely presents a lot of challenges, especially in comparison to a "regular" prog

Re: Advent of Code Day 8

2025-12-16 Thread Bernice Southey
Greg Sabino Mullane wrote: > What's so wrong with brute force? :) Yeah, a few more days of AoC changed my mind. > In case it helps, here is my solution: Thank you, this is very clever! I tried something similar, but with updating the circuit in my table on every loop. It ran a couple of minutes j