}
-# get the postgres search path, and cache it
-sub _get_pg_search_path {
- my ($self,$dbh) = @_;
- # cache the search path as ['schema','schema',...] in the storage
- # obj
- $self->{_pg_search_path} ||= do {
- my @search_path;
- my ($sp_string) = $dbh->selectrow_array('SHOW search_path');
- while( $sp_string =~ s/("[^"]+"|[^,]+),?// ) {
- unless( defined $1 and length $1 ) {
- $self->throw_exception("search path sanity check failed: '$1'")
- }
- push @search_path, $1;
- }
- \@search_path
- };
-}
-
sub _dbh_get_autoinc_seq {
my ($self, $dbh, $schema, $table, $col) = @_;
my $schema = shift;
#save the search path and reset it at the end
- my $search_path_save = $schema->storage->dbh_do('_get_pg_search_path');
+ my $search_path_save = eapk_get_search_path($schema);
eapk_drop_all($schema);
? $eapk_schemas[$schema_num]
: '';
- my $schema_name_actual = $schema_name || $s->storage->dbh_do('_get_pg_search_path')->[0];
+ my $schema_name_actual = $schema_name || eapk_get_search_path($s)->[0];
$s->source('ExtAPK')->name($schema_name ? $schema_name.'.apk' : 'apk');
#< clear sequence name cache
# class
sub eapk_seq_diag {
my $s = shift;
- my $schema = shift || $s->storage->dbh_do('_get_pg_search_path')->[0];
+ my $schema = shift || eapk_get_search_path($s)->[0];
diag "$schema.apk sequences: ",
join(', ',
);
}
+# get the postgres search path as an arrayref
+sub eapk_get_search_path {
+ my ( $s ) = @_;
+ # cache the search path as ['schema','schema',...] in the storage
+ # obj
+
+ return $s->storage->dbh_do(sub {
+ my (undef, $dbh) = @_;
+ my @search_path;
+ my ($sp_string) = $dbh->selectrow_array('SHOW search_path');
+ while ( $sp_string =~ s/("[^"]+"|[^,]+),?// ) {
+ unless( defined $1 and length $1 ) {
+ die "search path sanity check failed: '$1'";
+ }
+ push @search_path, $1;
+ }
+ \@search_path
+ });
+}
sub eapk_set_search_path {
my ($s,@sp) = @_;
my $sp = join ',',@sp;