package SQL::Translator::Parser::PostgreSQL;
# -------------------------------------------------------------------
-# $Id: PostgreSQL.pm,v 1.23 2003-08-07 18:15:51 kycl4rk Exp $
+# $Id: PostgreSQL.pm,v 1.24 2003-08-12 22:00:28 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.23 $ =~ /(\d+)\.(\d+)/;
+$VERSION = sprintf "%d.%02d", q$Revision: 1.24 $ =~ /(\d+)\.(\d+)/;
$DEBUG = 0 unless defined $DEBUG;
use Data::Dumper;
connect : /^\s*\\\connect.*\n/
-set : /SET/ /[^;]*/ ';'
+set : /set/i /[^;]*/ ';'
revoke : /revoke/i WORD(s /,/) /on/i TABLE(?) table_name /from/i name_with_opt_quotes(s /,/) ';'
{
}
elsif ( $meta->{'type'} eq 'not_null' ) {
$null = 0;
- next;
+# next;
}
elsif ( $meta->{'type'} eq 'primary_key' ) {
$is_pk = 1;
name => $item{'constraint_name'}[0] || '',
type => $type,
expression => $type eq 'check' ? $expression : '',
- deferreable => $item{'deferrable'},
+ deferrable => $item{'deferrable'},
deferred => $item{'deferred'},
reference_table => $desc->{'reference_table'},
reference_fields => $desc->{'reference_fields'},
column_constraint_type : /not null/i { $return = { type => 'not_null' } }
|
- /null/
+ /null/i
{ $return = { type => 'null' } }
|
- /unique/
+ /unique/i
{ $return = { type => 'unique' } }
|
/primary key/i
constraint_type => $type,
fields => $type ne 'check' ? $fields : [],
expression => $type eq 'check' ? $expression : '',
- deferreable => $item{'deferrable'},
+ deferrable => $item{'deferrable'},
deferred => $item{'deferred'},
reference_table => $desc->{'reference_table'},
reference_fields => $desc->{'reference_fields'},
}
}
|
- /check/ '(' /(.+)/ ')'
+ /check/i '(' /(.+)/ ')'
{
$return = {
type => 'check',
create_index : /create/i /index/i
-default_val : /default/i /(?:')?[\w\d().-]*(?:')?/
+default_val : /default/i /(\d+|'[^']+'|\w+\(.*?\))/
{
- my $val = $item[2] || '';
- $val =~ s/'//g;
+ my $val = defined $item[2] ? $item[2] : '';
+ $val =~ s/^'|'$//g;
$return = {
supertype => 'constraint',
type => 'default',
{ $item[1] }
| /'.*?'/ # XXX doesn't handle embedded quotes
{ $item[1] }
- | /NULL/
+ | /null/i
{ 'NULL' }
!;