File tree Expand file tree Collapse file tree 2 files changed +28
-9
lines changed
Expand file tree Collapse file tree 2 files changed +28
-9
lines changed Original file line number Diff line number Diff line change @@ -325,6 +325,27 @@ sub pg_version {
325325 return version-> declare($1 );
326326}
327327
328+ {
329+ my $maxlen ;
330+
331+ sub max_identifier_length () {
332+ $maxlen //= do {
333+ my $len = eval {
334+ connect_db()-> selectrow_array(
335+ " SELECT current_setting('max_identifier_length')"
336+ );
337+ };
338+ if ($@ ) {
339+ warn " Unable to determine max identifier length: $@ \n " ;
340+ warn " Defaulting to max identifier length $MAX_IDENTIFIER_LENGTH \n " ;
341+ $len = $MAX_IDENTIFIER_LENGTH ;
342+ }
343+ $len ;
344+ };
345+ }
346+ }
347+
348+
328349# Return a copy of a hash with all keys lowercased.
329350sub lower_keys ($) {
330351 my $hash = shift or return ;
@@ -385,7 +406,7 @@ sub quote_constant (@) {
385406 do {
386407 # make sure sample table names are unique and not too long
387408 $name = sprintf ' %04x__%s' , ++$seq , $key ;
388- $name = substr $name , 0, $MAX_IDENTIFIER_LENGTH ;
409+ $name = substr $name , 0, max_identifier_length ;
389410 } until !exists $cache { $name };
390411 $name ;
391412 };
Original file line number Diff line number Diff line change @@ -199,18 +199,16 @@ $dbh->do(qq{
199199 # names when necessary.
200200
201201 my $maxlen = 63;
202- eval {
203- my $config = $dbh -> selectrow_hashref(q{
204- SELECT current_setting('max_identifier_length') AS namedatalen
205- } );
206- $config //= {};
207- $maxlen = $config -> {namedatalen } // $maxlen ;
208- };
202+ $maxlen = eval {
203+ $dbh -> selectrow_array(
204+ " SELECT current_setting('max_identifier_length')"
205+ );
206+ } // $maxlen ;
209207 if ($@ ) {
210208 diag(" Unable to determine max identifer length: $@ " );
211209 diag(" Defaulting to max identifier length of '$maxlen '" );
212210 } else {
213- diag(" Max identifier length: $maxlen " );
211+ diag(" Max identifier length: $maxlen " ) if $opt { verbose } ;
214212 }
215213
216214 my $long_schema = ' long_schema_' . (' X' x $maxlen );
You can’t perform that action at this time.
0 commit comments