Git Product home page Git Product logo

bsql's Introduction

Deprecation warning

This repository is deprecated, currently /tg/station is using a rust based SQL client library, embedded in rust-g

This client library has a nasty habit of segfaulting if you do a reconnection option while there are queries out for processing.

You can find rust-g here - https://github.com/tgstation/rust-g - but it also comes packaged with the game.

Build Status

forthebadge forinfinityandbyond

BSQL

This is a non-blocking SQL library for BYOND games

Building

Install the c++ build chain for your operating system as well as CMake. Remember that you must build the library as x86 (because BYOND)

Windows

  • Install the vcpkg package manager (Example done in powershell)

    • git clone https://github.com/Microsoft/vcpkg
    • cd vcpkg
    • .\bootstrap-vcpkg.bat
    • .\vcpkg.exe integrate install (Accept admin prompt. Must restart shell after this)
  • Install libmariadb with .\vcpkg.exe install libmariadb:x86-windows

  • Option 1: Visual Studio

    • Set up a CMakeSettings.json in the project root with the path to the vcpkg toolchain file
    • Open and build BSQL.sln
  • Option 2: VS Command Line Build Tools (Requires CMake 3.8 or higher)

    • Run cmake -DCMAKE_TOOLCHAIN_FILE=C:/path/to/vcpkg/scripts/buildsystems/vcpkg.cmake path/to/code/root
    • Run C:/path/to/msbuild.exe BSQL.sln

Linux

  • Dependencies (Debian based distros)
  • libmariadb2:i386 libmariadbclient-dev:i386 libssl1.1:i386 (exact libssl version probably doesn't matter exactly)
  • Cmake expects the includes to be in /usr/include/mysql and the libraries to be in /usr/lib/i386-linux-gnu, you'll have to adjust the paths in CMakelists if your distro does it differently
  • Generate makefiles with cmake
  • Use make to build

Linux Alternative

  • Make the LinuxInstall.sh file executable via chmod +x LinuxInstall.sh
  • run LinuxInstall.sh as a super user
  • All dependencies will be installed and the binaries will be build for you.

Troubleshooting

  • Run ldd on the output .so file, ensure all dependencies exist and are valid
  • Run file on the output .so file and validate it's a 32 bit lib

Integrating

To integrate BSQL into your DM project, build it or download a windows release and drop the libmariadb and BSQL binaries in the root of your project folder. Then include the DMAPI (under src/DMAPI) in your project. Only include BSQL.dm and BSQL/includes.dm for maximum future compatibility. Modify the configuration options in BSQL.dm to your needs or create and include seperate config file. Follow the comments in BSQL.dm for further instructions

LICENSE

This project is licensed under the MIT license.

See LICENSE for more details.

bsql's People

Contributors

cyberboss avatar gh0st2242 avatar nethiafin avatar optimumtact avatar praisenarsie avatar shizcalev avatar spacemaniac avatar vuonojenmustaturska avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

bsql's Issues

Not woking on CentOS 7

rust-g loading successfully, but BSQL fails:

world/New
TestStart
Init time elapsed
Beginning test
BSQL_DEBUG: /world/proc/_BSQL_Internal_Call: Initialize()
runtime error: Unable to load library libBSQL.so

Library built with gcc 8.1.0

Requires visual studio

This is c++ land baby, real programmers program in notepad++ and/or vim!

It is unacceptable that the library manager to manage 1 library requires a graphical ide to work on windows.

Library not being initialized and failing to connect

I'm running /tg/station with the latest pre-compiled binary under Debian. Right now, the library fails to connect to the SQL server with the following messages:

[2019-10-15 16:34:54.437] Running /tg/ revision: 2019-10-15
 - origin/master: fbcc06ca029ed6141a2448adef4944d528a7217a
[2019-10-15 16:34:54.449] Loading config file config.txt...
[2019-10-15 16:34:54.451] Loading config file game_options.txt...
[2019-10-15 16:34:54.464] Loading config file dbconfig.txt...
[2019-10-15 16:34:54.465] Loading config file comms.txt...
[2019-10-15 16:34:54.465] Loading config file antag_rep.txt...
[2019-10-15 16:34:54.473] Loading config file maps.txt...
[2019-10-15 16:34:54.475] Loading config file in_character_filter.txt...
[2019-10-15 16:34:54.514] runtime error: Library not initialized!
 - proc name: Connect (/datum/controller/subsystem/dbcore/proc/Connect)
 -   source file: dbcore.dm,93
 -   usr: null
 -   src: Database (/datum/controller/subsystem/dbcore)
 -   call stack:
 - Database (/datum/controller/subsystem/dbcore): Connect()
 - load admins(null)
 - world: New()
 - 
[2019-10-15 16:34:54.515] SQL: Failed to connect to database while loading admins. Loading from backup.
[2019-10-15 16:34:54.516] runtime error: Cannot execute null.IsComplete().
 - proc name: run query (/datum/DBQuery/proc/run_query)
 -   source file: dbcore.dm,359
 -   usr: null
 -   src: /datum/DBQuery (/datum/DBQuery)
 -   call stack:
 - /datum/DBQuery (/datum/DBQuery): run query(1)
 - /datum/DBQuery (/datum/DBQuery): Execute(1, 1)
 - load admin ranks(1, null)
 - load admins(null)
 - world: New()
 - 
[2019-10-15 16:34:54.517] runtime error: Cannot execute null.GetErrorCode().
 - proc name: Execute (/datum/DBQuery/proc/Execute)
 -   source file: dbcore.dm,332
 -   usr: null
 -   src: /datum/DBQuery (/datum/DBQuery)
 -   call stack:
 - /datum/DBQuery (/datum/DBQuery): Execute(1, 1)
 - load admin ranks(1, null)
 - load admins(null)
 - world: New()
 - 
[2019-10-15 16:34:54.518] SQL: Error loading admin ranks from database. Loading from backup.
[2019-10-15 16:34:54.518] Unable to locate admins backup file.
[2019-10-15 16:34:54.528] runtime error: Cannot execute null.IsComplete().
 - proc name: run query (/datum/DBQuery/proc/run_query)
 -   source file: dbcore.dm,359
 -   usr: null
 -   src: /datum/DBQuery (/datum/DBQuery)
 -   call stack:
 - /datum/DBQuery (/datum/DBQuery): run query(1)
 - /datum/DBQuery (/datum/DBQuery): Execute(1, 1)
 - load admins(null)
 - world: New()
 - 
[2019-10-15 16:34:54.529] runtime error: Cannot execute null.GetErrorCode().
 - proc name: Execute (/datum/DBQuery/proc/Execute)
 -   source file: dbcore.dm,332
 -   usr: null
 -   src: /datum/DBQuery (/datum/DBQuery)
 -   call stack:
 - /datum/DBQuery (/datum/DBQuery): Execute(1, 1)
 - load admins(null)
 - world: New()
 - 
[2019-10-15 16:34:54.529] SQL: Error loading admins from database. Loading from backup.
[2019-10-15 16:34:54.530] runtime error: Cannot execute null.IsComplete().
 - proc name: IsConnected (/datum/controller/subsystem/dbcore/proc/IsConnected)
 -   source file: dbcore.dm,163
 -   usr: null
 -   src: Database (/datum/controller/subsystem/dbcore)
 -   call stack:
 - Database (/datum/controller/subsystem/dbcore): IsConnected()
 - Database (/datum/controller/subsystem/dbcore): Connect()
 - Database (/datum/controller/subsystem/dbcore): CheckSchemaVersion()
 - world: New()
 - 
[2019-10-15 16:34:54.532] runtime error: Library not initialized!
 - proc name: Connect (/datum/controller/subsystem/dbcore/proc/Connect)
 -   source file: dbcore.dm,93
 -   usr: null
 -   src: Database (/datum/controller/subsystem/dbcore)
 -   call stack:
 - Database (/datum/controller/subsystem/dbcore): Connect()
 - Database (/datum/controller/subsystem/dbcore): CheckSchemaVersion()
 - world: New()
 - 
[2019-10-15 16:34:54.532] SQL: Your server failed to establish a connection with the database.
[2019-10-15 16:34:54.533] runtime error: Cannot execute null.IsComplete().
 - proc name: IsConnected (/datum/controller/subsystem/dbcore/proc/IsConnected)
 -   source file: dbcore.dm,163
 -   usr: null
 -   src: Database (/datum/controller/subsystem/dbcore)
 -   call stack:
 - Database (/datum/controller/subsystem/dbcore): IsConnected()
 - Database (/datum/controller/subsystem/dbcore): Connect()
 - Database (/datum/controller/subsystem/dbcore): SetRoundID()
 - world: New()
 - 
[2019-10-15 16:34:54.534] runtime error: Library not initialized!
 - proc name: Connect (/datum/controller/subsystem/dbcore/proc/Connect)
 -   source file: dbcore.dm,93
 -   usr: null
 -   src: Database (/datum/controller/subsystem/dbcore)
 -   call stack:
 - Database (/datum/controller/subsystem/dbcore): Connect()
 - Database (/datum/controller/subsystem/dbcore): SetRoundID()
 - world: New()
 - 

Seems like a bug to me. Any ideas?

Can't get linux version of BSQL to work

I can't get SQL to work on the docker version of tgstation.
I get the error: [10:50:35] Runtime in library.dm,4: Unable to load library /root/.byond/bin/libBSQL.so

Here's the log for the round: https://gist.github.com/HiddenKn/8cb994b83be35c20497aa333b28b2d38

MariaDB version: Server version: 10.2.20-MariaDB-1:10.2.20+maria~bionic-log mariadb.org binary distribution

ldd output:
/tgstation/libBSQL.so: /usr/lib/i386-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.22' not found (required by /tgstation/libBSQL.so)
linux-gate.so.1 => (0xf77b7000)
libmariadb.so.2 => not found
libstdc++.so.6 => /usr/lib/i386-linux-gnu/libstdc++.so.6 (0xf75eb000)
libgcc_s.so.1 => /lib/i386-linux-gnu/libgcc_s.so.1 (0xf75ce000)
libc.so.6 => /lib/i386-linux-gnu/libc.so.6 (0xf7418000)
libm.so.6 => /lib/i386-linux-gnu/libm.so.6 (0xf73c3000)
/lib/ld-linux.so.2 (0xf77b8000)

I tried compiling it manually as well on my ubuntu server but ran into the same issue.

I can connect to the mysql server manually using the mysql command.

Terry crashing repeatedly during initialization.

.NET runtime event (EventID: 1026)

Application: dreamdaemon.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: exception code c0000005, exception address 6C687B98

Application Error event (EventID: 1000)

Faulting application name: dreamdaemon.exe, version: 5.0.512.1448, time stamp: 0x5b84d13f
Faulting module name: BSQL.dll, version: 0.0.0.0, time stamp: 0x5b57728f
Exception code: 0xc0000005
Fault offset: 0x00007b98
Faulting process id: 0x1ba8

Resource Log:

[7:41:16 PM]: CPU: 083% Memory: 427376KB
[7:41:21 PM]: CPU: 041% Memory: 24KB
[7:41:21 PM]: Crash detected! Exit code: -1073741819

Game Log:

[2018-09-23 19:41:13.225] GAME: Ancient Space Station loaded at at 62,148,9
[2018-09-23 19:41:13.361] GAME: Salvation loaded at at 204,69,10
[2018-09-23 19:41:13.400] GAME: Asteroid 5 loaded at at 31,138,8
[2018-09-23 19:41:13.584] GAME: Crashed Ship loaded at at 92,158,8

Runtime Log:

[2018-09-23 19:41:08.347] Loaded Lavaland in 1.8s!
[2018-09-23 19:41:10.687] Ruin loader finished with 0 left to spend.
[2018-09-23 19:41:13.584] Ruin loader finished with 24 left to spend.
[2018-09-23 19:41:14.809] Initialized Mapping subsystem within 44.8 seconds!
[2018-09-23 19:41:14.845] Initialized Networks subsystem within 0 seconds!
[2018-09-23 19:41:14.846] Initialized Economy subsystem within 0 seconds!

sql.log

[2018-09-23 19:41:20.887] SQL: Operation is not complete! | Query used: SELECT * FROM SS13library WHERE isnull(deleted) GROUP BY title ORDER BY rand() LIMIT 3;

Crashes when compiled on Arch, maybe

Reported on IRC, self-compiled BSQL on Arch, simultaneous with prefix being wrong

Fri Sep 13 18:39:45 2019
World opened on network port 8118.
Welcome BYOND! (5.0 Public Version 512.1472)
646 global variables
World loaded at 18:39:51!
Running /tg/ revision: 2019-09-09
origin/master: 583fafa5b8e20d28aabd4feb4f504aefb9ad7ef6
Loading config file config.txt...
Loading config file game_options.txt...
Loading config file dbconfig.txt...
Loading config file comms.txt...
Loading config file antag_rep.txt...
Loading config file maps.txt...
Loading config file in_character_filter.txt...
Database connection established.
The BYOND hub reports that port 8118 is reachable.
Initialized Title Screen subsystem within 0 seconds!
Initialized Database subsystem within 0 seconds!
Initialized Blackbox subsystem within 0 seconds!
Initialized Server Tasks subsystem within 0 seconds!
Initialized Input subsystem within 0 seconds!
Initialized Vis contents overlays subsystem within 0 seconds!
Initialized Materials subsystem within 0 seconds!
Initialized Research subsystem within 0 seconds!
Initialized Events subsystem within 0 seconds!
Initialized Jobs subsystem within 0 seconds!
Initialized Quirks subsystem within 0 seconds!
Initialized Ticker subsystem within 0 seconds!
Loading PubbyStation...
Loaded Station in 1.5s!
Loaded Lavaland in 0.9s!
Ruin loader finished with 0 left to spend.
Ruin loader finished with 0 left to spend.
Initialized Mapping subsystem within 4.4 seconds!
Initialized Networks subsystem within 0 seconds!
Initialized Economy subsystem within 0 seconds!
Initialized Atoms subsystem within 17.4 seconds!
Initialized Language subsystem within 0 seconds!
Initialized Machines subsystem within 0.1 seconds!
BUG: Crashing due to an illegal operation!
./StartServer.sh: line 2: 18454 Segmentation fault      (core dumped) DreamDaemon tgstation.dmb 8118 -trusted
[user@machine tgstation]$ ./StartServer.sh
Fri Sep 13 18:40:32 2019
World opened on network port 8118.
Welcome BYOND! (5.0 Public Version 512.1472)
646 global variables
World loaded at 18:40:38!
Running /tg/ revision: 2019-09-09
origin/master: 583fafa5b8e20d28aabd4feb4f504aefb9ad7ef6
Loading config file config.txt...
Loading config file game_options.txt...
Loading config file dbconfig.txt...
Loading config file comms.txt...
Loading config file antag_rep.txt...
Loading config file maps.txt...
Loading config file in_character_filter.txt...
Database connection established.
The BYOND hub reports that port 8118 is reachable.
Initialized Title Screen subsystem within 0 seconds!
Initialized Database subsystem within 0 seconds!
Initialized Blackbox subsystem within 0 seconds!
Initialized Server Tasks subsystem within 0 seconds!
Initialized Input subsystem within 0 seconds!
Initialized Vis contents overlays subsystem within 0 seconds!
Initialized Materials subsystem within 0 seconds!
Initialized Research subsystem within 0.1 seconds!
Initialized Events subsystem within 0 seconds!
Initialized Jobs subsystem within 0 seconds!
Initialized Quirks subsystem within 0 seconds!
Initialized Ticker subsystem within 0 seconds!
Loading PubbyStation...
Loaded Station in 1.4s!
Loaded Lavaland in 0.9s!
Ruin loader finished with 0 left to spend.
Ruin loader finished with 0 left to spend.
Initialized Mapping subsystem within 4.6 seconds!
Initialized Networks subsystem within 0 seconds!
Initialized Economy subsystem within 0 seconds!
Initialized Atoms subsystem within 18.8 seconds!
Initialized Language subsystem within 0.1 seconds!
Initialized Machines subsystem within 0 seconds!
BUG: Crashing due to an illegal operation!
proc name:  BSQL Internal Call (/world/proc/_BSQL_Internal_Call)
  source file: library.dm,4
  usr: null
  src: world
  call stack:
world:  BSQL Internal Call("ReleaseConnection", "1")
/datum/BSQL_Connection (/datum/BSQL_Connection): Destroy(0)
qdel(/datum/BSQL_Connection (/datum/BSQL_Connection), 0)
Database (/datum/controller/subsystem/dbcore): Disconnect()
/datum/DBQuery (/datum/DBQuery): Execute(1, 1)
create random books(2, the bookcase (Adult) (/obj/structure/bookcase/random/adult), 0, "Adult")
the bookcase (Adult) (/obj/structure/bookcase/random/adult): LateInitialize()
 
Backtrace for BYOND 512.1472 on Linux:
Generated at Fri Sep 13 18:41:03 2019
 
DreamDaemon [0x8048000, 0x0], [0x8048000, 0x804bd64]
libBSQL.so 0x3a5ae, 0x3a66e
linux-gate.so.1 [0xf7f20000, 0xf7f20950], [0xf7f20000, 0xf7f20950]
libBSQL.so 0x3a5ae, 0x3a66e
libBSQL.so 0x404b0, 0x404f5
libBSQL.so 0x405a8, 0x405c5
libBSQL.so 0x397e8, 0x3980c
libBSQL.so 0x3969c, 0x396f4
libBSQL.so 0x39502, 0x39523
libBSQL.so 0x3953c, 0x3955a
libBSQL.so 0x393d6, 0x393f7
libBSQL.so 0x38ef4, 0x38f2c
libBSQL.so 0x38730, 0x38750
libBSQL.so 0x382c0, 0x38314
libBSQL.so 0x382c0, 0x382f2
libBSQL.so 0x39246, 0x39272
libBSQL.so 0x3abec, 0x3ac0b
libBSQL.so 0x39cd4, 0x39dcb
libBSQL.so 0x39efc, 0x39f19
libBSQL.so 0x37966, 0x3798a
libBSQL.so 0x37700, 0x37758
libBSQL.so 0x3730e, 0x3732f
libBSQL.so 0x37348, 0x37366
libBSQL.so 0x36e9c, 0x36ebd
libBSQL.so 0x361a8, 0x361e0
libBSQL.so 0x35328, 0x35348
libBSQL.so 0x34aa8, 0x34afc
libBSQL.so 0x36672, 0x3669e
libBSQL.so 0x35ab6, 0x35b6c
libBSQL.so 0x34e3e, 0x34ec7
libBSQL.so 0x346e0, 0x34702
libBSQL.so 0x337c4, 0x337e9
libBSQL.so 0x30f13, 0x30fda
libbyond.so [0xf7946000, 0x0], 0x2cea97
libbyond.so [0xf7946000, 0x0], 0x2b218e
libbyond.so [0xf7946000, 0x0], 0x2bc1e2
libbyond.so [0xf7946000, 0x0], 0x2bddc4
libbyond.so [0xf7946000, 0x0], 0x2cd787
libbyond.so [0xf7946000, 0x0], 0x2a3566
libbyond.so [0xf7946000, 0x0], 0x2bc1e2
libbyond.so [0xf7946000, 0x0], 0x2bddc4
libbyond.so [0xf7946000, 0x0], 0x2cda20
libbyond.so [0xf7946000, 0x0], 0x2a3566
libbyond.so [0xf7946000, 0x0], 0x2bc1e2
libbyond.so [0xf7946000, 0x0], 0x2986ae
libbyond.so [0xf7946000, 0x0], 0x2bc1e2
libbyond.so [0xf7946000, 0x0], 0x2bddc4
libbyond.so [0xf7946000, 0x0], 0x2cd787
libbyond.so [0xf7946000, 0x0], 0x29bf61
libbyond.so [0xf7946000, 0x0], 0x2a7b46
 
Recent proc calls:
/world/proc/_BSQL_Library_Path
/datum/controller/configuration/proc/Get
/world/BSQL_Debug
/world/proc/_BSQL_Internal_Call
/datum/BSQL_Connection/Destroy
/datum/qdel_item/New
/proc/qdel
/datum/controller/subsystem/garbage/proc/Queue
/datum/proc/Destroy
/datum/controller/configuration/proc/Get
/world/BSQL_Debug
/world/proc/_BSQL_Library_Path
/datum/controller/configuration/proc/Get
/world/BSQL_Debug
/world/proc/_BSQL_Internal_Call
/datum/BSQL_Operation/Destroy
 
To help the BYOND developers debug this, please send the above trace as part
of a very detailed bug report: http://www.byond.com/members/?command=view_tracker&tracker=1
 
terminate called after throwing an instance of 'std::system_error'
  what():  Invalid argument

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.