Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit490ed1e

Browse files
committed
Fix hstore_plpython for Python 3.
In commitd51924b, I overlooked the need to provide linkage forPLyUnicode_FromStringAndSize, because that's only used (and indeedonly exists) in Python 3 builds.In light of the need to #if this item, rearrange the ordering ofthe code related to each function pointer, so as not to need more#if's than absolutely necessary.Per buildfarm.
1 parentc86c2d9 commit490ed1e

File tree

1 file changed

+21
-13
lines changed

1 file changed

+21
-13
lines changed

‎contrib/hstore_plpython/hstore_plpython.c

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,22 @@ extern void _PG_init(void);
1111

1212
/* Linkage to functions in plpython module */
1313
typedefchar*(*PLyObject_AsString_t) (PyObject*plrv);
14-
1514
staticPLyObject_AsString_tPLyObject_AsString_p;
15+
#ifPY_MAJOR_VERSION >=3
16+
typedefPyObject*(*PLyUnicode_FromStringAndSize_t) (constchar*s,Py_ssize_tsize);
17+
staticPLyUnicode_FromStringAndSize_tPLyUnicode_FromStringAndSize_p;
18+
#endif
1619

1720
/* Linkage to functions in hstore module */
1821
typedefHStore*(*hstoreUpgrade_t) (Datumorig);
19-
typedefint (*hstoreUniquePairs_t) (Pairs*a,int32l,int32*buflen);
20-
typedefHStore*(*hstorePairs_t) (Pairs*pairs,int32pcount,int32buflen);
21-
typedefsize_t (*hstoreCheckKeyLen_t) (size_tlen);
22-
typedefsize_t (*hstoreCheckValLen_t) (size_tlen);
23-
2422
statichstoreUpgrade_thstoreUpgrade_p;
23+
typedefint (*hstoreUniquePairs_t) (Pairs*a,int32l,int32*buflen);
2524
statichstoreUniquePairs_thstoreUniquePairs_p;
25+
typedefHStore*(*hstorePairs_t) (Pairs*pairs,int32pcount,int32buflen);
2626
statichstorePairs_thstorePairs_p;
27+
typedefsize_t (*hstoreCheckKeyLen_t) (size_tlen);
2728
statichstoreCheckKeyLen_thstoreCheckKeyLen_p;
29+
typedefsize_t (*hstoreCheckValLen_t) (size_tlen);
2830
statichstoreCheckValLen_thstoreCheckValLen_p;
2931

3032

@@ -34,29 +36,34 @@ static hstoreCheckValLen_t hstoreCheckValLen_p;
3436
void
3537
_PG_init(void)
3638
{
37-
/*These asserts verify that typedefs above match original declarations */
39+
/*Asserts verify that typedefs above match original declarations */
3840
AssertVariableIsOfType(&PLyObject_AsString,PLyObject_AsString_t);
39-
AssertVariableIsOfType(&hstoreUpgrade,hstoreUpgrade_t);
40-
AssertVariableIsOfType(&hstoreUniquePairs,hstoreUniquePairs_t);
41-
AssertVariableIsOfType(&hstorePairs,hstorePairs_t);
42-
AssertVariableIsOfType(&hstoreCheckKeyLen,hstoreCheckKeyLen_t);
43-
AssertVariableIsOfType(&hstoreCheckValLen,hstoreCheckValLen_t);
44-
4541
PLyObject_AsString_p= (PLyObject_AsString_t)
4642
load_external_function("$libdir/"PLPYTHON_LIBNAME,"PLyObject_AsString",
4743
true,NULL);
44+
#ifPY_MAJOR_VERSION >=3
45+
AssertVariableIsOfType(&PLyUnicode_FromStringAndSize,PLyUnicode_FromStringAndSize_t);
46+
PLyUnicode_FromStringAndSize_p= (PLyUnicode_FromStringAndSize_t)
47+
load_external_function("$libdir/"PLPYTHON_LIBNAME,"PLyUnicode_FromStringAndSize",
48+
true,NULL);
49+
#endif
50+
AssertVariableIsOfType(&hstoreUpgrade,hstoreUpgrade_t);
4851
hstoreUpgrade_p= (hstoreUpgrade_t)
4952
load_external_function("$libdir/hstore","hstoreUpgrade",
5053
true,NULL);
54+
AssertVariableIsOfType(&hstoreUniquePairs,hstoreUniquePairs_t);
5155
hstoreUniquePairs_p= (hstoreUniquePairs_t)
5256
load_external_function("$libdir/hstore","hstoreUniquePairs",
5357
true,NULL);
58+
AssertVariableIsOfType(&hstorePairs,hstorePairs_t);
5459
hstorePairs_p= (hstorePairs_t)
5560
load_external_function("$libdir/hstore","hstorePairs",
5661
true,NULL);
62+
AssertVariableIsOfType(&hstoreCheckKeyLen,hstoreCheckKeyLen_t);
5763
hstoreCheckKeyLen_p= (hstoreCheckKeyLen_t)
5864
load_external_function("$libdir/hstore","hstoreCheckKeyLen",
5965
true,NULL);
66+
AssertVariableIsOfType(&hstoreCheckValLen,hstoreCheckValLen_t);
6067
hstoreCheckValLen_p= (hstoreCheckValLen_t)
6168
load_external_function("$libdir/hstore","hstoreCheckValLen",
6269
true,NULL);
@@ -65,6 +72,7 @@ _PG_init(void)
6572

6673
/* These defines must be after the module init function */
6774
#definePLyObject_AsString PLyObject_AsString_p
75+
#definePLyUnicode_FromStringAndSize PLyUnicode_FromStringAndSize_p
6876
#definehstoreUpgrade hstoreUpgrade_p
6977
#definehstoreUniquePairs hstoreUniquePairs_p
7078
#definehstorePairs hstorePairs_p

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp