Hi patchers/hackers.

Here's a patch for initdb that does two things.

1) Encloses the created rulenames in quotes to preserve case
   in the creation step. (stores _RETpg... instead of _retpg...)
   I believe _RET is standard for views.
   
2) Renames pg_view to pg_views and pg_rule to pg_rules.
   I believe Jan and myself agreed this would be a "good idea"
   
Both aspects open for discussion.

Are there any docs considerations?

Keith.
Fri, 4 Sep 1998 00:27:34 +0100 (BST)
Keith Parks <emkxp01@mtcc.demon.co.uk>
Patch for initdb
Applied.  Let's see if this fixes the pg_user problem.


> Hi patchers/hackers.
> 
> Here's a patch for initdb that does two things.
> 
> 1) Encloses the created rulenames in quotes to preserve case
>    in the creation step. (stores _RETpg... instead of _retpg...)
>    I believe _RET is standard for views.
>    
> 2) Renames pg_view to pg_views and pg_rule to pg_rules.
>    I believe Jan and myself agreed this would be a "good idea"
>    
> Both aspects open for discussion.
> 
> Are there any docs considerations?
> 
> Keith. 

>   
Content-Description: initdb.sh.patch

> *** src/bin/initdb/initdb.sh.orig	Thu Sep  3 23:04:10 1998
> --- src/bin/initdb/initdb.sh	Thu Sep  3 23:14:30 1998
> ***************
> *** 425,431 ****
>   	postgres $PGSQL_OPT template1 > /dev/null
>   mv $PGDATA/base/template1/xpg_user $PGDATA/base/template1/pg_user
>   
> ! echo "CREATE RULE _RETpg_user AS ON SELECT TO pg_user DO INSTEAD	\
>   	    SELECT usename, usesysid, usecreatedb, usetrace,		\
>   	           usesuper, usecatupd, '********'::text as passwd,	\
>   		   valuntil FROM pg_shadow;" | \
> --- 425,431 ----
>   	postgres $PGSQL_OPT template1 > /dev/null
>   mv $PGDATA/base/template1/xpg_user $PGDATA/base/template1/pg_user
>   
> ! echo "CREATE RULE \"_RETpg_user\" AS ON SELECT TO pg_user DO INSTEAD	\
>   	    SELECT usename, usesysid, usecreatedb, usetrace,		\
>   	           usesuper, usecatupd, '********'::text as passwd,	\
>   		   valuntil FROM pg_shadow;" | \
> ***************
> *** 433,465 ****
>   echo "REVOKE ALL on pg_shadow FROM public" | \
>   	postgres $PGSQL_OPT template1 > /dev/null
>   
> ! echo "Creating view pg_rule"
> ! echo "CREATE TABLE xpg_rule (		\
>   	    rulename	name,		\
>   	    definition	text);" | postgres $PGSQL_OPT template1 > /dev/null
> ! #move it into pg_rule
> ! echo "UPDATE pg_class SET relname = 'pg_rule' WHERE relname = 'xpg_rule';" |\
>   	postgres $PGSQL_OPT template1 > /dev/null
> ! echo "UPDATE pg_type SET typname = 'pg_rule' WHERE typname = 'xpg_rule';" |\
>   	postgres $PGSQL_OPT template1 > /dev/null
> ! mv $PGDATA/base/template1/xpg_rule $PGDATA/base/template1/pg_rule
>   
> ! echo "CREATE RULE _RETpg_rule AS ON SELECT TO pg_rule DO INSTEAD	\
>   	    SELECT rulename, pg_get_ruledef(rulename) AS definition	\
>   	      FROM pg_rewrite;" | postgres $PGSQL_OPT template1 > /dev/null
>   
> ! echo "Creating view pg_view"
> ! echo "CREATE TABLE xpg_view (		\
>   	    viewname	name,		\
>   	    definition	text);" | postgres $PGSQL_OPT template1 > /dev/null
> ! #move it into pg_view
> ! echo "UPDATE pg_class SET relname = 'pg_view' WHERE relname = 'xpg_view';" |\
>   	postgres $PGSQL_OPT template1 > /dev/null
> ! echo "UPDATE pg_type SET typname = 'pg_view' WHERE typname = 'xpg_view';" |\
>   	postgres $PGSQL_OPT template1 > /dev/null
> ! mv $PGDATA/base/template1/xpg_view $PGDATA/base/template1/pg_view
>   
> ! echo "CREATE RULE _RETpg_view AS ON SELECT TO pg_view DO INSTEAD	\
>   	    SELECT relname AS viewname, 				\
>   	           pg_get_viewdef(relname) AS definition		\
>   	      FROM pg_class WHERE relhasrules AND			\
> --- 433,465 ----
>   echo "REVOKE ALL on pg_shadow FROM public" | \
>   	postgres $PGSQL_OPT template1 > /dev/null
>   
> ! echo "Creating view pg_rules"
> ! echo "CREATE TABLE xpg_rules (		\
>   	    rulename	name,		\
>   	    definition	text);" | postgres $PGSQL_OPT template1 > /dev/null
> ! #move it into pg_rules
> ! echo "UPDATE pg_class SET relname = 'pg_rules' WHERE relname = 'xpg_rules';" |\
>   	postgres $PGSQL_OPT template1 > /dev/null
> ! echo "UPDATE pg_type SET typname = 'pg_rules' WHERE typname = 'xpg_rules';" |\
>   	postgres $PGSQL_OPT template1 > /dev/null
> ! mv $PGDATA/base/template1/xpg_rules $PGDATA/base/template1/pg_rules
>   
> ! echo "CREATE RULE \"_RETpg_rules\" AS ON SELECT TO pg_rules DO INSTEAD	\
>   	    SELECT rulename, pg_get_ruledef(rulename) AS definition	\
>   	      FROM pg_rewrite;" | postgres $PGSQL_OPT template1 > /dev/null
>   
> ! echo "Creating view pg_views"
> ! echo "CREATE TABLE xpg_views (		\
>   	    viewname	name,		\
>   	    definition	text);" | postgres $PGSQL_OPT template1 > /dev/null
> ! #move it into pg_views
> ! echo "UPDATE pg_class SET relname = 'pg_views' WHERE relname = 'xpg_views';" |\
>   	postgres $PGSQL_OPT template1 > /dev/null
> ! echo "UPDATE pg_type SET typname = 'pg_views' WHERE typname = 'xpg_views';" |\
>   	postgres $PGSQL_OPT template1 > /dev/null
> ! mv $PGDATA/base/template1/xpg_views $PGDATA/base/template1/pg_views
>   
> ! echo "CREATE RULE \"_RETpg_views\" AS ON SELECT TO pg_views DO INSTEAD	\
>   	    SELECT relname AS viewname, 				\
>   	           pg_get_viewdef(relname) AS definition		\
>   	      FROM pg_class WHERE relhasrules AND			\


-- 
Bruce Momjian                          |  830 Blythe Avenue
maillist@candle.pha.pa.us              |  Drexel Hill, Pennsylvania 19026
  +  If your life is a hard drive,     |  (610) 353-9879(w)
  +  Christ can be your backup.        |  (610) 853-3000(h)

Wed, 9 Sep 1998 14:17:31 -0400 (EDT)
Bruce Momjian <maillist@candle.pha.pa.us>
Re: [HACKERS] Patch for initdb
> Applied.  Let's see if this fixes the pg_user problem.

Looks like not, and even if it did I would be worried. We shouldn't have
segfaults from query cleanup even if a table name is a bit screwy...

postgres=> select * from pg_user;
pqReadData() -- backend closed the channel unexpectedly.

> > Here's a patch for initdb that does two things.
> > Are there any docs considerations?

There is a diagram of system tables which is now out of date. No real
mention of these tables elsewhere in the sgml docs (yet). Feel free to
write some, but the patch by itself doesn't obligate you to :)

                    - Tom

Thu, 10 Sep 1998 01:54:23 +0000
"Thomas G. Lockhart" <lockhart@alumni.caltech.edu>
Re: [HACKERS] Patch for initdb