Skip to content

Commit ee08c36

Browse files
committed
New backend dirs html file.
1 parent 8cae12b commit ee08c36

File tree

1 file changed

+322
-0
lines changed

1 file changed

+322
-0
lines changed

src/tools/BACKEND_DIRS.html

Lines changed: 322 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,322 @@
1+
<HTML>
2+
<HEAD>
3+
<TITLE>PostgreSQL Backend Directories</TITLE>
4+
</HEAD>
5+
<BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#FF0000" VLINK="#A00000" ALINK="#0000FF">
6+
<H1 ALIGN=CENTER>
7+
PostgreSQL Backend Directories
8+
</H1>
9+
<H2 ALIGN=CENTER>
10+
by Bruce Momjian
11+
</H2 ALIGN=CENTER>
12+
<H2>
13+
<A HREF="../backend//bootstrap">bootstrap</A> - creates initial template database via initdb
14+
</H2>
15+
<P>
16+
Because PostgreSQL requires access to system tables for almost every
17+
operation, getting those system tables in place is a problem.
18+
You can't just create the tables and insert data into them in the normal way,
19+
because table creation and insertion requires the tables to already
20+
exist.
21+
This code <I>jams</I> the data directly into tables using a
22+
special syntax used only by the bootstrap procedure.
23+
</P>
24+
<H2>
25+
<A HREF="../backend//main">main</A> - passes control to postmaster or postgres
26+
</H2>
27+
<P>
28+
This checks the process name(argv[0]) and various flags, and passes
29+
control to the postmaster or postgres backend code.
30+
</P>
31+
<H2>
32+
<A HREF="../backend//postmaster">postmaster</A> - controls postgres server startup/termination
33+
</H2>
34+
<P>
35+
This creates shared memory, and then goes into a loop waiting for
36+
connection requests.
37+
When a connection request arrives, a <I>postgres</I> backend is started,
38+
and the connection is passed to it.
39+
</P>
40+
<H2>
41+
<A HREF="../backend//libpq">libpq</A> - backend libpq library routines
42+
</H2>
43+
<P>
44+
This handles communication to the client processes.
45+
</P>
46+
<H2>
47+
<A HREF="../backend//tcop">tcop</A> - traffic cop, dispatches request to proper module
48+
</H2>
49+
<P>
50+
This contains the <I>postgres</I> backend main handler, as well as the
51+
code that makes calls to the parser, optimizer, executor, and
52+
<I>/commands</I> functions.
53+
</P>
54+
<H2>
55+
<A HREF="../backend//parser">parser</A> - converts SQL query to query tree
56+
</H2>
57+
<P>
58+
This converts SQL queries coming from <I>libpq</I> into command-specific
59+
structures to be used the the optimizer/executor, or <I>/commands</I>
60+
routines.
61+
The SQL is lexically analyzed into keywords, identifiers, and constants,
62+
and passed to the parser.
63+
The parser creates command-specific structures to hold the elements of
64+
the query.
65+
The command-specific structures are then broken apart, checked, and passed to
66+
<I>/commands</I> processing routines, or converted into <I>Lists</I> of
67+
<I>Nodes</I> to be handled by the optimizer and executor.
68+
</P>
69+
<H2>
70+
<A HREF="../backend//optimizer">optimizer</A> - creates path and plan
71+
</H2>
72+
<P>
73+
This uses the parser output to generate an optimal plan for the
74+
executor.
75+
</P>
76+
<H4>
77+
<A HREF="../backend//optimizer/path">optimizer/path</A> - creates path from parser output
78+
</H4>
79+
<P>
80+
This takes the parser query output, and generates all possible methods of
81+
executing the request.
82+
It examines table join order, <I>where</I> clause restrictions,
83+
and optimizer table statistics to evaluate each possible execution
84+
method, and assigns a cost to each.
85+
</P>
86+
<H4>
87+
<A HREF="../backend//optimizer/geqo">optimizer/geqo</A> - genetic query optimizer
88+
</H4>
89+
<P>
90+
<I>optimizer/path</I> evaluates all possible ways to join the requested tables.
91+
When the number of tables becomes great, the number of tests made
92+
becomes great too.
93+
The Genetic Query Optimizer considers each table separately, then figures
94+
the most optimal order to perform the join.
95+
For a few tables, this method takes longer, but for a large number of
96+
tables, it is faster.
97+
There is an option to control when this feature is used.
98+
</P>
99+
<H4>
100+
<A HREF="../backend//optimizer/plan">optimizer/plan</A> - optimizes path output
101+
</H4>
102+
<P>
103+
This takes the <I>optimizer/path</I> output, chooses the path with the
104+
least cost, and creates a plan for the executor.
105+
</P>
106+
<H4>
107+
<A HREF="../backend//optimizer/prep">optimizer/prep</A> - handle special plan cases
108+
</H4>
109+
<P>
110+
This does special plan processing.
111+
</P>
112+
<H4>
113+
<A HREF="../backend//optimizer/util">optimizer/util</A> - optimizer support routines
114+
</H4>
115+
<P>
116+
This contains support routines used by other parts of the optimizer.
117+
</P>
118+
<H2>
119+
<A HREF="../backend//executor">executor</A> - executes complex node plans from optimizer
120+
</H2>
121+
<P>
122+
This handles <I>select, insert, update,</I> and <I>delete</I> statements.
123+
The operations required to handle these statement types include
124+
heap scans, index scans, sorting, joining tables, grouping, aggregates,
125+
and uniqueness.
126+
</P>
127+
<H2>
128+
<A HREF="../backend//commands">commands</A> - commands that do not require the executor
129+
</H2>
130+
<P>
131+
These process SQL commands that do not require complex handling.
132+
It includes <I>vacuum, copy, alter, create table, create type,</I> and
133+
many others.
134+
The code is called with the structures generated by the parser.
135+
Most of the routines do some processing, then call lower-level functions
136+
in the catalog directory to do the actual work.
137+
</P>
138+
<H2>
139+
<A HREF="../backend//catalog">catalog</A> - system catalog manipulation
140+
</H2>
141+
<P>
142+
This contains functions that manipulate the system tables or catalogs.
143+
Table, index, procedure, operator, type, and aggregate creation and
144+
manipulation routines are here.
145+
These are low-level routines, and are usually called by upper routines
146+
that pre-format user requests into a predefined format.
147+
</P>
148+
<H2>
149+
<A HREF="../backend//storage">storage</A> - manages various storage systems
150+
</H2>
151+
<P>
152+
These allow uniform resource access by the backend.
153+
<BR>
154+
<BR>
155+
<A HREF="../backend//storage/buffer">storage/buffer</A> - shared buffer pool manager
156+
<BR>
157+
<A HREF="../backend//storage/file">storage/file</A> - file manager
158+
<BR>
159+
<A HREF="../backend//storage/ipc">storage/ipc</A> - semaphores and shared memory
160+
<BR>
161+
<A HREF="../backend//storage/large_object">storage/large_object</A> - large objects
162+
<BR>
163+
<A HREF="../backend//storage/lmgr">storage/lmgr</A> - lock manager
164+
<BR>
165+
<A HREF="../backend//storage/page">storage/page</A> - page manager
166+
<BR>
167+
<A HREF="../backend//storage/smgr">storage/smgr</A> - storage/disk manager
168+
<BR>
169+
<BR>
170+
</P>
171+
<H2>
172+
<A HREF="../backend//access">access</A> - various data access methods
173+
</H2>
174+
<P>
175+
These control the way data is accessed in heap, indexes, and
176+
transactions.
177+
<BR>
178+
<BR>
179+
<A HREF="../backend//access/common">access/common</A> - common access routines
180+
<BR>
181+
<A HREF="../backend//access/gist">access/gist</A> - easy-to-define access method system
182+
<BR>
183+
<A HREF="../backend//access/hash">access/hash</A> - hash
184+
<BR>
185+
<A HREF="../backend//access/heap">access/heap</A> - heap is use to store data rows
186+
<BR>
187+
<A HREF="../backend//access/index">access/index</A> - used by all index types
188+
<BR>
189+
<A HREF="../backend//access/nbtree">access/nbtree</A> - Lehman and Yao's btree management algorithm
190+
<BR>
191+
<A HREF="../backend//access/rtree">access/rtree</A> - used for indexing of 2-dimensional data
192+
<BR>
193+
<A HREF="../backend//access/transam">access/transam</A> - transaction manager (BEGIN/ABORT/COMMIT)
194+
<BR>
195+
<BR>
196+
</P>
197+
<H2>
198+
<A HREF="../backend//nodes">nodes</A> - creation/manipulation of nodes and lists
199+
</H2>
200+
<P>
201+
PostgreSQL stores information about SQL queries in structures called
202+
nodes.
203+
<I>Nodes</I> are generic containers that have a <I>type</I> field and then a
204+
type-specific data section.
205+
Nodes are usually placed in <I>Lists.</I>
206+
A <I>List</I> is container with an <I>elem</I> element,
207+
and a <I>next</I> field that points to the next <I>List.</I>
208+
These <I>List</I> structures are chained together in a forward linked list.
209+
In this way, a chain of <I>List</I>s can contain an unlimited number of <I>Node</I>
210+
elements, and each <I>Node</I> can contain any data type.
211+
These are used extensively in the parser, optimizer, and executor to
212+
store requests and data.
213+
</P>
214+
<H2>
215+
<A HREF="../backend//utils">utils</A> - support routines
216+
</H2>
217+
<H4>
218+
<A HREF="../backend//utils/adt">utils/adt</A> - built-in data type routines
219+
</H4>
220+
<P>
221+
This contains all the PostgreSQL builtin data types.
222+
</P>
223+
<H4>
224+
<A HREF="../backend//utils/cache">utils/cache</A> - system/relation/function cache routines
225+
</H4>
226+
<P>
227+
PostgreSQL supports arbitrary data types, so no data types are hard-coded
228+
into the core backend routines.
229+
When the backend needs to find out about a type, is does a lookup of a
230+
system table.
231+
Because these system tables are referred to often, a cache is maintained
232+
that speeds lookups.
233+
There is a system relation cache, a function/operator cache, and a relation
234+
information cache.
235+
This last cache maintains information about all recently-accessed
236+
tables, not just system ones.
237+
</P>
238+
<H4>
239+
<A HREF="../backend//utils/error">utils/error</A> - error reporting routines
240+
</H4>
241+
<P>
242+
Reports backend errors to the front end.
243+
</P>
244+
<H4>
245+
<A HREF="../backend//utils/fmgr">utils/fmgr</A> - function manager
246+
</H4>
247+
<P>
248+
This handles the calling of dynamically-loaded functions, and the calling
249+
of functions defined in the system tables.
250+
</P>
251+
<H4>
252+
<A HREF="../backend//utils/hash">utils/hash</A> - hash routines for internal algorithms
253+
</H4>
254+
<P>
255+
These hash routines are used by the cache and memory-manager routines to
256+
do quick lookups of dynamic data storage structures maintained by the
257+
backend.
258+
</P>
259+
<H4>
260+
<A HREF="../backend//utils/init">utils/init</A> - various initialization stuff
261+
</H4>
262+
<H4>
263+
<A HREF="../backend//utils/misc">utils/misc</A> - miscellaneous stuff
264+
</H4>
265+
<H4>
266+
<A HREF="../backend//utils/mmgr">utils/mmgr</A> - memory manager(process-local memory)
267+
</H4>
268+
<P>
269+
When PostgreSQL allocates memory, it does so in an explicit context.
270+
Contexts can be statement-specific, transaction-specific, or
271+
persistent/global.
272+
By doing this, the backend can easily free memory once a statement or
273+
transaction completes.
274+
</P>
275+
<H4>
276+
<A HREF="../backend//utils/sort">utils/sort</A> - sort routines for internal algorithms
277+
</H4>
278+
<P>
279+
When statement output must be sorted as part of a backend operation,
280+
this code sorts the tuples, either in memory or using disk files.
281+
</P>
282+
<H4>
283+
<A HREF="../backend//utils/time">utils/time</A> - transaction time qualification routines
284+
</H4>
285+
<P>
286+
These routines do checking of tuple internal columns to determine if the
287+
current row is still valid, or is part of a non-committed transaction or
288+
superseded by a new row.
289+
</P>
290+
<H2>
291+
<A HREF="../backend//include">include</A> - include files
292+
</H2>
293+
<P>
294+
There are include directories for each subsystem.
295+
</P>
296+
<H2>
297+
<A HREF="../backend//lib">lib</A> - support library
298+
</H2>
299+
<P>
300+
This houses several generic routines.
301+
</P>
302+
<H2>
303+
<A HREF="../backend//regex">regex</A> - regular expression library
304+
</H2>
305+
<P>
306+
This is used for regular expression handling in the backend, i.e. '~'.
307+
</P>
308+
<H2>
309+
<A HREF="../backend//rewrite">rewrite</A> - rules system
310+
</H2>
311+
<P>
312+
This does processing for the rules system.
313+
</P>
314+
<H2>
315+
<A HREF="../backend//tioga">tioga</A> - unused (array handling?)
316+
</H2>
317+
<HR>
318+
<ADDRESS>
319+
Maintainer: Bruce Momjian<A
320+
HREF="mailto:maillist@candle.pha.pa.us">maillist@candle.pha.pa.us</a>)<BR>
321+
Last updated: Mon Oct 27 11:01:08 EST 1997
322+
</ADDRESS>

0 commit comments

Comments
 (0)