|
@@ -49,6 +49,7 @@
|
|
|
#include "hqlrepository.hpp"
|
|
|
#include "hqlir.hpp"
|
|
|
|
|
|
+#define ADD_IMPLICIT_FILEPOS_FIELD_TO_INDEX TRUE
|
|
|
#define FAST_FIND_FIELD
|
|
|
//#define USE_WHEN_FOR_SIDEEFFECTS
|
|
|
#define MANYFIELDS_THRESHOLD 2000
|
|
@@ -978,10 +979,16 @@ IHqlExpression * HqlGram::processIndexBuild(attribute & indexAttr, attribute * r
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- checkIndexRecordType(record, 1, false, *recordAttr);
|
|
|
+ bool hasFileposition = getBoolAttributeInList(flags, filepositionAtom, true);
|
|
|
+ unsigned numPayloadFields = hasFileposition ? 1 : 0;
|
|
|
+
|
|
|
+ checkIndexRecordType(record, numPayloadFields, false, *recordAttr);
|
|
|
}
|
|
|
+
|
|
|
+ //Recalculated because it might be updated in modifyIndexPayloadRecord() above
|
|
|
+ bool hasFileposition = getBoolAttributeInList(flags, filepositionAtom, true);
|
|
|
record.setown(checkBuildIndexRecord(record.getClear(), *recordAttr));
|
|
|
- record.setown(checkIndexRecord(record, *recordAttr));
|
|
|
+ record.setown(checkIndexRecord(record, *recordAttr, flags));
|
|
|
inputDataset.setown(createDatasetF(no_selectfields, LINK(dataset), LINK(record), NULL));
|
|
|
warnIfRecordPacked(inputDataset, *recordAttr);
|
|
|
}
|
|
@@ -6660,6 +6667,9 @@ IHqlExpression * HqlGram::createBuildIndexFromIndex(attribute & indexAttr, attri
|
|
|
IHqlExpression * payload = index->queryAttribute(_payload_Atom);
|
|
|
if (payload)
|
|
|
args.append(*LINK(payload));
|
|
|
+ IHqlExpression * fileposition = index->queryAttribute(filepositionAtom);
|
|
|
+ if (fileposition)
|
|
|
+ args.append(*LINK(fileposition));
|
|
|
if (distribution)
|
|
|
args.append(*distribution.getClear());
|
|
|
|
|
@@ -6819,22 +6829,22 @@ void HqlGram::checkSoapRecord(attribute & errpos)
|
|
|
}
|
|
|
|
|
|
|
|
|
-IHqlExpression * HqlGram::checkIndexRecord(IHqlExpression * record, const attribute & errpos)
|
|
|
+IHqlExpression * HqlGram::checkIndexRecord(IHqlExpression * record, const attribute & errpos, OwnedHqlExpr & indexAttrs)
|
|
|
{
|
|
|
unsigned numFields = record->numChildren();
|
|
|
- if (numFields)
|
|
|
+ if (numFields && getBoolAttributeInList(indexAttrs, filepositionAtom, true))
|
|
|
{
|
|
|
// if not, implies some error (already reported)
|
|
|
if (numFields == 1)
|
|
|
- reportError(ERR_INDEX_COMPONENTS, errpos, "Record for index should have at least one component and a fileposition");
|
|
|
+ {
|
|
|
+ indexAttrs.setown(createComma(indexAttrs.getClear(), createExprAttribute(filepositionAtom, createConstant(false))));
|
|
|
+ }
|
|
|
else
|
|
|
{
|
|
|
IHqlExpression * lastField = record->queryChild(numFields-1);
|
|
|
ITypeInfo * fileposType = lastField->queryType();
|
|
|
if (!isIntegralType(fileposType))
|
|
|
- reportError(ERR_INDEX_FILEPOS_EXPECTED_LAST, errpos, "Expected last field to be an integral fileposition field");
|
|
|
-// else if (fileposType->getSize() != 8)
|
|
|
-// reportWarning(ERR_INDEX_FILEPOS_UNEXPECTED_SIZE, errpos.pos, "Expected fileposition field to be 8 bytes");
|
|
|
+ indexAttrs.setown(createComma(indexAttrs.getClear(), createExprAttribute(filepositionAtom, createConstant(false))));
|
|
|
}
|
|
|
}
|
|
|
return LINK(record);
|
|
@@ -7223,14 +7233,15 @@ IHqlExpression * HqlGram::createRecordExcept(IHqlExpression * left, IHqlExpressi
|
|
|
}
|
|
|
|
|
|
|
|
|
-IHqlExpression * HqlGram::createIndexFromRecord(IHqlExpression * record, IHqlExpression * attr, const attribute & errpos)
|
|
|
+IHqlExpression * HqlGram::createIndexFromRecord(IHqlExpression * record, IHqlExpression * attrs, const attribute & errpos)
|
|
|
{
|
|
|
IHqlExpression * ds = createDataset(no_null, LINK(record), NULL);
|
|
|
- OwnedHqlExpr finalRecord = checkIndexRecord(record, errpos);
|
|
|
+ OwnedHqlExpr newAttrs = LINK(attrs);
|
|
|
+ OwnedHqlExpr finalRecord = checkIndexRecord(record, errpos, newAttrs);
|
|
|
finalRecord.setown(cleanIndexRecord(finalRecord));
|
|
|
|
|
|
OwnedHqlExpr transform = createClearTransform(finalRecord, errpos);
|
|
|
- return createDataset(no_newkeyindex, ds, createComma(LINK(finalRecord), transform.getClear(), LINK(attr)));
|
|
|
+ return createDataset(no_newkeyindex, ds, createComma(LINK(finalRecord), transform.getClear(), newAttrs.getClear()));
|
|
|
}
|
|
|
|
|
|
|
|
@@ -7993,28 +8004,33 @@ void HqlGram::modifyIndexPayloadRecord(SharedHqlExpr & record, SharedHqlExpr & p
|
|
|
payloadCount = fields.ordinality() - oldFields;
|
|
|
}
|
|
|
//This needs to be here until filepositions are no longer special cased.
|
|
|
- if (!lastFieldType || !lastFieldType->isInteger())
|
|
|
- {
|
|
|
- IHqlSimpleScope * payloadScope = payload ? payload->querySimpleScope() : NULL;
|
|
|
- IIdAtom * implicitFieldName;
|
|
|
- for (unsigned suffix =1;;suffix++)
|
|
|
- {
|
|
|
- StringBuffer name;
|
|
|
- name.append("__internal_fpos");
|
|
|
- if (suffix > 1)
|
|
|
- name.append(suffix);
|
|
|
- name.append("__");
|
|
|
- implicitFieldName = createIdAtom(name);
|
|
|
- OwnedHqlExpr resolved = scope->lookupSymbol(implicitFieldName);
|
|
|
- if (!resolved && payloadScope)
|
|
|
- resolved.setown(payloadScope->lookupSymbol(implicitFieldName));
|
|
|
- if (!resolved)
|
|
|
- break;
|
|
|
- }
|
|
|
+ if (!lastFieldType || !lastFieldType->isInteger() && getBoolAttributeInList(extra, filepositionAtom, true))
|
|
|
+ {
|
|
|
+ if (ADD_IMPLICIT_FILEPOS_FIELD_TO_INDEX)
|
|
|
+ {
|
|
|
+ IHqlSimpleScope * payloadScope = payload ? payload->querySimpleScope() : NULL;
|
|
|
+ IIdAtom * implicitFieldName;
|
|
|
+ for (unsigned suffix =1;;suffix++)
|
|
|
+ {
|
|
|
+ StringBuffer name;
|
|
|
+ name.append("__internal_fpos");
|
|
|
+ if (suffix > 1)
|
|
|
+ name.append(suffix);
|
|
|
+ name.append("__");
|
|
|
+ implicitFieldName = createIdAtom(name);
|
|
|
+ OwnedHqlExpr resolved = scope->lookupSymbol(implicitFieldName);
|
|
|
+ if (!resolved && payloadScope)
|
|
|
+ resolved.setown(payloadScope->lookupSymbol(implicitFieldName));
|
|
|
+ if (!resolved)
|
|
|
+ break;
|
|
|
+ }
|
|
|
|
|
|
- ITypeInfo * fileposType = makeIntType(8, false);
|
|
|
- fields.append(*createField(implicitFieldName, fileposType, createConstant(I64C(0)), createAttribute(_implicitFpos_Atom)));
|
|
|
- payloadCount++;
|
|
|
+ ITypeInfo * fileposType = makeIntType(8, false);
|
|
|
+ fields.append(*createField(implicitFieldName, fileposType, createConstant(I64C(0)), createAttribute(_implicitFpos_Atom)));
|
|
|
+ payloadCount++;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ extra.setown(createComma(extra.getClear(), createExprAttribute(filepositionAtom, createConstant(false))));
|
|
|
}
|
|
|
|
|
|
extra.setown(createComma(extra.getClear(), createAttribute(_payload_Atom, createConstant((__int64) payloadCount))));
|