1
0
mirror of https://git.FreeBSD.org/ports.git synced 2024-12-04 01:48:54 +00:00

databases/postgresql-plruby: Unbreak build with PostgreSQL 11

============================================================
PostgreSQL 11.4
 is unsupported.  Try plruby-0.4.2.
============================================================
*** Error code 1

http://package18.nyi.freebsd.org/data/120amd64-default-PR239514/2019-07-29_20h41m52s/logs/postgresql-plruby-0.5.7_4.log

While here deprecate it since it seems to have been abandoned in
2010.

PR:		239639
Approved by:	knu (maintainer timeout, 2 weeks)
This commit is contained in:
Tobias Kortkamp 2019-08-18 13:23:40 +00:00
parent c050c5d5e0
commit ebfce89036
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=509207
4 changed files with 231 additions and 2 deletions

View File

@ -13,6 +13,8 @@ COMMENT= PL/Ruby procedural language for the PostgreSQL database system
LICENSE= BSD2CLAUSE RUBY
LICENSE_COMB= dual
DEPRECATED= Abandonware
EXPIRATION_DATE= 2019-09-15
BROKEN_powerpc64= fails to build: ruby.h:628:35: call to 'ruby_safe_level_2_error' declared with attribute error: $SAFE=2 to 4 are obsolete
USES= uidfix pgsql

View File

@ -1,9 +1,11 @@
--- extconf.rb.orig 2017-08-31 10:56:23 UTC
--- extconf.rb.orig 2017-05-28 08:47:01 UTC
+++ extconf.rb
@@ -122,6 +122,8 @@ end
@@ -122,6 +122,10 @@ end
case version_str = `#{pg_config} --version`
when /^PostgreSQL ([7-9])\.([0-9]{1,3})(\.[0-9]{1,3})?$/
version = 10 * $1.to_i + $2.to_i
+when /^PostgreSQL 11/
+ version = 110
+when /^PostgreSQL 10/
+ version = 100
else

View File

