473,385 Members | 1,676 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Referencing columns from system tables possible?

Hello pgsql-general,

When trying to create a table

CREATE TABLE sessions (
id serial PRIMARY KEY,
procpid int4 REFERENCES pg_listener(listenerpid) ON DELETE CASCADE
);

I get a warning saying 'relation "pg_listener" is a system catalog'

Is it unreasonable and/or impossible to do this?

--
-Boris

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Nov 12 '05 #1
4 1588
On Fri, Nov 07, 2003 at 06:20:32PM -0800, Boris Popov wrote:
CREATE TABLE sessions (
id serial PRIMARY KEY,
procpid int4 REFERENCES pg_listener(listenerpid) ON DELETE CASCADE
);

I get a warning saying 'relation "pg_listener" is a system catalog'

Is it unreasonable and/or impossible to do this?


IMHO it's both. It's impossible because system catalogs don't have
trigger checking and other stuff, so you can't really have foreign
keys. To do so would make the whole system much slower.

It's also unreasonable because you shouldn't be relying on such a
system-specific way of representing user data. I remember what you were
trying to achieve; I don't have any ideas to give to you, but I can tell
you this is not what you are looking for.

(I don't remember why you rejected the idea of having a cron job to
delete entries belonging to expired sessions ...)

--
Alvaro Herrera (<alvherre[a]dcc.uchile.cl>)
"Los dioses no protegen a los insensatos. Éstos reciben protección de
otros insensatos mejor dotados" (Luis Wu, Mundo Anillo)

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to ma*******@postgresql.org so that your
message can get through to the mailing list cleanly

Nov 12 '05 #2
Hello Alvaro,

Friday, November 7, 2003, 7:25:33 PM, you wrote:

AH> On Fri, Nov 07, 2003 at 06:20:32PM -0800, Boris Popov wrote:
CREATE TABLE sessions (
id serial PRIMARY KEY,
procpid int4 REFERENCES pg_listener(listenerpid) ON DELETE CASCADE
);

I get a warning saying 'relation "pg_listener" is a system catalog'

Is it unreasonable and/or impossible to do this?


AH> IMHO it's both. It's impossible because system catalogs don't have
AH> trigger checking and other stuff, so you can't really have foreign
AH> keys. To do so would make the whole system much slower.

AH> It's also unreasonable because you shouldn't be relying on such a
AH> system-specific way of representing user data. I remember what you were
AH> trying to achieve; I don't have any ideas to give to you, but I can tell
AH> you this is not what you are looking for.

AH> (I don't remember why you rejected the idea of having a cron job to
AH> delete entries belonging to expired sessions ...)

Reason I'm trying to find a different solution is to avoid
implementing application heartbeat that updates the timestamp. On one
hand interval value has to be low to keep the system as close as
possible to real-time, yet it has to be rare enough to avoid
unnessecary load. If there was some way I could beat the backend into
maintaining the list automatically it'd be so much greater. It does it
already in pg_listener, this can't be hard to make available to
general public.

--
-Boris

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postgresql.org

Nov 12 '05 #3
On Fri, Nov 07, 2003 at 07:33:47PM -0800, Boris Popov wrote:

Boris,
AH> (I don't remember why you rejected the idea of having a cron job to
AH> delete entries belonging to expired sessions ...)

Reason I'm trying to find a different solution is to avoid
implementing application heartbeat that updates the timestamp.


I don't think there's another way because you'd need the "trigger on
disconnect" or some such that doesn't exist (yet).

--
Alvaro Herrera (<alvherre[a]dcc.uchile.cl>)
"Linux transformó mi computadora, de una `máquina para hacer cosas',
en un aparato realmente entretenido, sobre el cual cada día aprendo
algo nuevo" (Jaime Salinas)

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

Nov 12 '05 #4
Why not place the pid of the process into your session and set up a
cronjob to look at pg_listner and delete any pid's from the session file
that have gone away? Only down side is if you recycle pid's really quickly.

Alvaro Herrera wrote:
On Fri, Nov 07, 2003 at 07:33:47PM -0800, Boris Popov wrote:

Boris,
AH> (I don't remember why you rejected the idea of having a cron job to
AH> delete entries belonging to expired sessions ...)

Reason I'm trying to find a different solution is to avoid
implementing application heartbeat that updates the timestamp.


I don't think there's another way because you'd need the "trigger on
disconnect" or some such that doesn't exist (yet).

Nov 12 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: sreddy | last post by:
I am trying to write a sql query on self referencing table. Just to brief ..Database is related to a Hiring department of the Qwest company. I need to generate a Report used by in HR...
5
by: serge | last post by:
How can i enter Default Values of " " to all the columns of type character of all the tables (excluding system tables) and Default Values of 0 of all columns of type numbers. Excluding all primary...
2
by: Wing | last post by:
Hi all, I am using Microsoft Visual Studio .NET 2003 to program my code. I have following question. I am trying to adding a few bound columns which from a dataset that containing 2 tables to...
2
by: CSL | last post by:
I am using the DataGrid in a Windows Application, how can I adjust the widths of each column individually.
13
by: scorpion53061 | last post by:
Very urgent and I am very close but need a little help to get me over the edge........ I need to write these columns to a html file with each row containing these columns (seperated by breaks)....
5
by: Gary Blakely | last post by:
I'm giving this post another try - it can't be too difficult for everyone.... In the program below, the web page has dataGrid1. the only thing that has been done to it at design time is to...
5
by: mail | last post by:
Urgent help needed! I moved an application from ASP+ACCESS to ASP+MS SQLSERVER and I have the following problem: If the join on two tables results on duplicate colum names (which appear in...
5
by: Chris Brat | last post by:
Hi, Is it possible to retrieve details about the database, specifically a list of the tables in the database; and then to retrieve the columns and their types for the tables? Is this...
5
by: explode | last post by:
I made a procedure Public Sub Novo(ByVal nova1 As String, ByVal nova2 As String) that creates a new oledbDataAdapter with insert update select and delete commads. I also added that commands can...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.