From c51007b59bd469d68f0a7d92e20f2f388a11ed64 Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Mon, 5 Dec 2011 22:57:43 +0000 Subject: [PATCH] Testscripte dazu git-svn-id: http://svn.brehm-online.com/svn/my-stuff/sql-parse/trunk@302 ec8d2aa5-1599-4edb-8739-2b3a1bc399aa --- bin/test-mysql.pl | 73 +++++++++++++++++++++++++++++++++++++++ bin/test-oracle.pl | 85 ++++++++++++++++++++++++++++++++++++++++++++++ bin/test-parse.pl | 60 ++++++++++++++++++++++++++++++++ data/create_db.sql | 67 ++++++++++++++++++++++++++++++++++++ 4 files changed, 285 insertions(+) create mode 100755 bin/test-mysql.pl create mode 100755 bin/test-oracle.pl create mode 100755 bin/test-parse.pl create mode 100644 data/create_db.sql diff --git a/bin/test-mysql.pl b/bin/test-mysql.pl new file mode 100755 index 0000000..b1f9bd0 --- /dev/null +++ b/bin/test-mysql.pl @@ -0,0 +1,73 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use Data::Dumper; + +use FindBin; +use lib "$FindBin::Bin/../lib"; + +use Text::Parse::SQL; + +my $params = { + 'sql_syntax' => 'mysql', + 'debug' => 0, +}; + +my $parser = new Text::Parse::SQL( $params ); + +print $parser->_DUMP(); + +my $sql = <parse($sql); + +#$Data::Dumper::Indent = 1; + +print "Ergebnisse: " . Dumper($statements); + + diff --git a/bin/test-oracle.pl b/bin/test-oracle.pl new file mode 100755 index 0000000..b4075ca --- /dev/null +++ b/bin/test-oracle.pl @@ -0,0 +1,85 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use Data::Dumper; + +use FindBin; +use lib "$FindBin::Bin/../lib"; + +use Text::Parse::SQL; + +my $params = { + 'sql_syntax' => 'oracle', + 'debug' => 0, +}; + +my $parser = new Text::Parse::SQL( $params ); + +print $parser->_DUMP(); + +my $sql = <parse($sql); + +#$Data::Dumper::Indent = 1; + +print "Ergebnisse: " . Dumper($statements); + + diff --git a/bin/test-parse.pl b/bin/test-parse.pl new file mode 100755 index 0000000..373c15c --- /dev/null +++ b/bin/test-parse.pl @@ -0,0 +1,60 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use Data::Dumper; + +use FindBin; +use lib "$FindBin::Bin/../lib"; + +use Text::Parse::SQL; + +my $params = { + 'remove_block_comments' => 1, +}; + +my $sqlfile = $FindBin::Bin . "/../data/create_db.sql"; + +my $parser = new Text::Parse::SQL( $params ); + +print $parser->_DUMP(); + +my $sql = <parse($sql); + +$Data::Dumper::Indent = 1; + +print "Ergebnisse: " . Dumper($statements); + +$statements = $parser->parse_file($sqlfile); +print "Ergebnisse: " . Dumper($statements); diff --git a/data/create_db.sql b/data/create_db.sql new file mode 100644 index 0000000..0cd36f4 --- /dev/null +++ b/data/create_db.sql @@ -0,0 +1,67 @@ +-- +-- Erzeugung der Datenbank-Struktur. +-- +-- Voraussetzung: SqLite >=3.3 +-- + +-- $Id$ +-- $URL$ + +-- Tabelle newsletters + +DROP TABLE IF EXISTS "newsletters"; +CREATE TABLE "newsletters" ( + "nid" INTEGER PRIMARY KEY AUTOINCREMENT, + "title" TEXT COLLATE NOCASE NOT NULL, + "desc" TEXT, + "creation" TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP +); +CREATE INDEX IF NOT EXISTS "ix_newsletters_title" ON "newsletters" ( "title" ); + +INSERT INTO "newsletters" ( "nid", "title", "desc" ) VALUES ( 1, 'Default newsletter', 'Nicht zuzuordnende locations' ); + +-- Tabelle locations + +DROP TABLE IF EXISTS "locations"; +CREATE TABLE "locations" ( + "lid" INTEGER PRIMARY KEY AUTOINCREMENT, + "nid" INTEGER, + "url" TEXT COLLATE NOCASE NOT NULL, + "desc" TEXT, + "creation" TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP +); +CREATE INDEX IF NOT EXISTS "ix_locations_nid" ON "locations" ( "nid" ); + +INSERT INTO locations ( "nid", "url", "desc" ) VALUES ( 1, 'http://www.strato.de', 'Standard-Eintrag' ); +INSERT INTO locations ( "nid", "url", "desc" ) VALUES ( 1, 'http://www.strato.com', 'Standard-Eintrag' ); + + +-- Tabelle iplist + +DROP TABLE IF EXISTS "iplist"; +CREATE TABLE "iplist" ( + "id" INTEGER PRIMARY KEY AUTOINCREMENT, + "lid" INTEGER NOT NULL, + "ip" NOT NULL, + "type" TEXT NOT NULL DEFAULT 'r', + "tstamp" TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP +); +CREATE UNIQUE INDEX IF NOT EXISTS "ix_iplist_ident" ON "iplist" ( "lid", "ip", "type" ); +CREATE INDEX IF NOT EXISTS "ix_iplist_tstamp" ON "iplist" ( "tstamp" ); + +-- Tabelle count + +DROP TABLE IF EXISTS "count"; +CREATE TABLE "count" ( + "id" INTEGER PRIMARY KEY AUTOINCREMENT, + "lid" INTEGER NOT NULL, + "ip" NOT NULL, + "type" TEXT NOT NULL DEFAULT 'r', + "tstamp" TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP +); +CREATE INDEX IF NOT EXISTS "ix_count_lid" ON "count" ( "lid" ); +CREATE INDEX IF NOT EXISTS "ix_count_tstamp" ON "count" ( "tstamp" ); + +-- Bereinigen der gesamten Datenbank +VACUUM; + -- 2.39.5