pax_global_header 0000666 0000000 0000000 00000000064 14537531143 0014520 g ustar 00root root 0000000 0000000 52 comment=c500482304afdcbda041b05c62a151b73b22ee5d
cowsql-1.15.4/ 0000775 0000000 0000000 00000000000 14537531143 0013120 5 ustar 00root root 0000000 0000000 cowsql-1.15.4/.clang-format 0000664 0000000 0000000 00000000346 14537531143 0015476 0 ustar 00root root 0000000 0000000 BasedOnStyle: Chromium
BreakBeforeBraces: Custom
BraceWrapping:
AfterFunction: true
AfterStruct: true
IndentWidth: 8
UseTab: ForContinuationAndIndentation
PointerAlignment: Right
AllowAllParametersOfDeclarationOnNextLine: false
cowsql-1.15.4/.dir-locals.el 0000664 0000000 0000000 00000000266 14537531143 0015555 0 ustar 00root root 0000000 0000000 ((nil . ((fill-column . 80)))
(c-mode . ((c-file-style . "linux-tabs-only")
(flycheck-gcc-definitions . ("_GNU_SOURCE"))
(flycheck-clang-definitions . ("_GNU_SOURCE")))))
cowsql-1.15.4/.github/ 0000775 0000000 0000000 00000000000 14537531143 0014460 5 ustar 00root root 0000000 0000000 cowsql-1.15.4/.github/dependabot.yml 0000664 0000000 0000000 00000000542 14537531143 0017311 0 ustar 00root root 0000000 0000000 # Set update schedule for GitHub Actions
# for more info see: https://docs.github.com/en/code-security/dependabot/working-with-dependabot/keeping-your-actions-up-to-date-with-dependabot
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/" # checks for workflow files in .github/workflows
schedule:
interval: "weekly"
cowsql-1.15.4/.github/workflows/ 0000775 0000000 0000000 00000000000 14537531143 0016515 5 ustar 00root root 0000000 0000000 cowsql-1.15.4/.github/workflows/build-and-test.yml 0000664 0000000 0000000 00000001767 14537531143 0022067 0 ustar 00root root 0000000 0000000 name: CI Tests
on:
- push
- pull_request
jobs:
build-and-test:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Setup dependencies
run: |
sudo apt update
sudo apt install -y lcov libsqlite3-dev liblz4-dev libuv1-dev
- name: Build raft
run: |
git clone https://github.com/cowsql/raft.git --depth 1
cd raft
autoreconf -i
./configure --enable-debug --enable-sanitize
make -j4
sudo make install
sudo ldconfig
cd ..
- name: Build cowsql
run: |
autoreconf -i
./configure --enable-debug --enable-code-coverage --enable-sanitize
make CFLAGS=-O0 -j2
- name: Test
run: |
make CFLAGS=-O0 -j2 check || (cat ./test-suite.log && false)
- name: Coverage
run: make code-coverage-capture
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
verbose: true
cowsql-1.15.4/.github/workflows/coverity.yml 0000664 0000000 0000000 00000002772 14537531143 0021114 0 ustar 00root root 0000000 0000000 name: Coverity
on:
push:
branches:
- main
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download Coverity Build Tool
run: |
wget -q https://scan.coverity.com/download/cxx/linux64 --post-data "token=$TOKEN&project=cowsql/cowsql" -O cov-analysis-linux64.tar.gz
mkdir cov-analysis-linux64
tar xzf cov-analysis-linux64.tar.gz --strip 1 -C cov-analysis-linux64
env:
TOKEN: ${{ secrets.COVERITY_SCAN_TOKEN }}
- name: Install dependencies
run: |
sudo add-apt-repository -y ppa:cowsql/master
sudo apt-get update -qq
sudo apt-get install -qq gcc libsqlite3-dev liblz4-dev libuv1-dev libraft-dev
- name: Run coverity
run: |
export PATH="$(pwd)/cov-analysis-linux64/bin:${PATH}"
# Configure
autoreconf -i
mkdir build
cd build
../configure
# Build
cov-build --dir cov-int make -j4
tar czvf cowsql.tgz cov-int
# Submit the results
curl \
--form project=cowsql/cowsql \
--form token=${TOKEN} \
--form email=free@ekanayaka.io \
--form file=@cowsql.tgz \
--form version=master \
--form description="${GITHUB_SHA}" \
https://scan.coverity.com/builds?project=cowsql/cowsql
env:
TOKEN: ${{ secrets.COVERITY_SCAN_TOKEN }}
cowsql-1.15.4/.github/workflows/linting.yml 0000664 0000000 0000000 00000000526 14537531143 0020707 0 ustar 00root root 0000000 0000000 name: Linting
on:
- push
- pull_request
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: DoozyX/clang-format-lint-action@v0.16
with:
source: 'src test include'
exclude: 'test/lib/munit.*'
extensions: 'c,h'
clangFormatVersion: 14
style: file
cowsql-1.15.4/.gitignore 0000664 0000000 0000000 00000000421 14537531143 0015105 0 ustar 00root root 0000000 0000000 *.a
*.gcda
*.gcno
*.la
*.lo
*.log
*.o
*.so
*.trs
.deps
.dirstamp
.libs
Makefile
Makefile.in
aclocal.m4
aminclude_static.am
autom4te*.cache
confdefs.h
config.status
configure
coverage/
coverage.info
docs/build
unit-test
integration-test
cowsql.pc
libtool
stamp-h*
sqlite3.c
cowsql-1.15.4/.readthedocs.yaml 0000664 0000000 0000000 00000000453 14537531143 0016351 0 ustar 00root root 0000000 0000000 # .readthedocs.yaml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
version: 2
build:
os: ubuntu-22.04
tools:
python: "3.11"
sphinx:
configuration: docs/conf.py
python:
install:
- requirements: docs/requirements.txt
cowsql-1.15.4/AUTHORS 0000664 0000000 0000000 00000000360 14537531143 0014167 0 ustar 00root root 0000000 0000000 Unless mentioned otherwise in a specific file's header, all code in this
project is released under the LGPL v3 license.
The list of authors and contributors can be retrieved from the git
commit history and in some cases, the file headers.
cowsql-1.15.4/Dockerfile 0000664 0000000 0000000 00000002762 14537531143 0015121 0 ustar 00root root 0000000 0000000 # FROM debian:buster-slim as cowsql-lib-builder
FROM ubuntu as cowsql-lib-builder
ARG DEBIAN_FRONTEND="noninteractive"
ENV TZ=Europe/London
ENV LD_LIBRARY_PATH=/usr/local/lib
ENV GOROOT=/usr/local/go
ENV GOPATH=/go
ENV PATH=$GOPATH/bin:$GOROOT/bin:$PATH
RUN apt-get update && apt-get install -y git build-essential dh-autoreconf pkg-config libuv1-dev libsqlite3-dev liblz4-dev tcl8.6 wget
WORKDIR /opt
RUN git clone https://github.com/cowsql/raft.git && \
git clone https://github.com/cowsql/go-cowsql.git && \
wget -c https://golang.org/dl/go1.15.2.linux-amd64.tar.gz -O - | tar -xzf - -C /usr/local
WORKDIR /opt/raft
RUN autoreconf -i && ./configure && make && make install
WORKDIR /opt/cowsql
COPY . .
RUN autoreconf -i && ./configure && make && make install
WORKDIR /opt/go-cowsql
RUN go get -d -v ./... && \
go install -tags libsqlite3 ./cmd/cowsql-demo && \
go install -tags libsqlite3 ./cmd/cowsql
# FROM debian:buster-slim
FROM ubuntu
ARG DEBIAN_FRONTEND="noninteractive"
ENV TZ=Europe/London
ENV LD_LIBRARY_PATH=/usr/local/lib
ENV PATH=/opt:$PATH
COPY --from=cowsql-lib-builder /go/bin /opt/
COPY --from=cowsql-lib-builder /usr/local/lib /usr/local/lib
COPY --from=cowsql-lib-builder \
/usr/lib/x86_64-linux-gnu/libuv.so \
/usr/lib/x86_64-linux-gnu/libuv.so.1\
/usr/lib/x86_64-linux-gnu/libuv.so.1.0.0\
/usr/lib/
COPY --from=cowsql-lib-builder \
/lib/x86_64-linux-gnu/libsqlite3.so \
/lib/x86_64-linux-gnu/libsqlite3.so.0 \
/usr/lib/x86_64-linux-gnu/
cowsql-1.15.4/LICENSE 0000664 0000000 0000000 00000022076 14537531143 0014134 0 ustar 00root root 0000000 0000000 All files in this repository are licensed as follows. If you contribute
to this repository, it is assumed that you license your contribution
under the same license unless you state otherwise.
All files Copyright (C) 2017-2019 Canonical Ltd. unless otherwise specified in
the file.
All files modifications after the 9th of August 2023 Copyright (C) 2023 Free
Ekanayaka unless otherwise specified in the file.
The list of authors and contributors can be retrieved from the git commit
history and in some cases, the file headers.
This software is licensed under the LGPLv3, included below.
As a special exception to the GNU Lesser General Public License version 3
("LGPL3"), the copyright holders of this Library give you permission to
convey to a third party a Combined Work that links statically or dynamically
to this Library without providing any Minimal Corresponding Source or
Minimal Application Code as set out in 4d or providing the installation
information set out in section 4e, provided that you comply with the other
provisions of LGPL3 and provided that you meet, for the Application the
terms and conditions of the license(s) which apply to the Application.
Except as stated in this special exception, the provisions of LGPL3 will
continue to comply in full to this Library. If you modify this Library, you
may apply this exception to your version of this Library, but you are not
obliged to do so. If you do not wish to do so, delete this exception
statement from your version. This exception does not (and cannot) modify any
license terms which apply to the Application, with which you must still
comply.
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc.
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.
cowsql-1.15.4/Makefile.am 0000664 0000000 0000000 00000007235 14537531143 0015163 0 ustar 00root root 0000000 0000000 ACLOCAL_AMFLAGS = -I m4
AM_CFLAGS += $(CODE_COVERAGE_CFLAGS)
AM_CFLAGS += $(SQLITE_CFLAGS) $(UV_CFLAGS) $(RAFT_CFLAGS) $(PTHREAD_CFLAGS)
AM_LDFLAGS = $(UV_LIBS) $(RAFT_LIBS) $(PTHREAD_LIBS)
if !BUILD_SQLITE_ENABLED
AM_LDFLAGS += $(SQLITE_LIBS)
endif
include_HEADERS = include/cowsql.h
lib_LTLIBRARIES = libcowsql.la
libcowsql_la_CFLAGS = $(AM_CFLAGS) -fvisibility=hidden
libcowsql_la_LDFLAGS = $(AM_LDFLAGS) -version-info 0:1:0
libcowsql_la_SOURCES = \
src/bind.c \
src/client/protocol.c \
src/command.c \
src/conn.c \
src/db.c \
src/cowsql.c \
src/error.c \
src/format.c \
src/fsm.c \
src/gateway.c \
src/id.c \
src/leader.c \
src/lib/addr.c \
src/lib/buffer.c \
src/lib/transport.c \
src/logger.c \
src/message.c \
src/metrics.c \
src/config.c \
src/query.c \
src/registry.c \
src/request.c \
src/response.c \
src/roles.c \
src/server.c \
src/stmt.c \
src/tracing.c \
src/transport.c \
src/translate.c \
src/tuple.c \
src/vfs.c
if BUILD_SQLITE_ENABLED
libcowsql_la_SOURCES += sqlite3.c
endif
check_PROGRAMS = \
unit-test \
integration-test
TESTS = unit-test integration-test
check_LTLIBRARIES = libtest.la
libtest_la_CFLAGS = $(AM_CFLAGS) -DMUNIT_TEST_NAME_LEN=60 -Wno-unknown-warning-option -Wno-unused-result -Wno-conversion -Wno-uninitialized -Wno-maybe-uninitialized -Wno-strict-prototypes -Wno-old-style-definition
libtest_la_SOURCES = \
test/lib/endpoint.c \
test/lib/fault.c \
test/lib/fs.c \
test/lib/heap.c \
test/lib/logger.c \
test/lib/munit.c \
test/lib/raft_heap.c \
test/lib/server.c \
test/lib/sqlite.c \
test/lib/uv.c
unit_test_SOURCES = $(libcowsql_la_SOURCES)
unit_test_SOURCES += \
test/test_error.c \
test/test_integration.c \
test/unit/ext/test_uv.c \
test/unit/lib/test_addr.c \
test/unit/lib/test_buffer.c \
test/unit/lib/test_byte.c \
test/unit/lib/test_registry.c \
test/unit/lib/test_serialize.c \
test/unit/lib/test_transport.c \
test/unit/test_command.c \
test/unit/test_conn.c \
test/unit/test_gateway.c \
test/unit/test_concurrency.c \
test/unit/test_registry.c \
test/unit/test_replication.c \
test/unit/test_request.c \
test/unit/test_role_management.c \
test/unit/test_tuple.c \
test/unit/test_vfs.c \
test/unit/main.c
unit_test_CFLAGS = $(AM_CFLAGS) -Wno-unknown-warning-option -Wno-uninitialized -Wno-maybe-uninitialized -Wno-float-equal -Wno-conversion
unit_test_LDFLAGS = $(AM_LDFLAGS)
unit_test_LDADD = libtest.la
integration_test_SOURCES = \
test/integration/test_client.c \
test/integration/test_cluster.c \
test/integration/test_fsm.c \
test/integration/test_membership.c \
test/integration/test_node.c \
test/integration/test_role_management.c \
test/integration/test_server.c \
test/integration/test_vfs.c \
test/integration/main.c
integration_test_CFLAGS = $(AM_CFLAGS) -Wno-conversion
integration_test_LDFLAGS = $(AM_LDFLAGS) -no-install
integration_test_LDADD = libtest.la libcowsql.la
if DEBUG_ENABLED
AM_CFLAGS += -g
else
AM_CFLAGS += -O2
endif
if SANITIZE_ENABLED
AM_CFLAGS += -fsanitize=address
endif
if BACKTRACE_ENABLED
AM_CFLAGS += -DCOWSQL_ASSERT_WITH_BACKTRACE
AM_LDFLAGS += -lbacktrace
endif
if CODE_COVERAGE_ENABLED
include $(top_srcdir)/aminclude_static.am
CODE_COVERAGE_DIRECTORY=./src
CODE_COVERAGE_OUTPUT_DIRECTORY=coverage
CODE_COVERAGE_OUTPUT_FILE=coverage.info
CODE_COVERAGE_IGNORE_PATTERN="/usr/include/*"
CODE_COVERAGE_BRANCH_COVERAGE=1
CODE_COVERAGE_LCOV_OPTIONS=$(CODE_COVERAGE_LCOV_OPTIONS_DEFAULT) --rc lcov_excl_br_line="assert\("
clean-local: code-coverage-clean
distclean-local: code-coverage-dist-clean
endif # CODE_COVERAGE_ENABLED
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = cowsql.pc
cowsql-1.15.4/README.md 0000664 0000000 0000000 00000010044 14537531143 0014376 0 ustar 00root root 0000000 0000000 cowsql [](https://github.com/cowsql/cowsql/actions/workflows/build-and-test.yml) [](https://codecov.io/gh/cowsql/cowsql) [](https://cowsql.dev)
======
[English](./README.md)|[简体中文](./README_CH.md)
[cowsql](https://cowsql.dev) (/ˈkaʊ,siːkwəl/
[listen](http://ipa-reader.xyz/?text=%CB%88ka%CA%8A%2Csi%CB%90kw%C9%99l)) is a C
library that implements an embeddable and replicated SQL database engine with
high availability and automatic failover.
cowsql extends [SQLite](https://sqlite.org/) with a network protocol that can
connect together various instances of your application and have them act as a
highly-available cluster, with no dependency on external databases.
The name "cowsql" loosely refers to the ["pets
vs. cattle"](https://iamondemand.com/blog/devops-concepts-pets-vs-cattle/)
concept, since it's generaly fine to delete or rebuild a particular node of an
application that uses cowsql for data storage.
Fork of Canonical dqlite
------------------------
cowsql is a fork of Canonical's [dqlite](https://github.com/canonical/dqlite)
project, which was originally written by cowsql's author
[himself](https://github.com/canonical/dqlite/commits?author=freeekanayaka)
while working at Canonical.
Design highlights
----------------
* Asynchronous single-threaded implementation using [libuv](https://libuv.org/)
as event loop.
* Custom wire protocol optimized for SQLite primitives and data types.
* Data replication based on the [Raft](https://raft.github.io/) algorithm and its
efficient [C-raft](https://github.com/cowsql/raft) implementation.
License
-------
The cowsql library is released under a slightly modified version of LGPLv3, that
includes a copyright exception allowing users to statically link the library
code in their project and release the final work under their own terms. See the
full [license](./LICENSE) text.
Compatibility
-------------
cowsql runs on Linux and requires a kernel with support for [native async
I/O](https://man7.org/linux/man-pages/man2/io_setup.2.html) (not to be confused
with [POSIX AIO](https://man7.org/linux/man-pages/man7/aio.7.html)), which is
used by the libuv backend of C-raft.
Try it
-------
The simplest way to see cowsql in action is to use the demo program that comes
with the Go cowsql bindings. Please see the [relevant
documentation](https://github.com/cowsql/go-cowsql#demo) in that project.
Media
-----
There's no video about cowsql itself yet, but a talk about dqlite was given at
FOSDEM 2020, you can watch it
[here](https://fosdem.org/2020/schedule/event/dqlite/).
[Here](https://gcore.com/blog/comparing-litestream-rqlite-dqlite/) is a blog post from 2022 comparing dqlite with rqlite and Litestream, other replication software for SQLite. It largly applies to cowsql too.
Wire protocol
-------------
If you wish to write a client, please refer to the [wire protocol](https://dqlite.io/docs/protocol)
documentation.
Install
-------
If you are on a Debian-based system, you can get the latest development release from
cowsql's [dev PPA](https://launchpad.net/~cowsql/+archive/ubuntu/master):
```
sudo add-apt-repository ppa:cowsql/master
sudo apt-get update
sudo apt-get install libcowsql-dev
```
Build
-----
To build libcowsql from source you'll need:
* A reasonably recent version of [libuv](http://libuv.org/) (v1.8.0 or beyond).
* A reasonably recent version of sqlite3-dev
* A build of the [C-raft](https://github.com/cowsql/raft) Raft library.
Your distribution should already provide you with a pre-built libuv shared
library and libsqlite3-dev.
To build the raft library:
```
git clone https://github.com/cowsql/raft.git
cd raft
autoreconf -i
./configure
make
sudo make install
cd ..
```
Once all the required libraries are installed, in order to build the cowsql
shared library itself, you can run:
```
autoreconf -i
./configure
make
sudo make install
```
cowsql-1.15.4/README_CH.md 0000664 0000000 0000000 00000006127 14537531143 0014757 0 ustar 00root root 0000000 0000000
# cowsql
[](https://github.com/cowsql/cowsql/actions/workflows/build-and-test.yml) [](https://codecov.io/gh/cowsql/cowsql)
**注意**:中文文档有可能未及时更新,请以最新的英文[readme](./README.md)为准。
[cowsql](https://cowsql.io)是一个用C语言开发的可嵌入的,支持流复制的数据库引擎,具备高可用性和自动故障转移功能。
“cowsql”是“distributed SQLite”的简写,即分布式SQLite。意味着cowsql通过网络协议扩展SQLite,将应用程序的各个实例连接在一起,让它们作为一个高可用的集群,而不依赖外部数据库。
## 设计亮点
- 使用[libuv](https://libuv.org/)实现异步单线程的事件循环机制
- 针对SQLite 原始数据类型优化的自定义网络协议
- 基于[Raft](https://raft.github.io/)算法的数据复制及其高效[C-raft](https://github.com/cowsql/raft)实现
## license
cowsql库是在略微修改的 LGPLv3 版本下发布的,其中包括一个版权例外,允许用户在他们的项目中静态链接这个库的代码并按照自己的条款发布最终作品。如有需要,请查看完整[license](./LICENSE)文件。
## 兼容性
cowsql 在 Linux 上运行,由于C-raft 的 libuv 后端的实现,需要一个支持 [native async
I/O](https://man7.org/linux/man-pages/man2/io_setup.2.html) 的内核(注意不要和[POSIX AIO](https://man7.org/linux/man-pages/man7/aio.7.html)混淆)。
## 尝试使用
查看和了解cowsql的最简单方式是使用绑定了Go cowsql的demo样例程序,Go cowsql的使用可以参考它的项目文档[relevant
documentation](https://github.com/cowsql/go-cowsql#demo)。
## 视频
在 FOSDEM 2020 上有一个关于cowsql的演讲视频,您可以在[此处](https://fosdem.org/2020/schedule/event/cowsql/)观看。
## 网络协议
如果您想编写客户端,请参阅[网络协议](https://cowsql.io/docs/protocol)文档。
## 下载
如果您使用的是基于 Debian 的系统,您可以从 cowsql 的[dev PPA](https://launchpad.net/~cowsql/+archive/ubuntu/dev) 获得最新的开发版本:
```bash
sudo add-apt-repository ppa:cowsql/dev
sudo apt-get update
sudo apt-get install libcowsql-dev
```
## 源码构建
为了编译构建libcowsql,您需要准备:
- 较新版本的libuv(v1.18.0或之后的版本)
- 较新版本的sqlite3-dev
- 构建好的[C-raft](https://github.com/cowsql/raft)库
您的linux发行版应该已经为您提供了预构建的 libuv 共享库和 libsqlite3-dev,就不需要在下载了,否则还需要下载这两个依赖。
编译raft库运行如下命令:
```bash
git clone https://github.com/cowsql/raft.git
cd raft
autoreconf -i
./configure
make
sudo make install
cd ..
```
所有依赖的库都下载好后,运行如下命令手动编译cowsql库:
```bash
autoreconf -i
./configure
make
sudo make install
```
## 注意事项
当环境变量LIBRAFT_TRACE在启动时被设置,将启用详细跟踪。 cowsql-1.15.4/VERSION 0000664 0000000 0000000 00000000005 14537531143 0014163 0 ustar 00root root 0000000 0000000 0.1.0 cowsql-1.15.4/ac/ 0000775 0000000 0000000 00000000000 14537531143 0013503 5 ustar 00root root 0000000 0000000 cowsql-1.15.4/ac/.gitignore 0000664 0000000 0000000 00000000016 14537531143 0015470 0 ustar 00root root 0000000 0000000 *
!.gitignore
cowsql-1.15.4/configure.ac 0000664 0000000 0000000 00000005446 14537531143 0015417 0 ustar 00root root 0000000 0000000 AC_PREREQ(2.60)
AC_INIT([libcowsql], [1.15.4], [https://github.com/cowsql/cowsql])
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_AUX_DIR([ac])
AM_INIT_AUTOMAKE([subdir-objects -Wall -Werror -Wno-portability foreign])
AM_SILENT_RULES([yes])
AC_PROG_CC_STDC
AC_USE_SYSTEM_EXTENSIONS
AX_PTHREAD
LT_INIT
# TODO: eventually enable this
# AX_CHECK_COMPILE_FLAG([-Weverything], AM_CFLAGS+=" -Weverything")
# Whether to enable debugging code.
AC_ARG_ENABLE(debug, AS_HELP_STRING([--enable-debug[=ARG]], [enable debugging [default=no]]))
AM_CONDITIONAL(DEBUG_ENABLED, test "x$enable_debug" = "xyes")
# Whether to enable memory sanitizer.
AC_ARG_ENABLE(sanitize, AS_HELP_STRING([--enable-sanitize[=ARG]], [enable code sanitizers [default=no]]))
AM_CONDITIONAL(SANITIZE_ENABLED, test x"$enable_sanitize" = x"yes")
AM_COND_IF(SANITIZE_ENABLED,
AX_CHECK_COMPILE_FLAG([-fsanitize=address],
[true],
[AC_MSG_ERROR([address sanitizer not supported])]))
AC_ARG_ENABLE(backtrace, AS_HELP_STRING([--enable-backtrace[=ARG]], [print backtrace on assertion failure [default=no]]))
AM_CONDITIONAL(BACKTRACE_ENABLED, test "x$enable_backtrace" = "xyes")
AC_ARG_ENABLE(build-sqlite, AS_HELP_STRING([--enable-build-sqlite[=ARG]], [build libsqlite3 from sqlite3.c in the build root [default=no]]))
AM_CONDITIONAL(BUILD_SQLITE_ENABLED, test "x$enable_build_sqlite" = "xyes")
# Whether to enable code coverage.
AX_CODE_COVERAGE
# Checks for header files.
AC_CHECK_HEADERS([arpa/inet.h fcntl.h stdint.h stdlib.h string.h sys/socket.h unistd.h])
# Checks for typedefs, structures, and compiler characteristics.
AC_TYPE_SIZE_T
AC_TYPE_SSIZE_T
AC_TYPE_UINT16_T
AC_TYPE_UINT32_T
AC_TYPE_UINT8_T
# Enable large file support. This is mandatory in order to interoperate with
# libuv, which enables large file support by default, making the size of 'off_t'
# on 32-bit architecture be 8 bytes instead of the normal 4.
AC_SYS_LARGEFILE
# Checks for libraries
PKG_CHECK_MODULES(SQLITE, [sqlite3 >= 3.22.0], [], [])
PKG_CHECK_MODULES(UV, [libuv >= 1.8.0], [], [])
PKG_CHECK_MODULES(RAFT, [raft >= 0.17.1], [], [])
CC_CHECK_FLAGS_APPEND([AM_CFLAGS],[CFLAGS],[ \
-std=c11 \
-g \
--mcet \
-fcf-protection \
--param=ssp-buffer-size=4 \
-pipe \
-fno-strict-aliasing \
-fdiagnostics-color \
-fexceptions \
-fstack-clash-protection \
-fstack-protector-strong \
-fasynchronous-unwind-tables \
-fdiagnostics-show-option \
-Wall \
-Wextra \
-Wimplicit-fallthrough=5 \
-Wcast-align \
-Wstrict-prototypes \
-Wlogical-op \
-Wmissing-include-dirs \
-Wold-style-definition \
-Winit-self \
-Wfloat-equal \
-Wsuggest-attribute=noreturn \
-Wformat=2 \
-Wshadow \
-Wendif-labels \
-Wdate-time \
-Wnested-externs \
-Wconversion \
-Werror \
])
# To enable:
#
# -Wpedantic \
AC_SUBST(AM_CFLAGS)
AC_CONFIG_FILES([cowsql.pc Makefile])
AC_OUTPUT
cowsql-1.15.4/cowsql.pc.in 0000664 0000000 0000000 00000000424 14537531143 0015361 0 ustar 00root root 0000000 0000000 prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
Name: cowsql
Description: Distributed and embeddable SQL engine
Version: @PACKAGE_VERSION@
Libs: -L${libdir} -lcowsql
Libs.private: @SQLITE_LIBS@ @UV_LIBS@ @RAFT_LIBS@
Cflags: -I${includedir}
cowsql-1.15.4/doc/ 0000775 0000000 0000000 00000000000 14537531143 0013665 5 ustar 00root root 0000000 0000000 cowsql-1.15.4/doc/faq.md 0000664 0000000 0000000 00000000074 14537531143 0014757 0 ustar 00root root 0000000 0000000 Moved to the [website project](https://dqlite.io/docs/faq).
cowsql-1.15.4/doc/index.md 0000664 0000000 0000000 00000000070 14537531143 0015313 0 ustar 00root root 0000000 0000000 Moved to the [website project](https://dqlite.io/docs).
cowsql-1.15.4/doc/protocol.md 0000664 0000000 0000000 00000000101 14537531143 0016040 0 ustar 00root root 0000000 0000000 Moved to the [website project](https://dqlite.io/docs/protocol).
cowsql-1.15.4/docs/ 0000775 0000000 0000000 00000000000 14537531143 0014050 5 ustar 00root root 0000000 0000000 cowsql-1.15.4/docs/_themes/ 0000775 0000000 0000000 00000000000 14537531143 0015474 5 ustar 00root root 0000000 0000000 cowsql-1.15.4/docs/_themes/material/ 0000775 0000000 0000000 00000000000 14537531143 0017272 5 ustar 00root root 0000000 0000000 cowsql-1.15.4/docs/_themes/material/genindex.html 0000664 0000000 0000000 00000000321 14537531143 0021755 0 ustar 00root root 0000000 0000000 {#
basic/genindex.html
~~~~~~~~~~~~~~~~~~~
Template for an "all-in-one" index.
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
#}
cowsql-1.15.4/docs/_themes/material/layout.html 0000664 0000000 0000000 00000011540 14537531143 0021476 0 ustar 00root root 0000000 0000000
{%- macro css() %}
{%- for css in css_files %}
{%- if css|attr("filename") %}
{{ css_tag(css) }}
{%- else %}
{%- endif %}
{%- endfor %}
{%- endmacro %}
{%- macro header() %}
{%- endmacro %}
{%- macro navigation() %}