1 /*
2    Copyright (c) 2003, 2021, Oracle and/or its affiliates.
3 
4    This program is free software; you can redistribute it and/or modify
5    it under the terms of the GNU General Public License, version 2.0,
6    as published by the Free Software Foundation.
7 
8    This program is also distributed with certain software (including
9    but not limited to OpenSSL) that is licensed under separate terms,
10    as designated in a particular file or component or in included license
11    documentation.  The authors of MySQL hereby grant you an additional
12    permission to link the program and your derivative works with the
13    separately licensed software that they have included with MySQL.
14 
15    This program is distributed in the hope that it will be useful,
16    but WITHOUT ANY WARRANTY; without even the implied warranty of
17    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18    GNU General Public License, version 2.0, for more details.
19 
20    You should have received a copy of the GNU General Public License
21    along with this program; if not, write to the Free Software
22    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
23 */
24 
25 
26 
27 #include <signaldata/TcKeyReq.hpp>
28 
29 bool
printTCKEYREQ(FILE * output,const Uint32 * theData,Uint32 len,Uint16 receiverBlockNo)30 printTCKEYREQ(FILE * output, const Uint32 * theData, Uint32 len, Uint16 receiverBlockNo){
31 
32   const TcKeyReq * const sig = (TcKeyReq *) theData;
33 
34   UintR requestInfo = sig->requestInfo;
35 
36   fprintf(output, " apiConnectPtr: H\'%.8x, apiOperationPtr: H\'%.8x\n",
37 	  sig->apiConnectPtr, sig->apiOperationPtr);
38   fprintf(output, " Operation: %s, Flags: ",
39 	  sig->getOperationType(requestInfo) == ZREAD    ? "Read" :
40 	  sig->getOperationType(requestInfo) == ZREAD_EX ? "Read-Ex" :
41 	  sig->getOperationType(requestInfo) == ZUPDATE  ? "Update" :
42 	  sig->getOperationType(requestInfo) == ZINSERT  ? "Insert" :
43 	  sig->getOperationType(requestInfo) == ZDELETE  ? "Delete" :
44 	  sig->getOperationType(requestInfo) == ZWRITE   ? "Write"  :
45           sig->getOperationType(requestInfo) == ZUNLOCK  ? "Unlock" :
46           sig->getOperationType(requestInfo) == ZREFRESH ? "Refresh" :
47 	  "Unknown");
48   {
49     if(sig->getDirtyFlag(requestInfo)){
50       fprintf(output, "Dirty ");
51     }
52     if(sig->getStartFlag(requestInfo)){
53       fprintf(output, "Start ");
54     }
55     if(sig->getExecuteFlag(requestInfo)){
56       fprintf(output, "Execute ");
57     }
58     if(sig->getCommitFlag(requestInfo)){
59       fprintf(output, "Commit ");
60     }
61     if (sig->getNoDiskFlag(requestInfo)) {
62       fprintf(output, "NoDisk ");
63     }
64 
65     UintR TcommitType = sig->getAbortOption(requestInfo);
66     if (TcommitType == TcKeyReq::AbortOnError) {
67       fprintf(output, "AbortOnError ");
68     } else if (TcommitType == TcKeyReq::IgnoreError) {
69       fprintf(output, "IgnoreError ");
70     }//if
71 
72     if(sig->getSimpleFlag(requestInfo)){
73       fprintf(output, "Simple ");
74     }
75     if(sig->getScanIndFlag(requestInfo)){
76       fprintf(output, "ScanInd ");
77     }
78     if(sig->getInterpretedFlag(requestInfo)){
79       fprintf(output, "Interpreted ");
80     }
81     if(sig->getDistributionKeyFlag(sig->requestInfo)){
82       fprintf(output, "d-key ");
83     }
84     if(sig->getViaSPJFlag(sig->requestInfo)){
85       fprintf(output, " spj");
86     }
87     if(sig->getQueueOnRedoProblemFlag(sig->requestInfo))
88       fprintf(output, "Queue ");
89 
90     if(sig->getDeferredConstraints(sig->requestInfo))
91       fprintf(output, "Deferred-constraints ");
92 
93     if(sig->getDisableFkConstraints(sig->requestInfo))
94       fprintf(output, "Disable-FK-constraints ");
95 
96     fprintf(output, "\n");
97   }
98 
99   const int keyLen     = sig->getKeyLength(requestInfo);
100   const int attrInThis = sig->getAIInTcKeyReq(requestInfo);
101   const int attrLen = sig->getAttrinfoLen(sig->attrLen);
102   fprintf(output,
103 	  " keyLen: %d, attrLen: %d, AI in this: %d, tableId: %d, "
104 	  "tableSchemaVer: %d\n",
105 	  keyLen, attrLen, attrInThis,
106 	  sig->tableId, sig->tableSchemaVersion);
107 
108   fprintf(output, " transId(1, 2): (H\'%.8x, H\'%.8x)\n -- Variable Data --\n",
109 	  sig->transId1, sig->transId2);
110 
111   if (len >= TcKeyReq::StaticLength) {
112     Uint32 restLen = (len - TcKeyReq::StaticLength);
113     const Uint32 * rest = &sig->scanInfo;
114     while(restLen >= 7){
115       fprintf(output,
116               " H\'%.8x H\'%.8x H\'%.8x H\'%.8x H\'%.8x H\'%.8x H\'%.8x\n",
117               rest[0], rest[1], rest[2], rest[3],
118               rest[4], rest[5], rest[6]);
119       restLen -= 7;
120       rest += 7;
121     }
122     if(restLen > 0){
123       for(Uint32 i = 0; i<restLen; i++)
124         fprintf(output, " H\'%.8x", rest[i]);
125       fprintf(output, "\n");
126     }
127   } else {
128     fprintf(output, "*** invalid len %u ***\n", len);
129   }
130   return true;
131 }
132 
133