Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/postgresql/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C 在postgresql中为POINT3DZ创建自己的索引时出现SEGFULT_C_Postgresql_Postgis_Postgresql 9.4 - Fatal编程技术网

C 在postgresql中为POINT3DZ创建自己的索引时出现SEGFULT

C 在postgresql中为POINT3DZ创建自己的索引时出现SEGFULT,c,postgresql,postgis,postgresql-9.4,C,Postgresql,Postgis,Postgresql 9.4,我正在尝试为3d点编写自己的索引——POINT3DZ(使用pgis和postgres 9.4)。 我编写了一个类似于spgquadtreeproc.c[1]的代码 这是我的spg\u quad\u point3dz\u picksplit函数: PG_FUNCTION_INFO_V1(spg_quad_point3dz_picksplit); /* Decides how to create a new inner tuple over a set of leaf tuples. */ Datu

我正在尝试为3d点编写自己的索引——POINT3DZ(使用pgis和postgres 9.4)。 我编写了一个类似于spgquadtreeproc.c[1]的代码

这是我的
spg\u quad\u point3dz\u picksplit
函数:

PG_FUNCTION_INFO_V1(spg_quad_point3dz_picksplit);
/* Decides how to create a new inner tuple over a set of leaf tuples. */
Datum
spg_quad_point3dz_picksplit(PG_FUNCTION_ARGS){
    spgPickSplitIn *in = (spgPickSplitIn *) PG_GETARG_POINTER(0);
    spgPickSplitOut *out = (spgPickSplitOut *) PG_GETARG_POINTER(1);
    int i;
    POINT3DZ centroid, ctemp;

#ifdef USE_MEDIAN
    /* Use the median values of x and y as the centroid point */
    POINT3DZ      **sorted;

    sorted = palloc(sizeof(*sorted) * in->nTuples);
    for (i = 0; i < in->nTuples-1; i++){
        datumGetPoint3dzP(in->datums[i], sorted[i]);
    }

    centroid = palloc(sizeof(*centroid));

    qsort(sorted, in->nTuples, sizeof(*sorted), x_cmp);
    centroid->x = sorted[in->nTuples >> 1]->x;
    qsort(sorted, in->nTuples, sizeof(*sorted), y_cmp);
    centroid->y = sorted[in->nTuples >> 1]->y;
#else
    /* Use the average values of x and y as the centroid point */

    for (i = 0; i < in->nTuples; i++)
    {
        datumGetPoint3dzP(in->datums[i],&ctemp);
        centroid.x += ctemp.x;
        centroid.y += ctemp.y;
    }
    centroid.x /= in->nTuples;
    centroid.y /= in->nTuples;
#endif

    out->hasPrefix = true;
    out->prefixDatum = (Datum)&centroid;
    out->nNodes = 4;
    out->nodeLabels = NULL;     /* we don't need node labels */
    out->mapTuplesToNodes = palloc(sizeof(int) * in->nTuples);
    out->leafTupleDatums = palloc(sizeof(Datum) * in->nTuples);

    for (i = 0; i < in->nTuples; i++)   {
        POINT3DZ p;
        datumGetPoint3dzP(in->datums[i], &p);

        int quadrant = getQuadrant(&centroid,&p);

        out->leafTupleDatums[i] = (Datum)&p;
        out->mapTuplesToNodes[i] = quadrant- 1;
    }

    PG_RETURN_VOID();
} 
我在调试中发现调用
getPoint3dz\u p
时出错

getPoint3dz_p
是PostGIS(lwgeom)的一个函数[2]

错误:

CREATE INDEX example_sensors_index1 ON sensors_data USING spgist( geom geometry_point3dz_ops );
DEBUG:  StartTransactionCommand
DEBUG:  StartTransaction
DEBUG:  name: unnamed; blockState:       DEFAULT; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children: 
DEBUG:  ProcessUtility
DEBUG:  Creating index "example_sensors_index1" on table "sensors_data"
server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
日志: 有些信息是用波兰语写的。对于每个人,我都在每条消息下面贴了一个翻译。 以下是我日志的一部分:

你遇到过这样的错误吗?如何正确修复此代码?提前感谢您的帮助


链接:
[1] 37.187.79.115/postgresql-9.4beta3/src/backend/access/spgist/spgquadtreeproc.c

[2]

检查指针,确保其正确无误。例如,如果调用
getPoint3dz_p(点->点,0,p)确实是问题所在,然后做
point=lwgeom\u as\u lwpoint(lwgeom)返回有效指针?也许你应该检查一下。谢谢你的回复,我添加了
elog(WARINING,“ABCEDEF point:5d”,point)
点=lwgeom\u作为lwgeom点(lwgeom)在日志中我得到:
。。。1588170528警告:ABCDEF点:1588170688警告:ABCDEF点:1588170848警告:ABCDEF点:1588140880。所有的值都大于零,所以我认为指针具有有效的地址。同时检查其他指针。检查您的指针以确保它们是正确的。例如,如果调用
getPoint3dz_p(点->点,0,p)确实是问题所在,然后做
point=lwgeom\u as\u lwpoint(lwgeom)返回有效指针?也许你应该检查一下。谢谢你的回复,我添加了
elog(WARINING,“ABCEDEF point:5d”,point)
点=lwgeom\u作为lwgeom点(lwgeom)在日志中我得到:
。。。1588170528警告:ABCDEF点:1588170688警告:ABCDEF点:1588170848警告:ABCDEF点:1588140880。所有的值都大于零,所以我认为指针具有有效的地址。请检查其他指针。
CREATE INDEX example_sensors_index1 ON sensors_data USING spgist( geom geometry_point3dz_ops );
DEBUG:  StartTransactionCommand
DEBUG:  StartTransaction
DEBUG:  name: unnamed; blockState:       DEFAULT; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children: 
DEBUG:  ProcessUtility
DEBUG:  Creating index "example_sensors_index1" on table "sensors_data"
server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.