|
45 | 45 | #include <funcapi.h> |
46 | 46 | #include <access/genam.h> |
47 | 47 | #include <access/htup.h> |
48 | | -#include <access/table.h> |
| 48 | +#include <access/sysattr.h> |
49 | 49 | #include <catalog/namespace.h> |
50 | 50 | #include <catalog/pg_type.h> |
51 | 51 | #include <catalog/pg_extension.h> |
52 | 52 | #include <catalog/dependency.h> |
| 53 | +#include <catalog/indexing.h> |
53 | 54 | #include <commands/extension.h> |
54 | 55 | #include <lib/stringinfo.h> |
55 | 56 | #include <mb/pg_wchar.h> |
|
64 | 65 | #include <utils/fmgroids.h> |
65 | 66 | #include <utils/guc.h> |
66 | 67 |
|
| 68 | +#if PG_VERSION_NUM >= 90300 |
| 69 | +# include <access/htup_details.h> |
| 70 | +#endif |
| 71 | + |
67 | 72 | #if PG_VERSION_NUM >= 100000 |
68 | | -#include <utils/varlena.h> |
| 73 | +# include <utils/varlena.h> |
69 | 74 | #endif |
70 | 75 |
|
71 | | -#if PG_VERSION_NUM >= 90300 |
72 | | -#include <access/htup_details.h> |
| 76 | +#if PG_VERSION_NUM >= 120000 |
| 77 | +# include <access/table.h> |
| 78 | +#else |
| 79 | +# define table_open(rel, lock) heap_open((rel), (lock)) |
| 80 | +# define table_close(rel, lock) heap_close((rel), (lock)) |
| 81 | +#endif |
| 82 | + |
| 83 | +#ifndef PG_GETARG_JSONB_P |
| 84 | +#define PG_GETARG_JSONB_P(x) DatumGetJsonb(PG_GETARG_DATUM(x)) |
73 | 85 | #endif |
74 | 86 |
|
75 | 87 | /* CURL */ |
@@ -589,11 +601,15 @@ get_extension_schema(Oid ext_oid) |
589 | 601 | SysScanDesc scandesc; |
590 | 602 | HeapTuple tuple; |
591 | 603 | ScanKeyData entry[1]; |
592 | | - |
593 | 604 | rel = table_open(ExtensionRelationId, AccessShareLock); |
| 605 | +#if PG_VERSION_NUM >= 120000 |
| 606 | + Oid pg_extension_oid = Anum_pg_extension_oid; |
| 607 | +#else |
| 608 | + Oid pg_extension_oid = ObjectIdAttributeNumber; |
| 609 | +#endif |
594 | 610 |
|
595 | 611 | ScanKeyInit(&entry[0], |
596 | | - Anum_pg_extension_oid, |
| 612 | + pg_extension_oid, |
597 | 613 | BTEqualStrategyNumber, F_OIDEQ, |
598 | 614 | ObjectIdGetDatum(ext_oid)); |
599 | 615 |
|
@@ -1495,8 +1511,19 @@ Datum urlencode_jsonb(PG_FUNCTION_ARGS) |
1495 | 1511 | key = pnstrdup(v.val.string.val, v.val.string.len); |
1496 | 1512 | key_enc = urlencode_cstr(v.val.string.val, v.val.string.len); |
1497 | 1513 |
|
1498 | | - /* Read and encode the value */ |
| 1514 | + /* Read the value for this key */ |
| 1515 | +#if PG_VERSION_NUM < 130000 |
| 1516 | + { |
| 1517 | + JsonbValue k; |
| 1518 | + k.type = jbvString; |
| 1519 | + k.val.string.val = key; |
| 1520 | + k.val.string.len = strlen(key); |
| 1521 | + v = *findJsonbValueFromContainer(&jb->root, JB_FOBJECT, &k); |
| 1522 | + } |
| 1523 | +#else |
1499 | 1524 | getKeyJsonValueFromContainer(&jb->root, key, strlen(key), &v); |
| 1525 | +#endif |
| 1526 | + /* Read and encode the value */ |
1500 | 1527 | switch(v.type) |
1501 | 1528 | { |
1502 | 1529 | case jbvString: { |
|
0 commit comments