@@ -244,6 +244,51 @@ sub taptest
244
244
exit $status if $status ;
245
245
}
246
246
247
+ sub mangle_plpython3
248
+ {
249
+ my $tests = shift ;
250
+ mkdir " results" unless -d " results" ;
251
+ mkdir " sql/python3" ;
252
+ mkdir " results/python3" ;
253
+ mkdir " expected/python3" ;
254
+
255
+ foreach my $test (@$tests )
256
+ {
257
+ local $/ = undef ;
258
+ foreach my $dir (' sql' ,' expected' )
259
+ {
260
+ my $extension = ($dir eq ' sql' ? ' sql' : ' out' );
261
+
262
+ my @files = glob (" $dir /$test .$extension $dir /${test} _[0-9].$extension " );
263
+ foreach my $file (@files )
264
+ {
265
+ open (my $handle , " $file " ) || die " test file $file not found" ;
266
+ my $contents = <$handle >;
267
+ close ($handle );
268
+ map
269
+ {
270
+ s / except ([[:alpha:]][[:alpha:].]*), *([[:alpha:]][[:alpha:]]*):/ except $1 as $2 :/ g ;
271
+ s / <type 'exceptions\. ([[:alpha:]]*)'>/ <class '$1 '>/ g ;
272
+ s / <type 'long'>/ <class 'int'>/ g ;
273
+ s / ([0-9][0-9]*)L/ $1 / g ;
274
+ s / ([ [{])u"/ $1 "/ g ;
275
+ s / ([ [{])u'/ $1 '/ g ;
276
+ s / def next/ def __next__/ g ;
277
+ s / LANGUAGE plpython2?u/ LANGUAGE plpython3u/ g ;
278
+ s / EXTENSION ([^ ]*_)*plpython2?u/ EXTENSION $1plpython3u/ g ;
279
+ s / installing required extension "plpython2u"/ installing required extension "plpython3u"/ g ;
280
+ } $contents ;
281
+ my $base = basename $file ;
282
+ open ($handle , " >$dir /python3/$base " ) || die " opening python 3 file for $file " ;
283
+ print $handle $contents ;
284
+ close ($handle );
285
+ }
286
+ }
287
+ }
288
+ map { $_ =~ s ! ^! python3/! ; } @$tests ;
289
+ return @$tests ;
290
+ }
291
+
247
292
sub plcheck
248
293
{
249
294
chdir " ../../pl" ;
@@ -254,7 +299,8 @@ sub plcheck
254
299
my $lang = $pl eq ' tcl' ? ' pltcl' : $pl ;
255
300
if ($lang eq ' plpython' )
256
301
{
257
- next unless -d " ../../$Config /plpython2" ;
302
+ next unless -d " $topdir /$Config /plpython2" ||
<
6D40
td data-grid-cell-id="diff-a7ffdd71bd4ea2b5c69a971c666fbfe082620fb7e0408f0a92d7daee31802d63-257-303-0" data-selected="false" role="gridcell" style="background-color:var(--diffBlob-additionNum-bgColor, var(--diffBlob-addition-bgColor-num));text-align:center" tabindex="-1" valign="top" class="focusable-grid-cell diff-line-number position-relative left-side">
303
+ -d " $topdir /$Config /plpython3" ;
258
304
$lang = ' plpythonu' ;
259
305
}
260
306
else
@@ -264,6 +310,8 @@ sub plcheck
264
310
my @lang_args = (" --load-extension=$lang " );
265
311
chdir $pl ;
266
312
my @tests = fetchTests();
313
+ @tests = mangle_plpython3(\@tests )
314
+ if $lang eq ' plpythonu' && -d " $topdir /$Config /plpython3" ;
267
315
if ($lang eq ' plperl' )
268
316
{
269
317
@@ -279,6 +327,10 @@ sub plcheck
279
327
push (@tests , ' plperl_plperlu' );
280
328
}
281
329
}
330
+ elsif ($lang eq ' plpythonu' && -d " $topdir /$Config /plpython3" )
331
+ {
332
+ @lang_args = ();
333
+ }
282
334
print
283
335
" ============================================================\n " ;
284
336
print " Checking $lang \n " ;
@@ -297,7 +349,6 @@ sub plcheck
297
349
298
350
sub subdircheck
299
351
{
300
- my $subdir = shift ;
301
352
my $module = shift ;
302
353
303
354
if ( !-d " $module /sql"
@@ -311,43 +362,35 @@ sub subdircheck
311
362
my @tests = fetchTests();
312
363
my @opts = fetchRegressOpts();
313
364
314
- # Add some options for transform modules, see their respective
315
- # Makefile for more details regarding Python-version specific
365
+ # Special processing for python transform modules, see their respective
366
+ # Makefiles for more details regarding Python-version specific
316
367
# dependencies.
317
- if ( $module eq " hstore_plpython"
318
- || $module eq " ltree_plpython" )
368
+ if ( $module =~ / _plpython$ / )
319
369
{
320
370
die " Python not enabled in configuration"
321
371
if !defined ($config -> {python });
322
372
323
- # Attempt to get python version and location.
324
- # Assume python.exe in specified dir.
325
- my $pythonprog = " import sys;" . " print(str(sys.version_info[0]))" ;
326
- my $prefixcmd = $config -> {python } . " \\ python -c \" $pythonprog \" " ;
327
- my $pyver = ` $prefixcmd ` ;
328
- die " Could not query for python version!\n " if $? ;
329
- chomp ($pyver );
330
- if ($pyver eq " 2" )
373
+ @opts = grep { $_ !~ / plpythonu/ } @opts ;
374
+
375
+ if (-d " $topdir /$Config /plpython2" )
331
376
{
332
377
push @opts , " --load-extension=plpythonu" ;
333
378
push @opts , ' --load-extension=' . $module . ' u' ;
334
379
}
335
380
else
336
381
{
337
-
338
- # disable tests on python3 for now.
339
- chdir " .." ;
340
- return ;
382
+ # must be python 3
383
+ @tests = mangle_plpython3(\@tests );
341
384
}
342
385
}
343
386
344
-
345
387
print " ============================================================\n " ;
346
388
print " Checking $module \n " ;
347
389
my @args = (
348
390
" $topdir /$Config /pg_regress/pg_regress" ,
349
391
" --bindir=${topdir} /${Config} /psql" ,
350
392
" --dbname=contrib_regression" , @opts , @tests );
393
+ print join (' ' ,@args )," \n " ;
351
394
system (@args );
352
395
chdir " .." ;
353
396
}
@@ -358,17 +401,15 @@ sub contribcheck
358
401
my $mstat = 0;
359
402
foreach my $module (glob (" *" ))
360
403
{
361
-
362
404
# these configuration-based exclusions must match Install.pm
363
405
next if ($module eq " uuid-ossp" && !defined ($config -> {uuid }));
364
406
next if ($module eq " sslinfo" && !defined ($config -> {openssl }));
365
407
next if ($module eq " xml2" && !defined ($config -> {xml }));
366
- next if ($module eq " hstore_plperl" && !defined ($config -> {perl }));
367
- next if ($module eq " hstore_plpython" && !defined ($config -> {python }));
368
- next if ($module eq " ltree_plpython" && !defined ($config -> {python }));
408
+ next if ($module =~ / _plperl$ / && !defined ($config -> {perl }));
409
+ next if ($module =~ / _plpython$ / && !defined ($config -> {python }));
369
410
next if ($module eq " sepgsql" );
370
411
371
- subdircheck(" $topdir /contrib " , $module );
412
+ subdircheck($module );
372
413
my $status = $? >> 8;
373
414
$mstat ||= $status ;
374
415
}
@@ -381,7 +422,7 @@ sub modulescheck
381
422
my $mstat = 0;
382
423
foreach my $module (glob (" *" ))
383
424
{
384
- subdircheck(" $topdir /src/test/modules " , $module );
425
+ subdircheck($module );
385
426
my $status = $? >> 8;
386
427
$mstat ||= $status ;
387
428
}
0 commit comments