MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
too_basic.cpp
1 /*
2  Copyright (C) 2003-2006 MySQL AB
3  All rights reserved. Use is subject to license terms.
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; version 2 of the License.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program; if not, write to the Free Software
16  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18 
19 
20 
21 /****** THIS LINE IS 80 CHARACTERS WIDE - DO *NOT* EXCEED 80 CHARACTERS! ****/
22 
23 #include <ndb_global.h>
24 #include <NdbOut.hpp>
25 
26 //#include <cfg/cfg_db.h>
27 //#include <init/init_start_restart.h>
28 //#include "pcn_types.h"
29 //#include <testing/testing.h>
30 
31 extern "C" {
32 #include <cfg_db.h>
33 }
34 
35 typedef struct Employee {
36 
37  UInt32_t EmpNo;
38  char FirstName[22];
39  char LastName[22];
40 
41 } Employee_t;
42 #define CHECK_DB_CALL( Call ) \
43  CheckDbCall( Call, #Call, __FILE__, __LINE__ )
44 
45 
46 
47 /* --- Exported functions --- */
48 
49 /*---------------------------------------------------------------------------*/
50 int main() {
51 
52 
53  char EMP_TABLE_NAME[] = "employees";
54 
55  Employee_t t;
56 
57  CFG_DbColumnDesc_t EmpColDesc[] = {
58  { "first_name", CFG_DB_CHAR, PCN_SIZE_OF( Employee, FirstName ),
59  PCN_FALSE },
60  { "emp_no", CFG_DB_INT, PCN_SIZE_OF( Employee, EmpNo ), PCN_TRUE },
61  { "last_name", CFG_DB_CHAR, PCN_SIZE_OF( Employee, LastName ),
62  PCN_FALSE },
63  };
64 
65  int EmpNbCol = 3;
66 
67 
68 
69  CFG_DbColumnBinding_t ColBindings[] = {
70  CFG_DB_BINDING( "last_name", CFG_DB_CHAR, Employee, LastName ),
71  CFG_DB_BINDING( "emp_no", CFG_DB_INT, Employee, EmpNo ),
72  CFG_DB_BINDING( "first_name", CFG_DB_CHAR, Employee, FirstName)
73  };
74 
75 
76  Employee_t EMP_TABLE_DATA[] = {
77  { 1242, "Joe", "Dalton" },
78  { 123, "Lucky", "Luke" },
79  { 456, "Averell", "Dalton" },
80  { 8976, "Gaston", "Lagaffe" }
81  };
82 
83 
84  char* DbName;
85 
86  DbName = NULL;
87 
88 
89  // On Linux: will destroy the table to start from a clean slate.
90 
91  CFG_DbDestroy();
92  CFG_DbOpen( &DbName ) ;
93  CFG_DbCreateTable( EMP_TABLE_NAME,
94  EmpNbCol, EmpColDesc );
95 
96  CFG_DbTableExists( EMP_TABLE_NAME );
97 
98  //#ifndef CELLO_PLATFORM
99  //CHECK_DB_CALL( CFG_DbDumpSchema( stdout ) );
100  //#endif
101 
102  CFG_DbClose();
103  // INIT_StopSystem();
104 
105 }
106 
107