Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit372728b

Browse files
committed
Replace our traditional initial-catalog-data format with a better design.
Historically, the initial catalog data to be installed during bootstraphas been written in DATA() lines in the catalog header files. This hadlots of disadvantages: the format was badly underdocumented, it wasvery difficult to edit the data in any mechanized way, and due to thelack of any abstraction the data was verbose, hard to read/understand,and easy to get wrong.Hence, move this data into separate ".dat" files and represent it in a waythat can easily be read and rewritten by Perl scripts. The new format isessentially "key => value" for each column; while it's a bit repetitive,explicit labeling of each value makes the data far more readable and lesserror-prone. Provide a way to abbreviate entries by omitting field valuesthat match a specified default value for their column. This allows removalof a large amount of repetitive boilerplate and also lowers the barrier toadding new columns.Also teach genbki.pl how to translate symbolic OID references intonumeric OIDs for more cases than just "regproc"-like pg_proc references.It can now do that for regprocedure-like references (thus solving theproblem that regproc is ambiguous for overloaded functions), operators,types, opfamilies, opclasses, and access methods. Use this to turnnearly all OID cross-references in the initial data into symbolic form.This represents a very large step forward in readability and errorresistance of the initial catalog data. It should also reduce thedifficulty of renumbering OID assignments in uncommitted patches.Also, solve the longstanding problem that frontend code that would like touse OID macros and other information from the catalog headers often haddifficulty with backend-only code in the headers. To do this, arrange forall generated macros, plus such other declarations as we deem fit, to beplaced in "derived" header files that are safe for frontend inclusion.(Once clients migrate to using these pg_*_d.h headers, it will be possibleto get rid of the pg_*_fn.h headers, which only exist to quarantine codeaway from clients. That is left for follow-on patches, however.)The now-automatically-generated macros include the Anum_xxx and Natts_xxxconstants that we used to have to update by hand when adding or removingcatalog columns.Replace the former manual method of generating OID macros for pg_typeentries with an automatic method, ensuring that all built-in types haveOID macros. (But note that this patch does not change the way thatOID macros for pg_proc entries are built and used. It's not clear thatmaking that match the other catalogs would be worth extra code churn.)Add SGML documentation explaining what the new data format is and how towork with it.Despite being a very large change in the catalog headers, there is nocatversion bump here, because postgres.bki and related output fileshaven't changed at all.John Naylor, based on ideas from various people; review and minoradditional coding by me; previous review by Alvaro HerreraDiscussion:https://postgr.es/m/CAJVSVGWO48JbbwXkJz_yBFyGYW-M9YWxnPdxJBUosDC9ou_F0Q@mail.gmail.com
1 parent02f3e55 commit372728b

File tree

110 files changed

+22928
-12480
lines changed

Some content is hidden

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

110 files changed

+22928
-12480
lines changed

‎doc/src/sgml/bki.sgml

Lines changed: 635 additions & 26 deletions
Large diffs are not rendered by default.

