-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MySQL / MariaDB - Referential Integrity Support. #212
Comments
It's storage engine dependent. MyISAM is a no go. |
Referential Integrity script consolidation. Script is now sql/enable_RI.sql
If these tables, Note: Although it is not recommended, it could be possible to use different storage engines for other tables in the same DB. I would strongly recommend doing this on a test system vs a production system, in case it falls apart.
So you could, get it working now for testing. I have code in the unreleased pipeline that will automatically do the following. #214
If the above checks out, BASE would automatically perform the equivalent of the It can also run SQL that will remove the RI constraints from the DB tables, so we can toggle the whole feature with just the config var. I'm still working on it / testing it out. We don't want BASE to automatically trash a production DB. |
I have implemented RI as described for MySQL. I've moved, copied and deleted multiple events with no issues. Not sure if it's really working. I'm guessing that I'll see a database failure if it fails. Not real sure how to test this? |
We are just talking about MySQL right now, correct? I'm assuming that RI is working as intended on PostgreSQL, or is it? |
PostgreSQL 7+ is fine. The problem is #215 We actually inherited this bug from the ACID project. PostgreSQL has had RI since 7.0 Released 2000-05-08 https://en.wikipedia.org/wiki/PostgreSQL I think the assumption was that if an end user enabled this, they knew what they were doing. When I get this mess sorted, even if someone were to run BASE using a PostgreSQL 6x server and enabled RI in |
I'm still at a loss on how MSSQL is even possible with Barnyard2 as I've never seen anything on compiling Barnyard2 with MSSQL or Oracle. I just went back through my docs and the last time I supported MSSQL was back in 2012. There were shops that could only use Microsoft products. I'm willing to try MSSQL if you have any idea how to compile Barnyard2 with MSSQL :) |
I have no idea RE: Barnyard2 & MsSQL. Looking at their source, and knowing where they got it form, it "should" be possible. At some point I hope to get a free version of MsSQL, probably MSDE or SQLExpress running on a windows box, and can then play around with it. |
Code Cleanup. File(s): base_conf.php.dist : base_maintenance.php : includes/base_action.inc.php : setup/base_conf_contents.php Issue(s): #103 #212 #214 #215 Code Cleanup. File(s): includes/base_auth.inc.php Code Cleanup. File(s): includes/base_db.inc.php Issue(s): #103 #212 #214 #215 Added DB connection awarenes to multiple functions. This allows us to log transient DB connection errors. Code Cleanup. Function(s): baseisDBUp( LogError ) Returns true if DB connection is up, false otherwise. Optionally logs the connection error. : baseSetRI( State ) DB Referential Integrity (RI) Control. Enables / Disables RI on DB server software that supports it. Adding / removing the necessary RI structure to the DB. Respects the $use_referential_integrity conf var. : baseGetRI() Returns the RI status of the connected DB. : baseTSE( table ) Returns the MySQL/MariaDB storage engine of the requested table, empty string otherwise. File(s): includes/base_krnl.php Bumped Kernel Version to 0.0.7 Code Cleanup. Function(s): function VS2SV( VS ) Returns Semantic Version Array determined from supplied Version string, false if unsucessful. File(s): includes/base_rtl.php Bumped Kernel Version to 0.0.11 Code Cleanup. Function(s): function VS2SV( VS ) Returns Semantic Version Array determined from supplied Version string, false if unsucessful. File(s): sql/create_snort_tbls_*.sql Added DB creation scripts from the SNORT project. Schema 107 Now it is possible to manually initialize the entire DB from a BASE snapshot. File(s): sql/disable_RI*.sql Scripts to manually disable RI in the DB. Unit Test(s): Covers the following in the baseCon Class baseisDBUp() baseSetRI() baseGetRI() baseTSE()
Code Cleanup. File(s): includes/base_db.inc.php Function(s): baseFKeyExists( $key ) Returns true if RI is enabled and the RI Foreign Key exists in the DB structure, false otherwise. Unit Test(s): Covers the following in the baseCon Class baseFKeyExists()
I tried MSSQL Express 2008 specifying ODBC and MSSQL and Barnyard2 says they need to be compiled in. I'm guessing that BASE could be capable but would need a separate program, or the drain on BASE would be too great. Barnyard2 used the code from Snort and I'm thinking that is why it is littered with code referencing DB's that not supported. At one point when I was using Snort to access MSSQL, I used ODBC to make the DB connection. |
So, for barnyard2, it's an issues of
Were you able to run the DB creation script from BASE on the MsSQL server successfully? I opened #216 to add the MsSQL DB option to the PPHPUnit test set. Once I get that done, it should be possible to run the test sets using a MsSQL DB server. That could give is a better understanding of where BASE stands RE: MsSQL compatibility. |
I'm not sure if the Windows build process for barnyard2 follows the same path as Linux, aka, configure, make, make install, however these options when building barnyard2 might give you what you want. |
I have never used BASE to configure the DB's as I do that manually. I had no problem adding in all the .sql's and user authentications. In theory BASE should have been able to connect but I didn't try after Barnyard2 refused to connect. I'll have to setup another test system this weekend and see if BASE will connect to MSSQL. I'm compiling Barnyard2 on Cygwin which is a Unix-like environment and command-line interface for Windows. I would use the same command as Linux to compile. I'm sure compiling MSSQL or ODBC into Barnyard2 would require external files which I have no idea what that would be :) |
That makes life easier.
I'm not sure how the package management works in Cygwin, but this might help you. It looks like ODBC would be how we would get alerts from barnyard to MsSQL. |
When you get a chance, can you post the command lines you used to set this up for MsSQL. I'm sure like MySQL & PostgreSQL, MsSQL has it's own CLI tool with its own unique command line options to do this. I'll incorporate them into the setup script for the PHPUnit Tests. |
I did some research, for instance if I was building barnyard2 to use ODBC on debian, I would install the I found this online. In the list I found |
I have tried MSSQL 2008 and MSSQL 2022. I have installed the correct extension for PHP 8.2 along with the ODBC driver. BASE is throwing the error below.
|
Opened #226 to track this one. |
Could you also give me the output of |
In #192 you mentioned
What would the php.ini lines be for enabling the following:
We could detect when BASE is running on windows and issue a more appropriate error message about enabling the necessary extension. Unless, I'm missing something, error messages with advice about options to use when compiling PHP from source are not a lot of help. |
I'm using Apache2 extension=sqlsrv_82_ts The extension for PHP 8 is installed and gets loaded as there is no error. |
|
I can manually connect to the MSSQL 2022 Express DB using all the credentials from the base configuration but base fails to connect.
BASE has to make the connection to the MSSQL server first :) |
Fix is in the devel branch,. |
I had to switch back to ODBC 17 as I was getting the below error on ODBC 18:
After switching back to ODBC 17 I'm now getting BASE but it has an error: PHP Error: I remembered that for MSSQL a line needed changing in the base_stat_common.php file. I'm not sure if it messes with any of the other DB's.
BASE now comes up completely and I'm able to switch from base DB to archive DB with no issues. No PHP Errors:
RI seems to be doing what it is supposed to be doing, no issues. |
ODBC 18 looks like it is trying to establish an SSL connection to the MsSQL server and can't validate the certificate chain. Thanks for the error message on that, it lit up #227 . ODBC17 I'll dig into the SQL error and find out why it breaks on MsSQL. |
Online it said exclude SSL or to revert back to ODBC 17 and I did that :) |
I already have #213 open about this in general. Once I close that, it may be possible to upgrade to ODBC 18 and use SSL if you want to, but right now, BASE has no clue about SSL connections to the DB, although the underlying ADOdb library is capable of using SSL. |
Error introduced in BASE 1.4.4. |
ALTER
DB privileges.Expected Behavior:
Can we support this on newer versions of MySQL / MariaDB & how do we do that?
Current Behavior:
Apparently not supported.
The text was updated successfully, but these errors were encountered: