~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to examples/simple.c

  • Committer: Brian Aker
  • Date: 2010-11-06 15:43:10 UTC
  • mfrom: (1908.1.1 merge)
  • Revision ID: brian@tangent.org-20101106154310-g1jpjzwbc53pfc4f
Filesort encapsulation, plus modification to copy contructor

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
 * Copyright (C) 2008 Eric Day (eday@oddments.org)
5
5
 * All rights reserved.
6
6
 *
7
 
 * Redistribution and use in source and binary forms, with or without
8
 
 * modification, are permitted provided that the following conditions are
9
 
 * met:
10
 
 *
11
 
 *     * Redistributions of source code must retain the above copyright
12
 
 * notice, this list of conditions and the following disclaimer.
13
 
 *
14
 
 *     * Redistributions in binary form must reproduce the above
15
 
 * copyright notice, this list of conditions and the following disclaimer
16
 
 * in the documentation and/or other materials provided with the
17
 
 * distribution.
18
 
 *
19
 
 *     * The names of its contributors may not be used to endorse or
20
 
 * promote products derived from this software without specific prior
21
 
 * written permission.
22
 
 *
23
 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24
 
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25
 
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26
 
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27
 
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28
 
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29
 
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30
 
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31
 
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32
 
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33
 
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
 
 *
 
7
 * Use and distribution licensed under the BSD license.  See
 
8
 * the COPYING.BSD file in the root source directory for full text.
35
9
 */
36
10
 
37
 
 
38
11
#include <stdio.h>
39
12
#include <stdlib.h>
40
13
#include <string.h>
54
27
  const char *query= "SELECT TABLE_SCHEMA,TABLE_NAME FROM TABLES";
55
28
  drizzle_verbose_t verbose= DRIZZLE_VERBOSE_NEVER;
56
29
  drizzle_st drizzle;
57
 
  drizzle_con_st *con= (drizzle_con_st*)malloc(sizeof(drizzle_con_st));
 
30
  drizzle_con_st con;
58
31
  drizzle_result_st result;
59
32
  drizzle_return_t ret;
60
33
  int x;
109
82
 
110
83
  drizzle_set_verbose(&drizzle, verbose);
111
84
 
112
 
  if (drizzle_con_create(&drizzle, con) == NULL)
 
85
  if (drizzle_con_create(&drizzle, &con) == NULL)
113
86
  {
114
87
    printf("drizzle_con_create:NULL\n");
115
88
    return 1;
116
89
  }
117
90
 
118
91
  if (mysql)
119
 
    drizzle_con_add_options(con, DRIZZLE_CON_MYSQL);
120
 
 
121
 
  drizzle_con_set_tcp(con, host, port);
122
 
  drizzle_con_set_db(con, db);
123
 
 
124
 
  (void)drizzle_query_str(con, &result, query, &ret);
 
92
    drizzle_con_add_options(&con, DRIZZLE_CON_MYSQL);
 
93
 
 
94
  drizzle_con_set_tcp(&con, host, port);
 
95
  drizzle_con_set_db(&con, db);
 
96
 
 
97
  (void)drizzle_query_str(&con, &result, query, &ret);
125
98
  if (ret != DRIZZLE_RETURN_OK)
126
99
  {
127
 
    printf("drizzle_query:%s\n", drizzle_con_error(con));
 
100
    printf("drizzle_query:%s\n", drizzle_con_error(&con));
128
101
    return 1;
129
102
  }
130
103
 
131
104
  ret= drizzle_result_buffer(&result);
132
105
  if (ret != DRIZZLE_RETURN_OK)
133
106
  {
134
 
    printf("drizzle_result_buffer:%s\n", drizzle_con_error(con));
 
107
    printf("drizzle_result_buffer:%s\n", drizzle_con_error(&con));
135
108
    return 1;
136
109
  }
137
110
 
143
116
  }
144
117
 
145
118
  drizzle_result_free(&result);
146
 
  drizzle_con_free(con);
 
119
  drizzle_con_free(&con);
147
120
  drizzle_free(&drizzle);
148
121
 
149
 
  free(con);
150
122
  return 0;
151
123
}