‎doc/src/sgml/libpq.sgml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3566,7 +3566,7 @@ Oid PQftype(const PGresult *res,
35663566
You can query the system table <literal>pg_type</literal> to
35673567
obtain the names and properties of the various data types. The
35683568
<acronym>OID</acronym>s of the built-in data types are defined
3569-
in the file <filename>src/include/catalog/pg_type.h</filename>
3569+
in the file <filename>src/include/catalog/pg_type_d.h</filename>
35703570
in the source tree.
35713571
</para>
35723572
</listitem>

‎src/Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ endif
4141

4242
$(recurse)
4343

44+
# Update the commonly used headers before building the subdirectories;
45+
# otherwise, in a parallel build, several different sub-jobs will try to
46+
# remake them concurrently
47+
$(SUBDIRS:%=all-%-recurse): | submake-generated-headers
48+
4449
install: install-local
4550

4651
install-local: installdirs-local

‎src/backend/Makefile

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ endif
5353

5454
##########################################################################
5555

56-
all: submake-libpgport submake-schemapg postgres$(POSTGRES_IMP)
56+
all: submake-libpgport submake-catalog-headers postgres$(POSTGRES_IMP)
5757

5858
ifneq ($(PORTNAME), cygwin)
5959
ifneq ($(PORTNAME), win32)
@@ -151,19 +151,17 @@ utils/errcodes.h: utils/generate-errcodes.pl utils/errcodes.txt
151151
utils/fmgrprotos.h: utils/fmgroids.h
152152
touch$@
153153

154-
utils/fmgroids.h: utils/Gen_fmgrtab.pl catalog/Catalog.pm$(top_srcdir)/src/include/catalog/pg_proc.h
154+
utils/fmgroids.h: utils/Gen_fmgrtab.pl catalog/Catalog.pm$(top_srcdir)/src/include/catalog/pg_proc.dat$(top_srcdir)/src/include/access/transam.h
155155
$(MAKE) -C utils fmgroids.h fmgrprotos.h
156156

157157
utils/probes.h: utils/probes.d
158158
$(MAKE) -C utils probes.h
159159

160160
# run this unconditionally to avoid needing to know its dependencies here:
161-
catalog/schemapg.h: | submake-schemapg
161+
submake-catalog-headers:
162+
$(MAKE) -C catalog distprep generated-header-symlinks
162163

163-
submake-schemapg:
164-
$(MAKE) -C catalog schemapg.h
165-
166-
.PHONY: submake-schemapg
164+
.PHONY: submake-catalog-headers
167165

168166
# Make symlinks for these headers in the include directory. That way
169167
# we can cut down on the -I options. Also, a symlink is automatically
@@ -178,18 +176,13 @@ submake-schemapg:
178176

179177
.PHONY: generated-headers
180178

181-
generated-headers:$(top_builddir)/src/include/parser/gram.h$(top_builddir)/src/include/catalog/schemapg.h$(top_builddir)/src/include/storage/lwlocknames.h$(top_builddir)/src/include/utils/errcodes.h$(top_builddir)/src/include/utils/fmgroids.h$(top_builddir)/src/include/utils/fmgrprotos.h$(top_builddir)/src/include/utils/probes.h
179+
generated-headers:$(top_builddir)/src/include/parser/gram.h$(top_builddir)/src/include/storage/lwlocknames.h$(top_builddir)/src/include/utils/errcodes.h$(top_builddir)/src/include/utils/fmgroids.h$(top_builddir)/src/include/utils/fmgrprotos.h$(top_builddir)/src/include/utils/probes.h submake-catalog-headers
182180

183181
$(top_builddir)/src/include/parser/gram.h: parser/gram.h
184182
prereqdir=`cd'$(dir $<)'>/dev/null&& pwd`&&\
185183
cd'$(dir $@)'&& rm -f$(notdir$@)&&\
186184
$(LN_S)"$$prereqdir/$(notdir $<)".
187185

188-
$(top_builddir)/src/include/catalog/schemapg.h: catalog/schemapg.h
189-
prereqdir=`cd'$(dir $<)'>/dev/null&& pwd`&&\
190-
cd'$(dir $@)'&& rm -f$(notdir$@)&&\
191-
$(LN_S)"$$prereqdir/$(notdir $<)".
192-
193186
$(top_builddir)/src/include/storage/lwlocknames.h: storage/lmgr/lwlocknames.h
194187
prereqdir=`cd'$(dir $<)'>/dev/null&& pwd`&&\
195188
cd'$(dir $@)'&& rm -f$(notdir$@)&&\
@@ -225,7 +218,7 @@ utils/probes.o: utils/probes.d $(SUBDIROBJS)
225218
distprep:
226219
$(MAKE) -C parsergram.c gram.h scan.c
227220
$(MAKE) -C bootstrapbootparse.c bootscanner.c
228-
$(MAKE) -C catalogschemapg.h postgres.bki postgres.description postgres.shdescription
221+
$(MAKE) -C catalogdistprep
229222
$(MAKE) -C replicationrepl_gram.c repl_scanner.c syncrep_gram.c syncrep_scanner.c
230223
$(MAKE) -C storage/lmgrlwlocknames.h lwlocknames.c
231224
$(MAKE) -C utilsfmgrtab.c fmgroids.h fmgrprotos.h errcodes.h
@@ -327,13 +320,7 @@ endif
327320
##########################################################################
328321

329322
clean:
330-
rm -f$(LOCALOBJS) postgres$(X)$(POSTGRES_IMP)\
331-
$(top_builddir)/src/include/parser/gram.h\
332-
$(top_builddir)/src/include/catalog/schemapg.h\
333-
$(top_builddir)/src/include/storage/lwlocknames.h\
334-
$(top_builddir)/src/include/utils/fmgroids.h\
335-
$(top_builddir)/src/include/utils/fmgrprotos.h\
336-
$(top_builddir)/src/include/utils/probes.h
323+
rm -f$(LOCALOBJS) postgres$(X)$(POSTGRES_IMP)
337324
ifeq ($(PORTNAME), cygwin)
338325
rm -f postgres.dll libpostgres.a
339326
endif
@@ -345,15 +332,12 @@ distclean: clean
345332
rm -f port/tas.s port/dynloader.c port/pg_sema.c port/pg_shmem.c
346333

347334
maintainer-clean: distclean
335+
$(MAKE) -C catalog$@
348336
rm -f bootstrap/bootparse.c\
349337
bootstrap/bootscanner.c\
350338
parser/gram.c\
351339
parser/gram.h\
352340
parser/scan.c\
353-
catalog/schemapg.h\
354-
catalog/postgres.bki\
355-
catalog/postgres.description\
356-
catalog/postgres.shdescription\
357341
replication/repl_gram.c\
358342
replication/repl_scanner.c\
359343
replication/syncrep_gram.c\

‎src/backend/catalog/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
22
/postgres.description
33
/postgres.shdescription
44
/schemapg.h
5+
/pg_*_d.h
6+
/bki-stamp

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp