Revision 567

Date:
2016/04/19 22:22:48
Author:
ahitrov
Revision Log:
DBD::Pg version 3.0.0+ Unicode requirements

Files:

Legend:

 
Added
 
Removed
 
Modified
  • utf8/core/lib/Contenido/Keeper.pm

     
    209 209 # ----------------------------------------------------------------------------------------
    210 210 unless ($sth->execute(@$binds)) {
    211 211 $self->error;
    212 $log->error("DBI execute error on $$query\n".Data::Dumper::Dumper($binds)."\ncalled with opts:\n".Data::Dumper::Dumper(\%opts));
    212 $log->error("DBI execute error on $$query\n".Data::Dumper::Dumper($DBD::Pg::VERSION >= '3' ? Data::Recursive::Encode->encode_utf8($binds) : $binds)."\ncalled with opts:\n".Data::Dumper::Dumper(\%opts));
    213 213 return;
    214 214 }
    215 215 my $finish1 = Time::HiRes::time() if ($DEBUG);
     
    235 235 $Contenido::Globals::CORE_TIME += $finish2-$finish1;
    236 236 $Contenido::Globals::DB_COUNT++;
    237 237
    238 $log->info("get_items($proto) ".($mason_file ? "called from $mason_file" : '')." SQL: '$$query' with binds: '".join("', '", @$binds)."' fetched: $total records (total work time: $total_time ms, database time $db_time ms, core time $core_time ms)");
    238 $log->info("get_items($proto) ".($mason_file ? "called from $mason_file" : '')." SQL: '$$query' with binds: '".join("', '", map { ref $_ ? Data::Dumper::Dumper($DBD::Pg::VERSION >= '3' ? Data::Recursive::Encode->encode_utf8($_) : $_) : $DBD::Pg::VERSION >= '3' ? Encode::encode('utf-8', $_) : $_ } @$binds)."' fetched: $total records (total work time: $total_time ms, database time $db_time ms, core time $core_time ms)");
    239 239 }
    240 240
    241 241 #выдает предупреждение если полученно более 500 обьектов но не выставлен no_limit
    242 242 if ($total>999 and !($opts{no_limit} or $opts{limit})) {
    243 243 my $mason_comp = ref($HTML::Mason::Commands::m) ? $HTML::Mason::Commands::m->current_comp() : undef;
    244 244 my $mason_file = ref($mason_comp) ? $mason_comp->path : undef;
    245 $log->error("get_items($proto) ".($mason_file ? "called from $mason_file" : '')." SQL: '$$query' with binds: '".join("', '", @$binds)."' fetched 1000 records... гарантированно часть записей не получена из базы... или добавьте no_limit=>1 или разберитесь почему так много данных получаете");
    245 $log->error("get_items($proto) ".($mason_file ? "called from $mason_file" : '')." SQL: '$$query' with binds: '".join("', '", map { ref $_ ? Data::Dumper::Dumper($DBD::Pg::VERSION >= '3' ? Data::Recursive::Encode->encode_utf8($_) : $_) : $DBD::Pg::VERSION >= '3' ? Encode::encode('utf-8', $_) : $_ } @$binds)."' fetched 1000 records... гарантированно часть записей не получена из базы... или добавьте no_limit=>1 или разберитесь почему так много данных получаете");
    246 246 } elsif ($total>500 and !($opts{no_limit} or $opts{limit})) {
    247 247 my $mason_comp = ref($HTML::Mason::Commands::m) ? $HTML::Mason::Commands::m->current_comp() : undef;
    248 248 my $mason_file = ref($mason_comp) ? $mason_comp->path : undef;
    249 $log->warning("get_items($proto) ".($mason_file ? "called from $mason_file" : '')." SQL: '$$query' with binds: '".join("', '", @$binds)."' fetched over 500 ($total) records... или добавьте no_limit=>1 или разберитесь почему так много данных получаете");
    249 $log->warning("get_items($proto) ".($mason_file ? "called from $mason_file" : '')." SQL: '$$query' with binds: '".join("', '", map { ref $_ ? Data::Dumper::Dumper($DBD::Pg::VERSION >= '3' ? Data::Recursive::Encode->encode_utf8($_) : $_) : $DBD::Pg::VERSION >= '3' ? Encode::encode('utf-8', $_) : $_ } @$binds)."' fetched over 500 ($total) records... или добавьте no_limit=>1 или разберитесь почему так много данных получаете");
    250 250 }
    251 251
    252 252 # -----------------------------------------------------------------------------------------
  • utf8/core/lib/Contenido/Object.pm

     
    317 317 return Encode::decode('utf-8', $json_n->encode ({map { $_=> Encode::decode($state->db_encode_data, $self->{$_}, Encode::FB_HTMLCREF) } grep { !$virtual_fields->{$_} && (defined $self->{$_}) } @$extra_fields}));
    318 318 } else {
    319 319 my $content = Encode::decode('utf-8', $json_n->encode ({map { $_=>$self->{$_} } grep { !$virtual_fields->{$_} && (defined $self->{$_}) } @$extra_fields}));
    320 # warn "Store content is [$content]. UTF-8 Flag [".Encode::is_utf8($content)."]\n";
    320 warn "Store content is [".Encode::encode('utf-8', $content)."]. UTF-8 Flag [".Encode::is_utf8($content)."]\n";
    321 321 return $content;
    322 322 }
    323 323 } else {
     
    460 460 foreach my $i (0..$#{$binds}) {
    461 461 $binds->[$i] = Encode::decode($state->db_encode_data, $binds->[$i], Encode::FB_HTMLCREF);
    462 462 }
    463 } elsif ( $DBD::Pg::VERSION >= '3' ) {
    464 foreach my $i (0..$#{$binds}) {
    465 $binds->[$i] = Encode::decode('utf-8', $binds->[$i], Encode::FB_HTMLCREF);
    466 }
    463 467 }
    464 468
    465 469 return $query, $binds;
     
    525 529 push @binary_fields, scalar(@fields) if ($_->{db_type} eq 'bytea');
    526 530 if ($state->db_encode_data) {
    527 531 push @values, Encode::decode($state->db_encode_data, $value, Encode::FB_HTMLCREF);
    532 } elsif ($DBD::Pg::VERSION >= '3') {
    533 push @values, Encode::decode('utf-8', $value, Encode::FB_HTMLCREF);
    528 534 } else {
    529 535 push @values, $value;
    530 536 }
     
    563 569 $sth->bind_param($_, undef, {pg_type => DBD::Pg::PG_BYTEA});
    564 570 }
    565 571 unless ($sth->execute(@values, $self->{id})) {
    566 $log->error("DBI execute error on $sql\n".Data::Dumper::Dumper(\@values));
    572 $log->error("DBI execute error on $sql\n".Data::Dumper::Dumper( $DBD::Pg::VERSION >= '3' ? Data::Recursive::Encode->encode_utf8( \@values ) : \@values ));
    567 573 $sth->finish();
    568 574 return $self->t_abort();
    569 575 }
     
    590 596 $sth->bind_param($_, undef, {pg_type => DBD::Pg::PG_BYTEA});
    591 597 }
    592 598 unless ($sth->execute(@values)) {
    593 $log->error("DBI execute error on $sql\n".Data::Dumper::Dumper(\@values));
    599 $log->error("DBI execute error on $sql\n".Data::Dumper::Dumper( $DBD::Pg::VERSION >= '3' ? Data::Recursive::Encode->encode_utf8( \@values ) : \@values ));
    594 600 $sth->finish();
    595 601 return $self->t_abort();
    596 602 }
  • utf8/core/lib/Contenido/State.pm.proto

     
    36 36 $self->{db_password} = '@BASE_PASSWD@';
    37 37 $self->{db_port} = '@PGSQL_PORT@';
    38 38 $self->{db_prepare} = lc('@PGSQL_REAL_PREPARE@') eq 'yes' ? 1 : 0;
    39 $self->{db_enable_utf8} = lc('@PGSQL_ENABLE_UTF@') eq 'yes' ? 1 : 0;
    39 $self->{db_enable_utf8} = lc('@PGSQL_ENABLE_UTF@') eq 'yes' ? -1 : 0;
    40 40 $self->{db_client_encoding} = '@PGSQL_CLIENT_ENCODING@';
    41 41
    42 42 $self->{db_encode_data} = '@PGSQL_ENCODE_DATA@';
  • utf8/core/lib/SQL/Common.pm

     
    246 246
    247 247 if (@$value) {
    248 248 my $op = (ref($opts) eq 'HASH' and ($opts->{intersect} or $opts->{contains})) ? '@>' : '&&';
    249 # old versions DBD::Pg is SO STUPID!!!!
    250 # if ($DBD::Pg::VERSION<1.49) {
    251 # my $value_string = '{'.join(',',@{$value}).'}';
    252 # return [" ($field $op ?) "], [$value_string];
    253 # } else {
    254 # all versions before 2.0.0 also stupid
    255 if ($DBD::Pg::VERSION=~/^1\./) {
    256 my $ph_string = '?, 'x$#{$value}.'?';
    249 if ($DBD::Pg::VERSION=~/^1\./) {
    250 my $ph_string = '?, 'x$#{$value}.'?';
    257 251 return [" ($field $op ARRAY[$ph_string]::integer[]) "], $value;
    258 252 } else {
    259 return [" ($field $op ?::integer[]) "], [$value];
    260 }
    253 return [" ($field $op ?::integer[]) "], [$value];
    254 }
    261 255 } else {
    262 256 return [' FALSE '], [];
    263 257 }