summaryrefslogtreecommitdiff
path: root/util/db_sql_codegen/parsefuncs.c
blob: 35f3949689d093403fc0b2a632b06678176cda1e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
/*
 * See the file LICENSE for redistribution information.
 *
 * Copyright (c) 1996, 2015 Oracle and/or its affiliates.  All rights reserved.
 *
 */

/*
 * This file contains unused functions that are referenced by the
 * SQLite parser.  If one of these functions is actually invoked, it
 * indicates that the SQL input contains syntax that is unsupported
 * by this program.  Functions that we expect to be called by the
 * parser are in another compilation unit, buildpt.c.
 */

#include <stdio.h>
#include "db_sql_codegen.h"

/*
 * unsupported: The universal "unsupported syntax" error reporter.  In
 * most cases we'll have a parser context in hand when calling this
 * function, and the error message can be passed back to the caller by
 * setting it in the parser context.  Sometimes, however, we don't
 * have the context.  In all such cases, I expect that a subsequent
 * invocation of unsupported() will have the context and report the
 * error through the context.  Probably we could safely ignore these
 * context-less calls, but for now we'll go with a fallback of simply
 * printing the error message directly from here.
 *
 * The advantage of reporting the error through the parser context is
 * that, when the error message eventually gets printed, it will call
 * out a line number where the error was encountered.  We don't have
 * that information here, but it could be made available if this turns
 * out to be a problem.  Also, setting an error in the parser context
 * causes the program to exit after reporting the error.  Again, we
 * could do that here, but it would be ugly.
 */
static void unsupported(pParse, fname)
	Parse *pParse;
	char *fname;
{
	static char *fmt = "Unsupported SQL syntax (%s)\n";

	if (pParse)
		sqlite3ErrorMsg(pParse, fmt, fname);
	else
		fprintf(stderr, fmt, fname);
}

void sqlite3AddCheckConstraint(
  Parse *pParse,    /* Parsing context */
  Expr *pCheckExpr  /* The check expression */
)
{
	COMPQUIET(pCheckExpr, NULL);
	unsupported(pParse, "AddCheckConstraint");
}

void sqlite3AddCollateType(Parse *pParse, Token *pToken)
{
	COMPQUIET(pToken, NULL);
	unsupported(pParse, "AddCollateType");
}

void sqlite3AddDefaultValue(Parse *pParse, Expr *pExpr)
{
	COMPQUIET(pExpr, NULL);
	unsupported(pParse, "AddDefaultValue");
}

void sqlite3AddNotNull(Parse *pParse, int onError)
{
	COMPQUIET(onError, 0);
	unsupported(pParse, "AddNotNull");
}

void sqlite3AlterBeginAddColumn(Parse *pParse, SrcList *pSrc)
{
	COMPQUIET(pSrc, NULL);
	unsupported(pParse, "AlterBeginAddColumn");
}

void sqlite3AlterFinishAddColumn(Parse *pParse, Token *pColDef)
{
	COMPQUIET(pColDef, NULL);
	unsupported(pParse, "AlterFinishAddColumn");
}

void sqlite3AlterRenameTable(
  Parse *pParse,            /* Parser context. */
  SrcList *pSrc,            /* The table to rename. */
  Token *pName              /* The new table name. */
)
{
	COMPQUIET(pSrc, NULL);
	COMPQUIET(pName, NULL);
	unsupported(pParse, "AlterRenameTable");
}

void sqlite3Analyze(Parse *pParse, Token *pName1, Token *pName2)
{
	COMPQUIET(pName1, NULL);
	COMPQUIET(pName2, NULL);
	unsupported(pParse, "Analyze");
}

void sqlite3Attach(Parse *pParse, Expr *p, Expr *pDbname, Expr *pKey)
{
	COMPQUIET(p, NULL);
	COMPQUIET(pDbname, NULL);
	COMPQUIET(pKey, 0);
	unsupported(pParse, "Attach");
}

void sqlite3BeginTransaction(Parse *pParse, int type)
{
	COMPQUIET(type, 0);
	unsupported(pParse, "BeginTransaction");
}

