Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit bf56f07

Browse files
committed
Make OIDs optional, per discussions in pghackers. WITH OIDS is still the
default, but OIDS are removed from many system catalogs that don't need them. Some interesting side effects: TOAST pointers are 20 bytes not 32 now; pg_description has a three-column key instead of one. Bugs fixed in passing: BINARY cursors work again; pg_class.relhaspkey has some usefulness; pg_dump dumps comments on indexes, rules, and triggers in a valid order. initdb forced.
1 parent d062f0f commit bf56f07

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+1960
-1581
lines changed

contrib/chkpass/chkpass.sql

+2-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
-- darcy@druid.net
55
-- http://www.druid.net/darcy/
66
--
7-
-- $Header: /cvsroot/pgsql/contrib/chkpass/Attic/chkpass.sql,v 1.1 2001/05/03 12:32:13 darcy Exp $
7+
-- $Header: /cvsroot/pgsql/contrib/chkpass/Attic/chkpass.sql,v 1.2 2001/08/10 18:57:32 tgl Exp $
88
-- best viewed with tabs set to 4
99
-- %%PGDIR%% changed to your local directory where modules is
1010
--
@@ -73,9 +73,7 @@ create operator <> (
7373
procedure = ne
7474
);
7575

76-
INSERT INTO pg_description (objoid, description)
77-
SELECT oid, 'password type with checks'
78-
FROM pg_type WHERE typname = 'chkpass';
76+
COMMENT ON TYPE chkpass IS 'password type with checks';
7977

8078
--
8179
-- eof

contrib/findoidjoins/README.findoidjoins

+9-7
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ it on anything but an empty database, such as template1.
99
Uses pgeasy library.
1010

1111
Run on an empty database, it returns the system join relationships (shown
12-
below for 7.1). Note that unexpected matches may indicate bogus entries
12+
below for 7.2). Note that unexpected matches may indicate bogus entries
1313
in system tables --- don't accept a peculiar match without question.
1414
In particular, a field shown as joining to more than one target table is
15-
probably messed up. In 7.1, the *only* field that should join to more
15+
probably messed up. In 7.2, the *only* field that should join to more
1616
than one target is pg_description.objoid. (Running make_oidjoins_check
1717
is an easy way to spot fields joining to more than one table, BTW.)
1818

@@ -27,9 +27,8 @@ revision in the patterns of cross-links between system tables.
2727
(Ideally we'd just regenerate the script as part of the regression
2828
tests themselves, but that seems too slow...)
2929

30-
NOTE: in 7.1, make_oidjoins_check produces two bogus join checks, one for
31-
pg_database.datlastsysoid => pg_description.oid and one for
32-
pg_class.relfilenode => pg_class.oid. These are artifacts and should not
30+
NOTE: in 7.2, make_oidjoins_check produces one bogus join check, for
31+
pg_class.relfilenode => pg_class.oid. This is an artifact and should not
3332
be added to the oidjoins regress test.
3433

