プラグイン

 

プロプラエタリのため、作成不可

 


https://blog.infobuild.jp/e/?c=201902010745
https://gihyo.jp/dev/serial/01/mysql-road-construction-news/0084
https://norikone.hatenablog.com/entry/2018/12/29/MySQL%E3%81%AE%E3%82%B9%E3%83%88%E3%83%AC%E3%83%BC%E3%82%B8%E3%82%A8%E3%83%B3%E3%82%B8%E3%83%B3%E3%82%92%E8%87%AA%E4%BD%9C%E3%81%97%E3%81%A6%E3%81%BF%E3%82%8B


----(1)MySQL8.0.13をソースからインストール

yum -y groupinstall base
yum -y groupinstall development
systemctl stop mariadb.service
systemctl disable mariadb.service
yum -y remove mariadb-libs
yum -y install cmake
yum -y install ncurses-devel
yum -y install openssl-devel

cd
wget https://downloads.mysql.com/archives/get/file/mysql-boost-8.0.13.tar.gz

tar xzvf mysql-boost-8.0.13.tar.gz
cd mysql-8.0.13
cmake -DWITH_DEBUG=1 -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/tmp/boost
make
make install


--DB初期化

useradd -d /usr/local/mysql mysql
echo mysql | passwd --stdin mysql
chown -R mysql:mysql /usr/local/mysql

mkdir /var/lib/mysql

/usr/local/mysql/bin/mysqld --initialize --user=mysql --datadir=/var/lib/mysql --basedir=/usr/local/mysql

→表示されるパスワードを記録する

chown -R mysql:mysql /var/lib/mysql/*


su - mysql

vim .bash_profile
export PATH=/usr/local/mysql/bin:$PATH

. .bash_profile


mysqld --pid-file=/var/lib/mysql/mysqld.pid --datadir=/var/lib/mysql &


mysql -u root -p

alter user root@localhost identified by 'Aaa!1234';


exit

----(2)エンジン作成

cd /root/mysql-8.0.13/storage
cp -R example myengine


cd myengine
sed -i -e "s/example/myengine/g" Makefile
sed -i -e "s/EXAMPLE/MYENGINE/g" -e "s/example/myengine/g" CMakeLists.txt

mv ha_example.cc ha_myengine.cc
mv ha_example.h ha_myengine.h

sed -i -e "s/EXAMPLE/MYENGINE/g" -e "s/example/myengine/g" -e "s/Example/Myengine/g" ha_myengine.cc
sed -i -e "s/EXAMPLE/MYENGINE/g" -e "s/example/myengine/g" -e "s/Example/Myengine/g" ha_myengine.h

cd /root/mysql-8.0.13
cmake -DWITH_DEBUG=1 -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/tmp/boost
make
make install


su - mysql
mysql -u root -p


INSTALL PLUGIN myengine SONAME 'ha_myengine.so';

 

show engines;

create database test;
use test;
create table tab1(col1 int) engine=myengine;

show create table tab1;


https://www.percona.com/blog/2019/04/05/writing-postgresql-extensions-is-fun-c-language/


----(1)postgresql10.6をソースからインストール


--ユーザーと作業ディレクトリの作成

mkdir /usr/local/pgsql
useradd postgres
echo postgres | passwd --stdin postgres
chown postgres:postgres /usr/local/pgsql


--インストール作業

yum install -y gcc
yum install -y zlib-devel


cd /usr/local/src
wget https://ftp.postgresql.org/pub/source/v10.6/postgresql-10.6.tar.gz
tar xvzf postgresql-10.6.tar.gz
chown -R postgres:postgres postgresql-10.6
su postgres
cd postgresql-10.6
./configure --without-readline
make
make install

--環境変数を設定

vim ~/.bashrc

export PATH="$PATH":/usr/local/pgsql/bin
export POSTGRES_HOME=/usr/local/pgsql
export PGLIB=$POSTGRES_HOME/lib
export PGDATA=$POSTGRES_HOME/data
export MANPATH="$MANPATH":$POSTGRES_HOME/man
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH":"$PGLIB"

source ~/.bashrc

mkdir $PGDATA

--DBを初期化

initdb --no-locale


--Listenアドレスの設定

vim /usr/local/pgsql/data/postgresql.conf

#listen_addresses = 'localhost'

listen_addresses = '*'

log_destination = 'stderr,csvlog'
log_directory = 'pg_log'
logging_collector = on


--ListenIP範囲の設定
vim $PGDATA/pg_hba.conf

host all all 0.0.0.0/0 trust

--起動
pg_ctl status
pg_ctl -w start
pg_ctl status
pg_ctl -w stop
pg_ctl status


----(2)extension作成

cd
mkdir hello_world
cd hello_world

vim hello_world.control

comment = 'PostgreSQL Hello World Utility'
default_version = '0.0.1'
relocatable = true

vim hello_world--0.0.1.sql

CREATE OR REPLACE FUNCTION hello_world()
RETURNS TEXT
AS
$$
DECLARE
BEGIN
RETURN 'hello_world';
END
$$
LANGUAGE 'plpgsql';


vim Makefile

EXTENSION = hello_world
MODULE_big = hello_world
DATA = hello_world--0.0.1.sql

PG_CONFIG = pg_config
PGXS := $(shell $(PG_CONFIG) --pgxs)
include $(PGXS)

 

make USE_PGXS=1
make USE_PGXS=1 install

create extension hello_world;
\dx
select hello_world();

 

プロプラエタリのため、作成不可