View | Details | Raw Unified | Return to bug 239639 | Differences between
and this patch

Collapse All | Expand All

(-)databases/postgresql-plruby/files/patch-extconf.rb (-2 / +4 lines)
Lines 1-9 Link Here
1
--- extconf.rb.orig	2017-08-31 10:56:23 UTC
1
--- extconf.rb.orig	2017-05-28 08:47:01 UTC
2
+++ extconf.rb
2
+++ extconf.rb
3
@@ -122,6 +122,8 @@ end
3
@@ -122,6 +122,10 @@ end
4
 case version_str = `#{pg_config} --version`
4
 case version_str = `#{pg_config} --version`
5
 when /^PostgreSQL ([7-9])\.([0-9]{1,3})(\.[0-9]{1,3})?$/
5
 when /^PostgreSQL ([7-9])\.([0-9]{1,3})(\.[0-9]{1,3})?$/
6
    version = 10 * $1.to_i + $2.to_i
6
    version = 10 * $1.to_i + $2.to_i
7
+when /^PostgreSQL 11/
8
+   version = 110
7
+when /^PostgreSQL 10/
9
+when /^PostgreSQL 10/
8
+   version = 100
10
+   version = 100
9
 else
11
 else
(-)databases/postgresql-plruby/files/patch-src_plpl.c (+151 lines)
Line 0 Link Here
1
--- src/plpl.c.orig	2019-08-04 04:35:14 UTC
2
+++ src/plpl.c
3
@@ -137,12 +137,21 @@ pl_query_name(VALUE obj)
4
     }
5
     res = rb_ary_new2(tpl->dsc->natts);
6
     for (i = 0; i < tpl->dsc->natts; i++) {
7
+#if PG_VERSION_NUM < 110000
8
         if (tpl->dsc->attrs[i]->attisdropped) {
9
             attname = "";
10
         }
11
         else {
12
             attname = NameStr(tpl->dsc->attrs[i]->attname);
13
         }
14
+#else
15
+        if (tpl->dsc->attrs[i].attisdropped) {
16
+            attname = "";
17
+        }
18
+        else {
19
+            attname = NameStr(tpl->dsc->attrs[i].attname);
20
+        }
21
+#endif
22
         rb_ary_push(res, rb_tainted_str_new2(attname));
23
     }
24
     return res;
25
@@ -178,6 +187,7 @@ pl_query_type(VALUE obj)
26
     }
27
     res = rb_ary_new2(tpl->dsc->natts);
28
     for (i = 0; i < tpl->dsc->natts; i++) {
29
+#if PG_VERSION_NUM < 110000
30
         if (tpl->dsc->attrs[i]->attisdropped)
31
             continue;
32
         PLRUBY_BEGIN(1);
33
@@ -189,6 +199,19 @@ pl_query_type(VALUE obj)
34
             rb_raise(pl_ePLruby, "Cache lookup for attribute '%s' type %ld failed",
35
                      attname, OidGD(tpl->dsc->attrs[i]->atttypid));
36
         }
37
+#else
38
+        if (tpl->dsc->attrs[i].attisdropped)
39
+            continue;
40
+        PLRUBY_BEGIN(1);
41
+        attname = NameStr(tpl->dsc->attrs[i].attname);
42
+        typeTup = SearchSysCache(TYPEOID, OidGD(tpl->dsc->attrs[i].atttypid),
43
+                                 0, 0, 0);
44
+        PLRUBY_END;
45
+        if (!HeapTupleIsValid(typeTup)) {
46
+            rb_raise(pl_ePLruby, "Cache lookup for attribute '%s' type %ld failed",
47
+                     attname, OidGD(tpl->dsc->attrs[i].atttypid));
48
+        }
49
+#endif
50
         fpgt = (Form_pg_type) GETSTRUCT(typeTup);
51
         rb_ary_push(res, rb_tainted_str_new2(NameStr(fpgt->typname)));
52
         ReleaseSysCache(typeTup);
53
@@ -588,14 +611,23 @@ pl_tuple_heap(VALUE c, VALUE tuple)
54
     MEMZERO(nulls, char, RARRAY_LEN(c));
