[HACKERS] Creating a SHELL type [Was: User Defined Types in Java]

2006-05-14 Thread Thomas Hallgren
I just discovered that it is now possible to create a SHELL type using 
the 'CREATE TYPE type name' syntax using cvs head. Will this come in 
8.2 only or will it also be included in 8.1.4?


Kind Regards,
Thomas Hallgren


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


Re: [HACKERS] Creating a SHELL type [Was: User Defined Types in Java]

2006-05-14 Thread Martijn van Oosterhout
On Sun, May 14, 2006 at 09:14:38AM +0200, Thomas Hallgren wrote:
 I just discovered that it is now possible to create a SHELL type using 
 the 'CREATE TYPE type name' syntax using cvs head. Will this come in 
 8.2 only or will it also be included in 8.1.4?

Yeah, this was patched a little while ago. It's a new feature though,
so I don't imagine it will be backported.

Have a nice day,
-- 
Martijn van Oosterhout   kleptog@svana.org   http://svana.org/kleptog/
 From each according to his ability. To each according to his ability to 
 litigate.


signature.asc
Description: Digital signature


Re: [HACKERS] Inheritance, Primary Keys and Foreign Keys

2006-05-14 Thread Albert Cervera Areny
A Saturday 13 May 2006 08:33, Thomas Hallgren va escriure:
 Albert Cervera Areny wrote:
  Of course, that's an option for my case. Just wanted to know if this
  solution could be useful for PostgreSQL in general. Mainly because I'll
  add some triggers to check what maybe PostgreSQL should do itself but
  it's unimplemented.
 
  If that's not interesting or a proper solution for PostgreSQL I'll add it
  using the existing DDL in my application and that's all.
 
  What do you think?

 I think that if you want the database to improve its current inheritance
 behavior, then this trigger set is too limited. You need triggers that
 maintain both unique and primary keys and triggers that maintain cascade
 behavior.

True. I think those triggers should be used for all unique indexes, not only 
primary keys. What do you mean with triggers that maintain cascade behavior?


 In order to make it really good, you would also need to add some
 functionality to the mechanisms that maintain references. Today, they don't
 recognize inheritance at all.

Indeed, foreign keys should be inherited, as well as unique keys. And to look 
for the reference they should SELECT FROM instead of SELECT FROM ONLY.



 Personally, I use Hibernate. It tries to compensate for the lack of these
 features but since it is a middle-tier (or client) solution, it's not
 ideal. Another client can still violate the rules and to maintain integrity
 in the client is negative from a performance standpoint. I think it would
 be great if PostgreSQL could provide a more complete set of features that
 would enable inheritance. A good start would be to extend it with the
 functionality needed to maintain references, cascade actions, and enforce
 unique constraints.

 On the other hand, inheritance is a tricky business and a good OO-RDB
 mapper will give you several choices of how it should be mapped. There's no
 one size fits all. The best solution is probably if someone (you
 perhaps?) writes an external OO-RDB mapper module that executes in the
 backend. The author of such a tool would of course need some new nifty
 backend API's in order to do whats needed with references etc.

 I actually wrote something similar using Oracle a couple of years ago. It
 was based on type inheritance and views rather then tables and used
 'instead of' actions on all views (Oracles own mechanisms where far to
 limited). In some respect, I think that is a better solution. Inheritance
 and all that comes with it is more a 'type' thing then a 'table' thing in
 my world. A view is then used to _map_ the types to persistent storage,
 i.e. the 'tables'.

The library I'm developing (http://kandau.berlios.de) aims for very easy 
object persistency, and it offers a default O-R mapping schema. If the user 
wants, she can write her own, but as I'm working with PostgreSQL, I wanted to 
use the inheritance mechanism and extend it to fit the needs of this 
application. I think that inheritance at the database level as it's 
implemented in PostgreSQL is a very smart solution and I'd like it to be the 
default for my application.


 Regards,
 Thomas Hallgren

Thanks for your comments



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


Re: [HACKERS] Inheritance, Primary Keys and Foreign Keys

2006-05-14 Thread Thomas Hallgren

Albert Cervera Areny wrote:
 ...What do you mean with triggers that maintain cascade behavior?


It ties on to how references are handled. Since they currently ignore the inheritance 
aspect, you need triggers that enforce 'on cascade delete/update'. They will become obsolete 
if that changes (i.e. SELECT FROM instead of SELECT FROM ONLY).


Regards,
Thomas Hallgren


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


Re: [HACKERS] Inheritance, Primary Keys and Foreign Keys

