Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 8eda3eb

Browse files
committed
Use sort_template.h for qsort_tuple() and qsort_ssup().
Replace the Perl code previously used to generate specialized sort functions with sort_template.h. Reviewed-by: Daniel Gustafsson <daniel@yesql.se> Discussion: https://postgr.es/m/CA%2BhUKGJ2-eaDqAum5bxhpMNhvuJmRDZxB_Tow0n-gse%2BHG0Yig%40mail.gmail.com
1 parent f374f4d commit 8eda3eb

File tree

7 files changed

+21
-296
lines changed

7 files changed

+21
-296
lines changed

src/backend/Makefile

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,6 @@ distprep:
190190
$(MAKE) -C utils distprep
191191
$(MAKE) -C utils/adt jsonpath_gram.c jsonpath_scan.c
192192
$(MAKE) -C utils/misc guc-file.c
193-
$(MAKE) -C utils/sort qsort_tuple.c
194193

195194

196195
##########################################################################
@@ -312,8 +311,7 @@ maintainer-clean: distclean
312311
storage/lmgr/lwlocknames.h \
313312
utils/adt/jsonpath_gram.c \
314313
utils/adt/jsonpath_scan.c \
315-
utils/misc/guc-file.c \
316-
utils/sort/qsort_tuple.c
314+
utils/misc/guc-file.c
317315

318316

319317
##########################################################################

src/backend/utils/sort/.gitignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/backend/utils/sort/Makefile

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,4 @@ OBJS = \
2121
tuplesort.o \
2222
tuplestore.o
2323

24-
tuplesort.o: qsort_tuple.c
25-
26-
qsort_tuple.c: gen_qsort_tuple.pl
27-
$(PERL) $(srcdir)/gen_qsort_tuple.pl $< > $@
28-
2924
include $(top_srcdir)/src/backend/common.mk
30-
31-
maintainer-clean:
32-
rm -f qsort_tuple.c

src/backend/utils/sort/gen_qsort_tuple.pl

Lines changed: 0 additions & 272 deletions
This file was deleted.

src/backend/utils/sort/tuplesort.c

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -676,8 +676,27 @@ static void tuplesort_updatemax(Tuplesortstate *state);
676676
* reduces to ApplySortComparator(), that is single-key MinimalTuple sorts
677677
* and Datum sorts.
678678
*/
679-
#include "qsort_tuple.c"
680679

680+
#define ST_SORT qsort_tuple
681+
#define ST_ELEMENT_TYPE SortTuple
682+
#define ST_COMPARE_RUNTIME_POINTER
683+
#define ST_COMPARE_ARG_TYPE Tuplesortstate
684+
#define ST_CHECK_FOR_INTERRUPTS
685+
#define ST_SCOPE static
686+
#define ST_DECLARE
687+
#define ST_DEFINE
688+
#include "lib/sort_template.h"
689+
690+
#define ST_SORT qsort_ssup
691+
#define ST_ELEMENT_TYPE SortTuple
692+
#define ST_COMPARE(a, b, ssup) \
693+
ApplySortComparator((a)->datum1, (a)->isnull1, \
694+
(b)->datum1, (b)->isnull1, (ssup))
695+
#define ST_COMPARE_ARG_TYPE SortSupportData
696+
#define ST_CHECK_FOR_INTERRUPTS
697+
#define ST_SCOPE static
698+
#define ST_DEFINE
699+
#include "lib/sort_template.h"
681700

682701
/*
683702
* tuplesort_begin_xxx

src/tools/msvc/Solution.pm

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -665,16 +665,6 @@ sub GenerateFiles
665665
);
666666
}
667667

668-
if (IsNewer(
669-
'src/backend/utils/sort/qsort_tuple.c',
670-
'src/backend/utils/sort/gen_qsort_tuple.pl'))
671-
{
672-
print "Generating qsort_tuple.c...\n";
673-
system(
674-
'perl src/backend/utils/sort/gen_qsort_tuple.pl > src/backend/utils/sort/qsort_tuple.c'
675-
);
676-
}
677-
678668
if (IsNewer('src/bin/psql/sql_help.h', 'src/bin/psql/create_help.pl'))
679669
{
680670
print "Generating sql_help.h...\n";

src/tools/msvc/clean.bat

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ if %DIST%==1 if exist src\backend\storage\lmgr\lwlocknames.h del /q src\backend\
6262
if %DIST%==1 if exist src\pl\plpython\spiexceptions.h del /q src\pl\plpython\spiexceptions.h
6363
if %DIST%==1 if exist src\pl\plpgsql\src\plerrcodes.h del /q src\pl\plpgsql\src\plerrcodes.h
6464
if %DIST%==1 if exist src\pl\tcl\pltclerrcodes.h del /q src\pl\tcl\pltclerrcodes.h
65-
if %DIST%==1 if exist src\backend\utils\sort\qsort_tuple.c del /q src\backend\utils\sort\qsort_tuple.c
6665
if %DIST%==1 if exist src\bin\psql\sql_help.c del /q src\bin\psql\sql_help.c
6766
if %DIST%==1 if exist src\bin\psql\sql_help.h del /q src\bin\psql\sql_help.h
6867
if %DIST%==1 if exist src\common\kwlist_d.h del /q src\common\kwlist_d.h

0 commit comments

Comments
 (0)