1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
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));
|