use strict;
use warnings;
use File::Basename;
my $file = dirname($0) . "/../src/schema.tmpl";
my ($state, %output, $eol, $fk_bol, $fk_eol, $ltab, $pkey, $table_name, $pkey_name);
my ($szcol1, $szcol2, $szcol3, $szcol4, $sequences, $sql_suffix, $triggers);
my ($fkeys, $fkeys_prefix, $fkeys_suffix, $uniq, $delete_cascade);
my %table_types;
my %c = (
"type" => "code",
"database" => "",
"after" => "\t{0}\n};\n\n#undef ZBX_TYPE_LONGTEXT_LEN\n#undef ZBX_TYPE_SHORTTEXT_LEN\n",
"t_bigint" => "ZBX_TYPE_UINT",
"t_text" => "ZBX_TYPE_TEXT",
"t_double" => "ZBX_TYPE_FLOAT",
"t_id" => "ZBX_TYPE_ID",
"t_image" => "ZBX_TYPE_BLOB",
"t_bin" => "ZBX_TYPE_BLOB",
"t_integer" => "ZBX_TYPE_INT",
"t_longtext" => "ZBX_TYPE_LONGTEXT",
"t_nanosec" => "ZBX_TYPE_INT",
"t_serial" => "ZBX_TYPE_UINT",
"t_shorttext" => "ZBX_TYPE_SHORTTEXT",
"t_time" => "ZBX_TYPE_INT",
"t_varchar" => "ZBX_TYPE_CHAR",
"t_cuid" => "ZBX_TYPE_CUID",
);
$c{"before"} = "/*
** Zabbix
** Copyright (C) 2001-2023 Zabbix SIA
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** 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.
**/
#include \"zbxdbschema.h\"
#include \"zbxcommon.h\"
#if defined(HAVE_ORACLE)
# define ZBX_TYPE_SHORTTEXT_LEN 2048
#else
# define ZBX_TYPE_SHORTTEXT_LEN 65535
#endif
#define ZBX_TYPE_LONGTEXT_LEN 0
#define ZBX_TYPE_TEXT_LEN 65535
static zbx_db_table_t\ttables[] = {
";
my %mysql = (
"type" => "sql",
"database" => "mysql",
"before" => "",
"after" => "",
"table_options" => " ENGINE=InnoDB",