2006-05-14 Thread Hannu Krosing
Ühel kenal päeval, N, 2006-05-11 kell 23:28, kirjutas Albert Cervera
Areny:
 Of course, that's an option for my case. Just wanted to know if this solution 
 could be useful for PostgreSQL in general. Mainly because I'll add some 
 triggers to check what maybe PostgreSQL should do itself but it's 
 unimplemented. 
 
 If that's not interesting or a proper solution for PostgreSQL I'll add it 
 using the existing DDL in my application and that's all. 
 
 What do you think?
 
 A Tuesday 09 May 2006 21:43, Simon Riggs va escriure:
  On Tue, 2006-05-09 at 01:20 +0200, Albert Cervera Areny wrote:
 In my particular case (don't know about the SQL standard or other
   cases), it'd be enough if when an inherited table is created:
 - A primary key in the inherited table is created with the same columns
   as the super table.

This is the simple part.

 - A trigger is created in the new table that ensures that this primary
   key doesn't exist in the super table.

This grows very expensive fast, once you have more thean one inherited
table

 - A trigger is created in the super table that ensures that this primary
   key doesn't exist in it's sub tables.

Ditto

-- 

Hannu Krosing
Database Architect
Skype Technologies OÜ
Akadeemia tee 21 F, Tallinn, 12618, Estonia

Skype me:  callto:hkrosing
Get Skype for free:  http://www.skype.com

NOTICE: This communication contains privileged or other confidential
information. If you have received it in error, please advise the sender
by reply email and immediately delete the message and any attachments
without copying or disclosing the contents.


---(end of broadcast)---
TIP 5: don't forget to increase your free space map settings


Re: [HACKERS] audit table containing Select statements submitted

2006-05-14 Thread Marc Munro
You could do this using Veil, http://pgfoundry.org/projects/veil/, or
something like it.  A Veil access function,
http://veil.projects.postgresql.org/curdocs/overview-page.html, could be
used to record every row returned within a query to the user that
requested it.  Note that this operates at the level of fetches and not
the resultset, meaning that queries like:

select stuff from a where exists (select 1 from b where);

would record a fetch against b.

The basic trick is to replace table_that_you_want_audited with a view
that does something like: 

select * from table_that_you_want_audited 
where  audit_this_fetch(row_identifier);

You will also need instead-of triggers for insert, update and delete of
the view.

__
Marc

On Fri, 2006-05-12 at 14:19 -0300, [EMAIL PROTECTED]
wrote:
 From: Hogan, James F. Jr. 
 Sent: Thursday, May 04, 2006 12:46 PM
 To: 'pgsql-sql@postgresql.org'; 'pgsql-general@postgresql.org'
 Subject: audit table containing Select statements submitted
 
 No response from the pgsql-admin list so I though I would try cross
 posting here:
 pgsql-sql@postgresql.org
 pgsql-general@postgresql.org
 
 
 
 I just know I am not the first to try and do this 
 
 Jim
 
 *
 Can anyone point me in a direction that may help me populate in real
 time a table that holds?
 
 Current_user
 Timestamp
 The Select Statement Submitted by the User
 
 I need to be able to determine who viewed what and when they viewed
 it.
 
 I have considered the fact that the result from SELECT yesterday may
 be
 different than the result set returned by the SAME SELECT statement
 today, but when used in conjunction with the INSERT, UPDATE, DELETE
 audit logging I have already created, the answers to who viewed, what
 and when would be readily available. 
 
 I have been searching all morning and...
 
 The only thing I find on logging of Select statements is that the
 information can be held in the Log Files...if Logging is enabled.  
 
 As I am only interested in the statements presented against certain
 tables...
 
 Turning on logging gives me more than I need or care to look through. 
 
 I could write a script to parses the Log Files into a Database Table
 but
 would prefer to avoid enabling the file logging of statements if
 possible.
 
 Thanks for any reference or help you may be able to provide.
 
 Jim
 


signature.asc
Description: This is a digitally signed message part


Re: [HACKERS] Fwd: [pgsql-hackers-win32] Build with Visual Studio MSVC

2006-05-14 Thread Gurjeet Singh

Hi All,

   I know it has been over a week now since I said that I'll put
together a document that describes how to debug postgres using Eclipse
IDE on Windows. I have finally completed the first draft and uploaded
it here:

http://www.geocities.com/gurjeet79/pg_on_eclipse.txt

   And here's a screenshot of the fruits it'd  bear if someone tries
to follow it and go through with it:

http://www.geocities.com/gurjeet79/pg_on_eclipse.jpg

   Hope it helps to get more people more familiar with the postgres code.

   Thomas, thanks a lot for the background. IMO, now Eclipse + CDT is
very close to MSVC / VS.Net in terms of the features that I was
looking for. The debugger is well integrated now, and I haven't had
any issues in this last one week.

   Since you said that you haven't tried debugging on Windows, I'd
request you to go through this document and see if you like what you
finally can do within Eclipse. Any inputs on the document will be
appreciated.

Thanks,
Gurjeet.

On 5/8/06, Thomas Hallgren [EMAIL PROTECTED] wrote:

Gurjeet Singh wrote:
Thomas, I love the idea of eclipse; any platform, any language,
 one IDE. I am downloading it right now. Can you please send in the
 steps that you perform to setup the environment, including mingw
 toolkit; I will try to grow on that.

My setup is pretty basic. I can't give you an exact step by step instruction 
since it's been
a while since I last did it. I installed msys, mingw, Eclipse. and then, using 
the Eclipse
update manager and the 'Callisto' site, I installed the C/C++ plugin.

I also made sure that the PATH in effect for the Eclipse IDE contains entries 
for the
%MSYS_HOME%\bin and %MINGW_HOME%\bin. That's it basically.


 The idea of this effort is to
 have a GUI IDE, with a slew of features that MSVC offers: Memory
 window that allows you to edit memory inplace, call-stack window,
 watches, quick-expression evaluater with class/struct support, etc.
 etc. . If Eclipse can offer all these, then I dont think anyone would
 mind using it insead of MSVC.

Eclipse won't offer all of these. Not yet anyway. What you get is a fair C/C++ 
editor and
parsers for your make output that will annotate your files with errors and 
warnings. There's
said to be some debugging support too on top of gdb, but to be honest, I've 
never tried it
on Windows. I do my C-debugging using gdb on Linux. My attempts to use gdb on 
Windows have
been quite futile so far. Then again, I'm not using the latest MinGW version so 
perhaps
there's still hope.

All in all, Eclipse C/C++ has some way to go before it can match up with MSVC. 
My point was
that you can do Windows development without MSVC and you can do it fairly well. 
If you are a
Linux hacker, you might even prefer doing it that way. So as a platform, 
Windows is not by
any means left alone.

I really think that what you and others are trying to accomplish is very 
valuable. If not
for me (since I'm mixing Java and C and work on multiple platforms) then 
certainly for many
others. Personally, I'd rather see a Visual Studio port than one for VC++6.0. I 
wish you the
best of luck.

Regards,
Thomas Hallgren




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


Re: [HACKERS] Fwd: [pgsql-hackers-win32] Build with Visual Studio MSVC

2006-05-14 Thread Josh Berkus
Gurjeet,

     I know it has been over a week now since I said that I'll put
 together a document that describes how to debug postgres using Eclipse
 IDE on Windows. I have finally completed the first draft and uploaded
 it here:

Hey, are you a member of the Eclipse Project?   Mike was bugging me a few 
months ago about wanting more involvement by PostgreSQL people in their Data 
Tools project.

-- 
Josh Berkus
Aglio Database Solutions
San Francisco

---(end of broadcast)---
TIP 5: don't forget to increase your free space map settings


Re: [HACKERS] Fwd: [pgsql-hackers-win32] Build with Visual Studio MSVC

2006-05-14 Thread Gurjeet Singh

   No I am not... I used Eclipse for the first time just last week.
But yes, I wish to contribute to the CDT plugin. I think their Indexer
is a bit slow... it takes more than an hour (about two hours) to index
postgres' source code!!! Also, I just noticed that the background gdb
crashes when trying to open an uninitialized structure in the
'Variables' view.

   If you are talking about, Mike Taylor from Eclipse,
(http://www.eclipse.org/org/elections/candidate.php?year=2006id=mtaylor),
then I'd be delighted to get in touch with him and see if Postgres and
Eclipse can work more closely.

Gurjeet.

On 5/15/06, Josh Berkus josh@agliodbs.com wrote:

Gurjeet,

 I know it has been over a week now since I said that I'll put
 together a document that describes how to debug postgres using Eclipse
 IDE on Windows. I have finally completed the first draft and uploaded
 it here:

Hey, are you a member of the Eclipse Project?   Mike was bugging me a few
months ago about wanting more involvement by PostgreSQL people in their Data
Tools project.

--
Josh Berkus
Aglio Database Solutions
San Francisco



---(end of broadcast)---
TIP 3: Have you checked our extensive FAQ?

  http://www.postgresql.org/docs/faq