Re: Using CTID system column as a "temporary" primary key - Mailing list pgsql-general

From Sebastien Flaesch
Subject Re: Using CTID system column as a "temporary" primary key
Date
Msg-id DBAP191MB1289536BFF22FD8BD5FFEC61B0889@DBAP191MB1289.EURP191.PROD.OUTLOOK.COM
Whole thread Raw
In response to Re: Using CTID system column as a "temporary" primary key  (Geoff Winkless <pgsqladmin@geoff.dj>)
Responses Re: Using CTID system column as a "temporary" primary key  (Christophe Pettus <xof@thebuild.com>)
Re: Using CTID system column as a "temporary" primary key  (Kirk Wolak <wolakk@gmail.com>)
List 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@geoff.dj>
Sent: Tuesday, March 28, 2023 12:20 PM
To: Sebastien Flaesch <sebastien.flaesch@4js.com>
Cc: pgsql-general <pgsql-general@lists.postgresql.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.flaesch@4js.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

pgsql-general by date:

Previous
From: Sebastien Flaesch
Date:
Subject: Re: Using CTID system column as a "temporary" primary key
Next
From: Christophe Pettus
Date:
Subject: Re: Using CTID system column as a "temporary" primary key