Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecated functions #2732

Draft
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

cvvergara
Copy link
Member

@cvvergara cvvergara commented Jan 25, 2025

Removal of several deprecated functions

@pgRouting/admins

Summary by CodeRabbit

pgRouting v4.0.0 Release Notes

  • Deprecation and Removal

    • Removed multiple legacy and deprecated SQL functions across various routing algorithms
    • Eliminated internal functions like _pgr_dijkstra, _pgr_trsp, and _pgr_drivingDistance
    • Removed experimental and legacy functions for TSP, VRP, and point-based routing
  • Function Promotions

    • Promoted several routing functions to official status, including:
      • pgr_trsp
      • pgr_withPoints
      • pgr_withPointsDD
      • pgr_withPointsKSP
    • Promoted signatures for pathfinding algorithms like pgr_aStar, pgr_dijkstra
  • Signature Updates

    • Updated function signatures for driving distance and point-based routing
    • Simplified documentation for deprecated function removals
    • Streamlined internal function implementations

Copy link

coderabbitai bot commented Jan 25, 2025

Walkthrough

This pull request focuses on documenting function promotions and removals for pgRouting version 4.0.0. The changes involve updating release notes, removing legacy SQL functions, modifying function signatures, and cleaning up deprecated internal functions across multiple files. The modifications streamline the library's functionality by promoting stable functions and eliminating outdated implementations while maintaining backward compatibility.

Changes

