Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #include "postgres.h"
00030
00031 #include "access/printtup.h"
00032 #include "access/xact.h"
00033 #include "commands/copy.h"
00034 #include "commands/createas.h"
00035 #include "commands/matview.h"
00036 #include "executor/functions.h"
00037 #include "executor/tstoreReceiver.h"
00038 #include "libpq/libpq.h"
00039 #include "libpq/pqformat.h"
00040 #include "utils/portal.h"
00041
00042
00043
00044
00045
00046
00047 static void
00048 donothingReceive(TupleTableSlot *slot, DestReceiver *self)
00049 {
00050 }
00051
00052 static void
00053 donothingStartup(DestReceiver *self, int operation, TupleDesc typeinfo)
00054 {
00055 }
00056
00057 static void
00058 donothingCleanup(DestReceiver *self)
00059 {
00060
00061 }
00062
00063
00064
00065
00066
00067 static DestReceiver donothingDR = {
00068 donothingReceive, donothingStartup, donothingCleanup, donothingCleanup,
00069 DestNone
00070 };
00071
00072 static DestReceiver debugtupDR = {
00073 debugtup, debugStartup, donothingCleanup, donothingCleanup,
00074 DestDebug
00075 };
00076
00077 static DestReceiver spi_printtupDR = {
00078 spi_printtup, spi_dest_startup, donothingCleanup, donothingCleanup,
00079 DestSPI
00080 };
00081
00082
00083 DestReceiver *None_Receiver = &donothingDR;
00084
00085
00086
00087
00088
00089
00090 void
00091 BeginCommand(const char *commandTag, CommandDest dest)
00092 {
00093
00094 }
00095
00096
00097
00098
00099
00100 DestReceiver *
00101 CreateDestReceiver(CommandDest dest)
00102 {
00103 switch (dest)
00104 {
00105 case DestRemote:
00106 case DestRemoteExecute:
00107 return printtup_create_DR(dest);
00108
00109 case DestNone:
00110 return &donothingDR;
00111
00112 case DestDebug:
00113 return &debugtupDR;
00114
00115 case DestSPI:
00116 return &spi_printtupDR;
00117
00118 case DestTuplestore:
00119 return CreateTuplestoreDestReceiver();
00120
00121 case DestIntoRel:
00122 return CreateIntoRelDestReceiver(NULL);
00123
00124 case DestCopyOut:
00125 return CreateCopyDestReceiver();
00126
00127 case DestSQLFunction:
00128 return CreateSQLFunctionDestReceiver();
00129
00130 case DestTransientRel:
00131 return CreateTransientRelDestReceiver(InvalidOid);
00132 }
00133
00134
00135 return &donothingDR;
00136 }
00137
00138
00139
00140
00141
00142 void
00143 EndCommand(const char *commandTag, CommandDest dest)
00144 {
00145 switch (dest)
00146 {
00147 case DestRemote:
00148 case DestRemoteExecute:
00149
00150
00151
00152
00153
00154 pq_putmessage('C', commandTag, strlen(commandTag) + 1);
00155 break;
00156
00157 case DestNone:
00158 case DestDebug:
00159 case DestSPI:
00160 case DestTuplestore:
00161 case DestIntoRel:
00162 case DestCopyOut:
00163 case DestSQLFunction:
00164 case DestTransientRel:
00165 break;
00166 }
00167 }
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181 void
00182 NullCommand(CommandDest dest)
00183 {
00184 switch (dest)
00185 {
00186 case DestRemote:
00187 case DestRemoteExecute:
00188
00189
00190
00191
00192
00193 if (PG_PROTOCOL_MAJOR(FrontendProtocol) >= 3)
00194 pq_putemptymessage('I');
00195 else
00196 pq_putmessage('I', "", 1);
00197 break;
00198
00199 case DestNone:
00200 case DestDebug:
00201 case DestSPI:
00202 case DestTuplestore:
00203 case DestIntoRel:
00204 case DestCopyOut:
00205 case DestSQLFunction:
00206 case DestTransientRel:
00207 break;
00208 }
00209 }
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222 void
00223 ReadyForQuery(CommandDest dest)
00224 {
00225 switch (dest)
00226 {
00227 case DestRemote:
00228 case DestRemoteExecute:
00229 if (PG_PROTOCOL_MAJOR(FrontendProtocol) >= 3)
00230 {
00231 StringInfoData buf;
00232
00233 pq_beginmessage(&buf, 'Z');
00234 pq_sendbyte(&buf, TransactionBlockStatusCode());
00235 pq_endmessage(&buf);
00236 }
00237 else if (PG_PROTOCOL_MAJOR(FrontendProtocol) >= 2)
00238 pq_putemptymessage('Z');
00239
00240 pq_flush();
00241 break;
00242
00243 case DestNone:
00244 case DestDebug:
00245 case DestSPI:
00246 case DestTuplestore:
00247 case DestIntoRel:
00248 case DestCopyOut:
00249 case DestSQLFunction:
00250 case DestTransientRel:
00251 break;
00252 }
00253 }