Source
#!/usr/bin/env perl
#
# Zabbix
# Copyright (C) 2001-2022 Zabbix SIA
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
use ;
use :: ;
my (%output, $insert_into, $fields);
my %mysql = (
"database" => "mysql",
"before" => "START TRANSACTION;\n",
"after" => "COMMIT;\n",
"exec_cmd" => ";\n"
);
my %oracle = (
"database" => "oracle",
"before" => "SET DEFINE OFF\n",
"after" => "",
"exec_cmd" => "\n/\n\n"
);
my %postgresql = (
"database" => "postgresql",
"before" => "START TRANSACTION;\n",
"after" => "COMMIT;\n",
"exec_cmd" => ";\n"
);
my %sqlite3 = (
"database" => "sqlite3",
"before" => "BEGIN TRANSACTION;\n",
"after" => "COMMIT;\n",
"exec_cmd" => ";\n"
);
# Maximum line length that SQL*Plus can read from .sql file is 2499 characters.
# Splitting long entries in 'media_type' table have to happen before SQL*Plus limit has been reached and end-of-lien
# character has to stay intact in one line.
my $oracle_field_limit = 2048;
sub
{
my $line = $_[0];
$line = "`$line`" if ($output{'database'} eq 'mysql');