File Change Summary
doc/src/release_notes.rst Simplified section on deprecated functions, updated function signatures
sql/legacy/* Removed multiple legacy SQL files containing deprecated functions like pgr_tsp, pgr_alphashape, routing_legacy.sql
sql/sigs/pgrouting--4.0.sig Updated function signatures, removed internal functions
src/driving_distance/driving_distance.c Deprecated _pgr_drivingdistance function with error reporting
NEWS.md Documented function promotions and removals

Sequence Diagram

sequenceDiagram
    participant Library as pgRouting Library
    participant User as Developer
    participant Deprecated as Deprecated Functions
    participant New as New Functions

    Library->>Deprecated: Deprecation Notice
    Deprecated-->>User: Warning Message
    User->>New: Migrate to New Functions
    New->>Library: Use Updated Implementations
Loading

Possibly related PRs

Suggested labels

Documentation, functionality/official

Suggested reviewers

  • robe2

Poem

🐰 In the garden of code, where functions grow,
Legacy paths now gently flow
Deprecated whispers, a farewell song
To old signatures that no longer belong
Hop forward, brave routing, with signatures bright! 🚀


🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@cvvergara
Copy link
Member Author

@coderabbitai review

Copy link

coderabbitai bot commented Jan 25, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@cvvergara cvvergara changed the title Find deprecated Remove deprecated functions Jan 25, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4918c9e and 09663cd.

📒 Files selected for processing (17)
  • doc/src/release_notes.rst (2 hunks)
  • sql/driving_distance/_drivingDistance.sql (0 hunks)
  • sql/legacy/alpha_shape.sql (0 hunks)
  • sql/legacy/legacy-developers.sql (0 hunks)
  • sql/legacy/legacy_experimental.sql (0 hunks)
  • sql/legacy/pgrouting_version.sql (0 hunks)
  • sql/legacy/pointsAsPolygon.sql (0 hunks)
  • sql/legacy/routing_legacy.sql (0 hunks)
  • sql/legacy/tsp/TSPeucledian.sql (0 hunks)
  • sql/legacy/tsp/_makeDistanceMatrix.sql (0 hunks)
  • sql/legacy/tsp/tsp_v2.0_coordinates.sql (0 hunks)
  • sql/legacy/tsp/tsp_v2.0_matrix.sql (0 hunks)
  • sql/legacy/vrppdtw/_gsoc_vrppdtw.sql (0 hunks)
  • sql/legacy/vrppdtw/gsoc_vrppdtw.sql (0 hunks)
  • sql/sigs/pgrouting--4.0.sig (0 hunks)
  • src/driving_distance/driving_distance.c (0 hunks)
  • src/legacy/legacy.c (1 hunks)
💤 Files with no reviewable changes (15)
  • sql/legacy/pgrouting_version.sql
  • sql/legacy/vrppdtw/gsoc_vrppdtw.sql
  • sql/legacy/legacy-developers.sql
  • sql/legacy/alpha_shape.sql
  • sql/driving_distance/_drivingDistance.sql
  • sql/legacy/tsp/_makeDistanceMatrix.sql
  • sql/legacy/tsp/TSPeucledian.sql
  • sql/legacy/tsp/tsp_v2.0_coordinates.sql
  • src/driving_distance/driving_distance.c
  • sql/legacy/tsp/tsp_v2.0_matrix.sql
  • sql/legacy/vrppdtw/_gsoc_vrppdtw.sql
  • sql/legacy/pointsAsPolygon.sql
  • sql/legacy/legacy_experimental.sql
  • sql/sigs/pgrouting--4.0.sig
  • sql/legacy/routing_legacy.sql
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Ubuntu Boost (84)
  • GitHub Check: macos (macos-14)
  • GitHub Check: macos (macos-latest)
🔇 Additional comments (1)
src/legacy/legacy.c (1)

57-57: LGTM! Verify the migration impact.

The addition of _pgr_drivingdistance to the deprecated functions list is consistent with the existing pattern and correctly uses the PGROUTING_DEPRECATE macro with version 4.0.0.

Let's verify the impact of this deprecation:

✅ Verification successful

Deprecation properly implemented with clean migration path

The deprecated _pgr_drivingdistance function has been correctly moved to legacy.c with:

  • New implementation _pgr_drivingdistancev4 available in driving_distance.c
  • No remaining direct usage of deprecated version
  • Clean separation between legacy and new code
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining references to _pgr_drivingdistance that might need updating

# Check for any direct usage of the deprecated function
echo "Checking for direct usage of _pgr_drivingdistance..."
rg --type sql "_pgr_drivingdistance"

# Check for any SQL function definitions that might need updating
echo "Checking for SQL function definitions..."
rg --type sql "CREATE .*FUNCTION.*_pgr_drivingdistance"

# Look for any remaining implementation files
echo "Checking for implementation files..."
fd -e c -e h "driving_distance"

Length of output: 635


Script:

#!/bin/bash
# Check implementation files for any remaining _pgr_drivingdistance code

echo "Checking driving_distance.c content..."
rg -A 5 "_pgr_drivingdistance" src/driving_distance/driving_distance.c

echo -e "\nChecking header files for declarations..."
for file in include/drivers/driving_distance/*.h; do
    echo "=== Checking $file ==="
    rg "_pgr_drivingdistance" "$file"
done

echo -e "\nChecking for any remaining implementations..."
ast-grep --pattern 'PG_FUNCTION_INFO_V1(_pgr_drivingdistance)'

Length of output: 10225

doc/src/release_notes.rst Outdated Show resolved Hide resolved
doc/src/release_notes.rst Outdated Show resolved Hide resolved
doc/src/release_notes.rst Outdated Show resolved Hide resolved
@cvvergara
Copy link
Member Author

@coderabbitai review

Copy link

coderabbitai bot commented Jan 27, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🔭 Outside diff range comments (3)
pgtap/dijkstra/driving_distance/edge_cases/issue_519.pg (1)

Line range hint 47-64: Consider using a constant for client message level.

The client message level is set and reset multiple times. Consider defining a constant for the message level to improve maintainability.

+  DECLARE
+    CONSTANT WARNING_LEVEL constant text := 'WARNING';
+    CONSTANT NOTICE_LEVEL constant text := 'NOTICE';
   BEGIN
-    SET client_min_messages TO WARNING;
+    SET client_min_messages TO WARNING_LEVEL;
     ...
-    SET client_min_messages TO NOTICE;
+    SET client_min_messages TO NOTICE_LEVEL;
NEWS.md (2)

Line range hint 81-87: Fix incomplete function signatures.

Some function signatures are truncated and missing closing parentheses and parameter types.

Apply this diff to fix the signatures:

-* pgr_trsp(text,integer,double
+* pgr_trsp(text,integer,double precision,integer,double precision,boolean,boolean,text)
🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

50-50: Emphasis used instead of a heading
null

(MD036, no-emphasis-as-heading)


57-57: Emphasis used instead of a heading
null

(MD036, no-emphasis-as-heading)


73-73: Emphasis used instead of a heading
null

(MD036, no-emphasis-as-heading)


Line range hint 106-110: Fix inconsistent backtick usage.

Some function signatures have trailing backticks while others don't.

Apply this diff to make backtick usage consistent:

-* _pgr_dijkstra(text,anyarray,anyarray,boolean,boolean,boolean,bigint)``
-* _pgr_dijkstra(text,anyarray,anyarray,boolean,boolean,boolean,bigint,boolean)``
-* _pgr_dijkstra(text,text,boolean,boolean,bigint,boolean)``
-* _pgr_dijkstra(text,text,boolean,boolean,boolean)``
+* _pgr_dijkstra(text,anyarray,anyarray,boolean,boolean,boolean,bigint)
+* _pgr_dijkstra(text,anyarray,anyarray,boolean,boolean,boolean,bigint,boolean)
+* _pgr_dijkstra(text,text,boolean,boolean,bigint,boolean)
+* _pgr_dijkstra(text,text,boolean,boolean,boolean)
🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

50-50: Emphasis used instead of a heading
null

(MD036, no-emphasis-as-heading)


57-57: Emphasis used instead of a heading
null

(MD036, no-emphasis-as-heading)


73-73: Emphasis used instead of a heading
null

(MD036, no-emphasis-as-heading)

♻️ Duplicate comments (1)
doc/src/release_notes.rst (1)

83-84: ⚠️ Potential issue

Fix incomplete function signatures.

Some function signatures are truncated and missing closing parentheses and parameter types.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 09663cd and 3c92e00.

📒 Files selected for processing (9)
  • NEWS.md (1 hunks)
  • doc/src/release_notes.rst (1 hunks)
  • pgtap/dijkstra/driving_distance/edge_cases/issue_519.pg (3 hunks)
  • pgtap/dijkstra/driving_distance/inner_query.pg (1 hunks)
  • pgtap/dijkstra/driving_distance/no_crash_test.pg (2 hunks)
  • pgtap/dijkstra/driving_distance/types_check.pg (1 hunks)
  • sql/driving_distance/_drivingDistance.sql (0 hunks)
  • sql/sigs/pgrouting--4.0.sig (0 hunks)
  • src/driving_distance/driving_distance.c (2 hunks)
💤 Files with no reviewable changes (2)
  • sql/driving_distance/_drivingDistance.sql
  • sql/sigs/pgrouting--4.0.sig
🧰 Additional context used
🪛 markdownlint-cli2 (0.17.2)
NEWS.md

50-50: Emphasis used instead of a heading
null

(MD036, no-emphasis-as-heading)


57-57: Emphasis used instead of a heading
null

(MD036, no-emphasis-as-heading)


73-73: Emphasis used instead of a heading
null

(MD036, no-emphasis-as-heading)

⏰ Context from checks skipped due to timeout of 90000ms (16)
  • GitHub Check: macos (macos-14)
  • GitHub Check: macos (macos-latest)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Ubuntu Boost (86)
  • GitHub Check: Ubuntu Boost (84)
  • GitHub Check: Ubuntu Boost (83)
  • GitHub Check: Ubuntu Boost (80)
  • GitHub Check: Ubuntu Boost (79)
  • GitHub Check: Ubuntu Boost (78)
  • GitHub Check: Ubuntu Boost (77)
  • GitHub Check: Ubuntu Boost (76)
  • GitHub Check: Ubuntu Boost (75)
  • GitHub Check: Ubuntu Boost (68)
  • GitHub Check: Ubuntu Boost (56)
  • GitHub Check: Ubuntu clang
  • GitHub Check: Check queries
🔇 Additional comments (9)
pgtap/dijkstra/driving_distance/inner_query.pg (2)

23-23: Double-check the test plan logic.
Using NOT min_version('3.6.0') AND min_lib_version('5.0.0') to run plan(1) may reduce the original test coverage (108 tests). If this change is intentional, please confirm the desired test scope.


40-40: Confirm the direct call of inner_query.
If this call is part of a planned test, it looks fine. Otherwise, ensure that you capture or log the return set from inner_query() for clarity.

pgtap/dijkstra/driving_distance/no_crash_test.pg (1)

23-23: Verify the number of tests executed.
As in inner_query.pg, the conditional logic changes the total test count from 34 to 1 under certain conditions. Confirm if this reduction in test coverage is intentional.

pgtap/dijkstra/driving_distance/edge_cases/issue_519.pg (2)

22-22: LGTM! Version check and test plan look good.

The version check condition correctly handles both PostgreSQL version and library version compatibility.


44-46: LGTM! Proper deprecation notice.

The code correctly handles the deprecated internal function by returning a skip message for version 5.0.0 and above.

src/driving_distance/driving_distance.c (2)

163-165: LGTM! Clear deprecation marking.

The code is properly marked for removal in v5 with clear TODO comment.


168-169: LGTM! Function declarations follow standard pattern.

The deprecated function declarations follow the standard pattern using PGDLLEXPORT and PG_FUNCTION_INFO_V1.

NEWS.md (1)

Line range hint 88-102: LGTM! Clear documentation of deprecated internal functions.

The list of deprecated internal functions is well-documented with complete signatures.

🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

50-50: Emphasis used instead of a heading
null

(MD036, no-emphasis-as-heading)


57-57: Emphasis used instead of a heading
null

(MD036, no-emphasis-as-heading)


73-73: Emphasis used instead of a heading
null

(MD036, no-emphasis-as-heading)

doc/src/release_notes.rst (1)

Line range hint 106-110: Fix inconsistent backtick usage.

Some function signatures have trailing backticks while others don't.

Comment on lines +26 to +38
CREATE OR REPLACE FUNCTION inner_query() RETURNS SETOF TEXT AS
$BODY$
BEGIN
IF NOT min_version('3.6.0') AND min_lib_version('5.0.0') THEN
RETURN NEXT skip(1, 'Internal function deprecated on 3.6.0 and removed on 5.0.0');
RETURN;
END IF;

RETURN QUERY SELECT style_dijkstra('pgr_drivingdistance(', ',2, 1, true)');
RETURN QUERY SELECT style_dijkstra('pgr_drivingdistance(', ',ARRAY[2,3], 1, true)');
END;
$BODY$
LANGUAGE plpgsql;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

Consider refactoring the conditional logic for clarity.
The nested usage of NOT min_version('3.6.0') AND min_lib_version('5.0.0') can be a bit confusing. You might consider inverting or rewording the condition (e.g., ELSIF structure) for better readability.

Comment on lines +32 to +62
SELECT CASE
WHEN (min_version('3.6.0')) THEN
collect_tap(
set_eq(
$$SELECT proargnames from pg_proc where proname = 'pgr_drivingdistance'$$,
$$VALUES
('{"","","","directed","seq","depth","start_vid","pred","node","edge","cost","agg_cost"}'::TEXT[]),
('{"","","","directed","equicost","seq","depth","start_vid","pred","node","edge","cost","agg_cost"}'::TEXT[])
$$),

IF (min_version('3.6.0')) THEN
RETURN QUERY
SELECT set_eq(
$$SELECT proargnames from pg_proc where proname = 'pgr_drivingdistance'$$,
$$VALUES
('{"","","","directed","seq","depth","start_vid","pred","node","edge","cost","agg_cost"}'::TEXT[]),
('{"","","","directed","equicost","seq","depth","start_vid","pred","node","edge","cost","agg_cost"}'::TEXT[])
$$);
set_eq(
$$SELECT proallargtypes from pg_proc where proname = 'pgr_drivingdistance'$$,
$$VALUES
('{25,20,701,16,20,20,20,20,20,20,701,701}'::OID[]),
('{25,2277,701,16,16,20,20,20,20,20,20,701,701}'::OID[])
$$))
ELSE
collect_tap(
set_eq(
$$SELECT proargnames from pg_proc where proname = 'pgr_drivingdistance'$$,
$$VALUES
('{"","","","directed","seq","node","edge","cost","agg_cost"}'::TEXT[]),
('{"","","","directed","equicost","seq","from_v","node","edge","cost","agg_cost"}'::TEXT[])
$$),

RETURN QUERY
SELECT set_eq(
$$SELECT proallargtypes from pg_proc where proname = 'pgr_drivingdistance'$$,
$$VALUES
('{25,20,701,16,20,20,20,20,20,20,701,701}'::OID[]),
('{25,2277,701,16,16,20,20,20,20,20,20,701,701}'::OID[])
$$);
ELSE
-- old signatures
RETURN QUERY
SELECT set_eq(
$$SELECT proargnames from pg_proc where proname = 'pgr_drivingdistance'$$,
$$VALUES
('{"","","","directed","seq","node","edge","cost","agg_cost"}'::TEXT[]),
('{"","","","directed","equicost","seq","from_v","node","edge","cost","agg_cost"}'::TEXT[])
$$);

RETURN QUERY
SELECT set_eq(
$$SELECT proallargtypes from pg_proc where proname = 'pgr_drivingdistance'$$,
$$VALUES
('{25,20,701,16,23,20,20,701,701}'::OID[]),
('{25,2277,701,16,16,23,20,20,20,701,701}'::OID[])
$$);
END IF;
set_eq(
$$SELECT proallargtypes from pg_proc where proname = 'pgr_drivingdistance'$$,
$$VALUES
('{25,20,701,16,23,20,20,701,701}'::OID[]),
('{25,2277,701,16,16,23,20,20,20,701,701}'::OID[])
$$))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

Unify version checks with other files for consistency.
Here, the condition uses min_version('3.6.0') directly, while other files use a more complex compound check. Adopting a similar pattern throughout might enhance maintainability and readability.

Comment on lines +42 to +45
IF NOT min_version('3.6.0') AND min_lib_version('5.0.0') THEN
RETURN NEXT skip(1, 'Internal function deprecated on 3.6.0 and removed on 5.0.0');
RETURN;
END IF;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

Use an ELSIF block for more direct readability.
The condition to skip tests if the function is deprecated is correct, but inverting or restructuring the condition could make the code flow clearer.

Comment on lines +179 to +183
ereport(NOTICE, (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("A stored procedure is using deprecated C internal function '%s'", __func__),
errdetail("Library function '%s' was deprecated in pgRouting %s", __func__, "3.6.0"),
errhint("Consider upgrade pgRouting")));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

Consider using a macro for deprecation notices.

The deprecation notice is hardcoded. Consider creating a macro for consistent deprecation messages across the codebase.

+#define DEPRECATED_IN_5_0(func) \
+  ereport(NOTICE, ( \
+    errcode(ERRCODE_FEATURE_NOT_SUPPORTED), \
+    errmsg("A stored procedure is using deprecated C internal function '%s'", func), \
+    errdetail("Library function '%s' was deprecated in pgRouting %s", func, "3.6.0"), \
+    errhint("Consider upgrade pgRouting")))

 PGDLLEXPORT Datum
 _pgr_drivingdistance(PG_FUNCTION_ARGS) {
-    ereport(NOTICE, (
-            errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
-            errmsg("A stored procedure is using deprecated C internal function '%s'", __func__),
-            errdetail("Library function '%s' was deprecated in pgRouting %s", __func__, "3.6.0"),
-            errhint("Consider upgrade pgRouting")));
+    DEPRECATED_IN_5_0(__func__);

Committable suggestion skipped: line range outside the PR's diff.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant