mirror of
https://github.com/rsyslog/loganalyzer.git
synced 2025-09-25 18:59:12 +02:00
Added support to automatically add missing fields for MSSQL Driver in PDO LogStream class
This commit is contained in:
parent
43917f4810
commit
3d8f5074c6
@ -2166,18 +2166,21 @@ class LogStreamPDO extends LogStream {
|
|||||||
{
|
{
|
||||||
// check matching of error msg!
|
// check matching of error msg!
|
||||||
if (
|
if (
|
||||||
preg_match("/Unknown column '(.*?)' in '(.*?)'$/", $errdesc[2], $errOutArr ) || // MySQL
|
preg_match("/Unknown column '(.*?)' in '(.*?)'$/", $errdesc[2], $errOutArr ) || // MySQL
|
||||||
preg_match("/column \"(.*?)\" does not exist/", $errdesc[2], $errOutArr ) // PostgreSQL
|
preg_match("/column \"(.*?)\" does not exist/", $errdesc[2], $errOutArr ) || // PostgreSQL
|
||||||
|
preg_match("/Invalid column name '(.*?)'/", $errdesc[2], $errOutArr ) // MSSQL
|
||||||
// ERROR: column "checksum" does not exist LINE 1: ... eventsource, eventcategory, eventuser, systemid, checksum, ... ^
|
// ERROR: column "checksum" does not exist LINE 1: ... eventsource, eventcategory, eventuser, systemid, checksum, ... ^
|
||||||
)
|
)
|
||||||
|
{
|
||||||
$szMissingField = $errOutArr[1];
|
$szMissingField = $errOutArr[1];
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->PrintDebugError("ER_BAD_FIELD_ERROR - SQL Statement: ". $errdesc[2]);
|
$this->PrintDebugError("ER_BAD_FIELD_ERROR - SQL Statement: ". $errdesc[2]);
|
||||||
return ERROR_DB_DBFIELDNOTFOUND;
|
return ERROR_DB_DBFIELDNOTFOUND;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set Properties to default if NULL
|
// Set Properties to default if NULL
|
||||||
if ( $arrProperties == null )
|
if ( $arrProperties == null )
|
||||||
$arrProperties = $this->_arrProperties;
|
$arrProperties = $this->_arrProperties;
|
||||||
@ -2211,7 +2214,18 @@ class LogStreamPDO extends LogStream {
|
|||||||
if ( $fields[$myproperty]['FieldType'] == FILTER_TYPE_DATE )
|
if ( $fields[$myproperty]['FieldType'] == FILTER_TYPE_DATE )
|
||||||
$szUpdateSql = "ALTER TABLE " . $this->_logStreamConfigObj->DBTableName . " ADD " . $dbmapping[$szTableType]['DBMAPPINGS'][$myproperty] . " timestamp without time zone NULL";
|
$szUpdateSql = "ALTER TABLE " . $this->_logStreamConfigObj->DBTableName . " ADD " . $dbmapping[$szTableType]['DBMAPPINGS'][$myproperty] . " timestamp without time zone NULL";
|
||||||
}
|
}
|
||||||
|
else if ( $this->_logStreamConfigObj->DBType == DB_MSSQL )
|
||||||
|
{
|
||||||
|
// MYSQL Statements
|
||||||
|
if ( $fields[$myproperty]['FieldType'] == FILTER_TYPE_NUMBER )
|
||||||
|
$szUpdateSql = "ALTER TABLE " . $this->_logStreamConfigObj->DBTableName . " ADD " . $dbmapping[$szTableType]['DBMAPPINGS'][$myproperty] . " INT NOT NULL DEFAULT '0'";
|
||||||
|
if ( $fields[$myproperty]['FieldType'] == FILTER_TYPE_STRING )
|
||||||
|
$szUpdateSql = "ALTER TABLE " . $this->_logStreamConfigObj->DBTableName . " ADD " . $dbmapping[$szTableType]['DBMAPPINGS'][$myproperty] . " VARCHAR(60) NULL";
|
||||||
|
if ( $fields[$myproperty]['FieldType'] == FILTER_TYPE_DATE )
|
||||||
|
$szUpdateSql = "ALTER TABLE " . $this->_logStreamConfigObj->DBTableName . " ADD " . $dbmapping[$szTableType]['DBMAPPINGS'][$myproperty] . " DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00'";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Run SQL Command to add the missing field!
|
||||||
if ( strlen($szUpdateSql) > 0 )
|
if ( strlen($szUpdateSql) > 0 )
|
||||||
{
|
{
|
||||||
// Update Table schema now!
|
// Update Table schema now!
|
||||||
@ -2228,7 +2242,7 @@ class LogStreamPDO extends LogStream {
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Return failure!
|
// Return failure!
|
||||||
$this->PrintDebugError("ER_BAD_FIELD_ERROR - Field '" . $dbmapping[$szTableType]['DBMAPPINGS'][$myproperty] . "' is missing has to be added manually to the database layout!'");
|
$this->PrintDebugError("ER_BAD_FIELD_ERROR - Field '" . $dbmapping[$szTableType]['DBMAPPINGS'][$myproperty] . "' is missing and failed to be added automatically! The fields has to be added manually to the database layout!'");
|
||||||
return ERROR_DB_DBFIELDNOTFOUND;
|
return ERROR_DB_DBFIELDNOTFOUND;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user