3534
---------------------------------------------------------------------------
@@ -41,13 +40,13 @@ Join pg_aggregate.aggtranstype => pg_type.oid
4140
Join pg_aggregate.aggfinaltype => pg_type.oid
4241
Join pg_am.amgettuple => pg_proc.oid
4342
Join pg_am.aminsert => pg_proc.oid
44-
Join pg_am.amdelete => pg_proc.oid
4543
Join pg_am.ambeginscan => pg_proc.oid
4644
Join pg_am.amrescan => pg_proc.oid
4745
Join pg_am.amendscan => pg_proc.oid
4846
Join pg_am.ammarkpos => pg_proc.oid
4947
Join pg_am.amrestrpos => pg_proc.oid
5048
Join pg_am.ambuild => pg_proc.oid
49+
Join pg_am.ambulkdelete => pg_proc.oid
5150
Join pg_am.amcostestimate => pg_proc.oid
5251
Join pg_amop.amopid => pg_am.oid
5352
Join pg_amop.amopclaid => pg_opclass.oid
@@ -61,6 +60,7 @@ Join pg_class.reltype => pg_type.oid
6160
Join pg_class.relam => pg_am.oid
6261
Join pg_class.reltoastrelid => pg_class.oid
6362
Join pg_class.reltoastidxid => pg_class.oid
63+
Join pg_description.classoid => pg_class.oid
6464
Join pg_index.indexrelid => pg_class.oid
6565
Join pg_index.indrelid => pg_class.oid
6666
Join pg_opclass.opcdeftype => pg_type.oid
@@ -78,7 +78,9 @@ Join pg_proc.prolang => pg_language.oid
7878
Join pg_proc.prorettype => pg_type.oid
7979
Join pg_rewrite.ev_class => pg_class.oid
8080
Join pg_statistic.starelid => pg_class.oid
81-
Join pg_statistic.staop => pg_operator.oid
81+
Join pg_statistic.staop1 => pg_operator.oid
82+
Join pg_statistic.staop2 => pg_operator.oid
83+
Join pg_statistic.staop3 => pg_operator.oid
8284
Join pg_trigger.tgrelid => pg_class.oid
8385
Join pg_trigger.tgfoid => pg_proc.oid
8486
Join pg_type.typrelid => pg_class.oid

contrib/findoidjoins/findoidjoins.c

+5-7
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ main(int argc, char **argv)
3838
FROM pg_class c, pg_attribute a, pg_type t \
3939
WHERE a.attnum > 0 AND \
4040
relkind = 'r' AND \
41-
relhasrules = 'f' AND \
4241
(typname = 'oid' OR \
4342
typname = 'regproc') AND \
4443
a.attrelid = c.oid AND \
@@ -52,8 +51,7 @@ main(int argc, char **argv)
5251
DECLARE c_relations BINARY CURSOR FOR \
5352
SELECT relname \
5453
FROM pg_class c \
55-
WHERE relkind = 'r' AND \
56-
relhasrules = 'f' \
54+
WHERE relkind = 'r' AND relhasoids \
5755
ORDER BY 1; \
5856
");
5957
doquery("FETCH ALL IN c_relations");
@@ -71,14 +69,14 @@ main(int argc, char **argv)
7169
sprintf(query, "\
7270
DECLARE c_matches BINARY CURSOR FOR \
7371
SELECT count(*) \
74-
FROM %s t1, %s t2 \
75-
WHERE t1.%s = t2.oid ", relname, relname2, attname);
72+
FROM \"%s\" t1, \"%s\" t2 \
73+
WHERE t1.\"%s\" = t2.oid ", relname, relname2, attname);
7674
else
7775
sprintf(query, "\
7876
DECLARE c_matches BINARY CURSOR FOR \
7977
SELECT count(*) \
80-
FROM %s t1, %s t2 \
81-
WHERE RegprocToOid(t1.%s) = t2.oid ", relname, relname2, attname);
78+
FROM \"%s\" t1, \"%s\" t2 \
79+
WHERE RegprocToOid(t1.\"%s\") = t2.oid ", relname, relname2, attname);
8280

8381
doquery(query);
8482
doquery("FETCH ALL IN c_matches");

contrib/findoidjoins/make_oidjoins_check

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#! /bin/sh
22

33
# You first run findoidjoins on the template1 database, and send that
4-
# output into this file to generate a list of SQL statements.
4+
# output into this script to generate a list of SQL statements.
55

66
# NOTE: any field that findoidjoins thinks joins to more than one table
77
# will NOT be checked by the output of this script. You should be
@@ -41,7 +41,7 @@ $AWK -F'[ \.]' '\
4141
}
4242
{
4343
printf "\
44-
SELECT oid, %s.%s \n\
44+
SELECT ctid, %s.%s \n\
4545
FROM %s \n\
4646
WHERE %s.%s != 0 AND \n\
4747
NOT EXISTS(SELECT * FROM %s AS t1 WHERE t1.oid = %s.%s);\n",

contrib/intarray/_int.sql.in

+5-20
Original file line numberDiff line numberDiff line change
@@ -11,42 +11,27 @@ BEGIN TRANSACTION;
1111
CREATE FUNCTION _int_contains(_int4, _int4) RETURNS bool
1212
AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict);
1313