void sqlite3BeginTrigger(
  Parse *pParse,      /* The parse context of the CREATE TRIGGER statement */
  Token *pName1,      /* The name of the trigger */
  Token *pName2,      /* The name of the trigger */
  int tr_tm,          /* One of TK_BEFORE, TK_AFTER, TK_INSTEAD */
  int op,             /* One of TK_INSERT, TK_UPDATE, TK_DELETE */
  IdList *pColumns,   /* column list if this is an UPDATE OF trigger */
  SrcList *pTableName,/* The name of the table/view the trigger applies to */
  Expr *pWhen,        /* WHEN clause */
  int isTemp,         /* True if the TEMPORARY keyword is present */
  int noErr           /* Suppress errors if the trigger already exists */
)
{
	COMPQUIET(pName1, NULL);
	COMPQUIET(pName2, NULL);
	COMPQUIET(tr_tm, 0);
	COMPQUIET(op, 0);
	COMPQUIET(pColumns, NULL);
	COMPQUIET(pTableName, NULL);
	COMPQUIET(pWhen, NULL);
	COMPQUIET(isTemp, 0);
	COMPQUIET(noErr, 0);
	unsupported(pParse, "BeginTrigger");
}

void sqlite3CommitTransaction(Parse *pParse)
{
	unsupported(pParse, "CommitTransaction");
}

void sqlite3CreateView(
  Parse *pParse,     /* The parsing context */
  Token *pBegin,     /* The CREATE token that begins the statement */
  Token *pName1,     /* The token that holds the name of the view */
  Token *pName2,     /* The token that holds the name of the view */
  Select *pSelect,   /* A SELECT statement that will become the new view */
  int isTemp,        /* TRUE for a TEMPORARY view */
  int noErr          /* Suppress error messages if VIEW already exists */
)
{
	COMPQUIET(pBegin, NULL);
	COMPQUIET(pName1, NULL);
	COMPQUIET(pName2, NULL);
	COMPQUIET(pSelect, NULL);
	COMPQUIET(isTemp, 0);
	COMPQUIET(noErr, 0);
	unsupported(pParse, "CreateView");
}

void sqlite3DeleteFrom(
  Parse *pParse,         /* The parser context */
  SrcList *pTabList,     /* The table from which we should delete things */
  Expr *pWhere           /* The WHERE clause.  May be null */
)
{
	COMPQUIET(pTabList, NULL);
	COMPQUIET(pWhere, NULL);
	unsupported(pParse, "DeleteFrom");
}

void sqlite3DeleteTriggerStep(TriggerStep *pTriggerStep)
{
	COMPQUIET(pTriggerStep, NULL);
	unsupported(0, "DeleteTriggerStep");
}

void sqlite3Detach(Parse *pParse, Expr *pDbname)
{
	COMPQUIET(pDbname, NULL);
	unsupported(pParse, "Detach");
}

void sqlite3DropIndex(Parse *pParse, SrcList *pName, int ifExists)
{
	COMPQUIET(pName, NULL);
	COMPQUIET(ifExists, 0);
	unsupported(pParse, "DropIndex");
}

void sqlite3DropTable(Parse *pParse, SrcList *pName, int isView, int noErr)
{
	COMPQUIET(pName, NULL);
	COMPQUIET(isView, 0);
	COMPQUIET(noErr, 0);
	unsupported(pParse, "DropTable");
}

void sqlite3DropTrigger(Parse *pParse, SrcList *pName, int noErr)
{
	COMPQUIET(pName, NULL);
	COMPQUIET(noErr, 0);
	unsupported(pParse, "DropTrigger");
}

void sqlite3ExprAssignVarNumber(Parse *pParse, Expr *pExpr)
{
	COMPQUIET(pExpr, NULL);
	unsupported(pParse, "ExprAssignVarNumber");
}

void sqlite3ExprDelete(Expr *p)
{
	COMPQUIET(p, NULL);
	unsupported(0, "ExprDelete");
}

Expr *sqlite3ExprFunction(Parse *pParse, ExprList *pList, Token *pToken)
{
	COMPQUIET(pList, NULL);
	COMPQUIET(pToken, NULL);
	unsupported(pParse, "ExprFunction");
	return NULL;
}

void sqlite3ExprListDelete(ExprList *pList)
{
	COMPQUIET(pList, NULL);
	unsupported(0, "ExprListDelete");
}

Expr *sqlite3ExprSetColl(Parse *pParse, Expr *pExpr, Token *pName)
{
	COMPQUIET(pExpr, NULL);
	COMPQUIET(pName, NULL);
	unsupported(pParse, "ExprSetColl");
	return NULL;
}

void sqlite3ExprSetHeight(Expr *p)
{
	COMPQUIET(p, NULL);
	unsupported(0, "ExprSetHeight");
}

void sqlite3ExprSpan(Expr *pExpr, Token *pLeft, Token *pRight)
{
	COMPQUIET(pExpr, NULL);
	COMPQUIET(pLeft, NULL);
	COMPQUIET(pRight, NULL);
	unsupported(0, "ExprSpan");
}

void sqlite3FinishTrigger(
  Parse *pParse,          /* Parser context */
  TriggerStep *pStepList, /* The triggered program */
  Token *pAll             /* Token that describes the complete CREATE TRIGGER */
)
{
	COMPQUIET(pStepList, NULL);
	COMPQUIET(pAll, NULL);
	unsupported(pParse, "FinishTrigger");
}

IdList *sqlite3IdListAppend(sqlite3 *db, IdList *pList, Token *pToken)
{
	COMPQUIET(db, NULL);
	COMPQUIET(pList, NULL);
	COMPQUIET(pToken, NULL);
	unsupported(0, "IdListAppend");
	return NULL;
}

void sqlite3IdListDelete(IdList *pList)
{
	COMPQUIET(pList, NULL);
	unsupported(0, "IdListDelete");
}

void sqlite3Insert(
  Parse *pParse,        /* Parser context */
  SrcList *pTabList,    /* Name of table into which we are inserting */
  ExprList *pList,      /* List of values to be inserted */
  Select *pSelect,      /* A SELECT statement to use as the data source */
  IdList *pColumn,      /* Column names corresponding to IDLIST. */
  int onError           /* How to handle constraint errors */
)
{
	COMPQUIET(pTabList, NULL);
	COMPQUIET(pList, NULL);
	COMPQUIET(pSelect, NULL);
	COMPQUIET(pColumn, NULL);
	COMPQUIET(onError, 0);
	unsupported(pParse, "Insert");
}

int sqlite3JoinType(Parse *pParse, Token *pA, Token *pB, Token *pC)
{
	COMPQUIET(pA, NULL);
	COMPQUIET(pB, NULL);
	COMPQUIET(pC, NULL);
	unsupported(pParse, "JoinType");
	return 0;
}

Expr *sqlite3PExpr(
  Parse *pParse,          /* Parsing context */
  int op,                 /* Expression opcode */
  Expr *pLeft,            /* Left operand */
  Expr *pRight,           /* Right operand */
  const Token *pToken     /* Argument token */
)
{
	COMPQUIET(op, 0);
	COMPQUIET(pLeft, NULL);
	COMPQUIET(pRight, NULL);
	COMPQUIET(pToken, NULL);
	unsupported(pParse, "PExpr");
	return NULL;
}

void sqlite3Pragma(
  Parse *pParse,
  Token *pId1,        /* First part of [database.]id field */
  Token *pId2,        /* Second part of [database.]id field, or NULL */
  Token *pValue,      /* Token for <value>, or NULL */
  int minusFlag       /* True if a '-' sign preceded <value> */
)
{
	COMPQUIET(pId1, NULL);
	COMPQUIET(pId2, NULL);
	COMPQUIET(pValue, NULL);
	COMPQUIET(minusFlag, 0);
	unsupported(pParse, "Pragma");
}

