}
# Determine if a data_type is some type of BLOB
+# FIXME: these regexes are expensive, result of these checks should be cached in
+# the column_info .
sub _is_lob_type {
my ($self, $data_type) = @_;
- $data_type && ($data_type =~ /(?:lob|bfile|text|image|bytea|memo)/i
- || $data_type =~ /^long(?:\s*(?:raw|bit\s*varying|varbit|binary
+ $data_type && ($data_type =~ /lob|bfile|text|image|bytea|memo/i
+ || $data_type =~ /^long(?:\s+(?:raw|bit\s*varying|varbit|binary
|varchar|character\s*varying|nvarchar
- |national\s*character\s*varying))?$/xi);
+ |national\s*character\s*varying))?\z/xi);
+}
+
+sub _is_binary_lob_type {
+ my ($self, $data_type) = @_;
+ $data_type && ($data_type =~ /blob|bfile|image|bytea/i
+ || $data_type =~ /^long(?:\s+(?:raw|bit\s*varying|varbit|binary))?\z/xi);
+}
+
+sub _is_text_lob_type {
+ my ($self, $data_type) = @_;
+ $data_type && ($data_type =~ /^(?:clob|memo)\z/i
+ || $data_type =~ /^long(?:\s+(?:varchar|character\s*varying|nvarchar
+ |national\s*character\s*varying))\z/xi);
}
1;
my $self = shift;
my($source) = @_;
- my %bind_attributes;
+ my %bind_attributes = %{ $self->next::method(@_) };
foreach my $column ($source->columns) {
- my $data_type = $source->column_info($column)->{data_type}
- or next;
+ my %column_bind_attrs = %{ $bind_attributes{$column} || {} };
- my %column_bind_attrs = $self->bind_attribute_by_data_type($data_type);
+ my $data_type = $source->column_info($column)->{data_type};
- if ($data_type =~ /^[BC]LOB$/i) {
+ if ($self->_is_lob_type($data_type)) {
if ($DBD::Oracle::VERSION eq '1.23') {
$self->throw_exception(
"BLOB/CLOB support in DBD::Oracle == 1.23 is broken, use an earlier or later ".
);
}
- $column_bind_attrs{'ora_type'} = uc($data_type) eq 'CLOB'
+ $column_bind_attrs{'ora_type'} = $self->_is_text_lob_type($data_type)
? DBD::Oracle::ORA_CLOB()
: DBD::Oracle::ORA_BLOB()
;