@ -0,0 +1,151 @@
--- src/plpl.c.orig 2019-08-04 04:35:14 UTC
+++ src/plpl.c
@@ -137,12 +137,21 @@ pl_query_name(VALUE obj)
}
res = rb_ary_new2(tpl->dsc->natts);
for (i = 0; i < tpl->dsc->natts; i++) {
+#if PG_VERSION_NUM < 110000
if (tpl->dsc->attrs[i]->attisdropped) {
attname = "";
}
else {
attname = NameStr(tpl->dsc->attrs[i]->attname);
}
+#else
+ if (TupleDescAttr(tpl->dsc, i)->attisdropped) {
+ attname = "";
+ }
+ else {
+ attname = NameStr(TupleDescAttr(tpl->dsc, i)->attname);
+ }
+#endif
rb_ary_push(res, rb_tainted_str_new2(attname));
}
return res;
@@ -178,6 +187,7 @@ pl_query_type(VALUE obj)
}
res = rb_ary_new2(tpl->dsc->natts);
for (i = 0; i < tpl->dsc->natts; i++) {
+#if PG_VERSION_NUM < 110000
if (tpl->dsc->attrs[i]->attisdropped)
continue;
PLRUBY_BEGIN(1);
@@ -189,6 +199,19 @@ pl_query_type(VALUE obj)
rb_raise(pl_ePLruby, "Cache lookup for attribute '%s' type %ld failed",
attname, OidGD(tpl->dsc->attrs[i]->atttypid));
}
+#else
+ if (TupleDescAttr(tpl->dsc, i)->attisdropped)
+ continue;
+ PLRUBY_BEGIN(1);
+ attname = NameStr(TupleDescAttr(tpl->dsc, i)->attname);
+ typeTup = SearchSysCache(TYPEOID, OidGD(TupleDescAttr(tpl->dsc, i)->atttypid),
+ 0, 0, 0);
+ PLRUBY_END;
+ if (!HeapTupleIsValid(typeTup)) {
+ rb_raise(pl_ePLruby, "Cache lookup for attribute '%s' type %ld failed",
+ attname, OidGD(TupleDescAttr(tpl->dsc, i)->atttypid));
+ }
+#endif
fpgt = (Form_pg_type) GETSTRUCT(typeTup);
rb_ary_push(res, rb_tainted_str_new2(NameStr(fpgt->typname)));
ReleaseSysCache(typeTup);
@@ -588,14 +611,23 @@ pl_tuple_heap(VALUE c, VALUE tuple)
MEMZERO(nulls, char, RARRAY_LEN(c));
for (i = 0; i < RARRAY_LEN(c); i++) {
if (NIL_P(RARRAY_PTR(c)[i]) ||
+#if PG_VERSION_NUM < 110000
tupdesc->attrs[i]->attisdropped) {
+#else
+ TupleDescAttr(tupdesc, i)->attisdropped) {
+#endif
dvalues[i] = (Datum)0;
nulls[i] = 'n';
}
else {
nulls[i] = ' ';
+#if PG_VERSION_NUM < 110000
typid = tupdesc->attrs[i]->atttypid;
if (tupdesc->attrs[i]->attndims != 0 ||
+#else
+ typid = TupleDescAttr(tupdesc, i)->atttypid;
+ if (TupleDescAttr(tupdesc, i)->attndims != 0 ||
+#endif
tpl->att->attinfuncs[i].fn_addr == (PGFunction)array_in) {
pl_proc_desc prodesc;
FmgrInfo func;
@@ -1088,6 +1120,7 @@ plruby_build_tuple(HeapTuple tuple, TupleDesc tupdesc,
}
for (i = 0; i < tupdesc->natts; i++) {
+#if PG_VERSION_NUM < 110000
if (tupdesc->attrs[i]->attisdropped)
continue;
PLRUBY_BEGIN(1);
@@ -1101,7 +1134,21 @@ plruby_build_tuple(HeapTuple tuple, TupleDesc tupdesc,
rb_raise(pl_ePLruby, "Cache lookup for attribute '%s' type %ld failed",
attname, OidGD(tupdesc->attrs[i]->atttypid));
}
+#else
+ if (TupleDescAttr(tupdesc, i)->attisdropped)
+ continue;
+ PLRUBY_BEGIN(1);
+ attname = NameStr(TupleDescAttr(tupdesc, i)->attname);
+ attr = heap_getattr(tuple, i + 1, tupdesc, &isnull);
+ typeTup = SearchSysCache(TYPEOID, OidGD(TupleDescAttr(tupdesc, i)->atttypid),
+ 0, 0, 0);
+ PLRUBY_END;
+ if (!HeapTupleIsValid(typeTup)) {
+ rb_raise(pl_ePLruby, "Cache lookup for attribute '%s' type %ld failed",
+ attname, OidGD(TupleDescAttr(tupdesc, i)->atttypid));
+ }
+#endif
fpgt = (Form_pg_type) GETSTRUCT(typeTup);
typoutput = (Oid) (fpgt->typoutput);
#if PG_PL_VERSION >= 75
@@ -1115,6 +1162,7 @@ plruby_build_tuple(HeapTuple tuple, TupleDesc tupdesc,
int alen;
typname = NameStr(fpgt->typname);
+#if PG_VERSION_NUM < 110000
alen = tupdesc->attrs[i]->attlen;
typeid = tupdesc->attrs[i]->atttypid;
if (strcmp(typname, "text") == 0) {
@@ -1129,6 +1177,22 @@ plruby_build_tuple(HeapTuple tuple, TupleDesc tupdesc,
alen = tupdesc->attrs[i]->atttypmod - 4;
}
}
+#else
+ alen = TupleDescAttr(tupdesc, i)->attlen;
+ typeid = TupleDescAttr(tupdesc, i)->atttypid;
+ if (strcmp(typname, "text") == 0) {
+ alen = -1;
+ }
+ else if (strcmp(typname, "bpchar") == 0 ||
+ strcmp(typname, "varchar") == 0) {
+ if (TupleDescAttr(tupdesc, i)->atttypmod == -1) {
+ alen = 0;
+ }
+ else {
+ alen = TupleDescAttr(tupdesc, i)->atttypmod - 4;
+ }
+ }
+#endif
if ((type_ret & RET_DESC_ARR) == RET_DESC_ARR) {
res = rb_ary_new();
rb_ary_push(res, rb_tainted_str_new2(attname));
@@ -1190,8 +1254,13 @@ plruby_build_tuple(HeapTuple tuple, TupleDesc tupdesc,
fmgr_info(typoutput, &finfo);
+#if PG_VERSION_NUM < 110000
s = pl_convert_arg(attr, tupdesc->attrs[i]->atttypid,
&finfo, typelem,tupdesc->attrs[i]->attlen);
+#else
+ s = pl_convert_arg(attr, tupdesc->attrs[i].atttypid,
+ &finfo, typelem, TupleDescAttr(tupdesc, i)->attlen);
+#endif
}
PLRUBY_END_PROTECT;

View File

@ -0,0 +1,74 @@
--- src/plruby.c.orig 2019-08-04 04:30:44 UTC
+++ src/plruby.c
@@ -1184,17 +1184,29 @@ for_numvals(obj, argobj)
rb_raise(pl_ePLruby, "invalid attribute '%s'", RSTRING_PTR(key));
}
attnum -= 1;
+#if PG_VERSION_NUM < 110000
if (arg->tupdesc->attrs[attnum]->attisdropped) {
+#else
+ if (TupleDescAttr(arg->tupdesc, attnum)->attisdropped) {
+#endif
return Qnil;
}
PLRUBY_BEGIN(1);
typeTup = SearchSysCache(TYPEOID,
+#if PG_VERSION_NUM < 110000
OidGD(arg->tupdesc->attrs[attnum]->atttypid),
+#else
+ OidGD(TupleDescAttr(arg->tupdesc, attnum)->atttypid),
+#endif
0, 0, 0);
if (!HeapTupleIsValid(typeTup)) {
rb_raise(pl_ePLruby, "Cache lookup for attribute '%s' type %ld failed",
+#if PG_VERSION_NUM < 110000
RSTRING_PTR(key), OidGD(arg->tupdesc->attrs[attnum]->atttypid));
+#else
+ RSTRING_PTR(key), OidGD(TupleDescAttr(arg->tupdesc, attnum)->atttypid));
+#endif
}
fpg = (Form_pg_type) GETSTRUCT(typeTup);
ReleaseSysCache(typeTup);
@@ -1226,11 +1238,19 @@ for_numvals(obj, argobj)
else {
arg->modvalues[attnum] =
plruby_to_datum(value, &finfo,
+#if PG_VERSION_NUM < 110000
arg->tupdesc->attrs[attnum]->atttypid,
fpg->typelem,
(!VARLENA_FIXED_SIZE(arg->tupdesc->attrs[attnum]))
? arg->tupdesc->attrs[attnum]->attlen
: arg->tupdesc->attrs[attnum]->atttypmod);
+#else
+ TupleDescAttr(arg->tupdesc, attnum)->atttypid,
+ fpg->typelem,
+ (!VARLENA_FIXED_SIZE(TupleDescAttr(arg->tupdesc, attnum)))
+ ? TupleDescAttr(arg->tupdesc, attnum)->attlen
+ : TupleDescAttr(arg->tupdesc, attnum)->atttypmod);
+#endif
}
return Qnil;
}
@@ -1284,12 +1304,21 @@ pl_trigger_handler(struct pl_thread_st *plth)
tmp = rb_ary_new2(tupdesc->natts);
for (i = 0; i < tupdesc->natts; i++) {
+#if PG_VERSION_NUM < 110000
if (tupdesc->attrs[i]->attisdropped) {
rb_ary_push(tmp, rb_str_freeze_new2(""));
}
else {
rb_ary_push(tmp, rb_str_freeze_new2(NameStr(tupdesc->attrs[i]->attname)));
}
+#else
+ if (TupleDescAttr(tupdesc, i)->attisdropped) {
+ rb_ary_push(tmp, rb_str_freeze_new2(""));
+ }
+ else {
+ rb_ary_push(tmp, rb_str_freeze_new2(NameStr(TupleDescAttr(tupdesc, i)->attname)));
+ }
+#endif
}
rb_hash_aset(TG, rb_str_freeze_new2("relatts"), rb_ary_freeze(tmp));