Skip to content

How to write sql files

Vicky Vergara edited this page Oct 7, 2022 · 1 revision

_pgr_foo.sql file

The structure of the file

  • License
  • Version comment
  • Function(s)
  • Function(s) comment

Version comment

The line before the function must contain the version when

  • was created
  • was last changed logically

Function(s)

  • Use CREATE function
    • Do not use CREATE OR REPLACE function

function(s) comment

  • For each underscored function the comment is 'pgRouting internal function'
  • Don't forget the parameters on the commented function match the IN parameters of the function.

Example:

COMMENT ON FUNCTION _pgr_foo(TEXT)
IS 'pgRouting internal function';

Optional:

/*PGR-GNU*****************************************************************
File: _pgr_foo.sql

Copyright (c) <year> pgRouting developers
Mail: project@pgrouting.org

Function's developer:
Copyright (c) <year> <developer name>
Mail: <developer mail>

------


 ********************************************************************PGR-GNU*/

--v3.4.0
CREATE FUNCTION _pgr_foo(
    TEXT,
    OUT seq BIGINT,
    OUT node BIGINT
    )

RETURNS SETOF RECORD AS
'MODULE_PATHNAME'
LANGUAGE C IMMUTABLE STRICT;

-- COMMENTS
COMMENT ON FUNCTION _pgr_foo(TEXT)
IS 'pgRouting internal function';
Clone this wiki locally