Expr *sqlite3RegisterExpr(Parse *pParse, Token *pToken)
{
	COMPQUIET(pToken, NULL);
	unsupported(pParse, "RegisterExpr");
	return NULL;
}

void sqlite3Reindex(Parse *pParse, Token *pName1, Token *pName2)
{
	COMPQUIET(pName1, NULL);
	COMPQUIET(pName2, NULL);
	unsupported(pParse, "Reindex");
}

void sqlite3RollbackTransaction(Parse *pParse)
{
	unsupported(pParse, "RollbackTransaction");
}

int sqlite3Select(
  Parse *pParse,         /* The parser context */
  Select *p,             /* The SELECT statement being coded. */
  SelectDest *pDest,     /* What to do with the query results */
  Select *pParent,       /* Another SELECT for which this is a sub-query */
  int parentTab,         /* Index in pParent->pSrc of this query */
  int *pParentAgg,       /* True if pParent uses aggregate functions */
  char *aff              /* If eDest is SRT_Union, the affinity string */
)
{
	COMPQUIET(p, NULL);
	COMPQUIET(pDest, NULL);
	COMPQUIET(pParent, NULL);
	COMPQUIET(parentTab, 0);
	COMPQUIET(pParentAgg, NULL);
	COMPQUIET(aff, NULL);
	unsupported(pParse, "Select");
	return 0;
}

void sqlite3SelectDelete(Select *p)
{
	COMPQUIET(p, NULL);
	unsupported(0, "SelectDelete");
}

Select *sqlite3SelectNew(
  Parse *pParse,        /* Parsing context */
  ExprList *pEList,     /* which columns to include in the result */
  SrcList *pSrc,        /* the FROM clause -- which tables to scan */
  Expr *pWhere,         /* the WHERE clause */
  ExprList *pGroupBy,   /* the GROUP BY clause */
  Expr *pHaving,        /* the HAVING clause */
  ExprList *pOrderBy,   /* the ORDER BY clause */
  int isDistinct,       /* true if the DISTINCT keyword is present */
  Expr *pLimit,         /* LIMIT value.  NULL means not used */
  Expr *pOffset         /* OFFSET value.  NULL means no offset */
)
{
	COMPQUIET(pEList, NULL);
	COMPQUIET(pSrc, NULL);
	COMPQUIET(pWhere, NULL);
	COMPQUIET(pGroupBy, NULL);
	COMPQUIET(pHaving, NULL);
	COMPQUIET(pOrderBy, NULL);
	COMPQUIET(isDistinct, 0);
	COMPQUIET(pLimit, NULL);
	COMPQUIET(pOffset, NULL);
	unsupported(pParse, NULL);
	return NULL;
}

SrcList *sqlite3SrcListAppendFromTerm(
  Parse *pParse,          /* Parsing context */
  SrcList *p,             /* The left part of the FROM clause already seen */
  Token *pTable,          /* Name of the table to add to the FROM clause */
  Token *pDatabase,       /* Name of the database containing pTable */
  Token *pAlias,          /* The right-hand side of the AS subexpression */
  Select *pSubquery,      /* A subquery used in place of a table name */
  Expr *pOn,              /* The ON clause of a join */
  IdList *pUsing          /* The USING clause of a join */
)
{
	COMPQUIET(p, NULL);
	COMPQUIET(pTable, NULL);
	COMPQUIET(pDatabase, NULL);
	COMPQUIET(pAlias, NULL);
	COMPQUIET(pSubquery, NULL);
	COMPQUIET(pOn, NULL);
	COMPQUIET(pUsing, NULL);
	unsupported(pParse, "SrcListAppendFromTerm");
	return NULL;
}

void sqlite3SrcListDelete(SrcList *pList)
{
	COMPQUIET(pList, NULL);
	unsupported(0, "SrcListDelete");
}

void sqlite3SrcListShiftJoinType(SrcList *p)
{
	COMPQUIET(p, NULL);
	unsupported(0, "SrcListShiftJoinType");
}

