Coder Social home page Coder Social logo

pk_fk's People

Contributors

duartedenio avatar edimarjunior10 avatar geovanik avatar leonardobelinski avatar natanjmai avatar raphaelmacsabpf avatar ricardoparizotto avatar rogerioschmidt avatar trindad avatar zanuzzorz avatar

Watchers

 avatar  avatar  avatar

pk_fk's Issues

Vazamento de memória, função leObjeto

O programa até então desenvolvido está com alguns vazamentos de memória, algo que poderia ser resolvido mantendo as funcionalidades do mesmo. O primeiro a ser resolvido será o da função leobjeto().

==2984== 20 bytes in 1 blocks are definitely lost in loss record 5 of 46
==2984== at 0x402A17C: malloc (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==2984== by 0x8048845: leObjeto (in /home/gelinux/Área de Trabalho/PK_FK/prog)
==2984== by 0x804C2ED: abreTabela (in /home/gelinux/Área de Trabalho/PK_FK/prog)
==2984== by 0x804A0B9: finalizaInsert (in /home/gelinux/Área de Trabalho/PK_FK/prog)
==2984== by 0x804C636: main (in /home/gelinux/Área de Trabalho/PK_FK/prog)

Vazamento de memória na função procuraAtributoFK()

==4131==
==4131== 480 bytes in 1 blocks are definitely lost in loss record 23 of 42
==4131== at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==4131== by 0x40366B: procuraAtributoFK (in /home/edimarjunior/Documentos/Gits/PK_FK/prog)
==4131== by 0x40256C: finalizaInsert (in /home/edimarjunior/Documentos/Gits/PK_FK/prog)
==4131== by 0x404FE9: main (in /home/edimarjunior/Documentos/Gits/PK_FK/prog)
==4131==

Erro na função verificaChaveFK

Dada as tabelas:
employe(id, name);//id = PK;
client(id, name); //id = PK;
invoice(id, eid, cid, value);//id = PK; eid = FK(employe(id)); cid = FK(client(id));
A função tem um erro onde obrigava que os atributos FK de uma tabela fossem iguais ao da sua tabela original.
então logo ao inserir uma tupla em invoice, quando ele verifica se eid da tabela employe tem o valor para que a chave não fique inconsistente, está falhando pois ele procura por 'eid' e na tabela employe o nome do atributo é 'id'

Campo não estava sendo inicializada corretamente -- adicionaCampo()

==5442== Syscall param write(buf) points to uninitialised byte(s)
==5442== at 0x41159D3: __write_nocancel (syscall-template.S:82)
==5442== by 0x40B977E: new_do_write (fileops.c:530)
==5442== by 0x40B9A95: _IO_do_write@@GLIBC_2.1 (fileops.c:503)
==5442== by 0x40BAFBF: _IO_file_close_it@@GLIBC_2.1 (fileops.c:170)
==5442== by 0x40AE3A7: fclose@@GLIBC_2.1 (iofclose.c:62)
==5442== by 0x8049DD3: finalizaTabela (buffend.c:474)
==5442== by 0x804C2F8: main (exemploMain.c:25)
==5442== Address 0x4030008 is not stack'd, malloc'd or (recently) free'd
==5442== Uninitialised value was created by a heap allocation
==5442== at 0x4028308: malloc (vg_replace_malloc.c:263)
==5442== by 0x8049B2C: adicionaCampo (buffend.c:408)
==5442== by 0x804C220: main (exemploMain.c:21)

Inconsistência na deleção de tabelas com PK

Quando uma tabela com PK é deletada não é feita a verificação nas demais tabelas com FK's. Dessa maneira, se uma tabela com PK for deletada, as tabelas que possuírem FK's referenciando essa tabela ficarão inconsistentes pois continuarão referenciando valores que já não existem mais.

Buffer não utilizado

Funções de inserção e de verificação de chave primária leem direto do arquivo, desconsiderando o buffer.

Erro na função getPage

==9345== Invalid read of size 4
==9345== at 0x804ADAD: getPage (buffend.c:837)
==9345== by 0x804BECF: existeAtributo (buffend.c:1224)
==9345== by 0x804C2BB: verificaChavePK (buffend.c:1341)
==9345== by 0x804A396: finalizaInsert (buffend.c:627)
==9345== by 0x804CB62: main (exemploMain.c:53)
==9345== Address 0x423a594 is 4 bytes after a block of size 536,576 alloc'd
==9345== at 0x4028308: malloc (vg_replace_malloc.c:263)
==9345== by 0x8048DDF: initbuffer (buffend.c:102)
==9345== by 0x804BD71: iniciaAtributos (buffend.c:1191)
==9345== by 0x804BDC9: existeAtributo (buffend.c:1217)
==9345== by 0x804C2BB: verificaChavePK (buffend.c:1341)
==9345== by 0x804A396: finalizaInsert (buffend.c:627)
==9345== by 0x804CB62: main (exemploMain.c:53)

Vazamento de memória na função finalizaInsert

==3255== 116 bytes in 1 blocks are definitely lost in loss record 14 of 40
==3255== at 0x402A17C: malloc (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==3255== by 0x804A2FB: finalizaInsert (in /home/gelinux/Área de Trabalho/PK_FK/prog)
==3255== by 0x804CB84: main (in /home/gelinux/Área de Trabalho/PK_FK/prog)

Vazamento de memória na função verificaNomeTabela()

==6941== 20 bytes in 1 blocks are definitely lost in loss record 8 of 40
==6941== at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==6941== by 0x4019B7: verificaNomeTabela (in /home/edimarjunior/Documentos/Gits/PK_FK/prog)
==6941== by 0x400B49: leObjeto (in /home/edimarjunior/Documentos/Gits/PK_FK/prog)
==6941== by 0x404075: iniciaAtributos (in /home/edimarjunior/Documentos/Gits/PK_FK/prog)
==6941== by 0x404797: verificaChavePK (in /home/edimarjunior/Documentos/Gits/PK_FK/prog)
==6941== by 0x402606: finalizaInsert (in /home/edimarjunior/Documentos/Gits/PK_FK/prog)
==6941== by 0x405028: main (in /home/edimarjunior/Documentos/Gits/PK_FK/prog)
==6941==

Erro função existeArquivo()

Falha na função, pois ela retorna que existe o arquivo quando o mesmo foi deletado por alguma função do programa. Função pouco desnecessária também, pois deverá haver alguma verificação para o nome da tabela e também se não existe o arquivo, ele é criado automaticamente.

Erro na funcao imprime ( select * from nome_tupla )

Imprimindo conteúdo de apenas uma página do Buffer, por mais que existam tuplas em outras páginas.

Também informa o número de tuplas errado quando a quantidade de tuplas excede a capacidade de uma página do buffer.

Erro de alocação no insereValor()

==13053== Invalid write of size 1
==13053== at 0x4028AC5: strcpy (mc_replace_strmem.c:429)
==13053== by 0x8049FB2: insereValor (buffend.c:512)
==13053== by 0x804C788: main (exemploMain.c:74)
==13053== Address 0x444e062 is 6 bytes after a block of size 4 alloc'd
==13053== at 0x4028308: malloc (vg_replace_malloc.c:263)
==13053== by 0x8049F76: insereValor (buffend.c:509)
==13053== by 0x804C788: main (exemploMain.c:74)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.