zjjxxlgb / pgsqlparser

A tool can check the sql syntax of postgres and find the tables which been modified.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

pgsqlparser

功能:

定制postgres9.6源码,输入SQL文件进行SQL语法检查,并识别出哪些表有变更,提高SQL上线时备份的效率。

安装准备

yum install -y perl-ExtUtils-Embed readline-devel zlib-devel pam-devel libxml2-devel libxslt-devel openldap-devel Python-devel gcc-c++   openssl-devel cmake
groupadd pgsqlparser
useradd -g pgsqlparser pgsqlparser

mkdir -p /home/pgsqlparser/pgsql
mkdir -p /home/pgsqlparser/data
chown -R pgsqlparser:pgsqlparser /home/pgsqlparser/

vi /home/pgsqlparser/.bash_profile

export PGHOME=/home/pgsqlparser/pgsql/
export PGDATA=/home/pgsqlparser/pgdata
export PGDATABASE=pgsqlparser
export PGUSER=pgsqlparser
export PGPORT=5432
export MANPATH=$PGHOME/share/man:$MANPATH
export LD_LIBRARY_PATH=$PGHOME/lib
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/lib:/usr/lib:/usr/local/lib
export PATH=$PGHOME/bin:$PATH
export TEMP=/tmp
export TMPDIR=/tmp

开始编译安装

git clone https://github.com/zjjxxlgb/pgsqlparser.git
cd pgsqlparser
chmod u+x configure
./configure --prefix=/home/pgsqlparser/pgsql/  --with-perl --with-python --with-libxml --with-libxslt
make
make install

mv pgsqlparser/pgdata.tar.gz /home/pgsqlparser/
cd ..
tar -zxf pgdata.tar.gz

语法检测

postgres  <test2.sql postgres 2>&1|grep 'FATAL'

备份表识别(alter,drop,truncate,delete,update)

postgres  <test.sql postgres 2>&1|grep dbtablename

image

About

A tool can check the sql syntax of postgres and find the tables which been modified.

License:Other


Languages

Language:C 85.0%Language:PLpgSQL 4.6%Language:C++ 2.7%Language:TSQL 1.8%Language:Yacc 1.5%Language:Perl 1.5%Language:Makefile 0.8%Language:SQLPL 0.6%Language:Lex 0.5%Language:Shell 0.2%Language:M4 0.2%Language:Ruby 0.2%Language:Objective-C 0.1%Language:Roff 0.1%Language:Python 0.1%Language:XS 0.0%Language:Batchfile 0.0%Language:PLSQL 0.0%Language:Emacs Lisp 0.0%Language:DTrace 0.0%Language:Assembly 0.0%Language:sed 0.0%Language:Raku 0.0%Language:Csound Score 0.0%