TriggerStep *sqlite3TriggerDeleteStep(
  sqlite3 *db,            /* Database connection */
  Token *pTableName,      /* The table from which rows are deleted */
  Expr *pWhere            /* The WHERE clause */
)
{
	COMPQUIET(db, NULL);
	COMPQUIET(pTableName, NULL);
	COMPQUIET(pWhere, NULL);
	unsupported(0, "TriggerDeleteStep");
	return NULL;
}

TriggerStep *sqlite3TriggerInsertStep(
  sqlite3 *db,        /* The database connection */
  Token *pTableName,  /* Name of the table into which we insert */
  IdList *pColumn,    /* List of columns in pTableName to insert into */
  ExprList *pEList,   /* The VALUE clause: a list of values to be inserted */
  Select *pSelect,    /* A SELECT statement that supplies values */
  int orconf          /* The conflict algorithm (OE_Abort, OE_Replace, etc.) */
)
{
	COMPQUIET(db, NULL);
	COMPQUIET(pTableName, NULL);
	COMPQUIET(pColumn, NULL);
	COMPQUIET(pEList, NULL);
	COMPQUIET(pSelect, NULL);
	COMPQUIET(orconf, 0);
	unsupported(0, "TriggerInsertStep");
	return NULL;
}

TriggerStep *sqlite3TriggerSelectStep(sqlite3 *db, Select *pSelect)
{
	COMPQUIET(db, NULL);
	COMPQUIET(pSelect, NULL);
	unsupported(0, "TriggerSelectStep");
	return NULL;
}

TriggerStep *sqlite3TriggerUpdateStep(
  sqlite3 *db,         /* The database connection */
  Token *pTableName,   /* Name of the table to be updated */
  ExprList *pEList,    /* The SET clause: list of column and new values */
  Expr *pWhere,        /* The WHERE clause */
  int orconf           /* The conflict algorithm. (OE_Abort, OE_Ignore, etc) */
)
{
	COMPQUIET(db, NULL);
	COMPQUIET(pTableName, NULL);
	COMPQUIET(pEList, NULL);
	COMPQUIET(pWhere, NULL);
	COMPQUIET(orconf, 0);
	unsupported(0, "TriggerUpdateStep");
	return NULL;
}

void sqlite3Update(
  Parse *pParse,         /* The parser context */
  SrcList *pTabList,     /* The table in which we should change things */
  ExprList *pChanges,    /* Things to be changed */
  Expr *pWhere,          /* The WHERE clause.  May be null */
  int onError            /* How to handle constraint errors */
)
{
	COMPQUIET(pTabList, NULL);
	COMPQUIET(pChanges, NULL);
	COMPQUIET(pWhere, NULL);
	COMPQUIET(onError, 0);
	unsupported(pParse, "Update");
}

void sqlite3Vacuum(Parse *pParse)
{
	unsupported(pParse, "Vacuum");
}

void sqlite3VtabArgExtend(Parse *pParse, Token *p)
{
	COMPQUIET(p, NULL);
	unsupported(pParse, "VtabArgExtend");
}

void sqlite3VtabArgInit(Parse *pParse)
{
	unsupported(pParse, "VtabArgInit");
}

void sqlite3VtabBeginParse(
  Parse *pParse,        /* Parsing context */
  Token *pName1,        /* Name of new table, or database name */
  Token *pName2,        /* Name of new table or NULL */
  Token *pModuleName    /* Name of the module for the virtual table */
)
{
	COMPQUIET(pName1, NULL);
	COMPQUIET(pName2, NULL);
	COMPQUIET(pModuleName, NULL);
	unsupported(pParse, "VtabBeginParse");
}

void sqlite3VtabFinishParse(Parse *pParse, Token *pEnd)
{
	COMPQUIET(pEnd, NULL);
	unsupported(pParse, "VtabFinishParse");
}

void sqlite3DeleteTable(Table *pTable) {
	COMPQUIET(pTable, NULL);
	unsupported(0, "DeleteTable");
}

void sqlite3DeleteTrigger(Trigger *pTrigger) {
	COMPQUIET(pTrigger, NULL);
	unsupported(0, "DeleteTrigger");
}