55
     for (i = 0; i < RARRAY_LEN(c); i++) {
56
         if (NIL_P(RARRAY_PTR(c)[i]) || 
57
+#if PG_VERSION_NUM < 110000
58
             tupdesc->attrs[i]->attisdropped) {
59
+#else
60
+            tupdesc->attrs[i].attisdropped) {
61
+#endif
62
             dvalues[i] = (Datum)0;
63
             nulls[i] = 'n';
64
         }
65
         else {
66
             nulls[i] = ' ';
67
+#if PG_VERSION_NUM < 110000
68
             typid =  tupdesc->attrs[i]->atttypid;
69
             if (tupdesc->attrs[i]->attndims != 0 ||
70
+#else
71
+            typid =  tupdesc->attrs[i].atttypid;
72
+            if (tupdesc->attrs[i].attndims != 0 ||
73
+#endif
74
 		tpl->att->attinfuncs[i].fn_addr == (PGFunction)array_in) {
75
                 pl_proc_desc prodesc;
76
                 FmgrInfo func;
77
@@ -1088,6 +1120,7 @@ plruby_build_tuple(HeapTuple tuple, TupleDesc tupdesc,
78
     }
79
 
80
     for (i = 0; i < tupdesc->natts; i++) {
81
+#if PG_VERSION_NUM < 110000
82
         if (tupdesc->attrs[i]->attisdropped)
83
             continue;
84
         PLRUBY_BEGIN(1);
85
@@ -1101,7 +1134,21 @@ plruby_build_tuple(HeapTuple tuple, TupleDesc tupdesc,
86
             rb_raise(pl_ePLruby, "Cache lookup for attribute '%s' type %ld failed",
87
                      attname, OidGD(tupdesc->attrs[i]->atttypid));
88
         }
89
+#else
90
+        if (tupdesc->attrs[i].attisdropped)
91
+            continue;
92
+        PLRUBY_BEGIN(1);
93
+        attname = NameStr(tupdesc->attrs[i].attname);
94
+        attr = heap_getattr(tuple, i + 1, tupdesc, &isnull);
95
+        typeTup = SearchSysCache(TYPEOID, OidGD(tupdesc->attrs[i].atttypid),
96
+                                 0, 0, 0);
97
+        PLRUBY_END;
98
 
99
+        if (!HeapTupleIsValid(typeTup)) {
100
+            rb_raise(pl_ePLruby, "Cache lookup for attribute '%s' type %ld failed",
101
+                     attname, OidGD(tupdesc->attrs[i].atttypid));
102
+        }
103
+#endif
104
         fpgt = (Form_pg_type) GETSTRUCT(typeTup);
105
         typoutput = (Oid) (fpgt->typoutput);
106
 #if PG_PL_VERSION >= 75
107
@@ -1115,6 +1162,7 @@ plruby_build_tuple(HeapTuple tuple, TupleDesc tupdesc,
108
             int alen;
109
 
110
             typname = NameStr(fpgt->typname);
111
+#if PG_VERSION_NUM < 110000
112
             alen = tupdesc->attrs[i]->attlen;
113
             typeid = tupdesc->attrs[i]->atttypid;
114
             if (strcmp(typname, "text") == 0) {
115
@@ -1129,6 +1177,22 @@ plruby_build_tuple(HeapTuple tuple, TupleDesc tupdesc,
116
                     alen = tupdesc->attrs[i]->atttypmod - 4;
117
                 }
118
             }
119
+#else
120
+            alen = tupdesc->attrs[i].attlen;
121
+            typeid = tupdesc->attrs[i].atttypid;
122
+            if (strcmp(typname, "text") == 0) {
123
+                alen = -1;
124
+            }
125
+            else if (strcmp(typname, "bpchar") == 0 ||
126
+                     strcmp(typname, "varchar") == 0) {
127
+                if (tupdesc->attrs[i].atttypmod == -1) {
128
+                    alen = 0;
129
+                }
130
+                else {
131
+                    alen = tupdesc->attrs[i].atttypmod - 4;
132
+                }
133
+            }
134
+#endif
135
             if ((type_ret & RET_DESC_ARR) == RET_DESC_ARR) {
136
                 res = rb_ary_new();
137
                 rb_ary_push(res, rb_tainted_str_new2(attname));
138
@@ -1190,8 +1254,13 @@ plruby_build_tuple(HeapTuple tuple, TupleDesc tupdesc,
139
                 
140
                 fmgr_info(typoutput, &finfo);
141
                 
142
+#if PG_VERSION_NUM < 110000
143
                 s = pl_convert_arg(attr, tupdesc->attrs[i]->atttypid,
144
                                    &finfo, typelem,tupdesc->attrs[i]->attlen);
145
+#else
146
+                s = pl_convert_arg(attr, tupdesc->attrs[i].atttypid,
147
+                                   &finfo, typelem,tupdesc->attrs[i].attlen);
148
+#endif
149
             }
150
             PLRUBY_END_PROTECT;
151
 
(-)databases/postgresql-plruby/files/patch-src_plruby.c (+74 lines)
Line 0 Link Here
1
--- src/plruby.c.orig	2019-08-04 04:30:44 UTC
2
+++ src/plruby.c
3
@@ -1184,17 +1184,29 @@ for_numvals(obj, argobj)
4
         rb_raise(pl_ePLruby, "invalid attribute '%s'", RSTRING_PTR(key));
5
     }
6
     attnum -= 1;
7
+#if PG_VERSION_NUM < 110000
8
     if (arg->tupdesc->attrs[attnum]->attisdropped) {
9
+#else
10
+    if (arg->tupdesc->attrs[attnum].attisdropped) {
11
+#endif
12
         return Qnil;
13
     }
14
 
15
     PLRUBY_BEGIN(1);
16
     typeTup = SearchSysCache(TYPEOID,
17
+#if PG_VERSION_NUM < 110000
18
                              OidGD(arg->tupdesc->attrs[attnum]->atttypid),
19
+#else
20
+                             OidGD(arg->tupdesc->attrs[attnum].atttypid),
21
+#endif
22
                              0, 0, 0);
23
     if (!HeapTupleIsValid(typeTup)) {   
24
         rb_raise(pl_ePLruby, "Cache lookup for attribute '%s' type %ld failed",
25
+#if PG_VERSION_NUM < 110000
26
                  RSTRING_PTR(key), OidGD(arg->tupdesc->attrs[attnum]->atttypid));
27
+#else
28
+                 RSTRING_PTR(key), OidGD(arg->tupdesc->attrs[attnum].atttypid));
29
+#endif
30
     }
31
     fpg = (Form_pg_type) GETSTRUCT(typeTup);
32
     ReleaseSysCache(typeTup);
33
@@ -1226,11 +1238,19 @@ for_numvals(obj, argobj)
34
     else {
35
         arg->modvalues[attnum] = 
36
             plruby_to_datum(value, &finfo, 
37
+#if PG_VERSION_NUM < 110000
38
                             arg->tupdesc->attrs[attnum]->atttypid, 
39
                             fpg->typelem,
40
                             (!VARLENA_FIXED_SIZE(arg->tupdesc->attrs[attnum]))
41
                             ? arg->tupdesc->attrs[attnum]->attlen
42
                             : arg->tupdesc->attrs[attnum]->atttypmod);
43
+#else
44
+                            arg->tupdesc->attrs[attnum].atttypid, 
45
+                            fpg->typelem,
46
+                            (!VARLENA_FIXED_SIZE(arg->tupdesc->attrs[attnum]))
47
+                            ? arg->tupdesc->attrs[attnum].attlen
48
+                            : arg->tupdesc->attrs[attnum].atttypmod);
49
+#endif
50
     }
51
     return Qnil;
52
 }
53
@@ -1284,12 +1304,21 @@ pl_trigger_handler(struct pl_thread_st *plth)
54
 
55
     tmp = rb_ary_new2(tupdesc->natts);
56
     for (i = 0; i < tupdesc->natts; i++) {
57
+#if PG_VERSION_NUM < 110000
58
         if (tupdesc->attrs[i]->attisdropped) {
59
             rb_ary_push(tmp, rb_str_freeze_new2(""));
60
         }
61
         else {
62
             rb_ary_push(tmp, rb_str_freeze_new2(NameStr(tupdesc->attrs[i]->attname)));
63
         }
64
+#else
65
+        if (tupdesc->attrs[i].attisdropped) {
66
+            rb_ary_push(tmp, rb_str_freeze_new2(""));
67
+        }
68
+        else {
69
+            rb_ary_push(tmp, rb_str_freeze_new2(NameStr(tupdesc->attrs[i].attname)));
70
+        }
71
+#endif
72
     }
73
     rb_hash_aset(TG, rb_str_freeze_new2("relatts"), rb_ary_freeze(tmp));
74
 

Return to bug 239639