1. 如何修改Postgresql源碼新增一張系統表
1) 在catalog 的makefile 中添加相應的系統表頭文件
./src/backend/catalog/Makefile:42: pg_foreign_table.h pg_partition_key.h \
2) 建表 -- 以pg_partition_key為例汪肢羨:
2.1)在include的 catalog目錄下添加這困拍張表的定義
#ifndef PG_PARTITION_KEY_H
#define PG_PARTITION_KEY_H
#include 'catalog/genbki.h'
#define PartitionKeyRelationId 3180
CATALOG(pg_partition_key,3180) BKI_WITHOUT_OIDS
{
Oid pkrelid;
int16 pkattnum;
} FormData_pg_partition_key;
typedef FormData_pg_partition_key *Form_pg_partition_key;
#define Natts_pg_partition_key 2
#define Anum_pg_partition_key_pkrelid 1
#define Anum_pg_partition_key_pkattnum 2
#endif
2.2) 在飢仔catalog 的indexing.h 頭文件中添加系統表的唯一性索引
DECLARE_UNIQUE_INDEX(pg_partition_key_relid_index, 3181, on pg_partition_key using btree(pkrelid oid_ops));
#define PartitionKeyRelidIndexId 3181 r>3) Syscache -- 以 pg_partion_key為例:
3.1)首先要在syscache.h中添加 SysCacheIdentifier
3.2) 要在syscache.c 的 cacheinfo[] 中添加這張表
cache的定義:
struct cachedesc
{
2. 如何安裝並且開始調試PostgreSQL
如何安裝並且開始調試PostgreSQL
1. 安裝Linux操作系統
注意把gdb、Emacs或DDD這些開發工具都安裝上。如果是在虛擬機上安裝,依然需要山帶設置Linux系統的網路環境;另外需要設置文件共享,方便windows下面的postgreSQL源碼能在逗虛蘆Linux下面訪問到。
2. 安裝PostgreSQL
useradd postgre
(自動建立 postgre 組;設計人員為了安全考慮,PostgreSQL 不能以root 用戶運行,所以必須建立對應的用戶和組。)
解壓到 /usr/local/src
tar xvfz postgresql-8.4.tar.gz
cd postgresql-8.4
./configure --prefix=/usr/local/pgsql --enable-debug --enable-assert --without-readline --without-zlib
make
make install
chown -R postgre.postgre /usr/local/pgsql
3. 設置Postgres環境變數(非必須)
vi ~postgre/.bash_profile
添加:
PGLIB=/usr/local/pgsql/lib
PGDATA=$HOME/data
PATH=$PATH:/usr/local/pgsql/bin
MANPATH=$MANPATH:/usr/local/pgsql/man
export PGLIB PGDATA PATH MANPATH
4. 建立資料庫
以 postgres 用戶登錄:
su postgre
建立資料庫目錄:
mkdir data
啟動資料庫引擎:
initdb –D 「資料庫目錄」
之後可以根據提示,通過psql進入資料庫
5. 構造PostgreSQL調試環境
先 psql template1進去,然後
select pg_backend_pid();
獲得id,就是gdb後面用到的數字
gdb /usr/local/pgsql/bin/postgres 997(pid的數字)
如果只使譽信用gdb,全部是命令行界面;而Emac、DDD分別是彩色、黑白用戶互動式圖形界面。
6. 使用gdb進行調試