MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / execute

Method execute

examples/dbcrypt/CryptApplication.cpp:105–197  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

103 // passed to target database when using execute statement)
104
105 void execute(const char* dbName, const Action a)
106 {
107 status->init();
108
109 p = master->getDispatcher();
110
111 p->setDbCryptCallback(status, &key);
112 if (status->getState() & IStatus::STATE_ERRORS)
113 throw "setDbCryptCallback";
114
115 char s[256];
116 sprintf(s, "localhost:%s", dbName);
117 att = p->attachDatabase(status, s, 0, NULL);
118 if (status->getState() & IStatus::STATE_ERRORS)
119 throw "attachDatabase";
120
121 if (a != NONE)
122 {
123 tra = att->startTransaction(status, 0, NULL);
124 if (status->getState() & IStatus::STATE_ERRORS)
125 throw "startTransaction";
126 }
127
128 switch(a)
129 {
130 case ENC:
131 att->execute(status, tra, 0,
132 "ALTER DATABASE ENCRYPT WITH \"fbSampleDbCrypt\"", 3, NULL, NULL, NULL, NULL);
133 if (status->getState() & IStatus::STATE_ERRORS)
134 throw "execute";
135 break;
136
137 case DEC:
138 att->execute(status, tra, 0, "ALTER DATABASE DECRYPT", 3, NULL, NULL, NULL, NULL);
139 if (status->getState() & IStatus::STATE_ERRORS)
140 throw "execute";
141 break;
142
143 case EX_LCL:
144 case EX_RMT:
145 {
146 FB_MESSAGE(Output, CheckStatusWrapper,
147 (FB_VARCHAR(31), logon)
148 ) output(status, master);
149
150 const char* sqlL = "select current_user from rdb$database";
151 const char* sqlR = "execute block returns(logon varchar(31)) as begin "
152 "execute statement 'select current_user from rdb$database' "
153 "on external 'localhost:employee' as user 'test' password 'test' into :logon; "
154 "suspend; end";
155 const char* sql = a == EX_LCL ? sqlL : sqlR;
156
157 curs = att->openCursor(status, tra, 0, sql, 3, NULL, NULL, output.getMetadata(), NULL, 0);
158 if (status->getState() & IStatus::STATE_ERRORS)
159 throw "openCursor";
160
161 printf("\nExec SQL: %s\nReturns:\n", sql);
162 while (curs->fetchNext(status, output.getData()) == IStatus::RESULT_OK)

Callers 10

Triggers.cppFile · 0.45
mainFunction · 0.45
mainFunction · 0.45
mainFunction · 0.45
mainFunction · 0.45
mainFunction · 0.45
mainFunction · 0.45
mainFunction · 0.45
mainFunction · 0.45
mainFunction · 0.45

Calls 15

outputFunction · 0.85
getcharFunction · 0.85
initMethod · 0.45
getDispatcherMethod · 0.45
setDbCryptCallbackMethod · 0.45
getStateMethod · 0.45
attachDatabaseMethod · 0.45
startTransactionMethod · 0.45
openCursorMethod · 0.45
getMetadataMethod · 0.45
fetchNextMethod · 0.45
getDataMethod · 0.45

Tested by

no test coverage detected