From: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
---|---|
To: | jian he <jian(dot)universality(at)gmail(dot)com> |
Cc: | Dmitry Dolgov <9erthalion6(at)gmail(dot)com>, Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>, Erik Rijkers <er(at)xs4all(dot)nl>, Michael Paquier <michael(at)paquier(dot)xyz>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, DUVAL REMI <REMI(dot)DUVAL(at)cheops(dot)fr>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: Re: proposal: schema variables |
Date: | 2024-12-28 17:29:26 |
Message-ID: | CAFj8pRBQkR1PY5RPiopA59pv3SaQmqc21mW-eS9=-TH-dP2nQQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers pgsql-performance |
Hi
so 28. 12. 2024 v 11:35 odesílatel jian he <jian(dot)universality(at)gmail(dot)com>
napsal:
> hi.
>
> src9=# select 'XLogRecPtr'::regtype;
> ERROR: type "xlogrecptr" does not exist
> LINE 1: select 'XLogRecPtr'::regtype;
> ^
> so
> + <structfield>varcreate_lsn</structfield> <type>XLogRecPtr</type>
> should be
> <structfield>varcreate_lsn</structfield> <type>pg_lsn</type>
> ?
>
done
>
> also
> + <row>
> + <entry role="catalog_table_entry"><para role="column_definition">
> + <structfield>varcreate_lsn</structfield> <type>XLogRecPtr</type>
> + </para>
> + <para>
> + LSN of the transaction where the variable was created.
> + <structfield>varcreate_lsn</structfield> and
> + <structfield>oid</structfield> together form the all-time unique
> + identifier (<structfield>oid</structfield> alone is not enough,
> since
> + object identifiers can get reused).
> + </para></entry>
> + </row>
> +
> we have "pg_variable_oid_index" PRIMARY KEY, btree (oid)
> for table pg_variable.
> so I am confused by saying the column "oid" itself is not enough to
> prove unique.
>
The session variable is stored in memory until the end of the session.
Theoretically, some sessions with used session variables can be opened for
a very long time without any activity - so it is not possible to process
sinval message. Other sessions can drop and create a lot of session
variables (this is very possible with temporary session variables). Oid in
Postgres can overflow, and postgres can reuse used oid of dropped objects
(oid is only 32bit integer). And after some time, the session with the used
variable can be activated, and the session variable can be used. Before
usage the session variable is rechecked against pg_variable, and
theoretically the variable with the same oid can be there (although it is a
different variable with possibly different type). The implementation should
protect against this scenario. The stored value must not be used in this
case - the usage of old value is dangerous - the calculations with the
variable can lose sense or can crash postgres. LSN is forever unique - it
is 64bit integer - so it is our safeguard so we can detect obsolete values
(stored in memory) although there are variables with the same oid.
oid in pg_variable ensures a unique identifier for any session variable in
one moment. Compound key [oid, varcreate_lsn] is a unique identifier for
ever.
> in let.sgml
> <term><literal>session_variable</literal></term>
> should be
> <term><replaceable class="parameter">session_variable</replaceable></term>
>
done
>
> <term><literal>sql_expression</literal></term>
> should be
> <term><replaceable class="parameter">sql_expression</replaceable></term>
>
done
From | Date | Subject | |
---|---|---|---|
Next Message | Noah Misch | 2024-12-28 18:10:01 | Re: WARNING: missing lock on database "postgres" (OID 5) @ TID (0,4) |
Previous Message | jian he | 2024-12-28 16:46:28 | Re: Re: proposal: schema variables |
From | Date | Subject | |
---|---|---|---|
Next Message | Pavel Stehule | 2024-12-28 21:49:59 | Re: Re: proposal: schema variables |
Previous Message | jian he | 2024-12-28 16:46:28 | Re: Re: proposal: schema variables |