Compare commits
10 Commits
Author | SHA1 | Date | |
---|---|---|---|
3e2fa74004 | |||
b9d27b0dbc | |||
1f46b0a708 | |||
6eb67283df | |||
544701b4d8 | |||
48e24e8b76 | |||
77d04c9e82 | |||
901b322819 | |||
6f0b5ba942 | |||
07fa912c18 |
9
build.sh
9
build.sh
@ -48,6 +48,7 @@ else
|
|||||||
echo "Kernel is $kernel"
|
echo "Kernel is $kernel"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
os_version=$(cat /etc/os-release | grep -w VERSION_ID | awk -F '"' '{print $2}')
|
||||||
|
|
||||||
#######################################################################
|
#######################################################################
|
||||||
## print help information
|
## print help information
|
||||||
@ -62,8 +63,8 @@ function print_help()
|
|||||||
}
|
}
|
||||||
|
|
||||||
##default install version storage path
|
##default install version storage path
|
||||||
declare db_name_for_package='openGauss'
|
declare db_name_for_package='openGauss-Python'
|
||||||
declare version_number='5.0.0'
|
declare version_number='6.0.0'
|
||||||
|
|
||||||
if [ $# = 0 ] ; then
|
if [ $# = 0 ] ; then
|
||||||
echo "missing option"
|
echo "missing option"
|
||||||
@ -118,8 +119,8 @@ done
|
|||||||
## declare all package name
|
## declare all package name
|
||||||
#######################################################################
|
#######################################################################
|
||||||
declare version_string="${db_name_for_package}-${version_number}"
|
declare version_string="${db_name_for_package}-${version_number}"
|
||||||
declare package_pre_name="${version_string}-${dist_version}-${PLATFORM}"
|
declare package_pre_name="${version_string}-${dist_version}${os_version}-${PLATFORM}"
|
||||||
declare python_package_name="${package_pre_name}-Python.${install_package_format}.gz"
|
declare python_package_name="${package_pre_name}.${install_package_format}.gz"
|
||||||
|
|
||||||
declare BUILD_DIR="${LOCAL_DIR}/build"
|
declare BUILD_DIR="${LOCAL_DIR}/build"
|
||||||
declare MKGS_OK=0
|
declare MKGS_OK=0
|
||||||
|
@ -49,7 +49,7 @@ extern "C" {
|
|||||||
/* sql_compatibility values */
|
/* sql_compatibility values */
|
||||||
#define SQL_COMPATIBILITY_A 1
|
#define SQL_COMPATIBILITY_A 1
|
||||||
#define SQL_COMPATIBILITY_OTHER 5
|
#define SQL_COMPATIBILITY_OTHER 5
|
||||||
// #define SQL_COMPATIBILITY_B 2
|
#define SQL_COMPATIBILITY_B 2
|
||||||
// #define SQL_COMPATIBILITY_C 3
|
// #define SQL_COMPATIBILITY_C 3
|
||||||
// #define SQL_COMPATIBILITY_PG 4
|
// #define SQL_COMPATIBILITY_PG 4
|
||||||
|
|
||||||
|
@ -1356,14 +1356,32 @@ register_type_uint(connectionObject *self, PyThreadState **tstate)
|
|||||||
}
|
}
|
||||||
if (typecast_add((PyObject *)obj, self->string_types, 0) < 0) { goto end; }
|
if (typecast_add((PyObject *)obj, self->string_types, 0) < 0) { goto end; }
|
||||||
rv = 0;
|
rv = 0;
|
||||||
free(_typecast_INTEGER_types);
|
|
||||||
end:
|
end:
|
||||||
|
free(_typecast_INTEGER_types);
|
||||||
Py_XDECREF(values);
|
Py_XDECREF(values);
|
||||||
Py_XDECREF(name);
|
Py_XDECREF(name);
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int set_sql_compatibility(connectionObject *self, char *value)
|
||||||
|
{
|
||||||
|
switch (value[0]) {
|
||||||
|
case 'A':
|
||||||
|
case 'a':
|
||||||
|
self->sql_compatibility = SQL_COMPATIBILITY_A;
|
||||||
|
break;
|
||||||
|
case 'B':
|
||||||
|
case 'b':
|
||||||
|
self->sql_compatibility = SQL_COMPATIBILITY_B;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
self->sql_compatibility = SQL_COMPATIBILITY_OTHER;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* initialization and finalization methods */
|
/* initialization and finalization methods */
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -1410,19 +1428,25 @@ connection_setup(connectionObject *self, const char *dsn, long int async)
|
|||||||
Dprintf("connection_setup: good connection object at %p, refcnt = "
|
Dprintf("connection_setup: good connection object at %p, refcnt = "
|
||||||
FORMAT_CODE_PY_SSIZE_T,
|
FORMAT_CODE_PY_SSIZE_T,
|
||||||
self, Py_REFCNT(self));
|
self, Py_REFCNT(self));
|
||||||
|
PyThreadState *tstate = (PyThreadState *)malloc(sizeof(PyThreadState));
|
||||||
|
|
||||||
Py_BEGIN_ALLOW_THREADS;
|
Py_BEGIN_ALLOW_THREADS;
|
||||||
pthread_mutex_lock(&self->lock);
|
pthread_mutex_lock(&self->lock);
|
||||||
sql_compatibility_value = pq_get_guc_locked(self, "sql_compatibility", &_save);
|
sql_compatibility_value = pq_get_guc_locked(self, "sql_compatibility", &_save);
|
||||||
if (register_type_uint(self, &_save)) { goto exit; }
|
set_sql_compatibility(self, sql_compatibility_value);
|
||||||
|
memcpy(tstate, _save, sizeof(_save));
|
||||||
pthread_mutex_unlock(&self->lock);
|
pthread_mutex_unlock(&self->lock);
|
||||||
Py_END_ALLOW_THREADS;
|
Py_END_ALLOW_THREADS;
|
||||||
|
|
||||||
if (strcmp(sql_compatibility_value, "A") == 0) {
|
pthread_mutex_lock(&self->lock);
|
||||||
self->sql_compatibility = SQL_COMPATIBILITY_A;
|
if (register_type_uint(self, &tstate)) {
|
||||||
} else {
|
goto exit;
|
||||||
self->sql_compatibility = SQL_COMPATIBILITY_OTHER;
|
|
||||||
}
|
}
|
||||||
|
if (tstate) {
|
||||||
|
free(tstate);
|
||||||
|
tstate = NULL;
|
||||||
|
}
|
||||||
|
pthread_mutex_unlock(&self->lock);
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
if (sql_compatibility_value){
|
if (sql_compatibility_value){
|
||||||
|
@ -57,6 +57,16 @@ curs_get_cast(cursorObject *self, PyObject *oid)
|
|||||||
if (cast) { return cast; }
|
if (cast) { return cast; }
|
||||||
|
|
||||||
/* global lookup */
|
/* global lookup */
|
||||||
|
if (self->conn->sql_compatibility == SQL_COMPATIBILITY_B) {
|
||||||
|
/*
|
||||||
|
In mysql compatibility mode, we should convert the TIME column to a python datetime.timedelta type,
|
||||||
|
just like the behavior of PyMySQL and mysql-connector-python.
|
||||||
|
*/
|
||||||
|
if (PyLong_Check(oid)) {
|
||||||
|
long value = convert_time_oid_to_interval_oid(PyLong_AsLong(oid));
|
||||||
|
oid = PyLong_FromLong(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
cast = PyDict_GetItem(psyco_types, oid);
|
cast = PyDict_GetItem(psyco_types, oid);
|
||||||
Dprintf("curs_get_cast: global dict: %p", cast);
|
Dprintf("curs_get_cast: global dict: %p", cast);
|
||||||
if (cast) { return cast; }
|
if (cast) { return cast; }
|
||||||
|
@ -616,7 +616,7 @@ pq_get_pg_catalog_custom_type_oid(connectionObject *conn, const char *param, PyT
|
|||||||
char query[256];
|
char query[256];
|
||||||
int size;
|
int size;
|
||||||
unsigned int rv = 0;
|
unsigned int rv = 0;
|
||||||
|
char *temp_oid = NULL;
|
||||||
size = PyOS_snprintf(query, sizeof(query), "select oid from pg_type where typnamespace = 11 and typname= %s", param);
|
size = PyOS_snprintf(query, sizeof(query), "select oid from pg_type where typnamespace = 11 and typname= %s", param);
|
||||||
if (size < 0 || (size_t)size >= sizeof(query)) {
|
if (size < 0 || (size_t)size >= sizeof(query)) {
|
||||||
conn_set_error(conn, "query too large");
|
conn_set_error(conn, "query too large");
|
||||||
@ -645,8 +645,10 @@ pq_get_pg_catalog_custom_type_oid(connectionObject *conn, const char *param, PyT
|
|||||||
PQresStatus(PQresultStatus(conn->pgres)));
|
PQresStatus(PQresultStatus(conn->pgres)));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
temp_oid = PQgetvalue(conn->pgres, 0, 0);
|
||||||
rv = atoi(strdup(PQgetvalue(conn->pgres, 0, 0)));
|
if (temp_oid) {
|
||||||
|
rv = (unsigned int)atoi(temp_oid);
|
||||||
|
}
|
||||||
CLEARPGRES(conn->pgres);
|
CLEARPGRES(conn->pgres);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
@ -88,5 +88,7 @@ HIDDEN PyObject *typecast_array_from_python(
|
|||||||
HIDDEN PyObject *typecast_cast(
|
HIDDEN PyObject *typecast_cast(
|
||||||
PyObject *self, const char *str, Py_ssize_t len, PyObject *curs);
|
PyObject *self, const char *str, Py_ssize_t len, PyObject *curs);
|
||||||
|
|
||||||
|
HIDDEN long convert_time_oid_to_interval_oid(long value);
|
||||||
|
|
||||||
#endif /* !defined(PSYCOPG_TYPECAST_H) */
|
#endif /* !defined(PSYCOPG_TYPECAST_H) */
|
||||||
PyObject *typecast_new(PyObject *name, PyObject *values, PyObject *cast, PyObject *base);
|
PyObject *typecast_new(PyObject *name, PyObject *values, PyObject *cast, PyObject *base);
|
@ -31,6 +31,21 @@ static long int typecast_MACADDRARRAY_types[] = {1040, 0};
|
|||||||
static long int typecast_UNKNOWN_types[] = {705, 0};
|
static long int typecast_UNKNOWN_types[] = {705, 0};
|
||||||
|
|
||||||
|
|
||||||
|
long convert_time_oid_to_interval_oid(long value)
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
while (typecast_TIME_types[i] != 0) {
|
||||||
|
if (typecast_TIME_types[i] == value) {
|
||||||
|
Dprintf("convert time oid to interval oid");
|
||||||
|
value = typecast_INTERVAL_types[0];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static typecastObject_initlist typecast_builtins[] = {
|
static typecastObject_initlist typecast_builtins[] = {
|
||||||
{"NUMBER", typecast_NUMBER_types, typecast_NUMBER_cast, NULL},
|
{"NUMBER", typecast_NUMBER_types, typecast_NUMBER_cast, NULL},
|
||||||
{"LONGINTEGER", typecast_LONGINTEGER_types, typecast_LONGINTEGER_cast, NULL},
|
{"LONGINTEGER", typecast_LONGINTEGER_types, typecast_LONGINTEGER_cast, NULL},
|
||||||
|
@ -203,6 +203,11 @@ _parse_noninftz(const char *str, Py_ssize_t len, PyObject *curs)
|
|||||||
rv = PyObject_CallFunction(
|
rv = PyObject_CallFunction(
|
||||||
(PyObject*)PyDateTimeAPI->DateTimeType, "iiiiiiiO",
|
(PyObject*)PyDateTimeAPI->DateTimeType, "iiiiiiiO",
|
||||||
y, m, d, hh, mm, ss, us, tzinfo);
|
y, m, d, hh, mm, ss, us, tzinfo);
|
||||||
|
if (rv == NULL) {
|
||||||
|
/* illegal values are returned as str */
|
||||||
|
PyErr_Clear();
|
||||||
|
rv = PyUnicode_FromString(str);
|
||||||
|
}
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
Py_XDECREF(tzoff);
|
Py_XDECREF(tzoff);
|
||||||
|
Reference in New Issue
Block a user