Patch for initdb

Started by Keith Parksover 27 years ago4 messageshackers
Jump to latest
#1Keith Parks
emkxp01@mtcc.demon.co.uk

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.

Attachments:

initdb.sh.patchtext/plain; charset=us-ascii; name=initdb.sh.patch; x-unix-mode=0644Download+30-30
#2Bruce Momjian
bruce@momjian.us
In reply to: Keith Parks (#1)
Re: [HACKERS] 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)
#3Keith Parks
emkxp01@mtcc.demon.co.uk
In reply to: Bruce Momjian (#2)
Re: [PATCHES] Re: [HACKERS] Patch for initdb

Bruce Momjian

Applied. Let's see if this fixes the pg_user problem.

I'm not sure the pg_user problem is related to the _ret/_RET
translation but I have my fingers crossed for you.

It's strange but a week ago I seemed to have ALL the problems
now PostgreSQL works without any major problems on my system.

I get exactly 3 regression failures.

1) float8, SIGFPE, but expected.
2) geometry, precision error at the lowest level.
3) run_ruletest, postgres/pgsql username.

FYI: SPARC/Linux (Redhat 4.2)

Keith.

#4Thomas Lockhart
lockhart@alumni.caltech.edu
In reply to: Bruce Momjian (#2)
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