GithubHelp home page GithubHelp logo

rafsun42 / maria-server Goto Github PK

View Code? Open in Web Editor NEW

This project forked from agedb-inc/maria-server

0.0 0.0 0.0 1.06 GB

MariaDB server is a community developed fork of MySQL server. Started by core members of the original MySQL team, MariaDB actively works with outside developers to deliver the most featureful, stable, and sanely licensed open SQL server in the industry.

License: GNU General Public License v2.0

Shell 0.91% JavaScript 0.01% Ruby 0.02% C++ 56.02% Python 0.09% Perl 2.39% C 38.01% PHP 0.01% Objective-C 0.70% Java 0.10% PowerShell 0.01% Awk 0.01% Makefile 0.03% HTML 0.01% CMake 0.82% XS 0.02% DTrace 0.02% Batchfile 0.01% Yacc 0.83% Lex 0.02%

maria-server's Introduction

Build and Debug from source (Ubuntu 22.04)

Install Dependencies

Firstly Create configuration file in this path '/etc/apt/sources.list.d/mariadb.list` using following command:

sudo gedit /etc/apt/sources.list.d/mariadb.list

then Save the following repository configuration contents in the file /etc/apt/sources.list.d/mariadb.list. Note that the configuration is valid for the mariadb branch 11.0 and Ubuntu 22.04:

# Retrieved from: https://mariadb.org/download/?t=repo-config

# MariaDB 11.0 [RC] repository list - created 2023-02-24 18:43 UTC
# https://mariadb.org/download/
deb https://mirror.its.dal.ca/mariadb/repo/11.0/ubuntu jammy main
deb-src https://mirror.its.dal.ca/mariadb/repo/11.0/ubuntu jammy main
deb https://mirror.its.dal.ca/mariadb/repo/11.0/ubuntu jammy main/debug

Install dependencies:

sudo apt-get install software-properties-common \
      devscripts \
      equivs \
      curl \
      git
sudo apt-get build-dep mariadb-server

Import the repository key and update apt. You should not get any error from the mariadb repository server:

sudo curl -o /etc/apt/trusted.gpg.d/mariadb_release_signing_key.asc 'https://mariadb.org/mariadb_release_signing_key.asc'
sudo apt-get update

Build

Make sure you completed the previous steps without any failure before moving forward.

We will be working on 3 main directories maria-server (source directory), maria-server-build (build directory), and maria-server-data (data directory). You can choose any names. We will create them inside the home directory. You can choose any directory where root privilige is not required.

cd ~

Fork and, then clone the forked repo:

git clone https://github.com/{your-username}/maria-server

Create the build and data directory.

mkdir ~/maria-server-build
mkdir ~/maria-server-data

Run the following commands to start building. Notice the directory used in each command:

cd ~/maria-server-build
cmake ~/maria-server/ -DCMAKE_BUILD_TYPE=Debug
cmake --build ./ -j8

Configure

Before proceeding, you should have mariadb installed without any error from cmake.

Copy the following mariadb configuration into the file ~/.my.cnf. Set the absolute path to your data and build directory in the datadir and language entry before saving:

# Example MariadB config file.
# You can copy this to one of:
# /etc/my.cnf to set global options,
# /mysql-data-dir/my.cnf to get server specific options or
# ~/my.cnf for user specific options.
#
# One can use all long options that the program supports.
# Run the program with --help to get a list of available options

# This will be passed to all MariaDB clients
[client]
#password=my_password
#port=3306
#socket=/tmp/mysql.sock

# Here is entries for some specific programs
# The following values assume you have at least 32M ram

# The mariadb server  (both [mysqld] and [mariadb] works here)
[mariadb]
#port=3306
#socket=/tmp/mysql.sock

# The following three entries caused mysqld 10.0.1-MariaDB (and possibly other versions) to abort...
# skip-locking
# set-variable  = key_buffer=16M

loose-innodb_data_file_path = ibdata1:1000M
loose-mutex-deadlock-detector
gdb

######### Fix the two following paths

# Where you want to have your database
datadir={absolute-path-to-your-data-directory}

# Where you have your mysql/MariaDB source + sql/share/english
language={absolute-path-to-your-build-directory}/sql/share/english

########## One can also have a different path for different versions, to simplify development.

[mariadb-10.1]
lc-messages-dir=/my/maria-10.1/sql/share

[mariadb-10.2]
lc-messages-dir=/my/maria-10.2/sql/share

[mysqldump]
quick
set-variable = max_allowed_packet=16M

[mysql]
no-auto-rehash

[myisamchk]
set-variable= key_buffer=128M

Initialize data files in the data direcotry:

cd ~/maria-server-build
./scripts/mariadb-install-db --srcdir={absolute-path-to-your-source-directory} --user=$LOGNAME

Run

Check whether the install was successful:

./sql/mariadbd

You should see something similar to this in the terminal:

...
...
2023-02-24 14:37:06 0 [Note] ./sql/mariadbd: ready for connections.
Version: '11.0.1-MariaDB-debug'  socket: '/tmp/mysql.sock'  port: 3306  Source distribution

Shutdown the server using CTRL + C.

While the server was running, you could also run the client using ./client/mariadb to test SQL commands.

Debug (GDB)

Run gdb and the server with debug flag:

gdb -tui --args ./sql/mariadbd --gdb

Inside gdb, set breakpoint at the write_row function. This function is likely used by the sql INSERT command:

b write_row

Start the server within gdb:

run

In a separate terminal, run the client:

./client/mariadb

Set up a sample table:

CREATE DATABASE mydb;
USE mydb;
CREATE TABLE mytable (id int);

Insert a row into mytable. If gdb is setup correctly, the INSERT command will pause the client and trigger the breakpoint in the ha_innobase::write_row function.

INSERT INTO mytable VALUES ('1');

Debug (VSCode)

Use the following launch configuration. Make sure to set the build directory in the program entry. It should configure the default C\C++ extension to launch mariadb with debug flag:

"configurations": [
    ...,
    ...,
    {
        "name": "(gdb) Launch",
        "type": "cppdbg",
        "request": "launch",
        "program": "{absolute-path-to-your-build-directory}/sql/mariadbd",
        "args": ["--gdb", "--debug"],
        "stopAtEntry": false,
        "cwd": "${fileDirname}",
        "environment": [],
        "externalConsole": false,
        "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
            }
        ]
    }
]

Launch the server from the VSCode's Run and Debug tab. You can set breakpoints from the IDE's text editor. But, you have to run the sql commands from the client as shown in the previous section.

Rebuild

If you want to rebuild, first go the the source directory and run this command:

cd ~/maria-server
git clean -xffd && git submodule foreach --recursive git clean -xffd

Then, follow all the previous steps from the beginning.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.