You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
T-SQL: a CREATE FUNCTION swallows the declaration that follows it — the next CREATE VIEW is silently absent #2719
A CREATE FUNCTION consumes the declaration that follows it. The function itself is extracted; the next statement is not. Swapping the function for a procedure — same file, same following statement — extracts all three.
Found while isolating a separate bracket-quoting defect; this one is independent of quoting and reproduces with bare identifiers.
Repro
A — function, then view.schema.sql:
CREATETABLEdbo.Customer (Id INTNOT NULLPRIMARY KEY);
GO
CREATEFUNCTIONdbo.CustomerName (@Id INT)
RETURNS INTASBEGIN
RETURN (SELECT Id FROMdbo.CustomerWHERE Id = @Id);
END
GO
CREATEVIEWdbo.CustomerList
ASSELECT Id FROMdbo.Customer;
GO
graphify . --code-only
Actual — 3 nodes: schema.sql, dbo.Customer, dbo.CustomerName(). No dbo.CustomerList.
B — procedure, then the same view. Replace the function with:
CREATE PROCEDURE dbo.GetCustomer @Id INTASBEGINSELECT Id FROMdbo.CustomerWHERE Id = @Id;
END
GO
Actual — 4 nodes: schema.sql, dbo.Customer, dbo.GetCustomer(), dbo.CustomerList. The view is back.
C — the view alone, with no callable before it, also yields all three nodes. So CREATE VIEW is extracted normally; it is the preceding CREATE FUNCTION that loses it.
Notes
Both GO separators are present in every variant, so it is not a missing batch terminator.
Only the immediately following declaration is affected in these cases; I have not tested how far the swallow extends in longer files, and the effect is easy to miss in a large corpus because the lost declaration produces no warning — the build exits 0 and the graph simply omits it.
The practical consequence is that whether a declaration appears in the graph depends on what precedes it, which makes a node's absence hard to attribute to anything.
Activity
Merge upstream v8 into fix-2719-create-function-swallows-next
Recover a CREATE VIEW/TABLE swallowed by a preceding broken routine
Merge upstream v8 into fix 2719 create function swallows next