14-
INSERT INTO pg_description (objoid, description)
15-
SELECT oid, 'contains'::text
16-
FROM pg_proc
17-
WHERE proname = '_int_contains'::name;
14+
COMMENT ON FUNCTION _int_contains(_int4, _int4) IS 'contains';
1815

1916
CREATE FUNCTION _int_contained(_int4, _int4) RETURNS bool
2017
AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict);
2118

22-
INSERT INTO pg_description (objoid, description)
23-
SELECT oid, 'contained in'::text
24-
FROM pg_proc
25-
WHERE proname = '_int_contained'::name;
19+
COMMENT ON FUNCTION _int_contained(_int4, _int4) IS 'contained in';
2620

2721
CREATE FUNCTION _int_overlap(_int4, _int4) RETURNS bool
2822
AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict);
2923

30-
INSERT INTO pg_description (objoid, description)
31-
SELECT oid, 'overlaps'::text
32-
FROM pg_proc
33-
WHERE proname = '_int_overlap'::name;
24+
COMMENT ON FUNCTION _int_overlap(_int4, _int4) IS 'overlaps';
3425

3526
CREATE FUNCTION _int_same(_int4, _int4) RETURNS bool
3627
AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict);
3728

38-
INSERT INTO pg_description (objoid, description)
39-
SELECT oid, 'same as'::text
40-
FROM pg_proc
41-
WHERE proname = '_int_same'::name;
29+
COMMENT ON FUNCTION _int_same(_int4, _int4) IS 'same as';
4230

4331
CREATE FUNCTION _int_different(_int4, _int4) RETURNS bool
4432
AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict);
4533

46-
INSERT INTO pg_description (objoid, description)
47-
SELECT oid, 'different'::text
48-
FROM pg_proc
49-
WHERE proname = '_int_different'::name;
34+
COMMENT ON FUNCTION _int_different(_int4, _int4) IS 'different';
5035

5136
-- support routines for indexing
5237

doc/src/sgml/catalogs.sgml

+50-13
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<!--
22
Documentation of the system catalogs, directed toward PostgreSQL developers
3-
$Header: /cvsroot/pgsql/doc/src/sgml/catalogs.sgml,v 2.19 2001/07/15 22:48:15 tgl Exp $
3+
$Header: /cvsroot/pgsql/doc/src/sgml/catalogs.sgml,v 2.20 2001/08/10 18:57:32 tgl Exp $
44
-->
55

