473,508 Members | 2,363 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

namespace dilemma

I came across an interesting feature regarding namespace name changes.
To illustrate suppose you have two connections open whose commands occur in
the following sequence:

Time | Session A | Session B
------+---------------------------------+----------------------------
1 | CREATE SCHEMA my_schema; |
2 | CREATE TABLE my_schema.my_table |
| (my_column int); |
3 | BEGIN; |
4 | INSERT INTO my_schema.my_table |
| VALUES (1); |
5 | | BEGIN;
6 | | ALTER SCHEMA my_schema
| | RENAME TO your_schema;
7 | | COMMIT;
8 | SELECT my_column |
| FROM my_schema.my_table; |

If this is attempted, then session A results in the following error
after the command issued at time "8":
ERROR: schema "my_schema" does not exist

This feature occurs when the isolation level is either READ COMMITED or
SERIALIZABLE. If you instead were to attempt a table rename in session
B, then session B would appropriately hang waiting for an ACCESS EXCLUSIVE
lock.

My humble opinion (as a non-PostgreSQL developer) is that renaming the
schema in an implied rename of the table from my_schema.my_table to
your_schema.my_table. Therefore it should also obtain a lock of some
type.

As a result, all of my server side functions begin with something along
the lines of:
SELECT oid FROM pg_catalog.pg_namespaces
WHERE nspname = 'my_schema' FOR UPDATE;
I do this for every schema which the function consults through the SPI
manager. Also, AFAIK, to be very careful (paranoid) would require this
tedious approach for every transaction.

I attempted to get around this issue by adding various entries to
pg_rewrite to try to force a select statement on pg_namespace to be
rewritten as a SELECT ... FOR UPDATE. This failed. I have not tried to
patch the source, though I imagine it would not be difficult.

Any opinions on approaches to this issue or the correctness of the
current behavior of PostgreSQL are greatly appreciated.

Thanks,
Jeff Greco

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Nov 23 '05 #1
0 1056

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

Similar topics

1
2590
by: Pete | last post by:
I'm developing an open source CMS, but have come across a problem. The system dynamically creates .php files for the front-end of the site, meaning they're owned by user 'nobody'. However, for...
1
2720
by: Miha | last post by:
hi to everyone... could someone mail me a sample source code of the spatial prisoner's dilemma game...application code,not applet...thanx in advance mihael.sedmak@fer.hr
12
2403
by: Thomas Matthews | last post by:
Hi, According to Robert Martin's Dependency Inversion Principle, http://www.objectmentor.com/resources/articles/dip.pdf, when there is a need to test the type of an object, the code inside the...
0
1197
by: Colin Basterfield | last post by:
Hi all, Not sure if this is the most appropriate place for this so apologies if inappropriate... I have come back to a framework I built some time ago to see where some refactoring can take...
5
2517
by: c#freeskier89 | last post by:
Can someone please give me some information on sending data through a USB port. What I am trying to do is use the USB port (I get how to do it on a COM port). I am using VC# 2005. I have searched...
0
1038
by: Chris | last post by:
Hi, I have a dilemma. I have a web form that, when submitted, does a window.open js function to submit the form data to a new aspx page which then shows a report. I wanted to make sure that...
1
1291
by: Bishop | last post by:
I have a page that generates a grid of controls; at the end of each row is an update button that is dynamically created with an associated click event. The grid changes based on the date selected...
14
1556
by: ToddLMorgan | last post by:
Summary: How should multiple (related) projects be arranged (structured) and configured so that the following is possible: o Sharing common code (one of the projects would be a "common" project...
16
3144
by: hzmonte | last post by:
Correct me if I am wrong, declaring formal parameters of functions as const, if they should not be/is not changed, has 2 benefits; 1. It tells the program that calls this function that the...
0
7223
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,...
1
7036
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7489
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5624
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5047
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4705
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1547
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
414
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.