Coder Social home page Coder Social logo

Use STRICT tables about lastlog2 HOT 4 CLOSED

jirislaby avatar jirislaby commented on July 18, 2024
Use STRICT tables

from lastlog2.

Comments (4)

thkukuk avatar thkukuk commented on July 18, 2024

Ok, I understand the "STRICT" and added that, but I don't understand your comments about "NOT NULL", "UNIQUE" and "PRIMARY". I just followed the sqlite tutorial/introduction, first time I use sqlite.
NAME is the unique key and never empty, all other fields could be theoretically empty (TTY and RemoteHost for sure, not sure about TIME, but I think the some utilities clear that in some cases, too).

About "TIME": no, time should not be automatically set or updated.

from lastlog2.

jirislaby avatar jirislaby commented on July 18, 2024

Ok, everything is fine then.

from lastlog2.

jirislaby avatar jirislaby commented on July 18, 2024

Actually thinking about it more and looking into the code. You save '' as empty tty and rhost, for example:

lastlog2/lib/lastlog2.c

Lines 184 to 186 in be609c4

"REPLACE INTO Lastlog VALUES('%s', %llu, '%s', '%s');",
user, (long long int)ll_time, tty ? tty : "",
rhost ? rhost : "") < 0)

You never use NULL values AFAICS. The question is if you want/expect NULL values in the columns in the database. They behave sort of differently than empty ('') values. If not, I would do: tty TEXT NOT NULL DEFAULT '' and similar.

from lastlog2.

thkukuk avatar thkukuk commented on July 18, 2024

I'm using NULL values, it was only because of the asprintf that this was mapped to empty strings.
I hope the code is now fine regarding sqlite3.
Thanks for the hints!

from lastlog2.

Related Issues (3)

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.