Skip to content
Snippets Groups Projects
Select Git revision
  • benchmark-tools
  • postgres-lambda
  • master default
  • REL9_4_25
  • REL9_5_20
  • REL9_6_16
  • REL_10_11
  • REL_11_6
  • REL_12_1
  • REL_12_0
  • REL_12_RC1
  • REL_12_BETA4
  • REL9_4_24
  • REL9_5_19
  • REL9_6_15
  • REL_10_10
  • REL_11_5
  • REL_12_BETA3
  • REL9_4_23
  • REL9_5_18
  • REL9_6_14
  • REL_10_9
  • REL_11_4
23 results

tablefunc.c

Blame
    • Bruce Momjian's avatar
      620dddf8
      > The previous patch fixed an infinite recursion bug in · 620dddf8
      Bruce Momjian authored
      > contrib/tablefunc/tablefunc.c:connectby. But, other unmanageable error
      > seems to occur even if a table has commonplace tree data(see below).
      >
      > I would think the patch, ancestor check, should be
      >
      >   if (strstr(branch_delim || branchstr->data || branch_delim,
      >                        branch_delim || current_key || branch_delim))
      >
      > This is my image, not a real code. However, if branchstr->data includes
      > branch_delim, my image will not be perfect.
      
      Good point. Thank you Masaru for the suggested fix.
      
      Attached is a patch to fix the bug found by Masaru. His example now
      produces:
      
      regression=# SELECT * FROM connectby('connectby_tree', 'keyid',
      'parent_keyid', '11', 0, '-') AS t(keyid int, parent_keyid int, level
      int,
      branch text);
        keyid | parent_keyid | level |  branch
      
      -------+--------------+-------+----------
           11 |              |     0 | 11
           10 |           11 |     1 | 11-10
          111 |           11 |     1 | 11-111
            1 |          111 |     2 | 11-111-1
      (4 rows)
      
      While making the patch I also realized that the "no show branch" form of
      the  function was not going to work very well for recursion detection.
      Therefore  there is now a default branch delimiter ('~') that is used
      internally, for  that case, to enable recursion detection to work. If
      you need a different  delimiter for your specific data, you will have to
      use the "show branch" form  of the function.
      
      Joe Conway
      620dddf8
      History
      > The previous patch fixed an infinite recursion bug in
      Bruce Momjian authored
      > contrib/tablefunc/tablefunc.c:connectby. But, other unmanageable error
      > seems to occur even if a table has commonplace tree data(see below).
      >
      > I would think the patch, ancestor check, should be
      >
      >   if (strstr(branch_delim || branchstr->data || branch_delim,
      >                        branch_delim || current_key || branch_delim))
      >
      > This is my image, not a real code. However, if branchstr->data includes
      > branch_delim, my image will not be perfect.
      
      Good point. Thank you Masaru for the suggested fix.
      
      Attached is a patch to fix the bug found by Masaru. His example now
      produces:
      
      regression=# SELECT * FROM connectby('connectby_tree', 'keyid',
      'parent_keyid', '11', 0, '-') AS t(keyid int, parent_keyid int, level
      int,
      branch text);
        keyid | parent_keyid | level |  branch
      
      -------+--------------+-------+----------
           11 |              |     0 | 11
           10 |           11 |     1 | 11-10
          111 |           11 |     1 | 11-111
            1 |          111 |     2 | 11-111-1
      (4 rows)
      
      While making the patch I also realized that the "no show branch" form of
      the  function was not going to work very well for recursion detection.
      Therefore  there is now a default branch delimiter ('~') that is used
      internally, for  that case, to enable recursion detection to work. If
      you need a different  delimiter for your specific data, you will have to
      use the "show branch" form  of the function.
      
      Joe Conway