aboutsummaryrefslogtreecommitdiffstats
path: root/main
diff options
context:
space:
mode:
authorJakub Jirutka <jakub@jirutka.cz>2017-11-04 23:39:13 +0100
committerJakub Jirutka <jakub@jirutka.cz>2017-11-04 23:39:27 +0100
commitb9d5d37b25be42c7d8023b584caab511f800df13 (patch)
tree396a9b7221d567876a10f6d8e83f38c7199ce13a /main
parentef609351a6b52c7edab28bd0b549e1170fbf1723 (diff)
downloadaports-b9d5d37b25be42c7d8023b584caab511f800df13.tar.bz2
aports-b9d5d37b25be42c7d8023b584caab511f800df13.tar.xz
main/pllua: add missing patches
Diffstat (limited to 'main')
-rw-r--r--main/pllua/fix-on-32bit.patch33
-rw-r--r--main/pllua/fix-postgres10.patch209
2 files changed, 242 insertions, 0 deletions
diff --git a/main/pllua/fix-on-32bit.patch b/main/pllua/fix-on-32bit.patch
new file mode 100644
index 0000000000..fda3f78052
--- /dev/null
+++ b/main/pllua/fix-on-32bit.patch
@@ -0,0 +1,33 @@
+From 904a53bcc696a683f4a114d05400e5315e0ae70d Mon Sep 17 00:00:00 2001
+From: eugwne <eugeney.sergeev@gmail.com>
+Date: Mon, 10 Jul 2017 19:51:01 +0300
+Subject: [PATCH] 64 lua -> pg 32bit system
+
+Patch-Source: https://github.com/pllua/pllua/commit/904a53bcc696a683f4a114d05400e5315e0ae70d
+---
+ plluaapi.c | 10 ++++++++++
+ 1 file changed, 10 insertions(+)
+
+diff --git a/plluaapi.c b/plluaapi.c
+index f47a3b9..d0a1b4d 100644
+--- a/plluaapi.c
++++ b/plluaapi.c
+@@ -1095,8 +1095,18 @@ Datum luaP_todatum (lua_State *L, Oid type, int typmod, bool *isnull, int idx) {
+ dat = Int32GetDatum(lua_tointeger(L, idx));
+ break;
+ case INT8OID:
++#ifdef USE_FLOAT8_BYVAL
+ dat = Int64GetDatum(get64lua(L, idx));
+ break;
++#else
++ {
++ int64* value = (int64*)SPI_palloc(sizeof(int64));
++ *value = get64lua(L, idx);
++ dat = PointerGetDatum(value);
++ break;
++ }
++#endif
++
+ case TEXTOID: {
+ const char *s = lua_tostring(L, idx);
+ if (s == NULL) elog(ERROR,
diff --git a/main/pllua/fix-postgres10.patch b/main/pllua/fix-postgres10.patch
new file mode 100644
index 0000000000..c77c00f65c
--- /dev/null
+++ b/main/pllua/fix-postgres10.patch
@@ -0,0 +1,209 @@
+From 3fcf91f71b8a8a6ceb46b59b132ed8d7cc81eb63 Mon Sep 17 00:00:00 2001
+From: eugwne <eugeney.sergeev@gmail.com>
+Date: Mon, 2 Oct 2017 20:13:36 +0300
+Subject: [PATCH] text pgtype to oid
+
+Patch-Source: https://github.com/pllua/pllua/commit/3fcf91f71b8a8a6ceb46b59b132ed8d7cc81eb63
+
+diff --git a/expected/error_info.out b/expected/error_info.out
+index f29edb0..32be0fa 100644
+--- a/expected/error_info.out
++++ b/expected/error_info.out
+@@ -117,3 +117,10 @@ CONTEXT:
+ stack traceback(trusted):
+ [C]: in function 'error'
+ [string "anonymous"]:2: in main chunk
++do $$
++local status, err = subtransaction(function() local _ = fromstring('no_type_text','qwerty') end)
++if (err) then
++ print(err)
++end
++$$ language pllua
++INFO: type "no_type_text" does not exist
+diff --git a/expected/pgfunctest.out b/expected/pgfunctest.out
+index 81a225e..fc058c4 100644
+--- a/expected/pgfunctest.out
++++ b/expected/pgfunctest.out
+@@ -52,14 +52,12 @@ begin
+ raise exception '%', $1;
+ end
+ $$ language plpgsql;
++\set VERBOSITY 'terse'
+ do $$
+ pgfunc('pg_temp.throw_error(text)',{only_internal=false})("exception test")
+ $$ language pllua;
+ ERROR: exception test
+-CONTEXT:
+-stack traceback(trusted):
+- [C]: ?
+- [string "anonymous"]:2: in main chunk
++\set VERBOSITY 'default'
+ do $$
+ local f = pgfunc('pg_temp.throw_error(text)',{only_internal=false})
+ print(pcall(f, "exception test"))
+diff --git a/pllua.c b/pllua.c
+index 4ef2f3b..2139eb3 100644
+--- a/pllua.c
++++ b/pllua.c
+@@ -150,7 +150,7 @@ void luaL_setfuncs(lua_State *L, const luaL_Reg *l, int nup) {
+ }
+ #endif
+
+-int pg_to_regtype(char *typ_name)
++Oid pg_to_regtype(const char *typ_name)
+ {
+
+ Oid result;
+@@ -161,14 +161,17 @@ int pg_to_regtype(char *typ_name)
+ */
+
+ #if PG_VERSION_NUM < 90400
+- parseTypeString(typ_name, &result, &typmod);
++ PG_TRY();
++ {
++ parseTypeString(typ_name, &result, &typmod);
++ }
++ PG_CATCH();
++ {
++ result = InvalidOid;
++ }
++ PG_END_TRY();
+ #else
+- parseTypeString(typ_name, &result, &typmod, true);
++ parseTypeString(typ_name, &result, &typmod, true);
+ #endif
+-
+-
+- if (OidIsValid(result))
+- return result;
+- else
+- return -1;
++ return result;
+ }
+diff --git a/pllua.h b/pllua.h
+index 0a9fe99..d8d5df6 100644
+--- a/pllua.h
++++ b/pllua.h
+@@ -40,7 +40,6 @@ void luaP_pushtuple_trg (lua_State *L, TupleDesc desc, HeapTuple tuple,
+ HeapTuple luaP_totuple (lua_State *L);
+ HeapTuple luaP_casttuple (lua_State *L, TupleDesc tupdesc);
+ /* SPI */
+-Oid luaP_gettypeoid (const char *type_name);
+ void luaP_pushdesctable(lua_State *L, TupleDesc desc);
+ void luaP_registerspi(lua_State *L);
+ void luaP_pushcursor (lua_State *L, Portal cursor);
+diff --git a/plluaapi.c b/plluaapi.c
+index d0a1b4d..adbe9e4 100644
+--- a/plluaapi.c
++++ b/plluaapi.c
+@@ -452,16 +452,22 @@ static int luaP_warning (lua_State *L) {
+ #undef PLLUA_REPORT
+
+ static int luaP_fromstring (lua_State *L) {
+- int oid = luaP_gettypeoid(luaL_checkstring(L, 1));
+- const char *s = luaL_checkstring(L, 2);
+- luaP_Typeinfo *ti = luaP_gettypeinfo(L, oid);
+- int inoid = oid;
+- Datum v;
+- /* from getTypeIOParam in lsyscache.c */
+- if (ti->type == TYPTYPE_BASE && OidIsValid(ti->elem)) inoid = ti->elem;
+- v = InputFunctionCall(&ti->input, (char *) s, inoid, 0); /* typmod = 0 */
+- luaP_pushdatum(L, v, oid);
+- return 1;
++ const char *type_name = luaL_checkstring(L, 1);
++ Oid oid = pg_to_regtype(type_name);
++ if (oid == InvalidOid) {
++ return luaL_error(L,"type \"%s\" does not exist",type_name);
++ } else {
++ const char *s = luaL_checkstring(L, 2);
++ luaP_Typeinfo *ti = luaP_gettypeinfo(L, oid);
++ Oid inoid = oid;
++ Datum v;
++
++ /* from getTypeIOParam in lsyscache.c */
++ if (ti->type == TYPTYPE_BASE && OidIsValid(ti->elem)) inoid = ti->elem;
++ v = InputFunctionCall(&ti->input, (char *) s, inoid, 0); /* typmod = 0 */
++ luaP_pushdatum(L, v, oid);
++ }
++ return 1;
+ }
+
+ #ifdef PLLUA_DEBUG
+diff --git a/plluacommon.h b/plluacommon.h
+index dc7a5fa..c2f9852 100644
+--- a/plluacommon.h
++++ b/plluacommon.h
+@@ -93,6 +93,6 @@ int pllua_getmaster_index(lua_State *L);
+ ___m = MemoryContextSwitchTo(___mcxt)
+
+ #define MTOPG MemoryContextSwitchTo(___m);}
+-int pg_to_regtype(char *typ_name);
++Oid pg_to_regtype(const char *typ_name);
+
+ #endif // PLLUACOMMON_H
+diff --git a/plluaspi.c b/plluaspi.c
+index c50d107..f87280f 100644
+--- a/plluaspi.c
++++ b/plluaspi.c
+@@ -958,21 +958,6 @@ static int luaP_rowsplan (lua_State *L) {
+
+
+ /* ======= SPI ======= */
+-
+-Oid luaP_gettypeoid (const char *type_name) {
+-#if PG_VERSION_NUM < 80300
+- List *namelist = stringToQualifiedNameList(type_name, NULL);
+- HeapTuple typetup = typenameType(NULL, makeTypeNameFromNameList(namelist));
+-#else
+- List *namelist = stringToQualifiedNameList(type_name);
+- HeapTuple typetup = typenameType(NULL, makeTypeNameFromNameList(namelist), NULL);
+-#endif
+- Oid typeoid = HeapTupleGetOid(typetup);
+- ReleaseSysCache(typetup);
+- list_free(namelist);
+- return typeoid;
+-}
+-
+ static int luaP_prepare (lua_State *L) {
+ int nargs, cursoropt;
+ const char *q = luaL_checkstring(L, 1);
+@@ -995,7 +980,7 @@ static int luaP_prepare (lua_State *L) {
+ int k = lua_tointeger(L, -2);
+ if (k > 0) {
+ const char *s = luaL_checkstring(L, -1);
+- Oid type = luaP_gettypeoid(s);
++ Oid type = pg_to_regtype(s);
+ if (type == InvalidOid)
+ return luaL_error(L, "invalid type to plan: %s", s);
+ p->type[k - 1] = type;
+diff --git a/sql/error_info.sql b/sql/error_info.sql
+index 3a8ed85..aef7e7c 100644
+--- a/sql/error_info.sql
++++ b/sql/error_info.sql
+@@ -71,3 +71,10 @@ do $$
+ error()
+ $$language pllua;
+
++do $$
++local status, err = subtransaction(function() local _ = fromstring('no_type_text','qwerty') end)
++if (err) then
++ print(err)
++end
++$$ language pllua
++
+diff --git a/sql/pgfunctest.sql b/sql/pgfunctest.sql
+index 40c5350..65eaf33 100644
+--- a/sql/pgfunctest.sql
++++ b/sql/pgfunctest.sql
+@@ -47,9 +47,11 @@ raise exception '%', $1;
+ end
+ $$ language plpgsql;
+
++\set VERBOSITY 'terse'
+ do $$
+ pgfunc('pg_temp.throw_error(text)',{only_internal=false})("exception test")
+ $$ language pllua;
++\set VERBOSITY 'default'
+
+ do $$
+ local f = pgfunc('pg_temp.throw_error(text)',{only_internal=false})