File: sqlitecheck.pl

package info (click to toggle)
ratbox-services 1.2.4%2Brepack-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 11,760 kB
  • ctags: 6,989
  • sloc: ansic: 76,435; sh: 17,527; cpp: 3,029; perl: 1,048; makefile: 740; pascal: 607; yacc: 256; lex: 232
file content (45 lines) | stat: -rwxr-xr-x 807 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/perl -w
#
# sqlitecheck.pl
# Outputs SQL commands for checking an sqlite database will adhere to
# length limits on strings when imported into a database that actually
# cares about lengths.
#
# Takes the schema for the new database as its argument, outputs commands
# for use with the old database.
#
# Copyright (C) 2006 Lee Hardy <lee -at- leeh.co.uk>
# Copyright (C) 2006 ircd-ratbox development team
#
# $Id$

use strict;

unless($ARGV[0])
{
	print "Usage: ./sqlitecheck.pl <schema>\n";
	exit;
}

unless(open(INPUT, "<$ARGV[0]"))
{
	print "Unable to open $ARGV[0]\n";
	exit;
}

my $table = "";

while(<INPUT>)
{
	chomp;

	if($_ =~ /^CREATE TABLE (.*) \(/)
	{
		$table = $1;
		next;
	}
	elsif($_ =~ /\s*(.*) VARCHAR\((\d+)\)/)
	{
		print "SELECT * FROM $table WHERE LENGTH($1) > $2;\n";
	}
}