Skip to content
This repository has been archived by the owner on Dec 5, 2023. It is now read-only.

Commit

Permalink
Fix code cache to make CREATE OR REPLACE FUNCTION to work.
Browse files Browse the repository at this point in the history
  • Loading branch information
ItGacky committed Aug 28, 2010
1 parent 2c2f9b2 commit 3a5cfa4
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
15 changes: 15 additions & 0 deletions expected/plv8.out
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,21 @@ CREATE FUNCTION test_sql_error() RETURNS void AS $$ executeSql("ERROR") $$ LANGU
SELECT test_sql_error();
ERROR: syntax error at or near "ERROR"
DETAIL: test_sql_error() LINE 1: executeSql("ERROR")
-- REPLACE FUNCTION
CREATE FUNCTION replace_test() RETURNS integer AS $$ return 1; $$ LANGUAGE plv8;
SELECT replace_test();
replace_test
--------------
1
(1 row)

CREATE OR REPLACE FUNCTION replace_test() RETURNS integer AS $$ return 2; $$ LANGUAGE plv8;
SELECT replace_test();
replace_test
--------------
2
(1 row)

-- TRIGGER
CREATE FUNCTION test_trigger() RETURNS trigger AS
$$
Expand Down
3 changes: 3 additions & 0 deletions plv8.cc
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,7 @@ plv8_get_proc_cache(Oid fn_oid, bool validate, char ***argnames) throw()
proc->prosrc = NULL;
}
proc->function.Dispose();
proc->function.Clear();
}
else
{
Expand All @@ -485,6 +486,8 @@ plv8_get_proc_cache(Oid fn_oid, bool validate, char ***argnames) throw()
proc->prosrc = NULL;
}

Assert(proc->function.IsEmpty());

procStruct = (Form_pg_proc) GETSTRUCT(procTup);

prosrc = SysCacheGetAttr(PROCOID, procTup, Anum_pg_proc_prosrc, &isnull);
Expand Down
6 changes: 6 additions & 0 deletions sql/plv8.sql
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,12 @@ SELECT * FROM return_sql();
CREATE FUNCTION test_sql_error() RETURNS void AS $$ executeSql("ERROR") $$ LANGUAGE plv8;
SELECT test_sql_error();

-- REPLACE FUNCTION
CREATE FUNCTION replace_test() RETURNS integer AS $$ return 1; $$ LANGUAGE plv8;
SELECT replace_test();
CREATE OR REPLACE FUNCTION replace_test() RETURNS integer AS $$ return 2; $$ LANGUAGE plv8;
SELECT replace_test();

-- TRIGGER
CREATE FUNCTION test_trigger() RETURNS trigger AS
$$
Expand Down

0 comments on commit 3a5cfa4

Please sign in to comment.