$dbh->do("CREATE SEQUENCE $eapk_schemas[4].fooseq");
$dbh->do("CREATE SEQUENCE $eapk_schemas[3].fooseq");
- $dbh->do("SET search_path = ".join ',', @eapk_schemas );
+ $dbh->do("SET search_path = ".join ',', reverse @eapk_schemas );
});
# clear our search_path cache
qualify_table => 4,
);
+ eapk_poke( $schema );
eapk_poke( $schema, 0 );
eapk_poke( $schema, 2 );
eapk_poke( $schema, 4 );
eapk_poke( $schema, 1 );
eapk_poke( $schema, 0 );
eapk_poke( $schema, 1 );
+ eapk_poke( $schema );
eapk_poke( $schema, 4 );
eapk_poke( $schema, 3 );
eapk_poke( $schema, 1 );
? $eapk_schemas[$schema_num]
: '';
- my $schema_name_actual = $schema_name || eapk_get_search_path($s)->[0];
+ my $schema_name_actual = $schema_name || eapk_find_visible_schema($s);
$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 || eapk_get_search_path($s)->[0];
+ my $schema = shift || eapk_find_visible_schema($s);
diag "$schema.apk sequences: ",
join(', ',
});
}
+
+sub eapk_find_visible_schema {
+ my ($s) = @_;
+
+ my ($schema) =
+ $s->storage->dbh_do(sub {
+ $_[1]->selectrow_array(<<EOS);
+SELECT n.nspname
+FROM pg_catalog.pg_namespace n
+JOIN pg_catalog.pg_class c ON c.relnamespace = n.oid
+WHERE c.relname = 'apk'
+ AND pg_catalog.pg_table_is_visible(c.oid)
+EOS
+ });
+ return $schema;
+}