postgresql/contrib/seg/sort-segments.pl

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

31 lines
468 B
Perl
Raw Permalink Normal View History

#!/usr/bin/perl
# Copyright (c) 2021-2024, PostgreSQL Global Development Group
# this script will sort any table with the segment data type in its last column
2016-12-04 18:00:00 +01:00
use strict;
use warnings FATAL => 'all';
2016-12-04 18:00:00 +01:00
my @rows;
while (<>)
{
chomp;
push @rows, $_;
}
foreach (
sort {
2016-12-04 18:00:00 +01:00
my @ar = split("\t", $a);
my $valA = pop @ar;
$valA =~ s/[~<> ]+//g;
@ar = split("\t", $b);
2016-12-04 18:00:00 +01:00
my $valB = pop @ar;
$valB =~ s/[~<> ]+//g;
$valA <=> $valB
} @rows)
{
print "$_\n";
}