Re: Using CTID system column as a "temporary" primary key

From: Sebastien Flaesch <sebastien(dot)flaesch(at)4js(dot)com>
To: Geoff Winkless <pgsqladmin(at)geoff(dot)dj>
Cc: pgsql-general <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Using CTID system column as a "temporary" primary key
Date: 2023-03-28 10:39:54
Message-ID: DBAP191MB1289536BFF22FD8BD5FFEC61B0889@DBAP191MB1289.EURP191.PROD.OUTLOOK.COM
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


Hi Geoff,

Your remark makes total sense, and this is what should be done.

However, we have to deal with quite complex legacy 4GL code that we prefer to not touch, and we can adapt the SQL statements on the fly with our solution (kind of Java compiler/runtime system).

Next question:

How can I UPDATE or DELETE a row, with the CTID column?

When I bind a string parameter, I get this error:

SQLSTATE = 42883
MESSAGE: operator does not exist: tid = character varying

Do I have to cast() ?

Seb

________________________________
From: Geoff Winkless <pgsqladmin(at)geoff(dot)dj>
Sent: Tuesday, March 28, 2023 12:20 PM
To: Sebastien Flaesch <sebastien(dot)flaesch(at)4js(dot)com>
Cc: pgsql-general <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Using CTID system column as a "temporary" primary key

EXTERNAL: Do not click links or open attachments if you do not recognize the sender.

On Tue, 28 Mar 2023 at 10:28, Sebastien Flaesch <sebastien(dot)flaesch(at)4js(dot)com<mailto:sebastien(dot)flaesch(at)4js(dot)com>> wrote:
Is the CTID a good choice?

I think if you're honest with yourself you already know the answer to this question. The only real solution is to update the legacy code to use the primary key, or (if that's not possible) change the table definition to add your own indexed BIGSERIAL value called "ROWID" to the rows and use that instead (assuming it will be large enough).

Geoff

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Christophe Pettus 2023-03-28 12:39:27 Re: Using CTID system column as a "temporary" primary key
Previous Message Sebastien Flaesch 2023-03-28 10:24:46 Re: Using CTID system column as a "temporary" primary key