11/*-------------------------------------------------------------------------
22 *
3- *jsquery_manipulation .c
4- * Functions and operations to manipulate jsquery
3+ *jsquery_constr .c
4+ * Functions and operations to manipulate jsquery
55 *
66 * Copyright (c) 2014, PostgreSQL Global Development Group
77 * Author: Teodor Sigaev <teodor@sigaev.ru>
88 *
99 * IDENTIFICATION
10- * contrib/jsquery/jsquery_manipulation .c
10+ * contrib/jsquery/jsquery_constr .c
1111 *
1212 *-------------------------------------------------------------------------
1313 */
@@ -23,8 +23,8 @@ static int32
2323copyJsQuery (StringInfo buf ,JsQueryItem * jsq )
2424{
2525JsQueryItem elem ;
26- int32 next ,chld ;
27- int32 resPos = buf -> len - VARHDRSZ ;/* position from begining of jsquery data */
26+ int32 next ,chld ;
27+ int32 resPos = buf -> len - VARHDRSZ ;/* position from begining of jsquery data */
2828
2929check_stack_depth ();
3030
@@ -42,7 +42,7 @@ copyJsQuery(StringInfo buf, JsQueryItem *jsq)
4242case jqiKey :
4343case jqiString :
4444{
45- int32 len ;
45+ int32 len ;
4646char * s ;
4747
4848s = jsqGetString (jsq ,& len );
@@ -124,6 +124,10 @@ copyJsQuery(StringInfo buf, JsQueryItem *jsq)
124124* (int32 * )(buf -> data + argOut )= chld ;
125125}
126126break ;
127+ case jqiIndexArray :
128+ appendBinaryStringInfo (buf , (char * )& jsq -> arrayIndex ,
129+ sizeof (jsq -> arrayIndex ));
130+ break ;
127131case jqiNull :
128132case jqiCurrent :
129133case jqiLength :
@@ -150,7 +154,7 @@ joinJsQuery(JsQueryItemType type, JsQuery *jq1, JsQuery *jq2)
150154JsQuery * out ;
151155StringInfoData buf ;
152156int32 left ,right ,chld ;
153- JsQueryItem v ;
157+ JsQueryItem v ;
154158
155159initStringInfo (& buf );
156160enlargeStringInfo (& buf ,VARSIZE_ANY (jq1 )+ VARSIZE_ANY (jq2 )+ 4 * sizeof (int32 )+ VARHDRSZ );
@@ -188,9 +192,9 @@ PG_FUNCTION_INFO_V1(jsquery_join_and);
188192Datum
189193jsquery_join_and (PG_FUNCTION_ARGS )
190194{
191- JsQuery * jq1 = PG_GETARG_JSQUERY (0 );
192- JsQuery * jq2 = PG_GETARG_JSQUERY (1 );
193- JsQuery * out ;
195+ JsQuery * jq1 = PG_GETARG_JSQUERY (0 );
196+ JsQuery * jq2 = PG_GETARG_JSQUERY (1 );
197+ JsQuery * out ;
194198
195199out = joinJsQuery (jqiAnd ,jq1 ,jq2 );
196200
@@ -204,9 +208,9 @@ PG_FUNCTION_INFO_V1(jsquery_join_or);
204208Datum
205209jsquery_join_or (PG_FUNCTION_ARGS )
206210{
207- JsQuery * jq1 = PG_GETARG_JSQUERY (0 );
208- JsQuery * jq2 = PG_GETARG_JSQUERY (1 );
209- JsQuery * out ;
211+ JsQuery * jq1 = PG_GETARG_JSQUERY (0 );
212+ JsQuery * jq2 = PG_GETARG_JSQUERY (1 );
213+ JsQuery * out ;
210214
211215out = joinJsQuery (jqiOr ,jq1 ,jq2 );
212216