hacker emblem
Search | Tags | Photos | Flights | Gas Mileage | Log in

Test post

Started: 2022-02-09 22:43:23

Submitted: 2022-02-09 22:53:22

Visibility: World-readable

I don't always test my code, but when I do, I do it in production

I have an irritating little bug in my content engine that popped up when I updated my laptop to Postgres 12: my Perl code that tries to call last_insert_id after inserting a blog post fails with the new error:

DBD::Pg::db last_insert_id failed: No1 suitable column found for last_insert_id of table "changelog"

I think the problem is that the schema for this table, which basically dates back to the earliest incarnations of this site between 1999 and 2002, has been migrated forward so many times, to newer versions of Postgres on probably a dozen different servers over two decades, that the way the database was originally specified is no longer idiomatic Postgres, to the point where the database APIs I'm using can't figure out what the primary key on the database is to figure out what id the new row has. The row itself gets inserted, but everything else I'm trying to insert along with the new row doesn't get properly referenced.

For this table, the default for the id column had been:


and I've updated it to:


Which matches most of the rest of the tables in my database, and matches what I get when I create a brand new table with the type "serial".

I only have one copy of my database, though, so the only real way to test whether all of this works is to submit this entry and see what happens.

Version 2.0! now better than ever, with numbers!
- Scott J. Galvin, 15 October 2002, referencing Buildmeasite 2.0