Beispiel #1
0
static void Term_print(ExprTerm term) {
   switch (term.t) {
      case TERM_ID:
         printf("%s", term.id);
         break;
      case TERM_LITERAL:
         Literal_print(term.val);
         break;
      case TERM_NULL:
         printf("NULL");
         break;
      case TERM_COLREF:
         if (term.ref->tableName)
            printf("%s.", term.ref->tableName);
         printf("%s", term.ref->columnName);
         break;
      case TERM_FUNC:
         switch (term.f.t) {
            case FUNC_AVG:
               printf("AVG(");
               Expression_print(term.f.expr);
               printf(")");
               break;
            case FUNC_COUNT:
               printf("COUNT(");
               Expression_print(term.f.expr);
               printf(")");
               break;
            case FUNC_MAX:
               printf("MAX(");
               Expression_print(term.f.expr);
               printf(")");
               break;
            case FUNC_MIN:
               printf("MIN(");
               Expression_print(term.f.expr);
               printf(")");
               break;
            case FUNC_SUM:
               printf("SUM(");
               Expression_print(term.f.expr);
               printf(")");
               break;
            default:
               printf("Unknown function");
         }
         break;
      default:
         printf("Unknown term type");
   }
}
Beispiel #2
0
void Constraint_print(void *constraint_voidp)
{
    Constraint_t *constraint = (Constraint_t *)constraint_voidp;
    switch(constraint->t)
    {
    case CONS_DEFAULT:
        printf("Default: ");
        Literal_print(constraint->constraint.default_val);
        break;
    case CONS_PRIMARY_KEY:
        printf("Primary Key");
        break;
    case CONS_UNIQUE:
        printf("Unique");
        break;
    case CONS_FOREIGN_KEY:
        printf("Foreign key (%s, %s)", constraint->constraint.ref.table_name,
               constraint->constraint.ref.table_col_name);
        break;
    case CONS_AUTO_INCREMENT:
        printf("Auto increment");
        break;
    case CONS_NOT_NULL:
        printf("Not null");
        break;
    case CONS_CHECK:
        printf("Check: ");
        Condition_print(constraint->constraint.check);
        break;
    case CONS_SIZE:
        printf("Size: %u", constraint->constraint.size);
        break;
    default:
        printf("Unknown constraint type");
    }
}