package SQL::Translator::Parser::PostgreSQL;
# -------------------------------------------------------------------
-# $Id: PostgreSQL.pm,v 1.18 2003-06-17 02:12:23 kycl4rk Exp $
+# $Id: PostgreSQL.pm,v 1.23 2003-08-07 18:15:51 kycl4rk Exp $
# -------------------------------------------------------------------
# Copyright (C) 2003 Ken Y. Clark <kclark@cpan.org>,
# Allen Day <allenday@users.sourceforge.net>,
use strict;
use vars qw[ $DEBUG $VERSION $GRAMMAR @EXPORT_OK ];
-$VERSION = sprintf "%d.%02d", q$Revision: 1.18 $ =~ /(\d+)\.(\d+)/;
+$VERSION = sprintf "%d.%02d", q$Revision: 1.23 $ =~ /(\d+)\.(\d+)/;
$DEBUG = 0 unless defined $DEBUG;
use Data::Dumper;
set : /SET/ /[^;]*/ ';'
-revoke : /revoke/i WORD(s /,/) /on/i table_name /from/i name_with_opt_quotes(s /,/) ';'
+revoke : /revoke/i WORD(s /,/) /on/i TABLE(?) table_name /from/i name_with_opt_quotes(s /,/) ';'
{
my $table_name = $item{'table_name'};
push @{ $tables{ $table_name }{'permissions'} }, {
type => 'revoke',
actions => $item[2],
- users => $item[6],
+ users => $item[7],
}
}
-grant : /grant/i WORD(s /,/) /on/i table_name /to/i name_with_opt_quotes(s /,/) ';'
+grant : /grant/i WORD(s /,/) /on/i TABLE(?) table_name /to/i name_with_opt_quotes(s /,/) ';'
{
my $table_name = $item{'table_name'};
push @{ $tables{ $table_name }{'permissions'} }, {
type => 'grant',
actions => $item[2],
- users => $item[6],
+ users => $item[7],
}
}
}
pg_data_type :
- /(bigint|int8|bigserial|serial8)/
+ /(bigint|int8|bigserial|serial8)/i
{
$return = {
type => 'integer',
};
}
|
- /(smallint|int2)/
+ /(smallint|int2)/i
{
$return = {
type => 'integer',
};
}
|
- /int(eger)?|int4/
+ /int(eger)?|int4/i
{
$return = {
type => 'integer',
};
}
|
- /(double precision|float8?)/
+ /(double precision|float8?)/i
{
$return = {
type => 'float',
};
}
|
- /(real|float4)/
+ /(real|float4)/i
{
$return = {
type => 'real',
};
}
|
- /serial4?/
+ /serial4?/i
{
$return = {
type => 'integer',
};
}
|
- /bigserial/
+ /bigserial/i
{
$return = {
type => 'integer',
};
}
|
- /(bit varying|varbit)/
+ /(bit varying|varbit)/i
{
$return = { type => 'varbit' };
}
|
- /character varying/
+ /character varying/i
{
$return = { type => 'varchar' };
}
|
- /char(acter)?/
+ /char(acter)?/i
{
$return = { type => 'char' };
}
|
- /bool(ean)?/
+ /bool(ean)?/i
{
$return = { type => 'boolean' };
}
|
- /bytea/
+ /bytea/i
{
$return = { type => 'bytea' };
}
|
- /timestampz?/
+ /timestampz?/i
{
$return = { type => 'timestamp' };
}
|
- /(bit|box|cidr|circle|date|inet|interval|line|lseg|macaddr|money|numeric|decimal|path|point|polygon|text|time|varchar)/
+ /(bit|box|cidr|circle|date|inet|interval|line|lseg|macaddr|money|numeric|decimal|path|point|polygon|text|time|varchar)/i
{
$return = { type => $item[1] };
}
only : /only/i
-create_table : /create/i /table/i
+create_table : /create/i TABLE
create_index : /create/i /index/i
-default_val : /default/i /(?:')?[\w\d.-]*(?:')?/
+default_val : /default/i /(?:')?[\w\d().-]*(?:')?/
{
my $val = $item[2] || '';
$val =~ s/'//g;
$return = { type => $item[1] =~ /out/i ? 'without_oids' : 'with_oids' }
}
+TABLE : /table/i
+
SEMICOLON : /\s*;\n?/
WORD : /\w+/