mirror of
https://github.com/timescale/timescaledb.git
synced 2025-05-15 10:11:29 +08:00
Block c function definitions in latest-dev.sql
Having c function references in the versioned part of the sql scripts introduces linking requirements to the update script potentially preventing version updates. To prevent this we can have a dummy function in latest-dev.sql since it will get over- written as the final step of the extension update.
This commit is contained in:
parent
1a8318633b
commit
b8d958cb9e
2
.github/workflows/catalog-updates-check.yaml
vendored
2
.github/workflows/catalog-updates-check.yaml
vendored
@ -20,7 +20,7 @@ jobs:
|
||||
|
||||
- name: Check latest-dev contents
|
||||
run: |
|
||||
python scripts/check_updates_ast.py "sql/updates/latest-dev.sql"
|
||||
python scripts/check_updates_ast.py --latest "sql/updates/latest-dev.sql"
|
||||
|
||||
# To allow fixing previous mistakes we run the check against reverse-dev but don't
|
||||
# fail it on errors.
|
||||
|
@ -4,6 +4,12 @@ from pglast.visitors import Visitor
|
||||
from pglast import enums
|
||||
import sys
|
||||
import re
|
||||
import argparse
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("filename")
|
||||
parser.add_argument("--latest", action="store_true", help="process latest-dev.sql")
|
||||
args = parser.parse_args()
|
||||
|
||||
|
||||
class SQLVisitor(Visitor):
|
||||
@ -145,6 +151,17 @@ class SQLVisitor(Visitor):
|
||||
def visit_CreateFunctionStmt(
|
||||
self, ancestors, node
|
||||
): # pylint: disable=unused-argument
|
||||
if args.latest:
|
||||
# C functions should only appear in actual function definition but not
|
||||
# in latest-dev.sql as that would introduce a dependency on the library.
|
||||
lang = [elem for elem in node.options if elem.defname == "language"]
|
||||
if lang and lang[0].arg.sval == "c":
|
||||
self.errors += 1
|
||||
functype = "procedure" if node.is_procedure else "function"
|
||||
print(
|
||||
f"ERROR: Attempting to create {functype} {node.funcname[1].sval} with language 'c'"
|
||||
)
|
||||
|
||||
if len(node.funcname) == 2 and node.funcname[0].sval == "_timescaledb_internal":
|
||||
self.errors += 1
|
||||
functype = "procedure" if node.is_procedure else "function"
|
||||
@ -173,8 +190,9 @@ def visit_sql(sql):
|
||||
return visitor.errors
|
||||
|
||||
|
||||
def main():
|
||||
file = sys.argv[1]
|
||||
def main(args):
|
||||
file = args.filename
|
||||
|
||||
with open(file, "r", encoding="utf-8") as f:
|
||||
sql = f.read()
|
||||
errors = visit_sql(sql)
|
||||
@ -186,5 +204,5 @@ def main():
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
main(args)
|
||||
sys.exit(0)
|
||||
|
@ -8,7 +8,7 @@ CREATE FUNCTION @extschema@.enable_column_stats(
|
||||
column_name NAME,
|
||||
if_not_exists BOOLEAN = FALSE
|
||||
) RETURNS TABLE(column_stats_id INT, enabled BOOL)
|
||||
AS '@MODULE_PATHNAME@', 'ts_chunk_column_stats_enable' LANGUAGE C VOLATILE;
|
||||
AS 'SELECT NULL,NULL' LANGUAGE SQL VOLATILE SET search_path = pg_catalog, pg_temp;
|
||||
|
||||
-- Disable tracking of statistics on a column of a hypertable.
|
||||
--
|
||||
@ -21,7 +21,7 @@ CREATE FUNCTION @extschema@.disable_column_stats(
|
||||
column_name NAME,
|
||||
if_not_exists BOOLEAN = FALSE
|
||||
) RETURNS TABLE(hypertable_id INT, column_name NAME, disabled BOOL)
|
||||
AS '@MODULE_PATHNAME@', 'ts_chunk_column_stats_disable' LANGUAGE C VOLATILE;
|
||||
AS 'SELECT NULL,NULL,NULL' LANGUAGE SQL VOLATILE SET search_path = pg_catalog, pg_temp;
|
||||
|
||||
-- Track statistics for columns of chunks from a hypertable.
|
||||
-- Currently, we track the min/max range for a given column across chunks.
|
||||
|
Loading…
x
Reference in New Issue
Block a user