Re: [HACKERS] [PATCHES] [EMAIL PROTECTED]: Re: [BUGS] Problem identifying constraints which should not be inherited]

2008-03-31 Thread NikhilS
Hi Alex,

On Sun, Mar 30, 2008 at 7:10 AM, Alex Hunsaker [EMAIL PROTECTED] wrote:

 (trimmed cc's)

 Find attached inherited_constraint_v2.patch

 Changes since v1:
 -rebased against latest HEAD
 -changed enum { Anum_pg_constraint_... } back into #define
 Anum_pg_constraint_...
 -remove whitespace damage I added
 -fixed regression tests I added to be more robust
 -fixed
   create table ac (a int constraint check_a check (a  0));
   create table bc (a int constraint check_a check (a  0)) inherits (ac);
   so it properly works (removed crud I put into
 AddRelationRawConstraints and created a proper fix in DefineRelation)


I was taking a look at this patch to add the pg_dump related changes. Just
wanted to give you a heads up as this patch crashes if we run make
installcheck. Seems there is an issue introduced in the CREATE TABLE
REFERENCES code path due to your patch (this is without my pg_dump changes
just to be sure).  Looks like some memory overwrite issue. The trace is as
follows:

Core was generated by `postgres: nikhils regression [local] CREATE
TABLE '.
Program terminated with signal 11, Segmentation fault.
#0  0x08378024 in AllocSetCheck (context=0xa060368) at aset.c:1112
1112if (dsize  0  dsize  chsize 
*chdata_end != 0x7E)
(gdb) bt
#0  0x08378024 in AllocSetCheck (context=0xa060368) at aset.c:1112
#1  0x0837704f in AllocSetDelete (context=0xa060368) at aset.c:487
#2  0x083783c2 in MemoryContextDelete (context=0xa060368) at mcxt.c:196
#3  0x083797fb in PortalDrop (portal=0xa0845bc, isTopCommit=0 '\0') at
portalmem.c:448
#4  0x08281939 in exec_simple_query (
query_string=0xa07e564 CREATE TABLE enumtest_child (parent rainbow
REFERENCES enumtest_parent);) at postgres.c:992
#5  0x082857d4 in PostgresMain (argc=4, argv=0x9ffbe28, username=0x9ffbcc4
nikhils) at postgres.c:3550
#6  0x0824917b in BackendRun (port=0xa003180) at postmaster.c:3204
#7  0x082486a2 in BackendStartup (port=0xa003180) at postmaster.c:2827
#8  0x08245e9c in ServerLoop () at postmaster.c:1271
#9  0x082457fd in PostmasterMain (argc=3, argv=0x9ff9c60) at postmaster.c
:1019
#10 0x081e1c03 in main (argc=3, argv=0x9ff9c60) at main.c:188


Regards,
Nikhils
-- 
EnterpriseDB http://www.enterprisedb.com


Re: [HACKERS] Commit fest status

2008-03-31 Thread Gregory Stark
Tom Lane [EMAIL PROTECTED] writes:

 Well, it's the end of March, and I'm already starting to feel like we've
 been commit-festing forever :-(.  At this point I see only one remaining
 patch that seems likely to go in without any further discussion --- that's
 Pavel's plpgsql EXECUTE USING thing.  

A huge *thank you* for all your efforts. I know it's not the fun part of
your work.

 However, we've got boatloads of stuff that needs discussion and
 consensus-achievement. Please take a look at the queue
 http://momjian.us/cgi-bin/pgpatches

Alvaro tried to dump this list into:

http://wiki.postgresql.org/wiki/CommitFest:March

 and comment where you can.  Remember that substantive comments or
 reviews should go to the mailing lists --- you can add annotations to
 that page if you want, but they'll be ephemeral.

And the patch authors are unlikely to see them unless they're also doing
reviews.

-- 
  Gregory Stark
  EnterpriseDB  http://www.enterprisedb.com
  Get trained by Bruce Momjian - ask me about EnterpriseDB's PostgreSQL 
training!

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


Re: [HACKERS] Submission of Feature Request : RFC- for Implementing Transparent Data Encryption in P

2008-03-31 Thread Heikki Linnakangas

sanjay sharma wrote:

However there are certain fetures which are becoming key for putting postgres 
in areas where strong regulatory compliance is required.TDE is very helpful in 
storing data where there is strict privacy compliance requirement for example 
e.Government and e.Health. All columns of personal profile/health data do not 
need same level of security for all users and applications. Selective data 
encryption is very handy in an architecture where different applications are 
pulling data from a central data repository for processing and presenting to 
their users or where different users are changing different part of data set in 
central repository. These departmental applications may contain keys for 
decrypting and looking at only those columns needed by their users. Encrypting 
just needed column takes care of compliance requirement down the line in 
backups and archives.


You could implement that using views and contrib/pgcrypto. Create a view 
on the underlying table that encrypts/decrypts the data on access.


I'm not sure who the encryption is supposed to protect from in this 
scenario. From the superuser of the database server? It isn't really 
suitable for that: the way you describe it, the encryption/decryption is 
done in the server, so a malicious superuser that has full access to the 
server can still capture the data before it's encrypted, and can also 
recover the key from the running server, by crawling through system 
memory or installing hacked software to print it out.


It's better than nothing, as it does protect from a casual non-malicious 
observer, and it does protect the backups, but what I'd rather see is a 
system where the database server never sees the data in plaintext. You 
could do the encryption/decryption in the client, perhaps in the driver 
so that it's transparent to the application.


I'm not familiar with the compliance requirements you refer to. What 
exactly is required?


Another area where I would like to put a RFC is Auditing. A flag at the database level (conf file) or in DDL which puts audit columns ( created_by, creation_date, last_updated_by, last_update_date) on tables and automatically populates them would be a very nice  standard feature. Currently this needs code/trigger to be duplicated at each table which is a big grunt. At furthur higher level a way to audit data access/view for regulatory complinace like HIPPA is also needed.This should not be copy of Oracle FGA which has its own limitations. 


This could be implemented fairly easily as an external tool that queries 
the system catalogs, and adds the required columns and triggers.


--
  Heikki Linnakangas
  EnterpriseDB   http://www.enterprisedb.com

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


Re: [HACKERS] jaguar is failing

2008-03-31 Thread ohp
On Sun, 30 Mar 2008, Tom Lane wrote:

 Date: Sun, 30 Mar 2008 15:37:51 -0400
 From: Tom Lane [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Cc: pgsql-hackers list pgsql-hackers@postgresql.org
 Subject: Re: [HACKERS] jaguar is failing

 [EMAIL PROTECTED] writes:
  As you can see here:
  http://www.pgbuildfarm.org/cgi-bin/show_history.pl?nm=jaguarbr=HEAD
  Jaguar has been failing for two days while centaur is ok.

 I asked you to look into that yesterday
 http://archives.postgresql.org/pgsql-hackers/2008-03/msg01216.php
I saw it thid moring in the digest

 The copy of that mail that went directly to you bounced, with an error
 suggesting that your mail filtering setup has been broken for more
 than a year (you're depending on a blacklist server that ceased
 service in Dec 2006).  If you want, I'll post the bounce I expect
 to get from this.

Found the gulty and fired him :)
  The only diff is that jaguar is compiling with -DCLOBBER_CACHE_ALWAYS
  Is that related?

 Hmm, that might be the needed clue --- thanks for the reminder.

   regards, tom lane


-- 
Olivier PRENANT Tel: +33-5-61-50-97-00 (Work)
15, Chemin des Monges+33-5-61-50-97-01 (Fax)
31190 AUTERIVE   +33-6-07-63-80-64 (GSM)
FRANCE  Email: [EMAIL PROTECTED]
--
Make your life a dream, make your dream a reality. (St Exupery)

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


Re: [HACKERS] [PATCHES] Minimum selectivity estimate for LIKE 'prefix%'

2008-03-31 Thread Peter Eisentraut
Am Donnerstag, 6. März 2008 schrieb Tom Lane:
 What I propose doing about this is a small variant on Peter's original
 suggestion: compute the estimated selectivity for
 col = 'prefix'
 and clamp the result of prefix_selectivity to be at least that.

OK, first results with this patch are in: The selectivity estimations are 
adjusted nicely, but the cost calculation doesn't change at all.  Before:

Index Scan using foo_idx_3 on foo foo (cost=0.01..6.03 rows=1 width=8)

After:

Index Scan using foo_idx_3 on foo foo (cost=0.01..6.03 rows=627 width=8)

How is that possible?

Btw., the corresponding query plan for the LIKE 'constant' case is:

Index Scan using foo_idx_3 on foo foo (cost=0.00..2527.84 rows=627 width=8)

This is what we had hoped to get in the after case.

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


Re: [HACKERS] jaguar is failing

2008-03-31 Thread ohp
On Sun, 30 Mar 2008, Tom Lane wrote:

 Date: Sun, 30 Mar 2008 23:36:24 -0400
 From: Tom Lane [EMAIL PROTECTED]
 To: [EMAIL PROTECTED], pgsql-hackers list pgsql-hackers@postgresql.org
 Subject: Re: [HACKERS] jaguar is failing

 I wrote:
  [EMAIL PROTECTED] writes:
  The only diff is that jaguar is compiling with -DCLOBBER_CACHE_ALWAYS
  Is that related?

  Hmm, that might be the needed clue --- thanks for the reminder.

 Yup, that was it --- was able to duplicate the problem with
 -DCLOBBER_CACHE_ALWAYS.  So I think jaguar's efforts already paid
 for themselves ...

   regards, tom lane

Great!
Did you commit a patch already, do you want me to rerun the build?
-- 
Olivier PRENANT Tel: +33-5-61-50-97-00 (Work)
15, Chemin des Monges+33-5-61-50-97-01 (Fax)
31190 AUTERIVE   +33-6-07-63-80-64 (GSM)
FRANCE  Email: [EMAIL PROTECTED]
--
Make your life a dream, make your dream a reality. (St Exupery)

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


Re: [HACKERS] [GENERAL] ANALYZE getting dead tuple count hopelessly wrong

2008-03-31 Thread Pavan Deolasee
On Mon, Mar 31, 2008 at 1:33 PM, Stuart Brooks [EMAIL PROTECTED] wrote:
 I have a table with about 15 million rows which is constantly having
  tuples added to the head and deleted in blocks from the tail to maintain
  the size. The dead tuple count in pg_stat_user_tables tracks the deleted
  rows fairly accurately until an auto-ANALYZE is done in the background
  at which point the value it calculates is wrong by a factor of 2-3 times
  (calculated value is 30-50% of the correct value)

(copying -hackers)

Seems like the redirected-dead line pointers are playing spoil-sport here.
In this particular example, the deleted tuples may get truncated to
redirected-dead line pointers. Analyze would report them as empty
slots and not as dead tuples. So in the worst case, if all the deleted
tuples are already truncated to redirected-dead line pointers, analyze
may report zero dead tuple count.

This is a slightly tricky situation because in normal case we might want
to delay autovacuum to let subsequent UPDATEs in the page to reuse
the space released by  the deleted tuples. But in this particular example,
delaying autovacuum is not a good thing because the relation would
just keep growing.

I think we should check for redirected-dead line pointers in analyze.c
and report them as dead tuples. The other longer term alternative
could be to track redirected-dead line pointers and give them some
weightage while deciding on autovacuum. We can also update the
FSM information of a page when its pruned/defragged so that the page
can also be used for subsequent INSERTs or non-HOT UPDATEs in
other pages. This might be easier said than done.


Thanks,
Pavan

-- 
Pavan Deolasee
EnterpriseDB http://www.enterprisedb.com

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


[HACKERS] WIP: CASE statement for PL/pgSQL

2008-03-31 Thread Pavel Stehule
Hello

I finished this patch.

Proposal: http://archives.postgresql.org/pgsql-hackers/2008-01/msg00696.php

It's compatible with PL/SQL (Oracle) and SQL/PSM (ANSI).

CASE statements is parsed and transformed to CASE expression and
statements paths. Result of CASE expression is used as index to array
of statements paths. It's fast but I have to once time reparse SQL
queries - it generate about 150 lines code, because I need to get all
parameter's positions. It's one disadvantage. On second hand, this
statement needs only one expression evaluation.

Sample:

CREATE OR REPLACE FUNCTION foo(int)
RETURNS void AS $$
BEGIN
  CASE $1
  WHEN 1,2,3 THEN
 RAISE NOTICE '1,2';
 RAISE NOTICE '3';
  WHEN 4 THEN
 RAISE NOTICE '4';
  ELSE
 RAISE NOTICE 'other than 1,2,3,4';
  END CASE;
  RETURN;
END;
$$ LANGUAGE plpgsql;

This statement is transformated to:
three statement paths:
[0]
 RAISE NOTICE 'other than 1,2,3,4';
[1]
 RAISE NOTICE '1,2';
 RAISE NOTICE '3';
[2]
 RAISE NOTICE '4';

and case expression
CASE $1
  WHEN 1 THEN 1
  WHEN 2 THEN 1
  WHEN 3 THEN 1
  WHEN 4 THEN 2
END;

When result is NULL then it uses 0 path.

Questions:
a) is possible to use SQL scanner? Now, scanner isn't directly used everywhere.

any notes and comments are welcome

Regards
Pavel Stehule
*** ./gram.y.orig	2008-03-28 17:33:45.0 +0100
--- ./gram.y	2008-03-31 13:46:08.0 +0200
***
*** 15,23 
   */
  
  #include plpgsql.h
- 
  #include parser/parser.h
! 
  
  static PLpgSQL_expr		*read_sql_construct(int until,
  			int until2,
--- 15,24 
   */
  
  #include plpgsql.h
  #include parser/parser.h
! #include errno.h
! #include ctype.h
! #include string.h
  
  static PLpgSQL_expr		*read_sql_construct(int until,
  			int until2,
***
*** 46,52 
  static	char			*check_label(const char *yytxt);
  static	void			 check_labels(const char *start_label,
  	  const char *end_label);
! 
  %}
  
  %name-prefix=plpgsql_yy
--- 47,54 
  static	char			*check_label(const char *yytxt);
  static	void			 check_labels(const char *start_label,
  	  const char *end_label);
! static PLpgSQL_stmt	*make_case(int lineno, PLpgSQL_expr *case_expr, 
! List *when_clause_list, List *else_stmts);
  %}
  
  %name-prefix=plpgsql_yy
***
*** 79,84 
--- 81,91 
  			char *end_label;
  			List *stmts;
  		}		loop_body;
+ 		struct
+ 		{	
+ 			List *expr_list;
+ 			PLpgSQL_expr	*expr;
+ 		}		when_expr;
  		List	*list;
  		PLpgSQL_type			*dtype;
  		PLpgSQL_datum			*scalar;	/* a VAR, RECFIELD, or TRIGARG */
***
*** 95,100 
--- 102,108 
  		PLpgSQL_nsitem			*nsitem;
  		PLpgSQL_diag_item		*diagitem;
  		PLpgSQL_stmt_fetch		*fetch;
+ 		PLpgSQL_when_clause		*whenclause;
  }
  
  %type declhdr decl_sect
***
*** 109,115 
  %type str		decl_stmts decl_stmt
  
  %type expr	expr_until_semi expr_until_rightbracket
! %type expr	expr_until_then expr_until_loop
  %type expr	opt_exitcond
  
  %type ival	assign_var
--- 117,123 
  %type str		decl_stmts decl_stmt
  
  %type expr	expr_until_semi expr_until_rightbracket
! %type expr	expr_until_then expr_until_loop opt_expr_until_when
  %type expr	opt_exitcond
  
  %type ival	assign_var
***
*** 128,133 
--- 136,145 
  %type stmt	stmt_return stmt_raise stmt_execsql stmt_execsql_insert
  %type stmt	stmt_dynexecute stmt_for stmt_perform stmt_getdiag
  %type stmt	stmt_open stmt_fetch stmt_move stmt_close stmt_null
+ %type stmt	stmt_case
+ %type when_expr case_when_expr
+ %type whenclause when_clause
+ %type list	when_clause_list opt_case_default
  
  %type list	proc_exceptions
  %type exception_block exception_sect
***
*** 154,159 
--- 166,172 
  %token	K_ASSIGN
  %token	K_BEGIN
  %token	K_BY
+ %token	K_CASE
  %token	K_CLOSE
  %token	K_CONSTANT
  %token	K_CONTINUE
***
*** 611,616 
--- 624,631 
  		{ $$ = $1; }
  | stmt_if
  		{ $$ = $1; }
+ | stmt_case
+ 		{ $$ = $1; }
  | stmt_loop
  		{ $$ = $1; }
  | stmt_while
***
*** 809,814 
--- 824,869 
  	}
  ;
  
+ stmt_case		: K_CASE lno opt_expr_until_when when_clause_list opt_case_default K_END K_CASE ';'
+ 	{
+ 		$$ = make_case($2, $3, $4, $5);
+ 	}
+ ;
+ 
+ opt_case_default	:
+ 	{
+ 		$$ = NIL;
+ 	}
+ | K_ELSE proc_stmts
+ 	{
+ 		$$ = $2;
+ 	}
+ ;
+ 
+ when_clause_list	: when_clause_list when_clause
+ 	{
+ 		$$ = lappend($1, $2);
+ 	}
+ | when_clause
+ 	{
+ 		$$ = list_make1($1);
+ 	}
+ ;
+ 
+ when_clause		: K_WHEN lno case_when_expr proc_stmts
+ 	{
+ 		PLpgSQL_when_clause *new = palloc0(sizeof(PLpgSQL_when_clause));
+ 
+ 		new-cmd_type		= PLPGSQL_STMT_WHEN_CLAUSE;
+ 		new-lineno	= $2;
+ 		new-when_expr	= $3.expr;
+ 		new-when_expr_list	= $3.expr_list;
+ 	

Re: [HACKERS] first time hacker ;) messing with prepared statements

2008-03-31 Thread PFC

* Server restart and assorted like failover (you need to redo a
  global prepare).


Hmm?  He's proposing storing the info in a system catalog.  That hardly
seems volatile; it'll certainly survive a server restart.


Yes, it's in a system catalog.


I agree with the point that this isn't completely transparent to
applications, but if an app is already using named prepared statements
it would surely be a pretty small matter to make it use this feature.
The app code would likely get simpler instead of more complex, since
you'd stop worrying about whether a given statement had been prepared
yet in the current session.


Thanks. That was the idea behing this hack...


I'm having a problem with the terminology here, since AFAICT what your
patch does is exactly not a global prepare --- there is no permanently
stored cached plan.  That's a good thing probably, but it seems like
the feature needs to be described differently.


	Sure, but I couldn't come up with a suitable name at the time... perhaps  
CREATE STATEMENT (and DROP STATEMENT) ? This would describe it better  
(especially the DROP, because GLOBAL DEALLOCATE is a rather bad name,  
since it doesn't actually deallocate anything...)



I'm also pretty dubious about storing raw text in that catalog.  In the
first place, while I've not looked at your patch, I expect you are
pulling the raw text from debug_query_string.  That won't work in cases
where multiple SQL commands were submitted in one query string.


	LOL, you are right, I had tested with multiple queries on the same line  
from psql, but psql apparently splits the queries, when I feed multiple  
queries from PHP, one of them being GLOBAL PREPARE, it fails.



In the
second place, raw-text SQL commands will be subject to a whole lot of
ambiguity at parse time.  If for instance another session tries to use
the command with a different search_path or standard_conforming_string
setting, it'll get different results.  While I can think of use-cases
for that sort of behavior, it seems like mostly a bad idea.


You're right.


I'm thinking that a more appropriate representation would use stored
parse trees, the same as we do in pg_rewrite, and with the same
dependency information so that a stored statement couldn't outlive the
objects it depends on.


	Do the parse tree store fully qualified schema.table or  
schema.function ?
	I mean, if table T is mentioned in a parse tree which is stored, and the  
table is later dropped and recreated... or a column dropped... what  
happens ? Dropping the statement would seem more logical, since it would  
probably no longer be valid...



Another area that could do with more thought is the hard-wired
association between statement ownership and accessibility.  That's
likely to be pretty inconvenient in a lot of cases, particularly
systems that use role membership heavily.


Yes, need to think about that.


I also wonder whether statements should belong to schemas...


Since they are basically an extremely simple form of a function, why 
not ?
	(but since part of the goodness on prepared statements is that they are  
stored in a fast hash cache, wouldn't that add too much overhead ?)


Thanks for the helpful advice.

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


Re: Status of GIT mirror (Was [HACKERS] having problem in rsync'ing cvs)

2008-03-31 Thread Aidan Van Dyk
* Brendan Jurd [EMAIL PROTECTED] [080328 11:16]:
 On 29/03/2008, Aidan Van Dyk [EMAIL PROTECTED] wrote:
  * Brendan Jurd [EMAIL PROTECTED] [080327 16:36]:
   
Looking at the CVS logs, there was definitely commit action in that
timeframe, but none of it is showing up on the git shortlog.
 
  OK, so it should all be valid again.
 
 
 Looks good to me.  Thanks Aidan.

And, of course, after fixing the missing one, I forgot to enable the
cronjob *again*...

It's running now again.

Really.

a.


-- 
Aidan Van Dyk Create like a god,
[EMAIL PROTECTED]   command like a king,
http://www.highrise.ca/   work like a slave.


signature.asc
Description: Digital signature


Re: [HACKERS] [PATCHES] Minimum selectivity estimate for LIKE 'prefix%'

2008-03-31 Thread Tom Lane
Peter Eisentraut [EMAIL PROTECTED] writes:
 OK, first results with this patch are in: The selectivity estimations are 
 adjusted nicely, but the cost calculation doesn't change at all.  Before:

I've forgotten the context ... what's the whole query and plan again?
And which PG version exactly?

regards, tom lane

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


Re: [HACKERS] jaguar is failing

2008-03-31 Thread Tom Lane
[EMAIL PROTECTED] writes:
 Did you commit a patch already, do you want me to rerun the build?

Yes; no --- looks like it'll run by itself in an hour anyay.

regards, tom lane

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


Re: [HACKERS] Commit fest status

2008-03-31 Thread Tom Lane
Gregory Stark [EMAIL PROTECTED] writes:
 Tom Lane [EMAIL PROTECTED] writes:
 However, we've got boatloads of stuff that needs discussion and
 consensus-achievement. Please take a look at the queue
 http://momjian.us/cgi-bin/pgpatches

 Alvaro tried to dump this list into:
 http://wiki.postgresql.org/wiki/CommitFest:March

Last I looked, Alvaro had only listed live patches (things that seemed
to have some chance of getting committed in this fest).  That was fine
at the time, but now we need to expand our scope and consider the
threads that are discussing design decisions for future patches.
We can't close commit-fest till we've given some guidance on those.

regards, tom lane

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


Re: [HACKERS] first time hacker ;) messing with prepared statements

2008-03-31 Thread Tom Lane
PFC [EMAIL PROTECTED] writes:
   Do the parse tree store fully qualified schema.table or  
 schema.function ?

They store OIDs.

   I mean, if table T is mentioned in a parse tree which is stored, and 
 the  
 table is later dropped and recreated... or a column dropped... what  
 happens ?

Dependencies take care of that --- if you drop the table, the statement
goes away too.

 I also wonder whether statements should belong to schemas...

   Since they are basically an extremely simple form of a function, why 
 not ?
   (but since part of the goodness on prepared statements is that they are 
  
 stored in a fast hash cache, wouldn't that add too much overhead ?)

The lookup overhead would be trivial, I expect, compared to everything
else involved in a query.  But what you'd have to work out is the
interaction between that and ordinary prepared statements, which
traditionally haven't had a schema name attached to the statement name.

(Come to think of it, if there's a statement FOO and I explicitly do
PREPARE FOO, what happens?  Should the result depend on whether I've
used FOO earlier in the session?)

regards, tom lane

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


Re: [HACKERS] [GENERAL] ANALYZE getting dead tuple count hopelessly wrong

2008-03-31 Thread Tom Lane
Pavan Deolasee [EMAIL PROTECTED] writes:
 Seems like the redirected-dead line pointers are playing spoil-sport here.
 In this particular example, the deleted tuples may get truncated to
 redirected-dead line pointers. Analyze would report them as empty
 slots and not as dead tuples. So in the worst case, if all the deleted
 tuples are already truncated to redirected-dead line pointers, analyze
 may report zero dead tuple count.

[ Please see if you can stop using the redirected dead terminology ]

Yeah, I think I agree.  The page pruning code is set up so that changing
a line pointer to DEAD state doesn't change the count of dead tuples in
the table, so we are counting unreclaimed DEAD pointers as still being
dead tuples requiring VACUUM.  ANALYZE should surely not affect that.

It looks like there's no trivial way to get ANALYZE to do things that
way, though.  heap_release_fetch() doesn't distinguish a DEAD line
pointer from an unused or redirected one.  But in the current
implementation of ANALYZE there's really no benefit to using
heap_release_fetch anyway --- it always examines all line pointers
on each selected page, so we might as well rewrite it to use a simple
loop more like vacuum uses.

I notice that this'd leave heap_release_fetch completely unused...
at least in HEAD I'd be tempted to get rid of it and restore heap_fetch
to its former simplicity.

regards, tom lane

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


Re: [HACKERS] [PATCHES] Minimum selectivity estimate for LIKE 'prefix%'

2008-03-31 Thread Peter Eisentraut
Am Montag, 31. März 2008 schrieb Tom Lane:
 Peter Eisentraut [EMAIL PROTECTED] writes:
  OK, first results with this patch are in: The selectivity estimations are
  adjusted nicely, but the cost calculation doesn't change at all.  Before:

 I've forgotten the context ... what's the whole query and plan again?
 And which PG version exactly?

Please see http://archives.postgresql.org/pgsql-hackers/2008-01/msg00048.php

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


Re: [HACKERS] POSIX shared memory support

2008-03-31 Thread Stephen Frost
Chris, et al,

(commit-fest consensus discussion)
* Chris Marcellino wrote:
 In case you haven't had enough, here is another version of the code  
 to make Postgres use POSIX shared memory. Along with the issues that  
 have already been addressed, this version ensures that orphaned  
 backends are not in the database when restarting Postgres by using a  
 single 1 byte SysV segment to see who is attached to the segment  
 using shmctl/IPC_STAT/nattach.

This really feels like a deal-breaker to me.  My first reaction to this
patch, honestly, is that it's being justified for all the wrong reasons.
Changing to POSIX shm seems like a reasonable goal in general, provided
it can do what we need, but doing it to work around silly defaults
doesn't really work for me.  If the real issue you have is with the SysV
limits then I'd suggest you bring that up with the kernel/distribution
folks to get them to use something more sane.

Looking around a bit, it looks like it's already being addressed in some
places, for example Solaris 10 apparently uses 1/4th of memory, while
Centos 5 uses 4GB.  Suse also uses a larger default, from what I
understand.  Supporting this effort to get it raised on various
platforms and distributions seems like a much better approach.

Additionally, it strikes me that there *is* a limit on POSIX shared
memory too, generally half of ram on the systems I've looked at, but
there's no guarentee that'll always be the default or that half of ram
will always be enough for us.  So, even with this change, the problem
isn't completely 'solved'.

Finding a way for POSIX shm to do what we need, including Tom's
concerns, without depending on SvsV shm as a crutch work around, would
make this change much more reasonable and could be justified as moving
to a well defined POSIX standard, and means we may be able to support
platforms which either are new and don't implement SysV but just POSIX,
or cases where SysV is being actively depreceated.  Neither of which is
possible if we're stuck with using it in some cases.

Thanks,

Stephen


signature.asc
Description: Digital signature


Re: [HACKERS] [PATCHES] Minimum selectivity estimate for LIKE 'prefix%'

2008-03-31 Thread Tom Lane
Peter Eisentraut [EMAIL PROTECTED] writes:
 Am Montag, 31. März 2008 schrieb Tom Lane:
 I've forgotten the context ... what's the whole query and plan again?
 And which PG version exactly?

 Please see http://archives.postgresql.org/pgsql-hackers/2008-01/msg00048.php

Hm.  Now that I think about it, the index scan cost estimate is made
using a separate estimate of rows fetched (since this will depend on the
specific index qual clauses in use, whereas the overall row estimate for
the relation doesn't vary with index).  For the case at hand, the index
quals that it's looking at are the = and  clauses with close-together
comparison values, and so it comes out with a rock-bottom rowcount
estimate.  The clamping occuring over in prefix_selectivity isn't
relevant here.

Your original complaint was that the bad overall rowcount estimate was
leading to a bad join plan, and that should be fixed even though the
cost estimate for the indexscan itself is unrealistically small.

Changing the indexscan cost estimate would require patching the main
range-constraint-estimation code in clausesel.c.  I don't see any very
good fix for that, since it has to deal with much more general cases
than this.  In particular it doesn't really know whether it's dealing
with = or .

regards, tom lane

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


Re: [HACKERS] POSIX shared memory support

2008-03-31 Thread Tom Lane
Stephen Frost [EMAIL PROTECTED] writes:
 Finding a way for POSIX shm to do what we need, including Tom's
 concerns, without depending on SvsV shm as a crutch work around, would
 make this change much more reasonable and could be justified as moving
 to a well defined POSIX standard, and means we may be able to support
 platforms which either are new and don't implement SysV but just POSIX,
 or cases where SysV is being actively depreceated.  Neither of which is
 possible if we're stuck with using it in some cases.

Yeah, I would be far more interested in this patch if it avoided needing
SysV shmem at all.  The problem is to find an adequate substitute for
the nattch-based interlock against live children of a dead postmaster.

It's possible that file locking could be used instead, but that has its
own set of portability and reliability issues to address.  For example:
ISTR that on some NFS configurations, file locking silently doesn't
work, or might silently fail after it worked before, if the lock server
daemon should happen to crash.  And I don't even know what's available
on Windows.  So it'd need some research to make a credible proposal
along those lines.

regards, tom lane

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


Re: [HACKERS] Submission of Feature Request : RFC- for Implementing Transparent Data Encryption in P

2008-03-31 Thread sanjay sharma

Hello Heikki,
 
Although the solution could be implemented using views and functions and I am 
implementing a reference application using this approach but TDE can greatly 
reduce the design and maintenance complexcity. It would also take care of data 
protection in backups and archives.
You are correct to identify that TDE may not provide complete data security 
required for data like credit crad details but TDE seems to be ideally suited 
to take care of data privacy issues. Major chunk of the private data is of no 
interest to hackers and criminals but needs protection only from casual 
observers. To implement a full data security infrastucture to protect only 
privacy issues seems to be overkill. Compliance requirement for storing private 
data arises from each organizations own declared privacy policies and statutory 
bodies like privacy commissioners and other privacy watchdogs. These standards 
are not as strict as PCI, HIPPA or Sarnabes-Oxley
 
Compliance with HIPPA regulation requires not only maintaining all records of 
who created and updated the record but also who accessed and viewed records, 
when and in what context.
 
Cheers
 
Sanjay Sharma 
 
 
 Date: Mon, 31 Mar 2008 09:48:46 +0100 From: [EMAIL PROTECTED] To: [EMAIL 
 PROTECTED] CC: [EMAIL PROTECTED]; pgsql-hackers@postgresql.org Subject: Re: 
 [HACKERS] Submission of Feature Request : RFC- for Implementing Transparent 
 Data Encryption in P  sanjay sharma wrote:  However there are certain 
 fetures which are becoming key for putting postgres in areas where strong 
 regulatory compliance is required.TDE is very helpful in storing data where 
 there is strict privacy compliance requirement for example e.Government and 
 e.Health. All columns of personal profile/health data do not need same level 
 of security for all users and applications. Selective data encryption is very 
 handy in an architecture where different applications are pulling data from a 
 central data repository for processing and presenting to their users or where 
 different users are changing different part of data set in central 
 repository. These departmental applications may contain keys for decrypting 
 and looking at only those columns needed by their users. Encrypting just 
 needed column takes care of compliance requirement down the line in backups 
 and archives.  You could implement that using views and contrib/pgcrypto. 
 Create a view  on the underlying table that encrypts/decrypts the data on 
 access.  I'm not sure who the encryption is supposed to protect from in 
 this  scenario. From the superuser of the database server? It isn't really  
 suitable for that: the way you describe it, the encryption/decryption is  
 done in the server, so a malicious superuser that has full access to the  
 server can still capture the data before it's encrypted, and can also  
 recover the key from the running server, by crawling through system  memory 
 or installing hacked software to print it out.  It's better than nothing, 
 as it does protect from a casual non-malicious  observer, and it does 
 protect the backups, but what I'd rather see is a  system where the database 
 server never sees the data in plaintext. You  could do the 
 encryption/decryption in the client, perhaps in the driver  so that it's 
 transparent to the application.  I'm not familiar with the compliance 
 requirements you refer to. What  exactly is required?   Another area 
 where I would like to put a RFC is Auditing. A flag at the database level 
 (conf file) or in DDL which puts audit columns ( created_by, creation_date, 
 last_updated_by, last_update_date) on tables and automatically populates them 
 would be a very nice standard feature. Currently this needs code/trigger to 
 be duplicated at each table which is a big grunt. At furthur higher level a 
 way to audit data access/view for regulatory complinace like HIPPA is also 
 needed.This should not be copy of Oracle FGA which has its own limitations.  
  This could be implemented fairly easily as an external tool that queries  
 the system catalogs, and adds the required columns and triggers.  --  
 Heikki Linnakangas EnterpriseDB http://www.enterprisedb.com
_
Technology : Catch up on updates on the latest Gadgets, Reviews, Gaming and 
Tips to use technology etc.
http://computing.in.msn.com/

Re: [HACKERS] [GENERAL] ANALYZE getting dead tuple count hopelessly wrong

2008-03-31 Thread Pavan Deolasee
On Mon, Mar 31, 2008 at 9:02 PM, Tom Lane [EMAIL PROTECTED] wrote:


  [ Please see if you can stop using the redirected dead terminology ]



Apologies, will keep that in mind. Seems like a hang-over from the past :-)

  Yeah, I think I agree.  The page pruning code is set up so that changing
  a line pointer to DEAD state doesn't change the count of dead tuples in
  the table, so we are counting unreclaimed DEAD pointers as still being
  dead tuples requiring VACUUM.  ANALYZE should surely not affect that.

  It looks like there's no trivial way to get ANALYZE to do things that
  way, though.  heap_release_fetch() doesn't distinguish a DEAD line
  pointer from an unused or redirected one.  But in the current
  implementation of ANALYZE there's really no benefit to using
  heap_release_fetch anyway --- it always examines all line pointers
  on each selected page, so we might as well rewrite it to use a simple
  loop more like vacuum uses.


I agree. I would write a patch on these lines, unless you are already on to it.


Thanks,
Pavan

-- 
Pavan Deolasee
EnterpriseDB http://www.enterprisedb.com

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


Re: [HACKERS] Patch for pg_dump (function dumps)

2008-03-31 Thread Stephen Frost
* Dany DeBontridder ([EMAIL PROTECTED]) wrote:
 I often need  in command line to get the code of function, so I make a
 patch for pg_dump, thanks this patch pg_dump is able to dump only one
 functions or all the functions.

First, a couple of general comments about the patch:

#1: You need to read the developer FAQ located here:
http://www.postgresql.org/docs/faqs.FAQ_DEV.html
Particularly question 1.5, which discusses how a patch should be
submitted.
#2: The patch should be as readable as possible.  This includes not
making gratuitous whitespace changes (which are in a number of
places and just confuse things), comments like this:
/* Now we can get the object ?? */
also don't make for very easy reading.
#3: The patch should be in contextual diff format, not unified diff.
#4: Re-use existing structure and minimize code duplication
While I can understand some desire to restructure pg_dump code to
handle things as generalized objects, this patch doesn't actually go
all the way through and do that.  Instead it starts that work, only
adds support for functions, and then leaves the old methods and
whatnot the same.  Instead it should either be a large overhaul
(probably not necessary for the specific functionality being looked
for here) which is complete and well tested (and removes the old, no
longer used code), or it should be integrated into the existing
structure (which is what I would recommend here).
Given that both the new approach and the old were left after this
patch, there's some code duplication and really process
duplication happening.
#5: Given the above, I would suggest making '-B' explicitly for
functions and drop the 'function:' heading requirement.
#6: Passing an sql snippet to getFuncs to do the filtering strikes me as
a really terrible approach.  Instead, the approach used for schemas
and tables is much cleaner and using it would make it be consistant
with those other types.
#7: Again, following with the existing approach, the schemas and tables
use global variables to pass around what to include/exclude.  Unless
you're going to rewrite the whole thing to not do that, you should
follow that example when adding support for functions.  eg, getFuncs
really doesn't/shouldn't need to have its function definition
changed.
#8: Functions *can* be mixed-case, I'm pretty sure, and pg_dump should
definitely support that.  These kinds of issues would have been
handled for you if you had used processSQLNamePattern as the other
functions do.  This would also remove the need for the pg_strcat,
pg_free functions you've added, I believe.
#9: The vast majority of the code doesn't use 'pg_malloc' and so I would
hesitate to add more things which use it, and to add more pg_X
functions which then *also* are rarely used.  If it makes sense to
have pg_malloc/pg_free (and I'm not sold on that idea at all), then
it should be done consistantly, and probably seperately, from this.

This is probably enough.  My general feeling about this patch is that
it needs a rewrite and to be done using the existing structures and
following the same general processes we use for tables.  The resulting
code should be consistant and at least look like it was all written
towards a specific, defined structure.  That makes the code much more
maintainable and easier to pick up since you only have to understand one
structure which can be well documented rather than multiple not fully
thought out or documented structures.

As such, I would recommend rejecting this patch for this round and
waiting for a rewrite of it which can be reviewed during the next
commit-fest.

Thanks,

Stephen


signature.asc
Description: Digital signature


Re: [HACKERS] POSIX shared memory support

2008-03-31 Thread Stephen Frost
* Tom Lane ([EMAIL PROTECTED]) wrote:
 Yeah, I would be far more interested in this patch if it avoided needing
 SysV shmem at all.  The problem is to find an adequate substitute for
 the nattch-based interlock against live children of a dead postmaster.

Right, I had an idea about that but didn't really want to clutter the
response to the general idea with it.  At least on Linux (I don't know
if it's the case elsewhere..), creating a POSIX shm ends up creating an
actual 'file' in /dev/shm/, which you might be able to count the
hard-links to in order to get an idea of the number of processes using
it?  It was just a thought that struck me, not sure if it's at all
possible.

Thanks,

Stephen


signature.asc
Description: Digital signature


[HACKERS] pgkill

2008-03-31 Thread James Mansion
I was looking at the notify processing in async.c and I noticed that 
kill is called whether or not the
process has been signalled already, and whether or not 'this' process 
has signalled the process.


It seems unecessary to me - especially if we are on Win32 and the pgkill 
is implemented as

a CallNamedPipe.

My understanding is that signal is normally a fairly expensive operation 
at the best
of times, particularly so when its turned from a fire-and-forget to an 
RPC with

scheduling.

I appreciate that signal wishes to determine whether a process is dead, 
but it must
be questionable whether this is necessarily something that should be 
done by peers
when the information is immediately out of date and we can definitively 
determine

a crash in the master process anyway.

So:

1) why do the RPC, rather than detect death from the master process?

2) Why not use the existing compare-and-set atomic infrastructure to 
maintain
a 'pending signal' flag (or flags) in struct PGPROC and elide signals 
that are

flagged and not yet indicated as processed by the target process?

3) If we do both the above, would it not be cleaner to use an fd with a
local datagram socket than a signal on nearly all systems?  And a semaphore
on Win32? So its all picked up in select or WaitForMultipleObjects?

I know the comment in async.c is: 'but we do still send a SIGUSR2 signal,
just in case that backend missed the earlier signal for some reason.'. 
But that

seems somewhat lame - we might have multiple signals compressed but
does any system actually *lose* them?

It also occurred to me that we should not kill as we go, but accumulate a
set of pids to signal and then signal each after the iteration is 
complete so
we can do as little processing with the pg_notify resources held as 
possible,

and certainly no system calls if we can help it.

James


--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


Re: [HACKERS] [GENERAL] Can Postgres 8.x start if some disks containing tablespaces are not mounted?

2008-03-31 Thread Gurjeet Singh
On Mon, Mar 31, 2008 at 11:40 PM, Tom Lane [EMAIL PROTECTED] wrote:

 Morris Goldstein [EMAIL PROTECTED] writes:
  Suppose I have a database with $PGDATA on /dev/sda, and a tablespace
  directory on /dev/sdb. Will Postgres start successfully if /dev/sda is
  mounted and /dev/sdb is not? If not, why not?

 It will start, but you will have unpleasant failures when you try to use
 tables in the secondary tablespace ... note that if autovacuum is on,
 that is likely to happen even without any explicit action on your part.


One of the gripes I have with postgres is that, that it won't even complain
if one of the segments of a relation goes missing unless the missing segment
is referred to by an index!!!

The most troublesome part is that count(*) (i.e seq scan) scans only upto
the last sequential segment found. Here's a case in example:

Healthy:

count(*) : 2187001
size: 2441 MB
segments: 17651, .1, .2

Corrupt: 17651.1 missing
-
count(*) : 917503
size: 1024 MB
segments: 17651, .2
select max(a) from temp: 2187001 (uses index to locate the last tuple in
segment .2)

select a from temp where a = (select max(a) from temp)/2
ERROR:  could not read block 156214 of relation 1663/11511/17651: read only
0 of 8192 bytes

retore missing segment:
---
select a from temp where a = (select max(a) from temp)/2
  : 1093500


I think that the counter-argument would be that this has never been
reported in the field, but I wish our metadata records this somehow, and
reports an ERROR if it finds that a segment is missing.

Best regards,
-- 
[EMAIL PROTECTED]
[EMAIL PROTECTED] gmail | hotmail | indiatimes | yahoo }.com

EnterpriseDB http://www.enterprisedb.com

Mail sent from my BlackLaptop device


Re: [HACKERS] first time hacker ;) messing with prepared statements

2008-03-31 Thread James Mansion

Tom Lane wrote:

PFC [EMAIL PROTECTED] writes:
  
	Do the parse tree store fully qualified schema.table or  
schema.function ?



They store OIDs.
  
So, what happens if we reference a temporary table or something else 
that requires resolution

down a search path?

I believe Microsoft and Sybase have to defer some optimisation because 
of this.


James


--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


Re: [HACKERS] POSIX shared memory support

2008-03-31 Thread James Mansion

Tom Lane wrote:

Yeah, I would be far more interested in this patch if it avoided needing
SysV shmem at all.  The problem is to find an adequate substitute for
the nattch-based interlock against live children of a dead postmaster.

  
(confused) Why can't you use mmap of /dev/zero and inherit the fd into 
child processes?
(simple enough to do something similar on Win32, even if the mechanism 
isn't identical)



--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


[HACKERS] SPI support needed for EXECUTE USING

2008-03-31 Thread Tom Lane
The proposed EXECUTE USING patch represents a serious performance loss
compared to the traditional method of interpolating parameter values
into the query text, anytime the value of the parameter is important
for planning purposes.  We have fixed that in the Protocol BIND message
context by providing a way to push parameter values into the planning
process, but there is no way for plpgsql to do the same, because it
uses the SPI interface and SPI doesn't expose any way to do it.

I propose adding an additional SPI function along the lines of

int SPI_execute_with_args(const char *src,
  int nargs, Oid *argtypes,
  Datum *Values, const char *Nulls,
  bool read_only, long tcount);

to encapsulate the process of creating a one-shot plan and executing
it with specific parameter values.

Comments?

regards, tom lane

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


Re: [HACKERS] POSIX shared memory support

2008-03-31 Thread Tom Lane
Stephen Frost [EMAIL PROTECTED] writes:
 Right, I had an idea about that but didn't really want to clutter the
 response to the general idea with it.  At least on Linux (I don't know
 if it's the case elsewhere..), creating a POSIX shm ends up creating an
 actual 'file' in /dev/shm/, which you might be able to count the
 hard-links to in order to get an idea of the number of processes using
 it?  It was just a thought that struck me, not sure if it's at all
 possible.

That's not gonna work on anything but Linux, AFAIK.

regards, tom lane

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


Re: [HACKERS] [GENERAL] ANALYZE getting dead tuple count hopelessly wrong

2008-03-31 Thread Tom Lane
Pavan Deolasee [EMAIL PROTECTED] writes:
 On Mon, Mar 31, 2008 at 9:02 PM, Tom Lane [EMAIL PROTECTED] wrote:
 It looks like there's no trivial way to get ANALYZE to do things that
 way, though.  heap_release_fetch() doesn't distinguish a DEAD line
 pointer from an unused or redirected one.  But in the current
 implementation of ANALYZE there's really no benefit to using
 heap_release_fetch anyway --- it always examines all line pointers
 on each selected page, so we might as well rewrite it to use a simple
 loop more like vacuum uses.

 I agree. I would write a patch on these lines, unless you are already on to 
 it.

Please do --- I have a lot of other stuff on my plate.

regards, tom lane

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


Re: [HACKERS] actualized SQL/PSM patch

2008-03-31 Thread Stephen Frost
Pavel,

  Honestly, I havn't dug into the real patch all that deeply but I did
  notice a few minor issues which I've listed out below.  The bigger
  question I have for this patch, however, is just how close is it to
  PL/pgSQL?  If the differences are minor and far between would it be
  more reasonable to just make PL/pgSQL play double-duty and have a flag
  somewhere to indicate when it should be in 'PL/pgPSM' mode?

  Thanks.

#1: INSTALL.plpgpsm starts out saying:
Installation of PL/pgSQL
I'm guessing you just missed changing it.  Also in there: 
For installation any PL language you need superuser's rights.
should probably read:
For installation of any PL language you need superuser rights.
Or just:
To install any PL language you need to be the database superuser.

#2: pl_comp.c has a similar issue in its comments:
pl_comp.c as the top says Compiler part of the PL/pgSQL ..
plpgpsm_compile  Make an execution tree for a PL/pgSQL function.
Should read 'PL/pgPSM' there.

#3: pl_comp.c uses C++ style comments for something which I'm guessing
you didn't actually intend to even be in the patch:
//elog(ERROR, zatim konec);
in do_compile().

#4: Again in pl_comp.c there are C++ style comments, this time for
variables which can probably just be removed:
//PLpgPSM_nsitem  *nse;
//char *cp[1];

#5: In pl_exec.c, exec_stmt_open, again you have C++ style comments:
// ToDo: Holdable cursors

#6: In the expected.out, for the 'fx()' function, the CONTEXT says:
CONTEXT:  compile of PL/pgSQL function fx() near line 2
Even though it says LANGUAGE plpgpsm, which seems rather odd.

#7: gram.y also has in the comments Parser for the PL/pgSQL ..

#8: plpgpsm_compile_error_callback() passes PL/pgSQL to errcontext(),
probably the cause of #7 and fixing it and regenerating the expected
output would probably work.

#9: plerrcodes.h also has PL/pgSQL error codes in the comments at the
top.

#10: ditto for pl_exec.c Executor for the PL/pgSQL ..

#11: more error-strings being passed with PL/pgSQL in it in pl_exec.c:
 in exec_stmt_prepare() and exec_prepare_plan(), exec_stmt_execute():
 eg:
 cannot COPY to/from client in PL/pgSQL
 cannot begin/end transactions in PL/pgSQL
 cannot manipulate cursors directly in PL/pgSQL

#12: Also in the comments for plpgpsm_estate_setup are references to
 PL/pgSQL.

#13: pl_funcs.c also says Misc functions for the PL/pgSQL ..

#14: plpgpsqm_dumptree outputs:
 Execution tree of successfully compiled PL/pgSQL function
 Should be updated for PL/pgPSM

#15: Header comment in pl_handler.c also says PL/pgSQL

#16: Function-definition comment for plpgpsqm_call_handler also says
 PL/pgSQL
 ditto for plpgpsm_validator

#17: Header comment in plpgpsm.h say PL/pgSQL, other comments later as
 well, such as for the PLpgPSM_plugin struct

#18: Also for the header comment in scan.l

Enjoy,

Stephen


signature.asc
Description: Digital signature


Re: [HACKERS] pgkill

2008-03-31 Thread Tom Lane
James Mansion [EMAIL PROTECTED] writes:
 I was looking at the notify processing in async.c and I noticed that 
 kill is called whether or not the
 process has been signalled already, and whether or not 'this' process 
 has signalled the process.

 It seems unecessary to me -

It's not that easy to be sure of either of those conditions.

The notify code needs to be dumped and rewritten from scratch
--- I see little point in marginal optimizations, and none at
all in doing anything while the pg_listener table is still used
as communication mechanism.

regards, tom lane

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


Re: [HACKERS] POSIX shared memory support

2008-03-31 Thread Magnus Hagander
James Mansion wrote:
 Tom Lane wrote:
  Yeah, I would be far more interested in this patch if it avoided
  needing SysV shmem at all.  The problem is to find an adequate
  substitute for the nattch-based interlock against live children of
  a dead postmaster.
 

 (confused) Why can't you use mmap of /dev/zero and inherit the fd
 into child processes?
 (simple enough to do something similar on Win32, even if the
 mechanism isn't identical)

This is what we do on win32 today. We don't use the sysv emulation
layer anymore.

//Magnus

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


Re: [HACKERS] POSIX shared memory support

2008-03-31 Thread Tom Lane
Magnus Hagander [EMAIL PROTECTED] writes:
 James Mansion wrote:
 (confused) Why can't you use mmap of /dev/zero and inherit the fd
 into child processes?

 This is what we do on win32 today. We don't use the sysv emulation
 layer anymore.

Did we ever find an interlock that makes the win32 implementation
safe against the postmaster-dead-children-still-alive scenario?

regards, tom lane

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


Re: [HACKERS] pgkill

2008-03-31 Thread Andrew Dunstan



James Mansion wrote:
I was looking at the notify processing in async.c and I noticed that 
kill is called whether or not the
process has been signalled already, and whether or not 'this' process 
has signalled the process.


It seems unecessary to me - especially if we are on Win32 and the 
pgkill is implemented as

a CallNamedPipe.

My understanding is that signal is normally a fairly expensive 
operation at the best
of times, particularly so when its turned from a fire-and-forget to an 
RPC with

scheduling.

I appreciate that signal wishes to determine whether a process is 
dead, but it must
be questionable whether this is necessarily something that should be 
done by peers
when the information is immediately out of date and we can 
definitively determine

a crash in the master process anyway.

So:

1) why do the RPC, rather than detect death from the master process?

2) Why not use the existing compare-and-set atomic infrastructure to 
maintain
a 'pending signal' flag (or flags) in struct PGPROC and elide signals 
that are

flagged and not yet indicated as processed by the target process?

3) If we do both the above, would it not be cleaner to use an fd with a
local datagram socket than a signal on nearly all systems?  And a 
semaphore

on Win32? So its all picked up in select or WaitForMultipleObjects?

I know the comment in async.c is: 'but we do still send a SIGUSR2 signal,
just in case that backend missed the earlier signal for some reason.'. 
But that

seems somewhat lame - we might have multiple signals compressed but
does any system actually *lose* them?

It also occurred to me that we should not kill as we go, but accumulate a
set of pids to signal and then signal each after the iteration is 
complete so
we can do as little processing with the pg_notify resources held as 
possible,

and certainly no system calls if we can help it.




This whole area is due for a revamp, which I am planning on doing as 
part of implementing notification payloads. Work on that will probably 
start in about 2 weeks.


cheers

andrew

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


Re: [HACKERS] POSIX shared memory support

2008-03-31 Thread Magnus Hagander
Tom Lane wrote:
 Magnus Hagander [EMAIL PROTECTED] writes:
  James Mansion wrote:
  (confused) Why can't you use mmap of /dev/zero and inherit the fd
  into child processes?
 
  This is what we do on win32 today. We don't use the sysv emulation
  layer anymore.
 
 Did we ever find an interlock that makes the win32 implementation
 safe against the postmaster-dead-children-still-alive scenario?

Yes. I don't remember the details offhand (and I'm at the airport right
now), but the code that I put in there passed all those checks that we
could think of. (The one that the old, sysv emulating, code didn't as
well)

//Magnus

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


Re: [HACKERS] [GENERAL] Connection to PostgreSQL Using Certificate: Wrong Permissions on Private Key File

2008-03-31 Thread korry



Now libpq doesn't have any provision for DETAIL or HINT in its
locally-generated messages at the moment, so we can't just duplicate
the backend message, but we could do something like this example
from elsewhere in libpq:

if (stat_buf.st_mode  (S_IRWXG | S_IRWXO))
{
fprintf(stderr,
libpq_gettext(WARNING: password file \%s\ has world or group read 
access; permission should be u=rw (0600)\n),
pgpassfile);
return NULL;
}
  
Hmmm... I'm not crazy about libpq printing error messages to stderr.  
The client application can't intercept those messages. And those 
messages will often get lost - many client applications don't have 
useful stderr streams (think GUI application on Win32).


 -- Korry

--

 Korry Douglas  [EMAIL PROTECTED]
 EnterpriseDBhttp://www.enterprisedb.com


--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


[HACKERS] Guessing future postgresql features

2008-03-31 Thread Rafael Martinez
Hello

I am preparing a presentation about postgresql for GoOpen2008 [1] in
Norway. I am trying to guess some of the 'main' new features we could
expect to see in the next versions of postgresql.

After reading different documents on Internet, I have this list which I
plan to include in my presentation. Does anyone disagree with it?  ;-)

* Auto-tuning / auto-configuration
* Easy update-in-place - 'pgmigrator'
* More SQL99 and SQL2003 features
* Update-in-place optimizations which enhance OLTP performance
* Auto partitioning / Dynamic partitioning
* External tables interfaces (SQL/MED compliant)
* More exotic datatypes
* More query optimizer improvements
* Elimination of vacuum
* Improve XML support
* Pre-parsing phase that converts non-ISO syntax to supported syntax.

Thanks in advance for your feedback.

[1] http://friprog.no/ez/index.php?/nor/English

regards,
-- 
 Rafael Martinez, [EMAIL PROTECTED]
 Center for Information Technology Services
 University of Oslo, Norway

 PGP Public Key: http://folk.uio.no/rafael/

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


Re: [HACKERS] Cast as compound type

2008-03-31 Thread korry

David Fetter wrote:

I'd like to take a whack at making set-returning functions returning
SETOF RECORD a little more fun to use.  Let's imagine that we have a
table foo and a function returning SETOF RECORD that can return foos.
The call might look something like:

SELECT a, b, c
FROM f(ROW OF foo)
WHERE ...;

This would make it much easier and less error-prone to use SETOF
RECORD.
  
David, it sounds like you really want to declare the return type of the 
function?  In your above example, you want to say that, in this 
particular invocation, function f() returns a SETOF foo's.  Is that correct?


If you were to create function that returns a RECORD (not a SETOF 
RECORD), you would call it like this:


   SELECT * FROM f() AS (column1 type1, column2 type2, column3 type3);

In your case, I think you want to declare the return type using an 
explicitly defined composite type (possibly a table row); which would 
imply syntax such as:


   SELECT * FROM f() AS (foo);
  or
   SELECT * FROM f() AS (foo.*);

So, it seems like you want the syntax to look more like:

   SELECT a,b,c, FROM f() AS (SETOF foo);

Does that make sense to you?  Your original syntax implied that the ROW 
OF foo was somehow related to the function arguments.
  
 -- Korry



--

 Korry Douglas  [EMAIL PROTECTED]
 EnterpriseDBhttp://www.enterprisedb.com


--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


[HACKERS] How embarrassing: optimization of a one-shot query doesn't work

2008-03-31 Thread Tom Lane
While testing the changes I was making to Pavel's EXECUTE USING patch
to ensure that parameter values were being provided to the planner,
it became painfully obvious that the planner wasn't actually *doing*
anything with them.  For example

execute 'select count(*) from foo where x like $1' into c using $1;

wouldn't generate an indexscan when $1 was of the form 'prefix%'.

Some investigation showed that the planner is using the passed values
for estimation purposes, but not for any purposes where the value *must*
be correct (not only this LIKE-optimization, but constraint exclusion,
for instance).  The reason is that the parameter values are made
available to estimate_expression_value but not to eval_const_expressions.
This is a thinko in a cleanup patch I made early in 8.3 development:
http://archives.postgresql.org/pgsql-committers/2007-02/msg00352.php
I said to myself eval_const_expressions doesn't need any context,
because a constant expression's value must be independent of context,
so I can avoid changing its API.  Silly me.

The implication of this is that 8.3 is significantly worse than 8.2
in optimizing unnamed statements in the extended-Query protocol;
a feature that JDBC, at least, relies on.

The fix is simple: add PlannerInfo to eval_const_expressions's
parameter list, as was done for estimate_expression_value.  I am
slightly hesitant to do this in a stable branch, since it would break
any third-party code that might be calling that function.  I doubt there
is currently any production-grade code doing so, but if anyone out there
is actively using those planner hooks we put into 8.3, it's conceivable
this would affect them.

Still, the performance regression here is bad enough that I think there
is little choice.  Comments/objections?

regards, tom lane

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


Re: [HACKERS] Guessing future postgresql features

2008-03-31 Thread Gregory Stark
Rafael Martinez [EMAIL PROTECTED] writes:

 * Update-in-place optimizations which enhance OLTP performance
 * Improve XML support

These made it into 8.3. There could be more enhancements and more XML support
but you're probably looking at the stuff which already made 8.3.

 * Elimination of vacuum

Nobody's really proposed eliminating vacuum altogether but we're slowly
chipping away at it. One of the projects on the table for 8.4 would make it
much more efficient, especially for large tables which are partly static. So i
would say faster vacuum with reduced impact rather than elimination

 * Auto-tuning / auto-configuration
 * Easy update-in-place - 'pgmigrator'
 * Auto partitioning / Dynamic partitioning
 * External tables interfaces (SQL/MED compliant)
 * More exotic datatypes

All of these are on the table to one degree or another. But there's no
guarantees.

 * More SQL99 and SQL2003 features
 * More query optimizer improvements

These are pretty safe bets. I think Tom's already done some optimizer
improvements :)

 * Pre-parsing phase that converts non-ISO syntax to supported syntax.

I don't know what this refers to but it doesn't sound like the kind of thing
Postgres gets involved in.

-- 
  Gregory Stark
  EnterpriseDB  http://www.enterprisedb.com
  Ask me about EnterpriseDB's RemoteDBA services!

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


Re: [HACKERS] How embarrassing: optimization of a one-shot query doesn't work

2008-03-31 Thread Stephen Frost
* Tom Lane ([EMAIL PROTECTED]) wrote:
 The fix is simple: add PlannerInfo to eval_const_expressions's
 parameter list, as was done for estimate_expression_value.  I am
 slightly hesitant to do this in a stable branch, since it would break
 any third-party code that might be calling that function.  I doubt there
 is currently any production-grade code doing so, but if anyone out there
 is actively using those planner hooks we put into 8.3, it's conceivable
 this would affect them.
 
 Still, the performance regression here is bad enough that I think there
 is little choice.  Comments/objections?

I agree that we should update stable to fix this performance regression,
given the gravity of it.  I also feel that we need to do so ASAP, to
minimize the risk of people being affected by it.  The longer we wait on
it the more likely someone will write something which is affected.

The constraint-exclusion not being used will be a huge impact and
problem for people moving partitioned-data with dynamic pl/pgsql
generation functions to 8.3.

Robert, I'm suprised you weren't affected, or have you just not noticed
yet due to your fancy new-to-you hardware? ;)

Stephen


signature.asc
Description: Digital signature


Re: [HACKERS] Guessing future postgresql features

2008-03-31 Thread Jonah H. Harris
On Mon, Mar 31, 2008 at 7:02 PM, Rafael Martinez
[EMAIL PROTECTED] wrote:
  * Auto-tuning / auto-configuration

Perhaps.  Though, people have been saying they were going to do it
since 2001, and yet nothing substantial exists.

  * Easy update-in-place - 'pgmigrator'

This should be upgrade-in-place, not update-in-place

  * More SQL99 and SQL2003 features

Likely.

  * Update-in-place optimizations which enhance OLTP performance

Postgres does not have update-in-place.  I would just say OLTP
performance enhancements.

  * Auto partitioning / Dynamic partitioning

Likely.

  * External tables interfaces (SQL/MED compliant)

It would be nice to see distributed/federated code integrated into the
core, but I don't see it happening anytime soon.

  * More exotic datatypes

Doubt it.

  * More query optimizer improvements

Always

  * Elimination of vacuum

I wish.

  * Improve XML support

Probably.

  * Pre-parsing phase that converts non-ISO syntax to supported syntax.

Doubtful.  That's a pgfoundry-type external project.

-- 
Jonah H. Harris, Sr. Software Architect | phone: 732.331.1324
EnterpriseDB Corporation | fax: 732.331.1301
499 Thornall Street, 2nd Floor | [EMAIL PROTECTED]
Edison, NJ 08837 | http://www.enterprisedb.com/

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


Re: [HACKERS] How embarrassing: optimization of a one-shot query doesn't work

2008-03-31 Thread Tom Lane
Stephen Frost [EMAIL PROTECTED] writes:
 * Tom Lane ([EMAIL PROTECTED]) wrote:
 Still, the performance regression here is bad enough that I think there
 is little choice.  Comments/objections?

 I agree that we should update stable to fix this performance regression,
 given the gravity of it.  I also feel that we need to do so ASAP, to
 minimize the risk of people being affected by it.  The longer we wait on
 it the more likely someone will write something which is affected.

In the normal course of events I'd expect that we'd put out 8.3.2
in a month or so.  I'm not quite convinced that this issue is worth
speeding the cycle all by itself.  We've done that for data-loss
issues but never before for a mere performance problem.

The main reason I wanted to make some noise about this is to find out
if anyone is actually trying to call eval_const_expressions (or
relation_excluded_by_constraints, which it turned out needed to change
also) from 8.3 add-on code.  If anyone squawks we could think about a
faster update ...

regards, tom lane

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


Re: [HACKERS] [PATCHES] [EMAIL PROTECTED]: Re: [BUGS] Problem identifying constraints which should not be inherited]

2008-03-31 Thread Alex Hunsaker
On Mon, Mar 31, 2008 at 2:36 AM, NikhilS [EMAIL PROTECTED] wrote:
 Hi Alex,

 I was taking a look at this patch to add the pg_dump related changes. Just
 wanted to give you a heads up as this patch crashes if we run make
 installcheck. Seems there is an issue introduced in the CREATE TABLE
 REFERENCES code path due to your patch (this is without my pg_dump changes
 just to be sure).  Looks like some memory overwrite issue. The trace is as
 follows:

Ouch, sorry i did not reply sooner... been out with the flu.  Oddly
enough make check and make installcheck worked great on my 64 bit box.
 But on my laptop(32 bits) make check lights up like a christmas tree.
 Which is why I did not notice the problem. :(

Attached is a patch that fixes the problem... (it was debugging from
an earlier version)
diff --git a/src/backend/parser/parse_utilcmd.c b/src/backend/parser/parse_utilcmd.c
index f105d39..7d12156 100644
*** a/src/backend/parser/parse_utilcmd.c
--- /bsrc/backend/parser/parse_utilcmd.c
*** transformColumnDefinition(ParseState *ps
*** 409,417 
  	{
  		constraint = lfirst(clist);
  
- 		constraint-is_local = true;
- 		constraint-inhcount = 0;
- 
  		/*
  		 * If this column constraint is a FOREIGN KEY constraint, then we fill
  		 * in the current attribute's name and throw it into the list of FK
--- 409,414 

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


Re: [HACKERS] How embarrassing: optimization of a one-shot query doesn't work

2008-03-31 Thread Andrew Dunstan



Tom Lane wrote:

The main reason I wanted to make some noise about this is to find out
if anyone is actually trying to call eval_const_expressions (or
relation_excluded_by_constraints, which it turned out needed to change
also) from 8.3 add-on code.  If anyone squawks we could think about a
faster update ...


  


That assumes that someone working on using the planner hooks will read 
this thread - which might be reasonable - I guess they number of likely 
users is fairly small. But if they might miss it then it would be best 
to fix it ASAP, ISTM.


cheers

andrew

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


Re: [HACKERS] [GENERAL] Connection to PostgreSQL Using Certificate: Wrong Permissions on Private Key File

2008-03-31 Thread Tom Lane
korry [EMAIL PROTECTED] writes:
 Hmmm... I'm not crazy about libpq printing error messages to stderr.  

Me neither, feel free to submit a patch.

The basic problem here is that the obvious fix involves feeding
the message to a PQnoticeProcessor callback, but these messages
occur during connection setup and there's no way to have called
PQsetNoticeProcessor yet.

So I think you've got to invent some green-field API if you want
to improve it, and that means nothing will happen out in the
real world for three to five years :-(

regards, tom lane

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


Re: [JDBC] Re: [HACKERS] How embarrassing: optimization of a one-shot query doesn't work

2008-03-31 Thread Tom Lane
Andrew Dunstan [EMAIL PROTECTED] writes:
 Tom Lane wrote:
 If anyone squawks we could think about a
 faster update ...

 That assumes that someone working on using the planner hooks will read 
 this thread - which might be reasonable - I guess they number of likely 
 users is fairly small. But if they might miss it then it would be best 
 to fix it ASAP, ISTM.

Well, it's not like we have never before changed internal APIs in a
minor update.  (There have been security-related cases where we gave
*zero* notice of such changes.)  Nor am I willing to surrender the
option to do so again.  If there's somebody out there with a real
problem with this change, they need to speak up.

regards, tom lane

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


Re: [JDBC] Re: [HACKERS] How embarrassing: optimization of a one-shot query doesn't work

2008-03-31 Thread Guillaume Smet
On Tue, Apr 1, 2008 at 7:35 AM, Tom Lane [EMAIL PROTECTED] wrote:
  Well, it's not like we have never before changed internal APIs in a
  minor update.  (There have been security-related cases where we gave
  *zero* notice of such changes.)  Nor am I willing to surrender the
  option to do so again.  If there's somebody out there with a real
  problem with this change, they need to speak up.

+1 to fix it ASAP. A lot of people usually wait for 8.x.1 before
considering a migration and people are usually quite cautious with the
8.3 migration because of all the cast errors in the existing app.

Another question is how we can be sure it doesn't happen again. The
easiest way to test this is probably to have a JDBC test testing this
exact feature in the future benchfarm. Any comment?

-- 
Guillaume

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers