Skip to content

Commit

Permalink
support create or replace procedure
Browse files Browse the repository at this point in the history
  • Loading branch information
TCeason committed Sep 24, 2024
1 parent 06dc1c6 commit a6c4a2a
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/query/management/src/procedure/procedure_mgr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,16 @@ impl ProcedureMgr {
procedure_id: *existent.data,
}),
CreateOption::CreateOrReplace => {
unreachable!(
"create_procedure: CreateOrReplace should never conflict with existent"
);
let res = self
.kv_api
.update_id_value(name_ident, meta.clone())
.await?;

if let Some((id, _meta)) = res {
Ok(CreateProcedureReply { procedure_id: *id })
} else {
Err(AppError::from(name_ident.unknown_error(func_name!())).into())
}
}
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,23 @@ call procedure p1();
----
2

statement ok
CREATE or replace PROCEDURE p1() RETURNS int not null LANGUAGE SQL COMMENT='test' AS $$
BEGIN
LET x := -1;
LET sum := 10;
FOR x IN x TO x + 3 DO
sum := sum + x;
END FOR;
RETURN sum;
END;
$$;

query T
call procedure p1();
----
12

statement ok
CREATE PROCEDURE p1(x UInt8, sum UInt8) RETURNS int not null LANGUAGE SQL COMMENT='test' AS $$
BEGIN
Expand All @@ -45,6 +62,18 @@ BEGIN
END;
$$;

statement ok
CREATE OR REPLACE PROCEDURE p1() RETURNS int not null LANGUAGE SQL COMMENT='test' AS $$
BEGIN
LET x := -1;
LET sum := 0;
FOR x IN x TO x + 3 DO
sum := sum + x;
END FOR;
RETURN sum;
END;
$$;

query T
call procedure p1();
----
Expand Down

0 comments on commit a6c4a2a

Please sign in to comment.