Implementation of index added via CREATE\ALTER TABLE commands. */
| 5723 | |
| 5724 | /* Implementation of index added via CREATE\ALTER TABLE commands. */ |
| 5725 | void comdb2AddIndex( |
| 5726 | Parse *pParse, /* All information about this parse */ |
| 5727 | Token *pName, /* Index name (Optional) */ |
| 5728 | ExprList *pList, /* A list of columns to be indexed */ |
| 5729 | int onError, /* OE_Abort, OE_Ignore, OE_Replace, or OE_None */ |
| 5730 | Expr *pPIWhere, /* WHERE clause for partial indices */ |
| 5731 | const char *zStart, /* Start of WHERE clause token text */ |
| 5732 | const char *zEnd, /* End of WHERE clause token text */ |
| 5733 | int sortOrder, /* Sort order of primary key when pList==NULL */ |
| 5734 | u8 idxType, /* The index type */ |
| 5735 | int withOpts, /* WITH options (DATACOPY) */ |
| 5736 | ExprList *pdList /* A list of columns in the partial datacopy */ |
| 5737 | ) |
| 5738 | { |
| 5739 | if (comdb2IsPrepareOnly(pParse)) |
| 5740 | return; |
| 5741 | |
| 5742 | struct comdb2_ddl_context *ctx = pParse->comdb2_ddl_ctx; |
| 5743 | char *keyname; |
| 5744 | |
| 5745 | if (use_sqlite_impl(pParse)) { |
| 5746 | assert(ctx == 0); |
| 5747 | assert(idxType != SQLITE_IDXTYPE_DUPKEY); |
| 5748 | sqlite3CreateIndex(pParse, 0, 0, 0, pList, onError, 0, 0, 0, 0, |
| 5749 | idxType); |
| 5750 | return; |
| 5751 | } |
| 5752 | |
| 5753 | if (ctx == 0) { |
| 5754 | /* An error must have been set. */ |
| 5755 | assert(pParse->rc != 0); |
| 5756 | return; |
| 5757 | } |
| 5758 | |
| 5759 | if ((ctx->flags & DDL_NOOP) != 0) { |
| 5760 | return; |
| 5761 | } |
| 5762 | |
| 5763 | if (pName && pName->n > 0) { |
| 5764 | keyname = comdb2_strndup(ctx->mem, pName->z, pName->n); |
| 5765 | if (keyname == 0) |
| 5766 | goto oom; |
| 5767 | sqlite3Dequote(keyname); |
| 5768 | } else { |
| 5769 | /* Key name not specified, one will be generated later. */ |
| 5770 | keyname = 0; |
| 5771 | } |
| 5772 | |
| 5773 | comdb2AddIndexInt(pParse, keyname, pList, onError, pPIWhere, zStart, |
| 5774 | zEnd, sortOrder, idxType, withOpts, pdList); |
| 5775 | if (pParse->rc) |
| 5776 | goto cleanup; |
| 5777 | |
| 5778 | return; |
| 5779 | |
| 5780 | oom: |
| 5781 | setError(pParse, SQLITE_NOMEM, "System out of memory"); |
| 5782 |
no test coverage detected