PostgreSQL Source Code: src/backend/commands/copyfrom.c Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
22
23#include <ctype.h>
25#include <sys/stat.h>
26
53
54
55
56
57
58
59
60
61
62
63#define MAX_BUFFERED_TUPLES 1000
64
65
66
67
68
69#define MAX_BUFFERED_BYTES 65535
70
71
72
73
74
75#define MAX_PARTITION_BUFFERS 32
76
77
79{
83
86
88
89
90
91
92
93
95{
97 int bufferedTuples;
98 int bufferedBytes;
104
105
106
108
109
110
111
112
114 Oid *typioparam);
121
122
123
124
125
126
127
128
129
130
136};
137
138
144};
145
146
152};
153
154
157{
158 if (opts->csv_mode)
160 else if (opts->binary)
162
163
165}
166
167
168static void
170{
172
173
174
175
176
177
179 {
182 }
183 else
186
188
189
190
191
192
195 cstate->raw_fields = (char **) palloc(attr_count * sizeof(char *));
196}
197
198
199
200
201
202static void
204 Oid *typioparam)
205{
206 Oid func_oid;
207
210}
211
212
213static void
215{
216
217}
218
219
220static void
222{
223
225}
226
227
228
229
230
231static void
234{
235 Oid func_oid;
236
239}
240
241
242static void
244{
245
246}
247
248
249
250
251
252
253void
255{
257
259 {
262 return;
263 }
265 {
266
268 errcontext("COPY %s, line %" PRIu64 ", column %s",
272 else
276 }
277 else
278 {
280 {
281
282 char *attval;
283
285 errcontext("COPY %s, line %" PRIu64 ", column %s: \"%s\"",
289 attval);
291 }
293 {
294
295 errcontext("COPY %s, line %" PRIu64 ", column %s: null input",
299 }
300 else
301 {
302
303
304
305
306
308 {
309 char *lineval;
310
312 errcontext("COPY %s, line %" PRIu64 ": \"%s\"",
316 }
317 else
318 {
322 }
323 }
324 }
325}
326
327
328
329
330
331
332char *
334{
335#define MAX_COPY_DATA_DISPLAY 100
336
337 int slen = strlen(str);
339 char *res;
340
341
344
345
347
348
349
350
353 strcpy(res + len, "...");
354
355 return res;
356}
357
358
359
360
361
364{
366
371 buffer->nused = 0;
372
373 return buffer;
374}
375
376
377
378
379static inline void
382{
384
386
387
389
391}
392
393
394
395
396
397
398
399static void
402 int ti_options)
403{
407 miinfo->cstate = cstate;
408 miinfo->estate = estate;
409 miinfo->mycid = mycid;
411
412
413
414
415
416
419}
420
421
422
423
424static inline bool
426{
429 return true;
430 return false;
431}
432
433
434
435
436static inline bool
438{
440}
441
442
443
444
445static inline void
448 int64 *processed)
449{
452 int nused = buffer->nused;
455 int i;
456
458 {
459 int batch_size = resultRelInfo->ri_BatchSize;
460 int sent = 0;
461
463
464
466 Assert(batch_size > 1);
467
468
469
470
471
474
475 while (sent < nused)
476 {
477 int size = (batch_size < nused - sent) ? batch_size : (nused - sent);
478 int inserted = size;
480
481
482 rslots =
484 resultRelInfo,
485 &slots[sent],
486 NULL,
487 &inserted);
488
489 sent += size;
490
491
492 if (inserted <= 0)
493 continue;
494
495
498
499
500 if (resultRelInfo->ri_TrigDesc != NULL &&
502 {
504
505 for (i = 0; i < inserted; i++)
506 {
508
509
510
511
512
514
516 slot, NIL,
518 }
519 }
520
521
522 *processed += inserted;
524 *processed);
525 }
526
527 for (i = 0; i < nused; i++)
529
530
532 }
533 else
534 {
540
542
543
544
545
546
548
549
550
551
552
555 slots,
556 nused,
557 mycid,
558 ti_options,
561
562 for (i = 0; i < nused; i++)
563 {
564
565
566
567
569 {
570 List *recheckIndexes;
571
573 recheckIndexes =
575 buffer->slots[i], estate, false,
576 false, NULL, NIL, false);
578 slots[i], recheckIndexes,
581 }
582
583
584
585
586
587 else if (resultRelInfo->ri_TrigDesc != NULL &&
590 {
595 }
596
598 }
599
600
601 *processed += nused;
603 *processed);
604
605
607 cstate->cur_lineno = save_cur_lineno;
608 }
609
610
611 buffer->nused = 0;
612}
613
614
615
616
617
618
619static inline void
622{
624 int i;
625
626
628
629
631
633 {
636 }
637 else
639
640
643
647
649}
650
651
652
653
654
655
656
657
658
659
660
661static inline void
663 int64 *processed)
664{
666
668 {
670
672 }
673
676
677
678
679
680
681
682
684 {
686
688
689
690
691
692
694 {
695
696
697
698
700 "MAX_PARTITION_BUFFERS must be >= 2");
701
705 }
706
709 }
710}
711
712
713
714
715static inline void
717{
719
722
724}
725
726
727
728
729
730
731
732
733
737{
739 int nused;
740
741 Assert(buffer != NULL);
743
744 nused = buffer->nused;
745
746 if (buffer->slots[nused] == NULL)
748 return buffer->slots[nused];
749}
750
751
752
753
754
755static inline void
758{
760
761 Assert(buffer != NULL);
763
764
766
767
769
770
773}
774
775
776
777
780{
789
793 int ti_options = 0;
797 int64 processed = 0;
798 int64 excluded = 0;
799 bool has_before_insert_row_trig;
800 bool has_instead_insert_row_trig;
801 bool leafpart_use_multi_insert = false;
802
805
808
809
810
811
812
813
814 if (cstate->rel->rd_rel->relkind != RELKIND_RELATION &&
815 cstate->rel->rd_rel->relkind != RELKIND_FOREIGN_TABLE &&
816 cstate->rel->rd_rel->relkind != RELKIND_PARTITIONED_TABLE &&
819 {
820 if (cstate->rel->rd_rel->relkind == RELKIND_VIEW)
822 (errcode(ERRCODE_WRONG_OBJECT_TYPE),
823 errmsg("cannot copy to view \"%s\"",
825 errhint("To enable copying to a view, provide an INSTEAD OF INSERT trigger.")));
826 else if (cstate->rel->rd_rel->relkind == RELKIND_MATVIEW)
828 (errcode(ERRCODE_WRONG_OBJECT_TYPE),
829 errmsg("cannot copy to materialized view \"%s\"",
831 else if (cstate->rel->rd_rel->relkind == RELKIND_SEQUENCE)
833 (errcode(ERRCODE_WRONG_OBJECT_TYPE),
834 errmsg("cannot copy to sequence \"%s\"",
836 else
838 (errcode(ERRCODE_WRONG_OBJECT_TYPE),
839 errmsg("cannot copy to non-table relation \"%s\"",
841 }
842
843
844
845
846
847
848 if (RELKIND_HAS_STORAGE(cstate->rel->rd_rel->relkind) &&
852
853
854
855
856
857
858
859
860
861
862
863
865 {
866
867
868
869
870
871
872
873
874
875 if (cstate->rel->rd_rel->relkind == RELKIND_PARTITIONED_TABLE)
876 {
878 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
879 errmsg("cannot perform COPY FREEZE on a partitioned table")));
880 }
881
882
883 if (cstate->rel->rd_rel->relkind == RELKIND_FOREIGN_TABLE)
885 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
886 errmsg("cannot perform COPY FREEZE on a foreign table")));
887
888
889
890
891
892
893
894
895
899 (errcode(ERRCODE_INVALID_TRANSACTION_STATE),
900 errmsg("cannot perform COPY FREEZE because of prior transaction activity")));
901
905 (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
906 errmsg("cannot perform COPY FREEZE because the table was not created or truncated in the current subtransaction")));
907
909 }
910
911
912
913
914
915
920
921
923
925
926
927
928
929
932 mtstate->ps.state = estate;
937
941 resultRelInfo);
942
943
944
945
946
947
948
949
955 else
957
959
960
962
963
964
965
966
967
968
969
970
975
976
977
978
979
980 if (cstate->rel->rd_rel->relkind == RELKIND_PARTITIONED_TABLE)
982
985 &mtstate->ps);
986
987
988
989
990
991
992
993
994
995 if (resultRelInfo->ri_TrigDesc != NULL &&
998 {
999
1000
1001
1002
1003
1004
1006 }
1007 else if (resultRelInfo->ri_FdwRoutine != NULL &&
1009 {
1010
1011
1012
1013
1015 }
1016 else if (proute != NULL && resultRelInfo->ri_TrigDesc != NULL &&
1018 {
1019
1020
1021
1022
1023
1024
1025
1027 }
1029 {
1030
1031
1032
1033
1034
1035
1036
1037
1038
1040 }
1042 {
1043
1044
1045
1046
1047
1048
1049
1050
1052 }
1053 else
1054 {
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068 if (proute)
1070 else
1072
1074 estate, mycid, ti_options);
1075 }
1076
1077
1078
1079
1080
1081
1082
1084 {
1088 }
1089
1090 has_before_insert_row_trig = (resultRelInfo->ri_TrigDesc &&
1092
1093 has_instead_insert_row_trig = (resultRelInfo->ri_TrigDesc &&
1095
1096
1097
1098
1099
1100
1101
1103
1105
1106
1108 errcallback.arg = cstate;
1111
1112 for (;;)
1113 {
1115 bool skip_tuple;
1116
1118
1119
1120
1121
1122
1124
1125
1126 if (insertMethod == CIM_SINGLE || proute)
1127 {
1128 myslot = singleslot;
1129 Assert(myslot != NULL);
1130 }
1131 else
1132 {
1133 Assert(resultRelInfo == target_resultRelInfo);
1135
1137 resultRelInfo);
1138 }
1139
1140
1141
1142
1143
1145
1147
1148
1150 break;
1151
1154 {
1155
1156
1157
1158
1159
1160
1162
1163
1166
1170 (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
1171 errmsg("skipped more than REJECT_LIMIT (%" PRId64 ") rows due to data type incompatibility",
1173
1174
1175 continue;
1176 }
1177
1179
1180
1181
1182
1183
1185
1186
1188
1190 {
1192
1194 {
1195
1196
1197
1198
1200 ++excluded);
1201 continue;
1202 }
1203 }
1204
1205
1206 if (proute)
1207 {
1209
1210
1211
1212
1213
1214
1215 resultRelInfo = ExecFindPartition(mtstate, target_resultRelInfo,
1216 proute, myslot, estate);
1217
1218 if (prevResultRelInfo != resultRelInfo)
1219 {
1220
1221 has_before_insert_row_trig = (resultRelInfo->ri_TrigDesc &&
1223
1224 has_instead_insert_row_trig = (resultRelInfo->ri_TrigDesc &&
1226
1227
1228
1229
1230
1231
1233 !has_before_insert_row_trig &&
1234 !has_instead_insert_row_trig &&
1237
1238
1239 if (leafpart_use_multi_insert)
1240 {
1243 resultRelInfo);
1244 }
1247 {
1248
1249
1250
1251
1253 resultRelInfo,
1254 &processed);
1255 }
1256
1257 if (bistate != NULL)
1259 prevResultRelInfo = resultRelInfo;
1260 }
1261
1262
1263
1264
1265
1266
1267
1268
1271 !has_before_insert_row_trig ? myslot : NULL;
1272
1273
1274
1275
1276
1278 if (insertMethod == CIM_SINGLE || !leafpart_use_multi_insert)
1279 {
1280
1281 if (map != NULL)
1282 {
1284
1287 }
1288 }
1289 else
1290 {
1291
1292
1293
1294
1296
1297
1299
1301 resultRelInfo);
1302
1303 if (map != NULL)
1305 batchslot);
1306 else
1307 {
1308
1309
1310
1311
1312
1313
1314
1316 myslot = batchslot;
1317 }
1318 }
1319
1320
1322 }
1323
1324 skip_tuple = false;
1325
1326
1327 if (has_before_insert_row_trig)
1328 {
1330 skip_tuple = true;
1331 }
1332
1333 if (!skip_tuple)
1334 {
1335
1336
1337
1338
1339
1340 if (has_instead_insert_row_trig)
1341 {
1343 }
1344 else
1345 {
1346
1351
1352
1353
1354
1355
1359
1360
1361
1362
1363
1364
1365
1367 (proute == NULL || has_before_insert_row_trig))
1369
1370
1371 if (insertMethod == CIM_MULTI || leafpart_use_multi_insert)
1372 {
1373
1374
1375
1376
1378
1379
1381 resultRelInfo, myslot,
1384
1385
1386
1387
1388
1391 resultRelInfo,
1392 &processed);
1393
1394
1395
1396
1397
1398
1399
1400 continue;
1401 }
1402 else
1403 {
1404 List *recheckIndexes = NIL;
1405
1406
1408 {
1410 resultRelInfo,
1411 myslot,
1412 NULL);
1413
1414 if (myslot == NULL)
1415 continue;
1416
1417
1418
1419
1420
1421
1423 }
1424 else
1425 {
1426
1428 myslot, mycid, ti_options, bistate);
1429
1432 myslot,
1433 estate,
1434 false,
1435 false,
1436 NULL,
1438 false);
1439 }
1440
1441
1444
1446 }
1447 }
1448
1449
1450
1451
1452
1453
1454
1456 ++processed);
1457 }
1458 }
1459
1460
1462 {
1465 }
1466
1467
1469
1474 errmsg_plural("%" PRIu64 " row was skipped due to data type incompatibility",
1475 "%" PRIu64 " rows were skipped due to data type incompatibility",
1478
1479 if (bistate != NULL)
1481
1483
1484
1486
1487
1489
1491
1492
1493 if (target_resultRelInfo->ri_FdwRoutine != NULL &&
1496 target_resultRelInfo);
1497
1498
1501
1502
1503 if (proute)
1505
1506
1509
1511
1512 return processed;
1513}
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1531 Node *whereClause,
1533 bool is_program,
1535 List *attnamelist,
1537{
1539 bool pipe = (filename == NULL);
1542 num_defaults;
1544 Oid *typioparams;
1545 int *defmap;
1548 bool volatile_defexprs;
1549 const int progress_cols[] = {
1553 };
1554 int64 progress_vals[] = {
1556 0,
1557 0
1558 };
1559
1560
1562
1563
1564
1565
1566
1568 "COPY",
1570
1572
1573
1575
1576
1578
1579
1580 cstate->rel = rel;
1581
1583
1584
1585
1586
1588
1589 num_phys_attrs = tupDesc->natts;
1590
1591
1596 {
1597 List *attnums;
1599
1601
1602 foreach(cur, attnums)
1603 {
1606
1609 (errcode(ERRCODE_INVALID_COLUMN_REFERENCE),
1610
1611 errmsg("%s column \"%s\" not referenced by COPY",
1612 "FORCE_NOT_NULL", NameStr(attr->attname))));
1614 }
1615 }
1616
1617
1619 {
1623
1624
1625
1626
1627
1630 }
1631 else
1633
1634
1639 {
1640 List *attnums;
1642
1644
1645 foreach(cur, attnums)
1646 {
1649
1652 (errcode(ERRCODE_INVALID_COLUMN_REFERENCE),
1653
1654 errmsg("%s column \"%s\" not referenced by COPY",
1655 "FORCE_NULL", NameStr(attr->attname))));
1657 }
1658 }
1659
1660
1662 {
1663 List *attnums;
1665
1667
1669
1670 foreach(cur, attnums)
1671 {
1674
1677 (errcode(ERRCODE_INVALID_COLUMN_REFERENCE),
1678 errmsg_internal("selected column \"%s\" not referenced by COPY",
1679 NameStr(attr->attname))));
1681 }
1682 }
1683
1684
1687 else
1689
1690
1691
1692
1696 {
1698 }
1699 else
1700 {
1706 (errcode(ERRCODE_UNDEFINED_FUNCTION),
1707 errmsg("default conversion function for encoding \"%s\" to \"%s\" does not exist",
1710 }
1711
1713
1715
1716
1723
1724
1725
1726
1727
1728
1729
1733
1735
1736
1737 if (pstate)
1738 {
1741 }
1742
1743 num_defaults = 0;
1744 volatile_defexprs = false;
1745
1746
1747
1748
1749
1750
1751
1753 typioparams = (Oid *) palloc(num_phys_attrs * sizeof(Oid));
1754 defmap = (int *) palloc(num_phys_attrs * sizeof(int));
1756
1758 {
1760
1761
1762 if (att->attisdropped)
1763 continue;
1764
1765
1767 &in_functions[attnum - 1],
1768 &typioparams[attnum - 1]);
1769
1770
1771 defexprs[attnum - 1] = NULL;
1772
1773
1774
1775
1776
1777
1780 !att->attgenerated)
1781 {
1784
1785 if (defexpr != NULL)
1786 {
1787
1789
1790
1792
1793
1794
1796 {
1797 defmap[num_defaults] = attnum - 1;
1798 num_defaults++;
1799 }
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815 if (!volatile_defexprs)
1817 }
1818 }
1819 }
1820
1822
1823
1827
1828
1831 cstate->defmap = defmap;
1832 cstate->defexprs = defexprs;
1836
1837 if (data_source_cb)
1838 {
1842 }
1843 else if (pipe)
1844 {
1846 Assert(!is_program);
1849 else
1851 }
1852 else
1853 {
1855
1857 {
1863 errmsg("could not execute command \"%s\": %m",
1865 }
1866 else
1867 {
1868 struct stat st;
1869
1873 {
1874
1875 int save_errno = errno;
1876
1879 errmsg("could not open file \"%s\" for reading: %m",
1881 (save_errno == ENOENT || save_errno == EACCES) ?
1882 errhint("COPY FROM instructs the PostgreSQL server process to read a file. "
1883 "You may want a client-side facility such as psql's \\copy.") : 0));
1884 }
1885
1889 errmsg("could not stat file \"%s\": %m",
1891
1894 (errcode(ERRCODE_WRONG_OBJECT_TYPE),
1895 errmsg("\"%s\" is a directory", cstate->filename)));
1896
1897 progress_vals[2] = st.st_size;
1898 }
1899 }
1900
1902
1904
1906
1907 return cstate;
1908}
1909
1910
1911
1912
1913void
1915{
1916
1918
1919
1921 {
1923 }
1924 else
1925 {
1929 errmsg("could not close file \"%s\": %m",
1931 }
1932
1934
1937}
1938
1939
1940
1941
1942static void
1944{
1945 int pclose_rc;
1946
1948
1950 if (pclose_rc == -1)
1953 errmsg("could not close pipe to external command: %m")));
1954 else if (pclose_rc != 0)
1955 {
1956
1957
1958
1959
1960
1961
1964 return;
1965
1967 (errcode(ERRCODE_EXTERNAL_ROUTINE_EXCEPTION),
1968 errmsg("program \"%s\" failed",
1971 }
1972}
List * CopyGetAttnums(TupleDesc tupDesc, Relation rel, List *attnamelist)
void ProcessCopyOptions(ParseState *pstate, CopyFormatOptions *opts_out, bool is_from, List *options)
void pgstat_progress_start_command(ProgressCommandType cmdtype, Oid relid)
void pgstat_progress_update_param(int index, int64 val)
void pgstat_progress_update_multi_param(int nparam, const int *index, const int64 *val)
void pgstat_progress_end_command(void)
Bitmapset * bms_make_singleton(int x)
#define InvalidSubTransactionId
#define MemSet(start, val, len)
#define StaticAssertDecl(condition, errmessage)
#define OidIsValid(objectId)
bool contain_volatile_functions_not_nextval(Node *clause)
bool contain_volatile_functions(Node *clause)
static void CopyFromTextLikeStart(CopyFromState cstate, TupleDesc tupDesc)
char * CopyLimitPrintoutLength(const char *str)
static void CopyMultiInsertInfoSetupBuffer(CopyMultiInsertInfo *miinfo, ResultRelInfo *rri)
static const CopyFromRoutine * CopyFromGetRoutine(const CopyFormatOptions *opts)
static const CopyFromRoutine CopyFromRoutineBinary
static const CopyFromRoutine CopyFromRoutineText
static void CopyFromBinaryEnd(CopyFromState cstate)
static TupleTableSlot * CopyMultiInsertInfoNextFreeSlot(CopyMultiInsertInfo *miinfo, ResultRelInfo *rri)
static void CopyMultiInsertInfoInit(CopyMultiInsertInfo *miinfo, ResultRelInfo *rri, CopyFromState cstate, EState *estate, CommandId mycid, int ti_options)
static void CopyFromBinaryStart(CopyFromState cstate, TupleDesc tupDesc)
static void CopyMultiInsertInfoFlush(CopyMultiInsertInfo *miinfo, ResultRelInfo *curr_rri, int64 *processed)
static void CopyMultiInsertInfoStore(CopyMultiInsertInfo *miinfo, ResultRelInfo *rri, TupleTableSlot *slot, int tuplen, uint64 lineno)
static void CopyMultiInsertInfoCleanup(CopyMultiInsertInfo *miinfo)
#define MAX_PARTITION_BUFFERS
struct CopyMultiInsertInfo CopyMultiInsertInfo
static void CopyFromBinaryInFunc(CopyFromState cstate, Oid atttypid, FmgrInfo *finfo, Oid *typioparam)
#define MAX_BUFFERED_TUPLES
static bool CopyMultiInsertInfoIsFull(CopyMultiInsertInfo *miinfo)
CopyFromState BeginCopyFrom(ParseState *pstate, Relation rel, Node *whereClause, const char *filename, bool is_program, copy_data_source_cb data_source_cb, List *attnamelist, List *options)
static CopyMultiInsertBuffer * CopyMultiInsertBufferInit(ResultRelInfo *rri)
static void CopyFromTextLikeInFunc(CopyFromState cstate, Oid atttypid, FmgrInfo *finfo, Oid *typioparam)
static void CopyMultiInsertBufferFlush(CopyMultiInsertInfo *miinfo, CopyMultiInsertBuffer *buffer, int64 *processed)
static void ClosePipeFromProgram(CopyFromState cstate)
#define MAX_BUFFERED_BYTES
static void CopyMultiInsertBufferCleanup(CopyMultiInsertInfo *miinfo, CopyMultiInsertBuffer *buffer)
static void CopyFromTextLikeEnd(CopyFromState cstate)
uint64 CopyFrom(CopyFromState cstate)
void EndCopyFrom(CopyFromState cstate)
static const CopyFromRoutine CopyFromRoutineCSV
static bool CopyMultiInsertInfoIsEmpty(CopyMultiInsertInfo *miinfo)
struct CopyMultiInsertBuffer CopyMultiInsertBuffer
#define MAX_COPY_DATA_DISPLAY
void CopyFromErrorCallback(void *arg)
bool CopyFromTextOneRow(CopyFromState cstate, ExprContext *econtext, Datum *values, bool *nulls)
bool CopyFromCSVOneRow(CopyFromState cstate, ExprContext *econtext, Datum *values, bool *nulls)
void ReceiveCopyBinaryHeader(CopyFromState cstate)
void ReceiveCopyBegin(CopyFromState cstate)
bool CopyFromBinaryOneRow(CopyFromState cstate, ExprContext *econtext, Datum *values, bool *nulls)
bool NextCopyFrom(CopyFromState cstate, ExprContext *econtext, Datum *values, bool *nulls)
int errmsg_plural(const char *fmt_singular, const char *fmt_plural, unsigned long n,...)
int errmsg_internal(const char *fmt,...)
int errdetail_internal(const char *fmt,...)
int errcode_for_file_access(void)
ErrorContextCallback * error_context_stack
int errhint(const char *fmt,...)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
ExprState * ExecInitExpr(Expr *node, PlanState *parent)
ExprState * ExecInitQual(List *qual, PlanState *parent)
void ExecOpenIndices(ResultRelInfo *resultRelInfo, bool speculative)
List * ExecInsertIndexTuples(ResultRelInfo *resultRelInfo, TupleTableSlot *slot, EState *estate, bool update, bool noDupErr, bool *specConflict, List *arbiterIndexes, bool onlySummarizing)
void CheckValidResultRel(ResultRelInfo *resultRelInfo, CmdType operation, List *mergeActions)
bool ExecPartitionCheck(ResultRelInfo *resultRelInfo, TupleTableSlot *slot, EState *estate, bool emitError)
void ExecCloseResultRelations(EState *estate)
void ExecCloseRangeTableRelations(EState *estate)
void ExecConstraints(ResultRelInfo *resultRelInfo, TupleTableSlot *slot, EState *estate)
PartitionTupleRouting * ExecSetupPartitionTupleRouting(EState *estate, Relation rel)
ResultRelInfo * ExecFindPartition(ModifyTableState *mtstate, ResultRelInfo *rootResultRelInfo, PartitionTupleRouting *proute, TupleTableSlot *slot, EState *estate)
void ExecCleanupTupleRouting(ModifyTableState *mtstate, PartitionTupleRouting *proute)
void ExecResetTupleTable(List *tupleTable, bool shouldFree)
void ExecDropSingleTupleTableSlot(TupleTableSlot *slot)
TupleTableSlot * ExecStoreVirtualTuple(TupleTableSlot *slot)
TupleConversionMap * ExecGetRootToChildMap(ResultRelInfo *resultRelInfo, EState *estate)
void ExecInitRangeTable(EState *estate, List *rangeTable, List *permInfos, Bitmapset *unpruned_relids)
void ExecInitResultRelation(EState *estate, ResultRelInfo *resultRelInfo, Index rti)
void FreeExecutorState(EState *estate)
EState * CreateExecutorState(void)
#define ResetPerTupleExprContext(estate)
#define GetPerTupleExprContext(estate)
#define GetPerTupleMemoryContext(estate)
static bool ExecQual(ExprState *state, ExprContext *econtext)
FILE * OpenPipeStream(const char *command, const char *mode)
int ClosePipeStream(FILE *file)
FILE * AllocateFile(const char *name, const char *mode)
void fmgr_info(Oid functionId, FmgrInfo *finfo)
Assert(PointerIsAligned(start, uint64))
void ReleaseBulkInsertStatePin(BulkInsertState bistate)
BulkInsertState GetBulkInsertState(void)
void FreeBulkInsertState(BulkInsertState bistate)
@ COPY_LOG_VERBOSITY_DEFAULT
struct CopyFromStateData * CopyFromState
int(* copy_data_source_cb)(void *outbuf, int minread, int maxread)
List * lappend(List *list, void *datum)
List * list_delete_first(List *list)
void list_free(List *list)
bool list_member_int(const List *list, int datum)
void getTypeInputInfo(Oid type, Oid *typInput, Oid *typIOParam)
void getTypeBinaryInputInfo(Oid type, Oid *typReceive, Oid *typIOParam)
int GetDatabaseEncoding(void)
int pg_mbcliplen(const char *mbstr, int len, int limit)
int pg_get_client_encoding(void)
char * pstrdup(const char *in)
void pfree(void *pointer)
void * palloc0(Size size)
MemoryContext CurrentMemoryContext
void MemoryContextDelete(MemoryContext context)
#define AllocSetContextCreate
#define ALLOCSET_DEFAULT_SIZES
#define CHECK_FOR_INTERRUPTS()
Oid FindDefaultConversionProc(int32 for_encoding, int32 to_encoding)
void ExecComputeStoredGenerated(ResultRelInfo *resultRelInfo, EState *estate, TupleTableSlot *slot, CmdType cmdtype)
#define castNode(_type_, nodeptr)
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
static AmcheckOptions opts
FormData_pg_attribute * Form_pg_attribute
static int list_length(const List *l)
#define pg_encoding_to_char
Expr * expression_planner(Expr *expr)
bool ThereAreNoReadyPortals(void)
CommandDest whereToSendOutput
#define PROGRESS_COPY_COMMAND
#define PROGRESS_COPY_TYPE_FILE
#define PROGRESS_COPY_COMMAND_FROM
#define PROGRESS_COPY_TUPLES_PROCESSED
#define PROGRESS_COPY_TUPLES_EXCLUDED
#define PROGRESS_COPY_TUPLES_SKIPPED
#define PROGRESS_COPY_TYPE
#define PROGRESS_COPY_TYPE_PROGRAM
#define PROGRESS_COPY_BYTES_TOTAL
#define PROGRESS_COPY_TYPE_CALLBACK
#define PROGRESS_COPY_TYPE_PIPE
#define RelationGetRelid(relation)
#define RelationGetDescr(relation)
#define RelationGetRelationName(relation)
Node * build_column_default(Relation rel, int attrno)
bool ThereAreNoPriorRegisteredSnapshots(void)
void InvalidateCatalogSnapshot(void)
void initStringInfo(StringInfo str)
CopyLogVerbosityChoice log_verbosity
CopyOnErrorChoice on_error
bool * force_notnull_flags
void(* CopyFromEnd)(CopyFromState cstate)
void(* CopyFromInFunc)(CopyFromState cstate, Oid atttypid, FmgrInfo *finfo, Oid *typioparam)
void(* CopyFromStart)(CopyFromState cstate, TupleDesc tupDesc)
copy_data_source_cb data_source_cb
const struct CopyFromRoutine * routine
StringInfoData attribute_buf
bool * convert_select_flags
TransitionCaptureState * transition_capture
MemoryContext copycontext
ErrorSaveContext * escontext
TupleTableSlot * slots[MAX_BUFFERED_TUPLES]
ResultRelInfo * resultRelInfo
uint64 linenos[MAX_BUFFERED_TUPLES]
List * multiInsertBuffers
struct ErrorContextCallback * previous
void(* callback)(void *arg)
TupleTableSlot * ecxt_scantuple
EndForeignInsert_function EndForeignInsert
BeginForeignInsert_function BeginForeignInsert
ExecForeignInsert_function ExecForeignInsert
ExecForeignBatchInsert_function ExecForeignBatchInsert
GetForeignModifyBatchSize_function GetForeignModifyBatchSize
ResultRelInfo * resultRelInfo
ResultRelInfo * rootResultRelInfo
struct TransitionCaptureState * mt_transition_capture
SubTransactionId rd_firstRelfilelocatorSubid
SubTransactionId rd_newRelfilelocatorSubid
SubTransactionId rd_createSubid
TupleTableSlot * ri_PartitionTupleSlot
struct CopyMultiInsertBuffer * ri_CopyMultiInsertBuffer
TriggerDesc * ri_TrigDesc
struct FdwRoutine * ri_FdwRoutine
TupleTableSlot * tcs_original_insert_tuple
bool trig_insert_instead_row
bool trig_insert_after_row
bool trig_insert_new_table
bool trig_insert_before_row
bool has_generated_stored
TupleTableSlot * table_slot_create(Relation relation, List **reglist)
#define TABLE_INSERT_FROZEN
#define TABLE_INSERT_SKIP_FSM
static void table_finish_bulk_insert(Relation rel, int options)
static void table_multi_insert(Relation rel, TupleTableSlot **slots, int nslots, CommandId cid, int options, struct BulkInsertStateData *bistate)
static void table_tuple_insert(Relation rel, TupleTableSlot *slot, CommandId cid, int options, struct BulkInsertStateData *bistate)
TransitionCaptureState * MakeTransitionCaptureState(TriggerDesc *trigdesc, Oid relid, CmdType cmdType)
void ExecBSInsertTriggers(EState *estate, ResultRelInfo *relinfo)
bool ExecBRInsertTriggers(EState *estate, ResultRelInfo *relinfo, TupleTableSlot *slot)
bool ExecIRInsertTriggers(EState *estate, ResultRelInfo *relinfo, TupleTableSlot *slot)
void ExecARInsertTriggers(EState *estate, ResultRelInfo *relinfo, TupleTableSlot *slot, List *recheckIndexes, TransitionCaptureState *transition_capture)
void ExecASInsertTriggers(EState *estate, ResultRelInfo *relinfo, TransitionCaptureState *transition_capture)
void AfterTriggerEndQuery(EState *estate)
void AfterTriggerBeginQuery(void)
TupleTableSlot * execute_attr_map_slot(AttrMap *attrMap, TupleTableSlot *in_slot, TupleTableSlot *out_slot)
static FormData_pg_attribute * TupleDescAttr(TupleDesc tupdesc, int i)
static TupleTableSlot * ExecClearTuple(TupleTableSlot *slot)
static TupleTableSlot * ExecCopySlot(TupleTableSlot *dstslot, TupleTableSlot *srcslot)
static void ExecMaterializeSlot(TupleTableSlot *slot)
char * wait_result_to_str(int exitstatus)
bool wait_result_is_signal(int exit_status, int signum)
SubTransactionId GetCurrentSubTransactionId(void)
CommandId GetCurrentCommandId(bool used)