postgresql/contrib/seg/sort-segments.pl
Bruce Momjian 50e6eb731d Update copyright for 2025
Backpatch-through: 13
2025-01-01 11:21:55 -05:00

31 lines
468 B
Perl
Executable File

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