Bug #6586
parser/conversion bug when a database alias is used
100%
History
#2 Updated by Constantin Asofiei about 4 years ago
There is a bug when parsing/converting a program which uses a database alias:
- first program:
create alias dictdb for database p2j_test. run dictdb.p.
- second program:
def var i as int. for each dictdb._file: i = i + 1. end. message i.
directory.hints:<hints> <alias name="dictdb" database="p2j_test"/> </hints>
The dictdb.p program converts like this:
@DatabaseReferences(aliases =
{
"p2j_test"
}, tables =
{
"p2j_test._file"
})
public class Dictdb
{
MetaFile.Buf metaFile = RecordBuffer.define(MetaFile.Buf.class, "p2j_test", "metaFile", "_file");
Note how p2j_test is used instead of dictdb. This is incorrect.
The problem seems to be in SchemaDictionary.findTableInfo. I've added this code:
NameNode dbNode = node.getParent();
// don't just use getAst() here, we need the AST for the backing table if this is a buffer
// (this will work for both the simple case and the buffer case)
Aast ast = getTable(node);
String sig = ast != null ? (String) ast.getAnnotation("db_signature") : null;
String sname = getQualifiedName(node);
String bname = getRecordName(node, EntityName.TABLE, name);
String dname = (dbNode != null) ? dbNode.getName() : "";
String ldname = getLogicalDatabaseForTable(name, forceTemp, forcePersistent); <--- new code starts here
if (!ldname.equals(dname))
{
if (sname.startsWith(dname + "."))
{
sname = ldname + sname.substring(dname.length());
}
if (bname.startsWith(dname + "."))
{
bname = ldname + bname.substring(dname.length());
}
dname = ldname;
}
but this abends the conversion.
This is because the 'sname' (which ends up in the schemaname annotation) is prefixed with dictdb instead of p2j_test. I'll leave that to use p2j_test, but now the DatabaseReferences.tables annotations will use p2j_test instead of dictdb.
I'm working on fixing the DatabaseReferences.tables annotation.
#3 Updated by Constantin Asofiei about 4 years ago
- Status changed from New to Review
- Assignee set to Constantin Asofiei
- % Done changed from 0 to 100
The fix is in 6129a/13954.
#4 Updated by Eric Faulhaber about 4 years ago
- Status changed from Review to Test
Constantin Asofiei wrote:
The fix is in 6129a/13954.
I'm assuming the premise is correct. The code changes look correct to implement the fix.
#5 Updated by Constantin Asofiei about 4 years ago
getLogicalDatabaseForTable was previously being used (before findTableInfo was introduced), so yes, it makes sense. The RCODE-INFO:TABLE-LIST was an existing bug.