1 /* Copyright (c) 2003-2005 MySQL AB
2 Use is subject to license terms
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 as published by
6 the Free Software Foundation; version 2 of the License.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12
13 You should have received a copy of the GNU General Public License
14 along with this program; if not, write to the Free Software
15 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
16
17 #include <signaldata/CreateTrig.hpp>
18
printCREATE_TRIG_REQ(FILE * output,const Uint32 * theData,Uint32 len,Uint16 receiverBlockNo)19 bool printCREATE_TRIG_REQ(FILE * output, const Uint32 * theData, Uint32 len, Uint16 receiverBlockNo)
20 {
21 const CreateTrigReq * const sig = (CreateTrigReq *) theData;
22
23 //char triggerName[MAX_TAB_NAME_SIZE];
24 char triggerType[32];
25 char triggerActionTime[32];
26 char triggerEvent[32];
27
28 //sig->getTriggerName((char *) &triggerName);
29 switch (sig->getTriggerType()) {
30 case(TriggerType::SECONDARY_INDEX):
31 BaseString::snprintf(triggerType, sizeof(triggerType), "SECONDARY_INDEX");
32 break;
33 case(TriggerType::SUBSCRIPTION):
34 BaseString::snprintf(triggerType, sizeof(triggerType), "SUBSCRIPTION");
35 break;
36 case(TriggerType::ORDERED_INDEX):
37 BaseString::snprintf(triggerType, sizeof(triggerType), "ORDERED_INDEX");
38 break;
39 default:
40 BaseString::snprintf(triggerType, sizeof(triggerType), "UNKNOWN [%d]", (int)sig->getTriggerType());
41 break;
42 }
43 switch (sig->getTriggerActionTime()) {
44 case (TriggerActionTime::TA_BEFORE):
45 BaseString::snprintf(triggerActionTime, sizeof(triggerActionTime), "BEFORE");
46 break;
47 case(TriggerActionTime::TA_AFTER):
48 BaseString::snprintf(triggerActionTime, sizeof(triggerActionTime), "AFTER");
49 break;
50 case (TriggerActionTime::TA_DEFERRED):
51 BaseString::snprintf(triggerActionTime, sizeof(triggerActionTime), "DEFERRED");
52 break;
53 case (TriggerActionTime::TA_DETACHED):
54 BaseString::snprintf(triggerActionTime, sizeof(triggerActionTime), "DETACHED");
55 break;
56 default:
57 BaseString::snprintf(triggerActionTime, sizeof(triggerActionTime),
58 "UNKNOWN [%d]", (int)sig->getTriggerActionTime());
59 break;
60 }
61 switch (sig->getTriggerEvent()) {
62 case (TriggerEvent::TE_INSERT):
63 BaseString::snprintf(triggerEvent, sizeof(triggerEvent), "INSERT");
64 break;
65 case(TriggerEvent::TE_DELETE):
66 BaseString::snprintf(triggerEvent, sizeof(triggerEvent), "DELETE");
67 break;
68 case(TriggerEvent::TE_UPDATE):
69 BaseString::snprintf(triggerEvent, sizeof(triggerEvent), "UPDATE");
70 break;
71 case(TriggerEvent::TE_CUSTOM):
72 BaseString::snprintf(triggerEvent, sizeof(triggerEvent), "CUSTOM");
73 break;
74 default:
75 BaseString::snprintf(triggerEvent, sizeof(triggerEvent), "UNKNOWN [%d]", (int)sig->getTriggerEvent());
76 break;
77 }
78
79 fprintf(output, "User: %u, ", sig->getUserRef());
80 //fprintf(output, "Trigger name: \"%s\"\n", triggerName);
81 fprintf(output, "Type: %s, ", triggerType);
82 fprintf(output, "Action: %s, ", triggerActionTime);
83 fprintf(output, "Event: %s, ", triggerEvent);
84 fprintf(output, "Trigger id: %u, ", sig->getTriggerId());
85 fprintf(output, "Table id: %u, ", sig->getTableId());
86 fprintf(output, "Monitor replicas: %s ", (sig->getMonitorReplicas())?"true":"false");
87 fprintf(output, "Monitor all attributes: %s ", (sig->getMonitorAllAttributes())?"true":"false");
88 const AttributeMask& attributeMask = sig->getAttributeMask();
89
90 char buf[MAXNROFATTRIBUTESINWORDS * 8 + 1];
91 fprintf(output, "Attribute mask: %s", attributeMask.getText(buf));
92 fprintf(output, "\n");
93
94 return false;
95 }
96
printCREATE_TRIG_CONF(FILE * output,const Uint32 * theData,Uint32 len,Uint16 receiverBlockNo)97 bool printCREATE_TRIG_CONF(FILE * output, const Uint32 * theData, Uint32 len, Uint16 receiverBlockNo)
98 {
99 const CreateTrigConf * const sig = (CreateTrigConf *) theData;
100
101 fprintf(output, "User: %u, ", sig->getUserRef());
102 fprintf(output, "Trigger id: %u, ", sig->getTriggerId());
103 fprintf(output, "Table id: %u, ", sig->getTableId());
104 fprintf(output, "\n");
105
106 return false;
107 }
108
printCREATE_TRIG_REF(FILE * output,const Uint32 * theData,Uint32 len,Uint16 receiverBlockNo)109 bool printCREATE_TRIG_REF(FILE * output, const Uint32 * theData, Uint32 len, Uint16 receiverBlockNo)
110 {
111 const CreateTrigRef * const sig = (CreateTrigRef *) theData;
112
113 fprintf(output, "User: %u, ", sig->getUserRef());
114 fprintf(output, "Trigger id: %u, ", sig->getTriggerId());
115 fprintf(output, "Table id: %u, ", sig->getTableId());
116 fprintf(output, "Error code: %u, ", sig->getErrorCode());
117 fprintf(output, "\n");
118
119 return false;
120 }
121