数据库内核:使用Git管理代码
安装Git
root@postgresqlunbuntu:/# sudo apt update
root@postgresqlunbuntu:/# sudo apt install git
# 验证是否安装成功
root@postgresqlunbuntu:/# git --version
git version 2.25.1
管理本地代码
在 pghome 所在的目录下创建 git 仓库
postgre@postgresqlunbuntu:~/PGDev/pghome$ git init
Initialized empty Git repository in /home/postgre/PGDev/pghome/.git/
添加该目录下所有文件
postgre@postgresqlunbuntu:~/PGDev/pghome$ git add .
提交新添加的内容
# 第一次执行该命令时会提示不存在作者,按照提示配置邮箱和名字即可
postgre@postgresqlunbuntu:~/PGDev/pghome$ git config --global user.name "QJY"
postgre@postgresqlunbuntu:~/PGDev/pghome$ git config --global user.email "304735221@qq.com"
postgre@postgresqlunbuntu:~/PGDev/pghome$ git commit -m "pg_lab"
创建分支
postgre@postgresqlunbuntu:~/PGDev/pghome$ git branch lab2-1
切换到分支
postgre@postgresqlunbuntu:~/PGDev/pghome$ git checkout lab2-1
Switched to branch 'lab2-1'
查看当前所在分支
postgre@postgresqlunbuntu:~/PGDev/pghome$ git branch
* lab2-1
master
使用 vscode 编写和调试
配置 launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "postgresql",
"type": "cppdbg",
"request": "attach",
"program": "/home/postgre/PGDev/pghome/bin/postgres", //输入你的postgres可执行文件地址,在$PGHOME/bin目录下
"processId": "${command:pickProcess}",
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "Set Disassembly Flavor to Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
]
}
]
}
在终端打开想要调试的数据库
启动调试器
在文本框输入postgres,并选择相应的数据库进程