UnQL

Check-in [4c69266688]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Stubs for the flatten code.
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 4c69266688c51767f5d5a1c8e4cd543627657952
User & Date: drh 2011-07-25 13:59:01
Context
2011-07-25
19:26
Add partial support for the EACH keyword. check-in: 5d36d9f104 user: dan tags: trunk
13:59
Stubs for the flatten code. check-in: 4c69266688 user: drh tags: trunk
13:51
Add SQLITE_NO_SYNC to the SQLite backing store compilation. This makes tests run much faster, at the expense of crash survivability. We do not really care about surviving crashes in this prototype - at least not yet. check-in: 6ec01596ed user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/datasrc.c.

36
37
38
39
40
41
42



43
44
45
46
47
48
49
50
..
91
92
93
94
95
96
97



98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
...
128
129
130
131
132
133
134

135
136
137
138
139
140
141
...
163
164
165
166
167
168
169




170
171
172
173
174
175
176
...
182
183
184
185
186
187
188




189
190
191
192
193
194
195
...
290
291
292
293
294
295
296
297
    case TK_ID: {
      char *zSql = sqlite3_mprintf("SELECT x FROM \"%w\"", p->u.tab.zName);
      sqlite3_prepare_v2(pQuery->pStmt->pConn->db, zSql, -1, 
                         &p->u.tab.pStmt, 0);
      sqlite3_free(zSql);
      break;
    }




    case TK_NULL:                 /* Initializing a NULL DS is a no-op */
      assert( p->u.null.isDone==0 );
      break;
  }
  return XJD1_OK;
}

................................................................................
        p->pValue = xjd1JsonParse(zJson, -1);
        rc = XJD1_ROW;
      }else{
        p->u.tab.eofSeen = 1;
        rc = XJD1_DONE;
      }
      break;



    }
    case TK_NULL: {
      rc = (p->u.null.isDone ? XJD1_DONE : XJD1_ROW);
      p->u.null.isDone = 1;
      break;
    }
  }
  return rc;
}

/*
** Return the document that this data source if the document if the AS
** name of the document is zDocName or if zDocName==0.  The AS name is
** important since a join might have multiple documents.
**
** xjd1JsonRef() has been called on the returned string.  The caller
** must invoke xjd1JsonFree().
*/
JsonNode *xjd1DataSrcDoc(DataSrc *p, const char *zDocName){
  JsonNode *pRes = 0;
  if( p==0 ) return 0;
................................................................................
    case TK_SELECT: {
      assert( p->zAs );
      if( zDocName==0 ){
        pRes = xjd1JsonRef(p->pValue);
      }
      break;
    }

    case TK_ID: {
      if( zDocName==0 || (p->zAs==0 && strcmp(p->u.tab.zName, zDocName)==0) ){
        pRes = xjd1JsonRef(p->pValue);
      }
      break;
    }
    default: {
................................................................................
    case TK_SELECT: {
      xjd1QueryRewind(p->u.subq.q);
      break;
    }
    case TK_ID: {
      sqlite3_reset(p->u.tab.pStmt);
      break;




    }
    case TK_NULL: {
      p->u.null.isDone = 0;
      break;
    }
  }
  return XJD1_DONE;
................................................................................
int xjd1DataSrcClose(DataSrc *p){
  if( p==0 ) return XJD1_OK;
  xjd1JsonFree(p->pValue);  p->pValue = 0;
  switch( p->eDSType ){
    case TK_ID: {
      sqlite3_finalize(p->u.tab.pStmt);
      break;




    }
  }
  return XJD1_OK;
}

int xjd1DataSrcCount(DataSrc *p){
  int n = 1;
................................................................................
  }
  return pRet;
}
JsonNode *xjd1DataSrcRead(DataSrc *p, int iDoc){
  int iEntry = 1;
  return datasrcReadRecursive(p, &iEntry, iDoc);
}








>
>
>
|







 







>
>
>











|
|
|







 







>







 







>
>
>
>







 







>
>
>
>







 







<
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
..
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
...
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
...
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
...
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
...
305
306
307
308
309
310
311

    case TK_ID: {
      char *zSql = sqlite3_mprintf("SELECT x FROM \"%w\"", p->u.tab.zName);
      sqlite3_prepare_v2(pQuery->pStmt->pConn->db, zSql, -1, 
                         &p->u.tab.pStmt, 0);
      sqlite3_free(zSql);
      break;
    }
    case TK_FLATTENOP: {
      xjd1DataSrcInit(p->u.flatten.pNext, pQuery);
      break;
    }
    case TK_NULL:                 /* Initializing a NULL DS is a no-op */
      assert( p->u.null.isDone==0 );
      break;
  }
  return XJD1_OK;
}

................................................................................
        p->pValue = xjd1JsonParse(zJson, -1);
        rc = XJD1_ROW;
      }else{
        p->u.tab.eofSeen = 1;
        rc = XJD1_DONE;
      }
      break;
    }
    case TK_FLATTENOP: {
      break;
    }
    case TK_NULL: {
      rc = (p->u.null.isDone ? XJD1_DONE : XJD1_ROW);
      p->u.null.isDone = 1;
      break;
    }
  }
  return rc;
}

/*
** Return the document that this data source is current pointing to
** if the AS name of the document is zDocName or if zDocName==0.
** The AS name is important since a join might have multiple documents.
**
** xjd1JsonRef() has been called on the returned string.  The caller
** must invoke xjd1JsonFree().
*/
JsonNode *xjd1DataSrcDoc(DataSrc *p, const char *zDocName){
  JsonNode *pRes = 0;
  if( p==0 ) return 0;
................................................................................
    case TK_SELECT: {
      assert( p->zAs );
      if( zDocName==0 ){
        pRes = xjd1JsonRef(p->pValue);
      }
      break;
    }
    case TK_FLATTENOP:
    case TK_ID: {
      if( zDocName==0 || (p->zAs==0 && strcmp(p->u.tab.zName, zDocName)==0) ){
        pRes = xjd1JsonRef(p->pValue);
      }
      break;
    }
    default: {
................................................................................
    case TK_SELECT: {
      xjd1QueryRewind(p->u.subq.q);
      break;
    }
    case TK_ID: {
      sqlite3_reset(p->u.tab.pStmt);
      break;
    }
    case TK_FLATTENOP: {
      xjd1DataSrcRewind(p->u.flatten.pNext);
      break;
    }
    case TK_NULL: {
      p->u.null.isDone = 0;
      break;
    }
  }
  return XJD1_DONE;
................................................................................
int xjd1DataSrcClose(DataSrc *p){
  if( p==0 ) return XJD1_OK;
  xjd1JsonFree(p->pValue);  p->pValue = 0;
  switch( p->eDSType ){
    case TK_ID: {
      sqlite3_finalize(p->u.tab.pStmt);
      break;
    }
    case TK_FLATTENOP: {
      xjd1DataSrcClose(p->u.flatten.pNext);
      break;
    }
  }
  return XJD1_OK;
}

int xjd1DataSrcCount(DataSrc *p){
  int n = 1;
................................................................................
  }
  return pRet;
}
JsonNode *xjd1DataSrcRead(DataSrc *p, int iDoc){
  int iEntry = 1;
  return datasrcReadRecursive(p, &iEntry, iDoc);
}