Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
5dd9fc72
Commit
5dd9fc72
authored
Dec 09, 2000
by
Bruce Momjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update FAQ_DEV.
parent
5eced96f
Changes
2
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
597 additions
and
552 deletions
+597
-552
doc/FAQ_DEV
doc/FAQ_DEV
+92
-88
doc/src/FAQ/FAQ_DEV.html
doc/src/FAQ/FAQ_DEV.html
+505
-464
No files found.
doc/FAQ_DEV
View file @
5dd9fc72
...
@@ -27,6 +27,7 @@
...
@@ -27,6 +27,7 @@
11) What is configure all about?
11) What is configure all about?
12) How do I add a new port?
12) How do I add a new port?
13) What is CommandCounterIncrement()?
13) What is CommandCounterIncrement()?
13) Why don't we use threads in the backend?
_________________________________________________________________
_________________________________________________________________
1) What tools are available for developers?
1) What tools are available for developers?
...
@@ -36,8 +37,7 @@
...
@@ -36,8 +37,7 @@
/tools directory are designed for developers.
/tools directory are designed for developers.
RELEASE_CHANGES changes we have to make for each release
RELEASE_CHANGES changes we have to make for each release
SQL_keywords standard SQL'92 keywords
SQL_keywords standard SQL'92 keywords
backend description/flowchart of the backend directorie
backend description/flowchart of the backend directories
s
ccsym find standard defines made by your compiler
ccsym find standard defines made by your compiler
entab converts tabs to spaces, used by pgindent
entab converts tabs to spaces, used by pgindent
find_static finds functions that could be made static
find_static finds functions that could be made static
...
@@ -95,7 +95,7 @@ s
...
@@ -95,7 +95,7 @@ s
emacs:
emacs:
M-x set-variable tab-width
M-x set-variable tab-width
or
or
; Cmd to set tab stops &etc
for working with PostgreSQL code
; Cmd to set tab stops & indenting
for working with PostgreSQL code
(c-add-style "pgsql"
(c-add-style "pgsql"
'("bsd"
'("bsd"
(indent-tabs-mode . t)
(indent-tabs-mode . t)
...
@@ -108,8 +108,7 @@ s
...
@@ -108,8 +108,7 @@ s
and add this to your autoload list (modify file path in macro):
and add this to your autoload list (modify file path in macro):
(setq auto-mode-alist
(setq auto-mode-alist
(cons '("\\`/usr/local/src/pgsql/.*\\.[chyl]\\'" . pgsql-
(cons '("\\`/usr/local/src/pgsql/.*\\.[chyl]\\'" . pgsql-c-mode)
c-mode)
auto-mode-alist))
auto-mode-alist))
or
or
/*
/*
...
@@ -174,8 +173,7 @@ c-mode)
...
@@ -174,8 +173,7 @@ c-mode)
a typical code snipped that loops through a List containing Var
a typical code snipped that loops through a List containing Var
*'s and processes each one:
*'s and processes each one:
List *i, *list;
List *i, *list;
foreach(i, list)
foreach(i, list)
{
{
...
@@ -207,16 +205,14 @@ c-mode)
...
@@ -207,16 +205,14 @@ c-mode)
You can print nodes easily inside gdb. First, to disable output
You can print nodes easily inside gdb. First, to disable output
truncation when you use the gdb print command:
truncation when you use the gdb print command:
(gdb) set print elements 0
(gdb) set print elements 0
Instead of printing values in gdb format, you can use the next two
Instead of printing values in gdb format, you can use the next two
commands to print out List, Node, and structure contents in a verbose
commands to print out List, Node, and structure contents in a verbose
format that is easier to understand. List's are unrolled into nodes,
format that is easier to understand. List's are unrolled into nodes,
and nodes are printed in detail. The first prints in a short format,
and nodes are printed in detail. The first prints in a short format,
and the second in a long format:
and the second in a long format:
(gdb) call print(any_pointer)
(gdb) call print(any_pointer)
(gdb) call pprint(any_pointer)
(gdb) call pprint(any_pointer)
The output appears in the postmaster log file, or on your screen if
The output appears in the postmaster log file, or on your screen if
...
@@ -292,7 +288,7 @@ c-mode)
...
@@ -292,7 +288,7 @@ c-mode)
tables in columns of type Name. Name is a fixed-length,
tables in columns of type Name. Name is a fixed-length,
null-terminated type of NAMEDATALEN bytes. (The default value for
null-terminated type of NAMEDATALEN bytes. (The default value for
NAMEDATALEN is 32 bytes.)
NAMEDATALEN is 32 bytes.)
typedef struct nameData
typedef struct nameData
{
{
char data[NAMEDATALEN];
char data[NAMEDATALEN];
} NameData;
} NameData;
...
@@ -311,8 +307,8 @@ c-mode)
...
@@ -311,8 +307,8 @@ c-mode)
9) How do I efficiently access information in tables from the backend code?
9) How do I efficiently access information in tables from the backend code?
You first need to find the tuples(rows) you are interested in. There
You first need to find the tuples(rows) you are interested in. There
are two ways. First, SearchSysCache() and related functions allow
are two ways. First, SearchSysCache() and related functions allow
you
you
to query the system catalogs. This is the preferred way to access
to query the system catalogs. This is the preferred way to access
system tables, because the first call to the cache loads the needed
system tables, because the first call to the cache loads the needed
rows, and future requests can return the results without accessing the
rows, and future requests can return the results without accessing the
base table. The caches use system table indexes to look up tuples. A
base table. The caches use system table indexes to look up tuples. A
...
@@ -321,13 +317,14 @@ c-mode)
...
@@ -321,13 +317,14 @@ c-mode)
src/backend/utils/cache/lsyscache.c contains many column-specific
src/backend/utils/cache/lsyscache.c contains many column-specific
cache lookup functions.
cache lookup functions.
The rows returned are cache-owned versions of the heap rows. Therefore,
The rows returned are cache-owned versions of the heap rows.
you must not modify or delete the tuple returned by SearchSysCache().
Therefore, you must not modify or delete the tuple returned by
What you *should* do is release it with ReleaseSysCache() when you are
SearchSysCache(). What you should do is release it with
done using it; this informs the cache that it can discard that tuple
ReleaseSysCache() when you are done using it; this informs the cache
if necessary. If you neglect to call ReleaseSysCache(), then the cache
that it can discard that tuple if necessary. If you neglect to call
entry will remain locked in the cache until end of transaction, which is
ReleaseSysCache(), then the cache entry will remain locked in the
tolerable but not very desirable.
cache until end of transaction, which is tolerable but not very
desirable.
If you can't use the system cache, you will need to retrieve the data
If you can't use the system cache, you will need to retrieve the data
directly from the heap table, using the buffer cache that is shared by
directly from the heap table, using the buffer cache that is shared by
...
@@ -345,27 +342,25 @@ c-mode)
...
@@ -345,27 +342,25 @@ c-mode)
heap_fetch(), you must pass a Buffer pointer, and ReleaseBuffer() it
heap_fetch(), you must pass a Buffer pointer, and ReleaseBuffer() it
when completed.
when completed.
Once you have the row, you can get data that is common
Once you have the row, you can get data that is common to all tuples,
to all tuples, like t_self and t_oid, by merely accessing the
like t_self and t_oid, by merely accessing the HeapTuple structure
HeapTuple structure entries. If you need a table-specific column, you
entries. If you need a table-specific column, you should take the
should take the HeapTuple pointer, and use the GETSTRUCT() macro to
HeapTuple pointer, and use the GETSTRUCT() macro to access the
access the table-specific start of the tuple. You then cast the
table-specific start of the tuple. You then cast the pointer as a
pointer as a Form_pg_proc pointer if you are accessing the pg_proc
Form_pg_proc pointer if you are accessing the pg_proc table, or
table, or Form_pg_type if you are accessing pg_type. You can then
Form_pg_type if you are accessing pg_type. You can then access the
access the columns by using a structure pointer:
columns by using a structure pointer:
((Form_pg_class) GETSTRUCT(tuple))->relnatts
((Form_pg_class) GETSTRUCT(tuple))->relnatts
You must not directly change live tuples in this way. The best way is
You must not directly change live tuples in this way. The best way
to use heap_modifytuple() and pass it your original tuple, and the
is to use heap_modifytuple() and pass it your original tuple, and the
values you want changed. It returns a palloc'ed tuple, which you pass
values you want changed. It returns a palloc'ed tuple, which you
to heap_replace(). You can delete tuples by passing the tuple's t_self
pass to heap_replace(). You can delete tuples by passing the tuple's
to heap_destroy(). You use t_self for heap_update() too. Remember,
t_self to heap_destroy(). You use t_self for heap_update() too.
tuples can be either system cache copies, which may go away after you
call ReleaseSysCache(), or read directly from disk buffers, which go
Remember, tuples can be either system cache copies, which may go away
away when you heap_getnext(), heap_endscan, or ReleaseBuffer(), in the
after you call ReleaseSysCache(), or read directly from disk buffers,
heap_fetch() case. Or it may be a palloc'ed tuple, that you must
which go away when you heap_getnext(), heap_endscan, or ReleaseBuffer(),
in the heap_fetch() case. Or it may be a palloc'ed tuple, that you must
pfree() when finished.
pfree() when finished.
10) What is elog()?
10) What is elog()?
...
@@ -429,3 +424,12 @@ c-mode)
...
@@ -429,3 +424,12 @@ c-mode)
to be broken into pieces so each piece can see rows modified by
to be broken into pieces so each piece can see rows modified by
previous pieces. CommandCounterIncrement() increments the Command
previous pieces. CommandCounterIncrement() increments the Command
Counter, creating a new part of the transaction.
Counter, creating a new part of the transaction.
14) Why don't we use threads in the backend?
There are several reasons threads are not used:
* Historically, threads were unsupported and buggy.
* An error in one backend can corrupt other backends.
* Speed improvements using threads are small compared to the
remaining backend startup time.
* The backend code would be more complex.
doc/src/FAQ/FAQ_DEV.html
View file @
5dd9fc72
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment