ProvSQL C/C++ API
Adding support for provenance and uncertainty management to PostgreSQL databases
Loading...
Searching...
No Matches
compatibility.c
Go to the documentation of this file.
1
/**
2
* @file compatibility.c
3
* @brief Backport implementations for missing PostgreSQL API functions.
4
*
5
* Provides implementations of functions that do not exist in older
6
* PostgreSQL versions but are declared in @c compatibility.h.
7
*
8
* Currently provides:
9
* - @c list_insert_nth() for PostgreSQL < 13, where the linked-list-based
10
* @c List implementation did not include this helper.
11
*/
12
#include "
compatibility.h
"
13
14
#if PG_VERSION_NUM < 130000
15
List *
list_insert_nth
(List *list,
int
pos,
void
*datum)
16
{
17
unsigned
i=0;
18
ListCell *p, *prev, *
new
;
19
20
if
(!list && pos==0)
21
return
list_make1(datum);
22
23
for
(p = list->head, prev=NULL; p && i<pos; ++i, prev=p, p=p->next)
24
;
25
26
Assert(i==pos);
27
28
if
(prev==NULL)
29
return
lcons(datum, list);
30
31
new
= (ListCell *) palloc(
sizeof
(ListCell));
32
new
->next=p;
33
new
->data.ptr_value=datum;
34
prev->next=
new
;
35
36
if
(!p)
37
list->tail=
new
;
38
39
++list->length;
40
41
return
list;
42
}
43
#endif
list_insert_nth
List * list_insert_nth(List *list, int pos, void *datum)
Insert datum at position pos in list (PG < 13 backport).
Definition
compatibility.c:15
compatibility.h
PostgreSQL cross-version compatibility shims for ProvSQL.
← Back to provsql.org