8000 Add a test harness for the red-black tree code. · postgres/postgres@610bbdd · GitHub
[go: up one dir, main page]

Skip to content
{"payload":{"commit":{"oid":"610bbdd8acfcbeedad1176188f53ce5c7905e280","url":"/postgres/postgres/commit/610bbdd8acfcbeedad1176188f53ce5c7905e280","authoredDate":"2017-09-10T13:26:46.000-04:00","committedDate":"2017-09-10T13:26:46.000-04:00","shortMessage":null,"shortMessageMarkdown":"\u003cdiv\u003eAdd a test harness for the red-black tree code.\u003c/div\u003e","shortMessageMarkdownLink":null,"bodyMessageHtml":"This improves the regression tests' coverage of rbtree.c from pretty\nawful (because some of the functions aren't used yet) to basically 100%.\n\nVictor Drobny, reviewed by Aleksander Alekseev and myself\n\nDiscussion: \u003ca href=\"https://postgr.es/m/c9d61310e16e75f8acaf6cb1c48b7b77@postgrespro.ru\" rel=\"nofollow\"\u003ehttps://postgr.es/m/c9d61310e16e75f8acaf6cb1c48b7b77@postgrespro.ru\u003c/a\u003e","authors":[{"login":"tglsfdc","displayName":"Tom Lane","avatarUrl":"https://avatars.githubusercontent.com/u/8755309?v=4","path":"/tglsfdc","isGitHub":false}],"committerAttribution":false,"committer":{"login":"tglsfdc","displayName":"Tom Lane","avatarUrl":"https://avatars.githubusercontent.com/u/8755309?v=4","path":"/tglsfdc","isGitHub":false},"parents":["f80e782a6b4dcdea78f053f1505fff316f3a3289"],"globalRelayId":"MDY6Q29tbWl0OTI3NDQyOjYxMGJiZGQ4YWNmY2JlZWRhZDExNzYxODhmNTNjZTVjNzkwNWUyODA=","sha1":"f80e782a6b4dcdea78f053f1505fff316f3a3289","sha2":"610bbdd8acfcbeedad1176188f53ce5c7905e280"},"currentUser":null,"repo":{"id":927442,"defaultBranch":"master","name":"postgres","ownerLogin":"postgres","currentUserCanPush":false,"isFork":false,"isEmpty":false,"createdAt":"2010-09-21T11:35:45.000Z","ownerAvatar":"https://avatars.githubusercontent.com/u/177543?v=4","public":true,"private":false,"isOrgOwned":true},"diffEntryData":[{"diffLines":[{"stylingDirective":null,"type":"HUNK","blobLineNumber":12,"text":"@@ -13,6 +13,7 @@ SUBDIRS = \\","html":"@@ -13,6 +13,7 @@ SUBDIRS = \\","displayNoNewLineWarning":false,"position":0,"left":12,"right":12},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":13,"text":" \t\t test_extensions \\","html":" \t\t test_extensions \u003cspan class=\"pl-cce\"\u003e\\\u003c/span\u003e","displayNoNewLineWarning":false,"position":1,"left":13,"right":13},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":14,"text":" \t\t test_parser \\","html":" \t\t test_parser \u003cspan class=\"pl-cce\"\u003e\\\u003c/span\u003e","displayNoNewLineWarning":false,"position":2,"left":14,"right":14},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":15,"text":" \t\t test_pg_dump \\","html":" \t\t test_pg_dump \u003cspan class=\"pl-cce\"\u003e\\\u003c/span\u003e","displayNoNewLineWarning":false,"position":3,"left":15,"right":15},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":16,"text":"+\t\t test_rbtree \\","html":"+\t\t test_rbtree \u003cspan class=\"pl-cce\"\u003e\\\u003c/span\u003e","displayNoNewLineWarning":false,"position":4,"left":15,"right":16},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":17,"text":" \t\t test_rls_hooks \\","html":" \t\t test_rls_hooks \u003cspan class=\"pl-cce\"\u003e\\\u003c/span\u003e","displayNoNewLineWarning":false,"position":5,"left":16,"right":17},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":18,"text":" \t\t test_shm_mq \\","html":" \t\t test_shm_mq \u003cspan class=\"pl-cce\"\u003e\\\u003c/span\u003e","displayNoNewLineWarning":false,"position":6,"left":17,"right":18},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":19,"text":" \t\t worker_spi","html":" \t\t worker_spi","displayNoNewLineWarning":false,"position":7,"left":18,"right":19}],"diffNumber":0,"diffSize":"0 Bytes","isBinary":false,"isTooBig":false,"collapsed":false,"isSubmodule":false,"lineCount":23,"linesChanged":1,"newTreeEntry":{"lineCount":23,"path":"src/test/modules/Makefile","mode":100644,"isGenerated":false},"oldTreeEntry":{"lineCount":0,"path":"src/test/modules/Makefile","mode":100644},"linesAdded":1,"linesDeleted":0,"path":"src/test/modules/Makefile","pathDigest":"69be03c779708ca276d2bfc962d2d352fe26838b8dd958a3c9daef867e23b449","status":"MODIFIED","truncatedReason":null,"oldOid":"f80e782a6b4dcdea78f053f1505fff316f3a3289","newOid":"610bbdd8acfcbeedad1176188f53ce5c7905e280","copilotChatReference":null,"deletedSha":"f80e782a6b4dcdea78f053f1505fff316f3a3289","canToggleRichDiff":false,"defaultToRichDiff":false,"proseDifffHtml":null,"renderInfo":null,"dependencyDiffPath":null,"submodule":null},{"diffLines":[{"stylingDirective":null,"type":"HUNK","blobLineNumber":0,"text":"@@ -0,0 +1,4 @@","html":"@@ -0,0 +1,4 @@","displayNoNewLineWarning":false,"position":0,"left":null,"right":0},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":1,"text":"+# Generated subdirectories","html":"+\u003cspan class=\"pl-c\"\u003e\u003cspan class=\"pl-c\"\u003e#\u003c/span\u003e Generated subdirectories\u003c/span\u003e","displayNoNewLineWarning":false,"position":1,"left":null,"right":1},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":2,"text":"+/log/","html":"+/\u003cspan class=\"pl-e\"\u003elog\u003c/span\u003e/","displayNoNewLineWarning":false,"position":2,"left":null,"right":2},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":3,"text":"+/results/","html":"+/\u003cspan class=\"pl-e\"\u003eresults\u003c/span\u003e/","displayNoNewLineWarning":false,"position":3,"left":null,"right":3},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":4,"text":"+/tmp_check/","html":"+/\u003cspan class=\"pl-e\"\u003etmp_check\u003c/span\u003e/","displayNoNewLineWarning":false,"position":4,"left":null,"right":4}],"diffNumber":1,"diffSize":"0 Bytes","isBinary":false,"isTooBig":false,"collapsed":false,"isSubmodule":false,"lineCount":4,"linesChanged":4,"newTreeEntry":{"lineCount":4,"path":"src/test/modules/test_rbtree/.gitignore","mode":100644,"isGenerated":false},"oldTreeEntry":null,"linesAdded":4,"linesDeleted":0,"path":"src/test/modules/test_rbtree/.gitignore","pathDigest":"565b8831e3ea7fa62db4e7e6856b97dabd7102338f7f0edf9bd0d0a3770c119f","status":"ADDED","truncatedReason":null,"oldOid":"f80e782a6b4dcdea78f053f1505fff316f3a3289","newOid":"610bbdd8acfcbeedad1176188f53ce5c7905e280","copilotChatReference":null,"deletedSha":"f80e782a6b4dcdea78f053f1505fff316f3a3289","canToggleRichDiff":false,"defaultToRichDiff":false,"proseDifffHtml":null,"renderInfo":null,"dependencyDiffPath":null,"submodule":null},{"diffLines":[{"stylingDirective":null,"type":"HUNK","blobLineNumber":0,"text":"@@ -0,0 +1,21 @@","html":"@@ -0,0 +1,21 @@","displayNoNewLineWarning":false,"position":0,"left":null,"right":0},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":1,"text":"+# src/test/modules/test_rbtree/Makefile","html":"+\u003cspan class=\"pl-c\"\u003e\u003cspan class=\"pl-c\"\u003e#\u003c/span\u003e src/test/modules/test_rbtree/Makefile\u003c/span\u003e","displayNoNewLineWarning":false,"position":1,"left":null,"right":1},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":2,"text":"+","html":"+","displayNoNewLineWarning":false,"position":2,"left":null,"right":2},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":3,"text":"+MODULE_big = test_rbtree","html":"+\u003cspan class=\"pl-smi\"\u003eMODULE_big\u003c/span\u003e = test_rbtree","displayNoNewLineWarning":false,"position":3,"left":null,"right":3},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":4,"text":"+OBJS = test_rbtree.o $(WIN32RES)","html":"+\u003cspan class=\"pl-smi\"\u003eOBJS\u003c/span\u003e = test_rbtree.o \u003cspan class=\"pl-s\"\u003e$(\u003cspan class=\"pl-smi\"\u003eWIN32RES\u003c/span\u003e)\u003c/span\u003e","displayNoNewLineWarning":false,"position":4,"left":null,"right":4},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":5,"text":"+PGFILEDESC = \"test_rbtree - test code for red-black tree library\"","html":"+\u003cspan class=\"pl-smi\"\u003ePGFILEDESC\u003c/span\u003e = \u0026quot;test_rbtree - test code for red-black tree library\u0026quot;","displayNoNewLineWarning":false,"position":5,"left":null,"right":5},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":6,"text":"+","html":"+","displayNoNewLineWarning":false,"position":6,"left":null,"right":6},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":7,"text":"+EXTENSION = test_rbtree","html":"+\u003cspan class=\"pl-smi\"\u003eEXTENSION\u003c/span\u003e = test_rbtree","displayNoNewLineWarning":false,"position":7,"left":null,"right":7},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":8,"text":"+DATA = test_rbtree--1.0.sql","html":"+\u003cspan class=\"pl-smi\"\u003eDATA\u003c/span\u003e = test_rbtree--1.0.sql","displayNoNewLineWarning":false,"position":8,"left":null,"right":8},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":9,"text":"+","html":"+","displayNoNewLineWarning":false,"position":9,"left":null,"right":9},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":10,"text":"+REGRESS = test_rbtree","html":"+\u003cspan class=\"pl-smi\"\u003eREGRESS\u003c/span\u003e = test_rbtree","displayNoNewLineWarning":false,"position":10,"left":null,"right":10},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":11,"text":"+","html":"+","displayNoNewLineWarning":false,"position":11,"left":null,"right":11},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":12,"text":"+ifdef USE_PGXS","html":"+\u003cspan class=\"pl-k\"\u003eifdef\u003c/span\u003e \u003cspan class=\"pl-smi\"\u003eUSE_PGXS\u003c/span\u003e","displayNoNewLineWarning":false,"position":12,"left":null,"right":12},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":13,"text":"+PG_CONFIG = pg_config","html":"+\u003cspan class=\"pl-smi\"\u003ePG_CONFIG\u003c/span\u003e = pg_config","displayNoNewLineWarning":false,"position":13,"left":null,"right":13},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":14,"text":"+PGXS := $(shell $(PG_CONFIG) --pgxs)","html":"+\u003cspan class=\"pl-smi\"\u003ePGXS\u003c/span\u003e := \u003cspan class=\"pl-s\"\u003e$(\u003cspan class=\"pl-c1\"\u003eshell\u003c/span\u003e \u003cspan class=\"pl-s\"\u003e$(\u003cspan class=\"pl-smi\"\u003ePG_CONFIG\u003c/span\u003e)\u003c/span\u003e --pgxs)\u003c/span\u003e","displayNoNewLineWarning":false,"position":14,"left":null,"right":14},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":15,"text":"+include $(PGXS)","html":"+\u003cspan class=\"pl-k\"\u003einclude\u003c/span\u003e \u003cspan class=\"pl-s\"\u003e$(\u003cspan class=\"pl-smi\"\u003ePGXS\u003c/span\u003e)\u003c/span\u003e","displayNoNewLineWarning":false,"position":15,"left":null,"right":15},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":16,"text":"+else","html":"+else","displayNoNewLineWarning":false,"position":16,"left":null,"right":16},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":17,"text":"+subdir = src/test/modules/test_rbtree","html":"+\u003cspan class=\"pl-smi\"\u003esubdir\u003c/span\u003e = src/test/modules/test_rbtree","displayNoNewLineWarning":false,"position":17,"left":null,"right":17},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":18,"text":"+top_builddir = ../../../..","html":"+\u003cspan class=\"pl-smi\"\u003etop_builddir\u003c/span\u003e = ../../../..","displayNoNewLineWarning":false,"position":18,"left":null,"right":18},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":19,"text":"+include $(top_builddir)/src/Makefile.global","html":"+\u003cspan class=\"pl-k\"\u003einclude\u003c/span\u003e \u003cspan class=\"pl-s\"\u003e$(\u003cspan class=\"pl-smi\"\u003etop_builddir\u003c/span\u003e)\u003c/span\u003e/src/Makefile.global","displayNoNewLineWarning":false,"position":19,"left":null,"right":19},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":20,"text":"+include $(top_srcdir)/contrib/contrib-global.mk","html":"+\u003cspan class=\"pl-k\"\u003einclude\u003c/span\u003e \u003cspan class=\"pl-s\"\u003e$(\u003cspan class=\"pl-smi\"\u003etop_srcdir\u003c/span\u003e)\u003c/span\u003e/contrib/contrib-global.mk","displayNoNewLineWarning":false,"position":20,"left":null,"right":20},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":21,"text":"+endif","html":"+\u003cspan class=\"pl-k\"\u003eendif\u003c/span\u003e","displayNoNewLineWarning":false,"position":21,"left":null,"right":21}],"diffNumber":2,"diffSize":"0 Bytes","isBinary":false,"isTooBig":false,"collapsed":false,"isSubmodule":false,"lineCount":21,"linesChanged":21,"newTreeEntry":{"lineCount":21,"path":"src/test/modules/test_rbtree/Makefile","mode":100644,"isGenerated":false},"oldTreeEntry":null,"linesAdded":21,"linesDeleted":0,"path":"src/test/modules/test_rbtree/Makefile","pathDigest":"91a4716f493e31ce50219de8451564e99104f35fd255feac6924d8a0496ca883","status":"ADDED","truncatedReason":null,"oldOid":"f80e782a6b4dcdea78f053f1505fff316f3a3289","newOid":"610bbdd8acfcbeedad1176188f53ce5c7905e280","copilotChatReference":null,"deletedSha":"f80e782a6b4dcdea78f053f1505fff316f3a3289","canToggleRichDiff":false,"defaultToRichDiff":false,"proseDifffHtml":null,"renderInfo":null,"dependencyDiffPath":null,"submodule":null},{"diffLines":[{"stylingDirective":null,"type":"HUNK","blobLineNumber":0,"text":"@@ -0,0 +1,13 @@","html":"@@ -0,0 +1,13 @@","displayNoNewLineWarning":false,"position":0,"left":null,"right":0},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":1,"text":"+test_rbtree is a test module for checking the correctness of red-black","html":"+test_rbtree is a test module for checking the correctness of red-black","displayNoNewLineWarning":false,"position":1,"left":null,"right":1},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":2,"text":"+tree operations.","html":"+tree operations.","displayNoNewLineWarning":false,"position":2,"left":null,"right":2},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":3,"text":"+","html":"+","displayNoNewLineWarning":false,"position":3,"left":null,"right":3},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":4,"text":"+These tests are performed on red-black trees that store integers.","html":"+These tests are performed on red-black trees that store integers.","displayNoNewLineWarning":false,"position":4,"left":null,"right":4},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":5,"text":"+Since the rbtree logic treats the comparison function as a black","html":"+Since the rbtree logic treats the comparison function as a black","displayNoNewLineWarning":false,"position":5,"left":null,"right":5},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":6,"text":"+box, it shouldn't be important exactly what the key type is.","html":"+box, it shouldn\u0026#39;t be important exactly what the key type is.","displayNoNewLineWarning":false,"position":6,"left":null,"right":6},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":7,"text":"+","html":"+","displayNoNewLineWarning":false,"position":7,"left":null,"right":7},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":8,"text":"+Checking the correctness of traversals is based on the fact that a red-black","html":"+Checking the correctness of traversals is based on the fact that a red-black","displayNoNewLineWarning":false,"position":8,"left":null,"right":8},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":9,"text":"+tree is a binary search tree, so the elements should be visited in increasing","html":"+tree is a binary search tree, so the elements should be visited in increasing","displayNoNewLineWarning":false,"position":9,"left":null,"right":9},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":10,"text":"+(for Left-Current-Right) or decreasing (for Right-Current-Left) order.","html":"+(for Left-Current-Right) or decreasing (for Right-Current-Left) order.","displayNoNewLineWarning":false,"position":10,"left":null,"right":10},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":11,"text":"+","html":"+","displayNoNewLineWarning":false,"position":11,"left":null,"right":11},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":12,"text":"+Also, this module does some checks of the correctness of the find, delete","html":"+Also, this module does some checks of the correctness of the find, delete","displayNoNewLineWarning":false,"position":12,"left":null,"right":12},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":13,"text":"+and leftmost operations.","html":"+and leftmost operations.","displayNoNewLineWarning":false,"position":13,"left":null,"right":13}],"diffNumber":3,"diffSize":"0 Bytes","isBinary":false,"isTooBig":false,"collapsed":false,"isSubmodule":false,"lineCount":13,"linesChanged":13,"newTreeEntry":{"lineCount":13,"path":"src/test/modules/test_rbtree/README","mode":100644,"isGenerated":false},"oldTreeEntry":null,"linesAdded":13,"linesDeleted":0,"path":"src/test/modules/test_rbtree/README","pathDigest":"df4f38f41379b6c325e7f3212a6da652b2836685b36374212acc272abc35a86e","status":"ADDED","truncatedReason":null,"oldOid":"f80e782a6b4dcdea78f053f1505fff316f3a3289","newOid":"610bbdd8acfcbeedad1176188f53ce5c7905e280","copilotChatReference":null,"deletedSha":"f80e782a6b4dcdea78f053f1505fff316f3a3289","canToggleRichDiff":false,"defaultToRichDiff":false,"proseDifffHtml":null,"renderInfo":null,"dependencyDiffPath":null,"submodule":null},{"diffLines":[{"stylingDirective":null,"type":"HUNK","blobLineNumber":0,"text":"@@ -0,0 +1,12 @@","html":"@@ -0,0 +1,12 @@","displayNoNewLineWarning":false,"position":0,"left":null,"right":0},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":1,"text":"+CREATE EXTENSION test_rbtree;","html":"+CREATE EXTENSION test_rbtree;","displayNoNewLineWarning":false,"position":1,"left":null,"right":1},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":2,"text":"+--","html":"+--","displayNoNewLineWarning":false,"position":2,"left":null,"right":2},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":3,"text":"+-- These tests don't produce any interesting output. We're checking that","html":"+-- These tests don\u0026#39;t produce any interesting output. We\u0026#39;re checking that","displayNoNewLineWarning":false,"position":3,"left":null,"right":3},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":4,"text":"+-- the operations complete without crashing or hanging and that none of their","html":"+-- the operations complete without crashing or hanging and that none of their","displayNoNewLineWarning":false,"position":4,"left":null,"right":4},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":5,"text":"+-- internal sanity tests fail.","html":"+-- internal sanity tests fail.","displayNoNewLineWarning":false,"position":5,"left":null,"right":5},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":6,"text":"+--","html":"+--","displayNoNewLineWarning":false,"position":6,"left":null,"right":6},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":7,"text":"+SELECT test_rb_tree(10000);","html":"+SELECT test_rb_tree(10000);","displayNoNewLineWarning":false,"position":7,"left":null,"right":7},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":8,"text":"+ test_rb_tree ","html":"+ test_rb_tree ","displayNoNewLineWarning":false,"position":8,"left":null,"right":8},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":9,"text":"+--------------","html":"+--------------","displayNoNewLineWarning":false,"position":9,"left":null,"right":9},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":10,"text":"+ ","html":"+ ","displayNoNewLineWarning":false,"position":10,"left":null,"right":10},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":11,"text":"+(1 row)","html":"+(1 row)","displayNoNewLineWarning":false,"position":11,"left":null,"right":11},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":12,"text":"+","html":"+","displayNoNewLineWarning":false,"position":12,"left":null,"right":12}],"diffNumber":4,"diffSize":"0 Bytes","isBinary":false,"isTooBig":false,"collapsed":false,"isSubmodule":false,"lineCount":12,"linesChanged":12,"newTreeEntry":{"lineCount":12,"path":"src/test/modules/test_rbtree/expected/test_rbtree.out","mode":100644,"isGenerated":false},"oldTreeEntry":null,"linesAdded":12,"linesDeleted":0,"path":"src/test/modules/test_rbtree/expected/test_rbtree.out","pathDigest":"fb68a2b3485007135a9b0f8f0d36c35e280159f0c61fa84af16838ef7a69af58","status":"ADDED","truncatedReason":null,"oldOid":"f80e782a6b4dcdea78f053f1505fff316f3a3289","newOid":"610bbdd8acfcbeedad1176188f53ce5c7905e280","copilotChatReference":null,"deletedSha":"f80e782a6b4dcdea78f053f1505fff316f3a3289","canToggleRichDiff":false,"defaultToRichDiff":false,"proseDifffHtml":null,"renderInfo":null,"dependencyDiffPath":null,"submodule":null},{"diffLines":[{"stylingDirective":null,"type":"HUNK","blobLineNumber":0,"text":"@@ -0,0 +1,8 @@","html":"@@ -0,0 +1,8 @@","displayNoNewLineWarning":false,"position":0,"left":null,"right":0},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":1,"text":"+CREATE EXTENSION test_rbtree;","html":"+CREATE EXTENSION test_rbtree;","displayNoNewLineWarning":false,"position":1,"left":null,"right":1},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":2,"text":"+","html":"+","displayNoNewLineWarning":false,"position":2,"left":null,"right":2},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":3,"text":"+--","html":"+\u003cspan class=\"pl-c\"\u003e\u003cspan class=\"pl-c\"\u003e--\u003c/span\u003e\u003c/span\u003e","displayNoNewLineWarning":false,"position":3,"left":null,"right":3},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":4,"text":"+-- These tests don't produce any interesting output. We're checking that","html":"+\u003cspan class=\"pl-c\"\u003e\u003cspan class=\"pl-c\"\u003e--\u003c/span\u003e These tests don\u0026#39;t produce any interesting output. We\u0026#39;re checking that\u003c/span\u003e","displayNoNewLineWarning":false,"position":4,"left":null,"right":4},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":5,"text":"+-- the operations complete without crashing or hanging and that none of their","html":"+\u003cspan class=\"pl-c\"\u003e\u003cspan class=\"pl-c\"\u003e--\u003c/span\u003e the operations complete without crashing or hanging and that none of their\u003c/span\u003e","displayNoNewLineWarning":false,"position":5,"left":null,"right":5},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":6,"text":"+-- internal sanity tests fail.","html":"+\u003cspan class=\"pl-c\"\u003e\u003cspan class=\"pl-c\"\u003e--\u003c/span\u003e internal sanity tests fail.\u003c/span\u003e","displayNoNewLineWarning":false,"position":6,"left":null,"right":6},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":7,"text":"+--","html":"+\u003cspan class=\"pl-c\"\u003e\u003cspan class=\"pl-c\"\u003e--\u003c/span\u003e\u003c/span\u003e","displayNoNewLineWarning":false,"position":7,"left":null,"right":7},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":8,"text":"+SELECT test_rb_tree(10000);","html":"+\u003cspan class=\"pl-k\"\u003eSELECT\u003c/span\u003e test_rb_tree(\u003cspan class=\"pl-c1\"\u003e10000\u003c/span\u003e);","displayNoNewLineWarning":false,"position":8,"left":null,"right":8}],"diffNumber":5,"diffSize":"0 Bytes","isBinary":false,"isTooBig":false,"collapsed":false,"isSubmodule":false,"lineCount":8,"linesChanged":8,"newTreeEntry":{"lineCount":8,"path":"src/test/modules/test_rbtree/sql/test_rbtree.sql","mode":100644,"isGenerated":false},"oldTreeEntry":null,"linesAdded":8,"linesDeleted":0,"path":"src/test/modules/test_rbtree/sql/test_rbtree.sql","pathDigest":"5ebc857fe2c9b2ce2eeb033442ed8d51d0865bfeb55433c8a5d9c00f03773d7b","status":"ADDED","truncatedReason":null,"oldOid":"f80e782a6b4dcdea78f053f1505fff316f3a3289","newOid":"610bbdd8acfcbeedad1176188f53ce5c7905e280","copilotChatReference":null,"deletedSha":"f80e782a6b4dcdea78f053f1505fff316f3a3289","canToggleRichDiff":false,"defaultToRichDiff":false,"proseDifffHtml":null,"renderInfo":null,"dependencyDiffPath":null,"submodule":null},{"diffLines":[{"stylingDirective":null,"type":"HUNK","blobLineNumber":0,"text":"@@ -0,0 +1,8 @@","html":"@@ -0,0 +1,8 @@","displayNoNewLineWarning":false,"position":0,"left":null,"right":0},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":1,"text":"+/* src/test/modules/test_rbtree/test_rbtree--1.0.sql */","html":"+\u003cspan class=\"pl-c\"\u003e\u003cspan class=\"pl-c\"\u003e/*\u003c/span\u003e src/test/modules/test_rbtree/test_rbtree--1.0.sql \u003cspan class=\"pl-c\"\u003e*/\u003c/span\u003e\u003c/span\u003e","displayNoNewLineWarning":false,"position":1,"left":null,"right":1},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":2,"text":"+","html":"+","displayNoNewLineWarning":false,"position":2,"left":null,"right":2},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":3,"text":"+-- complain if script is sourced in psql, rather than via CREATE EXTENSION","html":"+\u003cspan class=\"pl-c\"\u003e\u003cspan class=\"pl-c\"\u003e--\u003c/span\u003e complain if script is sourced in psql, rather than via CREATE EXTENSION\u003c/span\u003e","displayNoNewLineWarning":false,"position":3,"left":null,"right":3},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":4,"text":"+\\echo Use \"CREATE EXTENSION test_rbtree\" to load this file. \\quit","html":"+\\echo Use \u003cspan class=\"pl-s\"\u003e\u003cspan class=\"pl-pds\"\u003e\u0026quot;\u003c/span\u003eCREATE EXTENSION test_rbtree\u003cspan class=\"pl-pds\"\u003e\u0026quot;\u003c/span\u003e\u003c/span\u003e to load this file. \\quit","displayNoNewLineWarning":false,"position":4,"left":null,"right":4},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":5,"text":"+","html":"+","displayNoNewLineWarning":false,"position":5,"left":null,"right":5},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":6,"text":"+CREATE FUNCTION test_rb_tree(size INTEGER)","html":"+\u003cspan class=\"pl-k\"\u003eCREATE\u003c/span\u003e \u003cspan class=\"pl-k\"\u003eFUNCTION\u003c/span\u003e \u003cspan class=\"pl-en\"\u003etest_rb_tree\u003c/span\u003e(size \u003cspan class=\"pl-k\"\u003eINTEGER\u003c/span\u003e)","displayNoNewLineWarning":false,"position":6,"left":null,"right":6},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":7,"text":"+\tRETURNS pg_catalog.void STRICT","html":"+\tRETURNS \u003cspan class=\"pl-c1\"\u003epg_catalog\u003c/span\u003e.\u003cspan class=\"pl-c1\"\u003evoid\u003c/span\u003e STRICT","displayNoNewLineWarning":false,"position":7,"left":null,"right":7},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":8,"text":"+\tAS 'MODULE_PATHNAME' LANGUAGE C;","html":"+\t\u003cspan class=\"pl-k\"\u003eAS\u003c/span\u003e \u003cspan class=\"pl-s\"\u003e\u003cspan class=\"pl-pds\"\u003e\u0026#39;\u003c/span\u003eMODULE_PATHNAME\u003cspan class=\"pl-pds\"\u003e\u0026#39;\u003c/span\u003e\u003c/span\u003e LANGUAGE C;","displayNoNewLineWarning":false,"position":8,"left":null,"right":8}],"diffNumber":6,"diffSize":"0 Bytes","isBinary":false,"isTooBig":false,"collapsed":false,"isSubmodule":false,"lineCount":8,"linesChanged":8,"newTreeEntry":{"lineCount":8,"path":"src/test/modules/test_rbtree/test_rbtree--1.0.sql","mode":100644,"isGenerated":false},"oldTreeEntry":null,"linesAdded":8,"linesDeleted":0,"path":"src/test/modules/test_rbtree/test_rbtree--1.0.sql","pathDigest":"7d7ebfeb6959b646563b0e4b92c7ad563a28682a31e5c86a9330993f43fb27dd","status":"ADDED","truncatedReason":null,"oldOid":"f80e782a6b4dcdea78f053f1505fff316f3a3289","newOid":"610bbdd8acfcbeedad1176188f53ce5c7905e280","copilotChatReference":null,"deletedSha":"f80e782a6b4dcdea78f053f1505fff316f3a3289","canToggleRichDiff":false,"defaultToRichDiff":false,"proseDifffHtml":null,"renderInfo":null,"dependencyDiffPath":null,"submodule":null},{"path":"src/test/modules/test_rbtree/test_rbtree.c","pathDigest":"0a7ec8d5ce9dbe1b09a3171c4966901ba5746bc88855b068436911c45f53db3c","status":"ADDED"},{"path":"src/test/modules/test_rbtree/test_rbtree.control","pathDigest":"1cabcb1fd22b52058005a64fcc1c3f5dd85bcb8ee093a3ee321dc4e577b501fc","status":"ADDED"}],"splitViewPreference":"unified","ignoreWhitespace":false,"repoOwnerGlobalRelayId":"MDEyOk9yZ2FuaXphdGlvbjE3NzU0Mw==","commentsPreference":"visible","diffLineSpacingPreference":"relaxed","useMonospaceFont":false,"pasteUrlLinkAsPlainText":false,"userNotices":[],"path":"/postgres/postgres/commit/610bbdd8acfcbeedad1176188f53ce5c7905e280","fileTreeExpanded":true,"headerInfo":{"additions":484,"deletions":0,"filesChanged":9,"filesChangedString":"9"},"moreDiffsToLoad":true,"asyncDiffLoadInfo":{"startIndex":7,"truncated":false,"byteCount":2333,"lineShownCount":80},"commentInfo":{"canComment":false,"locked":false,"canLock":false,"repoArchived":false},"csrf_tokens":{"/users/diffview?diff=split":{"post":"z2LM_s092T2fmXlW7iQu8VKmFi_xtwt1yGkZ-KGB7qqTpAOopQhgRYDOslDjSclCDb7BzzjP5-p8EsS5nY8Xjw"},"/users/diffview?diff=unified":{"post":"dNQ1MVLj0R6sQGq_73xRORW6-LjvlYVGvV4hYSAj4O0oEvpnOtZoZrMXobniEbaKSqIvWCbtadkJJfwgHC0ZyA"},"/notifications/thread":{"post":"Y9cTDcne4t4dPZ5ytv879TcdZWiIXlKG9wMEiXlcYlSgUKWCaWbNRMR6mj9LP6eSly3EfeDCbVdMi3iLClMGhw"}}},"title":"Add a test harness for the red-black tree code. · postgres/postgres@610bbdd","appPayload":{"helpUrl":"https://docs.github.com","findInDiffWorkerPath":"/assets-cdn/worker/find-in-diff-worker-2bfe39677d14.js","enabled_features":{"diff_ux_refresh_beta":false,"diff_inline_comments":true,"diff_ux_refresh_ssr_five":false,"diff_ux_refresh_ssr_ten":false,"react_diff_line_type_character_correction":true}}}

Commit 610bbdd

Browse files
committed
Add a test harness for the red-black tree code.
This improves the regression tests' coverage of rbtree.c from pretty awful (because some of the functions aren't used yet) to basically 100%. Victor Drobny, reviewed by Aleksander Alekseev and myself Discussion: https://postgr.es/m/c9d61310e16e75f8acaf6cb1c48b7b77@postgrespro.ru
1 parent f80e782 commit 610bbdd

File tree

9 files changed

+484
-0
lines changed

9 files changed

+484
-0
lines changed

src/test/modules/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ SUBDIRS = \
1313
test_extensions \
1414
test_parser \
1515
test_pg_dump \
16+
test_rbtree \
1617
test_rls_hooks \
1718
test_shm_mq \
1819
worker_spi
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Generated subdirectories
2+
/log/
3+
/results/
4+
/tmp_check/

src/test/modules/test_rbtree/Makefile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# src/test/modules/test_rbtree/Makefile
2+
3+
MODULE_big = test_rbtree
4+
OBJS = test_rbtree.o $(WIN32RES)
5+
PGFILEDESC = "test_rbtree - test code for red-black tree library"
6+
7+
EXTENSION = test_rbtree
8+
DATA = test_rbtree--1.0.sql
9+
10+
REGRESS = test_rbtree
11+
12+
ifdef USE_PGXS
13+
PG_CONFIG = pg_config
14+
PGXS := $(shell $(PG_CONFIG) --pgxs)
15+
include $(PGXS)
16+
else
17+
subdir = src/test/modules/test_rbtree
18+
top_builddir = ../../../..
19+
include $(top_builddir)/src/Makefile.global
20+
include $(top_srcdir)/contrib/contrib-global.mk
21+
endif

src/test/modules/test_rbtree/README

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
test_rbtree is a test module for checking the correctness of red-black
2+
tree operations.
3+
4+
These tests are performed on red-black trees that store integers.
5+
Since the rbtree logic treats the comparison function as a black
6+
box, it shouldn't be important exactly what the key type is.
7+
8+
Checking the correctness of traversals is based on the fact that a red-black
9+
tree is a binary search tree, so the elements should be visited in increasing
10+
(for Left-Current-Right) or decreasing (for Right-Current-Left) order.
11+
12+
Also, this module does some checks of the correctness of the find, delete
13+
and leftmost operations.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
CREATE EXTENSION test_rbtree;
2+
--
3+
-- These tests don't produce any interesting output. We're checking that
4+
-- the operations complete without crashing or hanging and that none of their
5+
-- internal sanity tests fail.
6+
--
7+
SELECT test_rb_tree(10000);
8+
test_rb_tree
9+
--------------
10+
11+
(1 row)
12+
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CREATE EXTENSION test_rbtree;
2+
3+
--
4+
-- These tests don't produce any interesting output. We're checking that
5+
-- the operations complete without crashing or hanging and that none of their
6+
-- internal sanity tests fail.
7+
--
8+
SELECT test_rb_tree(10000);
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/* src/test/modules/test_rbtree/test_rbtree--1.0.sql */
2+
3+
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
< 4D2D code>4+
\echo Use "CREATE EXTENSION test_rbtree" to load this file. \quit
5+
6+
CREATE FUNCTION test_rb_tree(size INTEGER)
7+
RETURNS pg_catalog.void STRICT
8+
AS 'MODULE_PATHNAME' LANGUAGE C;

0 commit comments

Comments
 (0)
0