66
<chapter id="catalogs">
@@ -532,9 +532,9 @@
532532
<para>
533533
<structname>pg_class</structname> catalogues tables and mostly
534534
everything else that has columns or is otherwise similar to a
535-
table. This includes indexes (but see
535+
table. This includes indexes (but see also
536536
<structname>pg_index</structname>), sequences, views, and some
537-
kinds of special relation kinds. Below, when we mean all of these
537+
kinds of special relation. Below, when we mean all of these
538538
kinds of objects we speak of <quote>relations</quote>. Not all
539539
fields are meaningful for all relation types.
540540
</para>
@@ -565,8 +565,8 @@
565565
<entry><type>oid</type></entry>
566566
<entry>pg_type.oid</entry>
567567
<entry>
568-
The data type that corresponds to this table (not functional,
569-
only set for system tables)
568+
The OID of the data type that corresponds to this table, if any
569+
(zero for indexes, which have no pg_type entry)
570570
</entry>
571571
</row>
572572

@@ -631,14 +631,19 @@
631631
<entry>reltoastidxid</entry>
632632
<entry><type>oid</type></entry>
633633
<entry>pg_class.oid</entry>
634-
<entry>Oid of the index on the TOAST table for this table, 0 if none</entry>
634+
<entry>
635+
For a TOAST table, the OID of its index. 0 if not a TOAST table.
636+
</entry>
635637
</row>
636638

637639
<row>
638640
<entry>relhasindex</entry>
639641
<entry><type>bool</type></entry>
640642
<entry></entry>
641-
<entry>True if this is a table and it has at least one index</entry>
643+
<entry>True if this is a table and it has (or recently had) any indexes.
644+
This is set by CREATE INDEX, but not cleared immediately by DROP INDEX.
645+
VACUUM clears relhasindex if it finds the table has no indexes.
646+
</entry>
642647
</row>
643648

644649
<row>
@@ -664,7 +669,7 @@
664669
<entry><type>int2</type></entry>
665670
<entry></entry>
666671
<entry>
667-
Number of columns in the relation, besides system columns.
672+
Number of user columns in the relation (system columns not counted).
668673
There must be this many corresponding entries in
669674
<structname>pg_attribute</structname>. See also
670675
<structname>pg_attribute</structname>.<structfield>attnum</structfield>.
@@ -695,23 +700,38 @@
695700
<entry>relukeys</entry>
696701
<entry><type>int2</type></entry>
697702
<entry></entry>
698-
<entry>unused (<emphasis>Not</emphasis> the number of unique keys or something.)</entry>
703+
<entry>unused (<emphasis>Not</emphasis> the number of unique keys)</entry>
699704
</row>
700705

701706
<row>
702707
<entry>relfkeys</entry>
703708
<entry><type>int2</type></entry>
704709
<entry></entry>
705-
<entry>Number foreign keys on the table</entry>
710+
<entry>unused (<emphasis>Not</emphasis> the number of foreign keys on the table)</entry>
711+
</row>
712+
713+
<row>
714+
<entry>relrefs</entry>
715+
<entry><type>int2</type></entry>
716+
<entry></entry>
717+
<entry>unused</entry>
718+
</row>
719+
720+
<row>
721+
<entry>relhasoids</entry>
722+
<entry><type>bool</type></entry>
723+
<entry></entry>
724+
<entry>
725+
True if we generate an OID for each row of the relation.
726+
</entry>
706727
</row>
707728

708729
<row>
709730
<entry>relhaspkey</entry>
710731
<entry><type>bool</type></entry>
711732
<entry></entry>
712733
<entry>
713-
unused (No, this does not say whether the table has a primary
714-
key. It's really unused.)
734+
True if the table has (or once had) a primary key.
715735
</entry>
716736
</row>
717737

@@ -726,7 +746,7 @@
726746
<entry>relhassubclass</entry>
727747
<entry><type>bool</type></entry>
728748
<entry></entry>
729-
<entry>At least one table inherits this one</entry>
749+
<entry>At least one table inherits from this one</entry>
730750
</row>
731751

732752
<row>
@@ -874,6 +894,23 @@
874894
<entry>The oid of the object this description pertains to</entry>
875895
</row>
876896

897+
<row>
898+
<entry>classoid</entry>
899+
<entry><type>oid</type></entry>
900+
<entry>pg_class.oid</entry>
901+
<entry>The oid of the system catalog this object appears in</entry>
902+
</row>
903+
904+
<row>
905+
<entry>objsubid</entry>
906+
<entry><type>int4</type></entry>
907+
<entry></entry>
908+
<entry>For a comment on a table attribute, this is the attribute's
909+
column number (the objoid and classoid refer to the table itself).
910+
For all other object types, this field is presently zero.
911+
</entry>
912+
</row>
913+
877914
<row>
878915
<entry>description</entry>
879916
<entry><type>text</type></entry>

0 commit comments

Comments
 (0)